When using `import` inside classic worker, syntax error happens during dev but build success
See original GitHub issueDescribe the bug
When import
is used in classic worker, the following error happens during dev.
Uncaught SyntaxError: Cannot use import statement outside a module
But build works with it and the bundle seems to be correctly bundled.
According to the docs, import
can be used inside classic worker if worker is imported with query suffixes.
There is no mention about constructor type worker import. But if it is the recommended way, I think it would be good to support it too. Also it is useful for #8466.
https://github.com/vitejs/vite/issues/8466#issuecomment-1146655205 might be related.
Reproduction
https://stackblitz.com/edit/vitejs-vite-mhmcjy?file=main.js
System Info
stackblitz
Vite: 2.9.9, 3.0.0-alpha.9
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 https://github.com/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.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:13 (12 by maintainers)
Top Results From Across the Web
my project java code has some syntax error but it is maven ...
eclipse - my project java code has some syntax error but it is maven build working success, it makes me confused - Stack...
Read more >Troubleshoot pipeline runs - Azure DevOps - Microsoft Learn
Learn how to troubleshoot pipeline runs in Azure Pipelines and Team Foundation Server.
Read more >How to Think Like a Computer Scientist: Learning with Python ...
Syntax errors are produced by Python when it is translating the source code into byte code. They usually indicate that there is something...
Read more >Best Practices - Apache Airflow
Do not use INSERT during a task re-run, an INSERT statement might lead to ... is not necessary to create Operators and build...
Read more >Cannot use import statement outside a module' | HackerNoon
2 Quick and Easy Ways to Fix 'Uncaught SyntaxError: Cannot use import ... This error arises when we try to use import inside...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Following this issue. This is the biggest inhibitor to running workers with imports in dev mode with Firefox. I can’t be the only one who develops against Firefox, right?
so the issue asks for