Skip to content

sass dynamic import is undefined when building with "modern-compiler" and sass-embedded #19052

@cod1r

Description

@cod1r

Describe the bug

I expect to do builds without any crashes relating to "sass" being an undefined import.

The actual behavior is that in css.ts, the dynamic import is expecting properties to be on the default export but instead properties are exported individually (named exports w/e you want to call it).

Reproduction

stackblitz link wasn't working out. had a different sass-embedded error lmao

just have sass files and try importing them and then doing a vite build with sass-embedded. the sass-embedded dynamic import will try to grab a default export but sass embedded doesn't have one

Steps to reproduce

  1. import sass file
  2. run vite build

System Info

System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M2
    Memory: 1.10 GB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.3.0 - ~/.local/state/fnm_multishells/60516_1734950576395/bin/node
    Yarn: 4.5.3 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - ~/.local/state/fnm_multishells/60516_1734950576395/bin/npm
    bun: 1.1.42 - /opt/homebrew/bin/bun
    Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 131.0.6778.205
    Firefox Nightly: 134.0a1
    Safari: 18.1.1
  npmPackages:
    @vitejs/plugin-react: ^4.3.1 => 4.3.3
    rollup: ^4.21.2 => 4.27.3
    vite: ^6.0.5 => 6.0.5

Used Package Manager

yarn

Logs

      compilerPromise ??= sass.initAsyncCompiler();
                               ^


[vite:css] [sass] Cannot read properties of undefined (reading 'initAsyncCompiler')
file: /Users/cod1r/workspace/repositories/games/spelltower/spelltower.scss```

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vite.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to [vuejs/core](https://github.com/vuejs/core) instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vite.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions