Skip to content

Sass compilation is broken when running with Vue 3.5.12 and above #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
imnatgreen opened this issue Mar 12, 2025 · 0 comments
Open

Comments

@imnatgreen
Copy link

In Vue 3.5.12, compiler-sfc was updated (vuejs/core#11992) to use the Sass modern API if it is available.

This means it uses the modern compileString instead of legacy renderSync, which breaks as it doesn't support the legacy importer that vue-jest is providing.

This causes template compilation to fail: [vue-jest] Error: Vue template compilation failed

Related: pipe01/esbuild-plugin-vue3#30

I think replacing the existing importer:

importer: (url, prev) => ({
  file: applyModuleNameMapper(
    url,
    prev === 'stdin' ? filePath : prev,
    jestConfig,
    lang
  )
}),

with something like this

importer: {
  findFileUrl(url, context) {
    const resolvedPath = applyModuleNameMapper(
      url,
      context.containingUrl,
      jestConfig,
      lang
    )
    return pathToFileURL(resolvedPath)
  }
}

could work, but I couldn't get Sass to resolve my @/... imports with the modern importer, I think something more is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant