Skip to content

Imported SCSS files seem to cause "Cannot read properties of undefined (reading 'paths')" issue #5472

Closed
@flayks

Description

@flayks

Describe the bug

Since the latest versions of SvelteKit (or SASS, maybe Vite?), imported SCSS stylesheets like so are causing an issue:

<!-- ./src/components/atoms/Button.svelte -->
<script>
    export let text
</script>

<button>
    {text}
</button>

<style lang="scss">
    @import "../../style/atoms/button";
</style>
[vite-plugin-svelte-kit] Cannot read properties of undefined (reading 'paths')
error during build:
TypeError: Cannot read properties of undefined (reading 'paths')

Commenting the @import line doesn't cause the problem anymore.

Reproduction

Tried it on a fresh repo with a single <Button> component importing a .scss file (to keep the scoping and avoid bloating the single-file component of potentially hundreds of lines of SCSS)

https://github.com/flayks/sveltekit-bug-reading-paths-sass/blob/main/src/components/atoms/Button.svelte

Tried to downgrade a few version of SK and Vite but cannot really find the origin of issue so far

Logs

> Using @sveltejs/adapter-auto
[vite-plugin-svelte-kit] Cannot read properties of undefined (reading 'paths')
error during build:
TypeError: Cannot read properties of undefined (reading 'paths')
    at create_builder (file:///Users/flayks/Desktop/test/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.370_svelte@3.49.0+vite@2.9.14/node_modules/@sveltejs/kit/dist/chunks/index2.js:52:48)
    at adapt (file:///Users/flayks/Desktop/test/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.370_svelte@3.49.0+vite@2.9.14/node_modules/@sveltejs/kit/dist/chunks/index2.js:204:18)
    at Object.closeBundle (file:///Users/flayks/Desktop/test/node_modules/.pnpm/@sveltejs+kit@1.0.0-next.370_svelte@3.49.0+vite@2.9.14/node_modules/@sveltejs/kit/dist/vite.js:3104:11)
    at async Promise.all (index 0)
    at async /Users/flayks/Desktop/test/node_modules/.pnpm/rollup@2.76.0/node_modules/rollup/dist/shared/rollup.js:23693:13
    at async catchUnfinishedHookActions (/Users/flayks/Desktop/test/node_modules/.pnpm/rollup@2.76.0/node_modules/rollup/dist/shared/rollup.js:23174:20)
    at async rollupInternal (/Users/flayks/Desktop/test/node_modules/.pnpm/rollup@2.76.0/node_modules/rollup/dist/shared/rollup.js:23682:5)
    at async doBuild (/Users/flayks/Desktop/test/node_modules/.pnpm/vite@2.9.14_sass@1.53.0/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:41710:24)
    at async build (/Users/flayks/Desktop/test/node_modules/.pnpm/vite@2.9.14_sass@1.53.0/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:41552:16)
    at async CAC.<anonymous> (/Users/flayks/Desktop/test/node_modules/.pnpm/vite@2.9.14_sass@1.53.0/node_modules/vite/dist/node/cli.js:738:9)
 ELIFECYCLE  Command failed with exit code 1.

System Info

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 133.59 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - /usr/local/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 8.11.0 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 103.1.40.113
    Firefox: 102.0
    Safari: 15.5
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.55 
    @sveltejs/adapter-vercel: 1.0.0-next.60 => 1.0.0-next.60 
    @sveltejs/kit: next => 1.0.0-next.370 
    svelte: ^3.49.0 => 3.49.0 
    vite: ^2.9.14 => 2.9.14

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions