-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Description
Describe the bug
There should be some environmental variable to skip the maybeJSX variable bailing, or it should be a warning.
This flags incorrectly for us, as we're specifically serving Svelte files without the Svelte plugin for integration with a file editor.
This comes from line 198 of importAnalysis.ts:
| const maybeJSX = !isVue && isJSRequest(importer) |
Also see: #6246
Reproduction
https://stackblitz.com/edit/vitejs-vite-9nnfuu?file=counter.js
System Info
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 87.70 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
Browsers:
Chrome: 105.0.5195.125
Firefox: 104.0.1
Safari: 15.6.1Used Package Manager
npm
Logs
17:34:04 [vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
Plugin: vite:import-analysis
File: /home/projects/vitejs-vite-9nnfuu/foo/bar.svelte
1 | <script>
2 | let foo = 'bar';
3 | </script>
| ^
4 | <h1>this is a file that should be served as is</h1>
at formatError (file:///home/projects/vitejs-vite-9nnfuu/node_modules/vite/dist/node/chunks/dep-665b0112.js:40828:46)
at TransformContext.error (file:///home/projects/vitejs-vite-9nnfuu/node_modules/vite/dist/node/chunks/dep-665b0112.js:40824:19)
at TransformContext.transform (file:///home/projects/vitejs-vite-9nnfuu/node_modules/vite/dist/node/chunks/dep-665b0112.js:37495:22)
at async Object.transform (file:///home/projects/vitejs-vite-9nnfuu/node_modules/vite/dist/node/chunks/dep-665b0112.js:41077:30)
at async loadAndTransform (file:///home/projects/vitejs-vite-9nnfuu/node_modules/vite/dist/node/chunks/dep-665b0112.js:37338:29)
Validations
- Follow our Code of Conduct
- 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.
- 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 instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable