Skip to content
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

[Bug] Certain variable and function name in scss can cause fatal error in vite #3729

Closed
6 tasks done
Mister-Hope opened this issue Jun 9, 2021 · 1 comment · Fixed by #3752
Closed
6 tasks done

Comments

@Mister-Hope
Copy link

Mister-Hope commented Jun 9, 2021

Describe the bug

Certain variable and function name in scss can cause fatal error in vite

Reproduction

https://github.com/Mister-Hope/vite-bug/

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 4.54 GB / 15.89 GB
  Binaries:
    Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 7.14.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.41)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    vite: ^2.3.7 => 2.3.7

Used package manager:

yarn

Logs

$ C:\projects\my-vue-app\node_modules\.bin\vite --debug
  vite:config bundled config file loaded in 37ms +0ms
  vite:config using resolved config: {
  vite:config   server: {
  vite:config     port: 8080,
  vite:config     fsServe: { root: 'C:/projects/my-vue-app', strict: false }
  vite:config   },
  vite:config   configFile: 'C:/projects/my-vue-app/vite.config.ts',
  vite:config   configFileDependencies: [ 'vite.config.ts' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   root: 'C:/projects/my-vue-app',
  vite:config   base: '/',
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: 'C:\\projects\\my-vue-app\\public',
  vite:config   cacheDir: 'C:\\projects\\my-vue-app\\node_modules\\.vite',
  vite:config   command: 'serve',
  vite:config   mode: 'development',
  vite:config   isProduction: false,
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:dynamic-import-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillDynamicImport: false,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     minify: 'terser',
  vite:config     terserOptions: {},
  vite:config     cleanCssOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   },
  vite:config   createResolver: [Function: createResolver],
  vite:config   optimizeDeps: { esbuildOptions: { keepNames: undefined } }
  vite:config } +7ms
  vite:deps Hash is consistent. Skipping. Use --force to override. +0ms

  vite v2.3.7 dev server running at:

  > Local: http://localhost:8080/
  > Network: use `--host` to expose

  ready in 327ms.

  vite:spa-fallback Rewriting GET / to /index.html +0ms
  vite:time 27ms  /index.html +0ms
  vite:resolve 3ms   /projects/my-vue-app/node_modules/vite/dist/client/client -> C:/projects/my-vue-app/node_modules/vite/dist/client/client.js +0ms
  vite:resolve 4ms   /@vite/client -> C:/projects/my-vue-app/node_modules/vite/dist/client/client.js +1ms
  vite:resolve 1ms   /src/main.ts -> C:/projects/my-vue-app/src/main.ts +7ms
  vite:load 2ms   [fs] /src/main.ts +0ms
  vite:load 7ms   [fs] /@vite/client +2ms
  vite:resolve 1ms   ./env -> C:/projects/my-vue-app/node_modules/vite/dist/client/env.js +18ms
  vite:resolve 0ms   /node_modules/vite/dist/client/env.js -> C:/projects/my-vue-app/node_modules/vite/dist/client/env.js +1ms
  vite:transform 14ms  /@vite/client +0ms
  vite:time 35ms  /@vite/client +77ms
  vite:resolve 6ms   @a/b -> C:/projects/my-vue-app/packages/b/index.js +12ms
  vite:resolve 0ms   /packages/b/index.js -> C:/projects/my-vue-app/packages/b/index.js +1ms
  vite:transform 30ms  /src/main.ts +12ms
  vite:time 35ms  /src/main.ts +12ms
  vite:load 2ms   [fs] /node_modules/vite/dist/client/env.js +62ms
  vite:rewrite 0ms   [no imports] node_modules\vite\dist\client\env.js +0ms
  vite:transform 1ms   /node_modules/vite/dist/client/env.js +35ms
  vite:time 6ms   /node_modules/vite/dist/client/env.js +34ms
  vite:load 3ms   [fs] /packages/b/index.js +3ms
  vite:resolve 0ms   ./index.scss -> C:/projects/my-vue-app/packages/b/index.scss +39ms
  vite:resolve 1ms   /packages/b/index.scss -> C:/projects/my-vue-app/packages/b/index.scss +2ms
  vite:transform 4ms   /packages/b/index.js +6ms
  vite:time 11ms  /packages/b/index.js +7ms
  vite:load 0ms   [fs] /packages/b/index.scss +15ms
  vite:resolve 3ms   @a/a/svg -> C:/projects/my-vue-app/packages/a/svg.scss +0ms
C:\projects\my-vue-app\node_modules\sass\sass.dart.js:27341
      throw error;
      ^

Invalid argument(s): Uri c:%5Cprojects%5Cmy-vue-app%5Cpackages%5Ca%5Csvg.scss must have scheme 'file:'.
    at Object.wrapException (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:1234:17)
    at WindowsStyle.pathFromUri$1 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:33151:17)
    at StaticClosure.fromUri (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:16133:37)
    at Object.NullableExtension_andThen0 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:18450:40)
    at Object._wrapException (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:13015:14)
    at _render_closure1.call$2 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:81648:21)
    at _RootZone.runBinary$3$3 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:27468:18)
    at _FutureListener.handleError$1 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:26017:19)
    at _Future__propagateToListeners_handleError.call$0 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:26315:49)
    at Object._Future__propagateToListeners (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:4544:77) {
  dartException: <ref *1> ArgumentError {
    _hasValue: false,
    invalidValue: null,
    name: null,
    message: "Uri c:%5Cprojects%5Cmy-vue-app%5Cpackages%5Ca%5Csvg.scss must have scheme 'file:'.",
    '$thrownJsError': <ref *2> Invalid argument(s): Uri c:%5Cprojects%5Cmy-vue-app%5Cpackages%5Ca%5Csvg.scss must have scheme 'file:'.
        at Object.wrapException (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:1234:17)
        at WindowsStyle.pathFromUri$1 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:33151:17)
        at StaticClosure.fromUri (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:16133:37)
        at Object.NullableExtension_andThen0 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:18450:40)
        at Object._wrapException (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:13015:14)
        at _render_closure1.call$2 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:81648:21)
        at _RootZone.runBinary$3$3 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:27468:18)
        at _FutureListener.handleError$1 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:26017:19)
        at _Future__propagateToListeners_handleError.call$0 (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:26315:49)
        at Object._Future__propagateToListeners (C:\projects\my-vue-app\node_modules\sass\sass.dart.js:4544:77) {
      dartException: [Circular *1],
      '$cachedTrace': _StackTrace {
        _exception: [Circular *2],
        _trace: "Invalid argument(s): Uri c:%5Cprojects%5Cmy-vue-app%5Cpackages%5Ca%5Csvg.scss must have scheme 'file:'.\n" +
          '    at Object.wrapException (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:1234:17)\n' +
          '    at WindowsStyle.pathFromUri$1 (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:33151:17)\n' +
          '    at StaticClosure.fromUri (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:16133:37)\n' +
          '    at Object.NullableExtension_andThen0 (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:18450:40)\n' +
          '    at Object._wrapException (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:13015:14)\n' +
          '    at _render_closure1.call$2 (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:81648:21)\n' +
          '    at _RootZone.runBinary$3$3 (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:27468:18)\n' +
          '    at _FutureListener.handleError$1 (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:26017:19)\n' +
          '    at _Future__propagateToListeners_handleError.call$0 (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:26315:49)\n' +
          '    at Object._Future__propagateToListeners (C:\\projects\\my-vue-app\\node_modules\\sass\\sass.dart.js:4544:77)'
      }
    }
  }
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • 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 https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Addtional info:

Lines triggeres this bug:

@function svg-url($string) {
  // FIXME: The above line is triggering this error, must be certain function name with params.
  // I haven't figure out what kind of functionname and param name can trigger this error

  // original function is removed
  @return "";
}

This is absolutely not a bug with sass because it's working prefect with webpack.

@github-actions
Copy link

This issue has been locked since it has been closed for more than 14 days.

If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant