-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Labels
feat: deps optimizerEsbuild Dependencies OptimizationEsbuild Dependencies Optimizationhas workaroundp3-downstream-blockerBlocking the downstream ecosystem to work properly (priority)Blocking the downstream ecosystem to work properly (priority)
Description
Describe the bug
When a .svelte file exports a snippet through its <script module>
block, it can cause a fail in the optimizer scan due to an export of something that isn't defined in the script ({#snippet foo()}
in the template defines it.
https://svelte.dev/docs/svelte/snippet#Exporting-snippets
downstream issue: sveltejs/vite-plugin-svelte#1066
error:
(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error: Failed to scan for dependencies from entries:
/home/projects/github-odonlwum-5xwrmunq/index.html
✘ [ERROR] "foo" is not declared in this file
script:/home/projects/github-odonlwum-5xwrmunq/src/Snippet.svelte?id=0:2:12:
2 │ export { foo };
╵ ~~~
at failureErrorWithLog (/home/projects/github-odonlwum-5xwrmunq/node_modules/esbuild/lib/main.js:1457:15)
The error does not happen if the script block uses lang=ts <script module lang="ts">
Reproduction
Steps to reproduce
npm i && npm run dev
System Info
not relevant
Used Package Manager
npm
Logs
No response
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.
reinhard-sanz and matrs
Metadata
Metadata
Assignees
Labels
feat: deps optimizerEsbuild Dependencies OptimizationEsbuild Dependencies Optimizationhas workaroundp3-downstream-blockerBlocking the downstream ecosystem to work properly (priority)Blocking the downstream ecosystem to work properly (priority)