-
Notifications
You must be signed in to change notification settings - Fork 78
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
Cannot load worker module unless the worker.js is under public/. #69
Comments
Hi @bfang711 - from what you described, it's clear |
Yes. of course.
Many thanks. |
- plugins: [new HtmlWebpackPlugin(), new WorkerPlugin(globalObject: 'self')],
+ plugins: [new HtmlWebpackPlugin(), new WorkerPlugin({ globalObject: 'self' })], |
hi Jason, Thank you for your prompt response. I changed it, however still the same issue. Any other clue what can cause the issue? thank you. |
Ah - I see the problem now: you're telling Webpack to bundle for Nodejs via Here's a setup with the information provided - it works in both dev and prod modes, as long as |
I marked as invalid for now, but please let me know what happens with your build. I actually was under the impression |
hi. Jason Do you think react-scripts could be the issue here? |
Oh, yes. That explains why WorkerPlugin wasn't running, your configuration wasn't actually being used! I'm going to close this one out since it's not related to the plugin, but I hope you're able to eject and get it working! |
Hi, Jason,
Here is what I did. I npm install react-scripts on your given example, and
added in a simple public/index.html as it needed. Then same issue popped
up.
Then I followed your instructions to do "npm run eject", which
basically running react-scripts eject, and re compile. However still the
same issue.
Do you by any chance know how to fix this or any suggestions? (Actually all
I need is to use react in my website, and of course worker-plugin)
thank you so much.
Jason Miller <notifications@github.com> 于2020年5月2日周六 下午10:57写道:
… Closed #69 <#69>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#69 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADEH6IELAENYYHOD6FOTMK3RPTMSXANCNFSM4MMZTBPQ>
.
|
I would like put my worker.js under the same
src/
directory asmain.js
, which loads worker. (src/
is parallel topublic/
) However I got the following error ifworker.js
is undersrc/
.//in main.js
let worker = new Worker('./worker.js', {type:"module"});
However if I put
worker.js
underpublic/
, or any directory under public/, everything works fine. Seems like it can only load frompublic/
aka.http://<my domain>/
, if it is under any directory parallel topublic/
, then it cannot find it. am I right on this?Plus, in
worker.js
, I cannotimport
any thing innode_modules/
like what I do for other js files insrc/
.thanks.
The text was updated successfully, but these errors were encountered: