question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using `import` inside classic worker, syntax error happens during dev but build success

See original GitHub issue

Describe 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

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
egriff38commented, Oct 12, 2022

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?

1reaction
poyohocommented, Jun 6, 2022

so the issue asks for

  1. dynamic import support in classic worker (build mode)
  2. static import support in classic worker (dev mode) 😵
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found