-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Web-Worker failed to load #15359
Comments
I can reproduce the issue on stackblitz as well (though it takes quite some time to load all unbundled monaco-editor related assets...) https://stackblitz.com/edit/github-nwnjfg?file=src%2Flanguages%2FlanguageSetup.ts The difference of these two seems to be Vite's deps optimization.
// src/languages/languageSetup.ts
import FlinkSQLWorker from 'monaco-sql-languages/out/esm/flinksql/flinksql.worker?worker';
// src/languages/languageSetup.ts
import FlinkSQLWorker from './workerTransform/flinksql.worker?worker';
// src/languages/workerTransform/flinksql.worker.ts
import 'monaco-sql-languages/out/esm/flinksql/flinksql.worker'; Only for the 2nd case, Vite shows a following log and tweaking
I'm not sure if this is a known limitation or such usage is not supposed to work. Also, if |
@hi-ogawa Thank you for your answer. Regarding Do you mean that in the first case, Vite won't pre-bundle the worker files of monaco-sql-languages, leading to this problem? If that's true, how could I make Vite trigger pre-bundling in the first case? Or are you suggesting that I need to ensure monaco-sql-languages can function properly even without pre-bundling? |
Your 2nd approach seems to be a reasonable workaround and it makes sense to me. My assumption is that Unfortunately, I'm not so familiar with deps optimization / pre-bundling either, so you might need to wait for someone who is more experienced can figure out the root cause.
It's just an observation from the surface level since I'm not familiar with monaco-editor ecosystem, but comparing with monaco-editor's builtin modules like EDIT: Small follow up after trying to understand Vite's deps optimization. I'm not sure if this explains the whole story, but I spotted that there is vite/packages/vite/src/node/plugins/resolve.ts Lines 839 to 845 in 5684fcd
vite/packages/vite/src/node/constants.ts Line 55 in 5684fcd
|
I'm having a similar issue, but with TLA usage inside an imported worker via
Even though my vite config contains
I'm guessing that whatever runs |
@Banou26 Do you use |
I'm having a similar issue with the monaco-editor package
Reference: code I'm trying to use this block of code to get the editor workers instead of the calls to CDNs, I get this error message when I try to build the project (using yarn build)
Any idea around how to fix this? |
Your error looks like a typescript error, so it's a different nature of the issue from the one discussed here. // @ts-ignore
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'; |
Thank you for the reply! |
I have this code below: NOTE: Any idea how to fix this? |
@vcsavinash OP's issue is specific to dev, so if you are having an issue on build, then that should be a different cause. Please open a separate issue with a reproduction, so we can properly investigate it. |
Describe the bug
Unable to integrate monaco-sql-languages in a vite project.
Maybe it's not an issue with vite, but I do need help. I'm maintaining monaco-sql-languages, and I found monaco-yaml having the same issue and it wasn't resolved
Related to this issue, I can't comment under this issue because it's locked. The last comment on this issue said it was fixed, but I still reproduce the issue. Also, in the documentation for the monaco-yaml repository, it is mentioned that it is still not compatible with Vite.
This is a weird bug where when I import the worker file directly from monaco-sql-languages, an gets an exception. But if I used the way mentioned in the moanco-yaml repository, it worked well.
Reproduction
https://github.com/HaydenOrz/monaco-sql-languages-vite
Steps to reproduce
npm install
npm dev
System Info
Used Package Manager
npm
Validations
Edit:
If you use the method mentioned above, i.e., create a new file and import the worker file internally, and then use the new file as a worker file.
src/languages/workerTransform/flinksql.worker.ts
using the worker file
This only works in development mode. Exceptions will still occur in production mode. ( testing via
npm run build & npm run preview
)The text was updated successfully, but these errors were encountered: