-
Notifications
You must be signed in to change notification settings - Fork 79
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
loader worker-plugin/loader is not found by webpack #62
Comments
@stephanemagnenat TypeScript doesn't allow loader syntax in imports - I'd recommend using Webpack configuration to apply the loader instead: module.exports = {
module: {
rules: [
{
test: /\.worklet\.(js|ts)x?$/,
loader: 'worker-plugin/loader'
}
]
}
} With the above in your Webpack configuration, you should be able to do: import musicWorkletURL from './music.worklet'; I'm not aware of any clean way to specify types for this, so I'd recommend casting the value to a String. |
Thank you for your answer! I am using Webpack actually. I also tried the option you propose before posting the issue, but then Webpack crashed at startup due to the node VM exhausting its memory. It seems that in my configuration, something triggers an infinite loop in Webpack when using a rule with the worker-plugin (but not with other plugins), and a non-detection when using the loader syntax in imports. So I see no other way to find the source of the issue than to make a minimal test case, and if the latter works, to bisect between it and my configuration until the problem appears. Of course it would take some time, that is why I did not do it yet. |
@stephanemagnenat Sounds tricky. A reproduction would be super helpful as you mentioned. In the meantime, I think one way to work around this would be to configure the loader so that it only runs in your main compiler, not any compilers spawned by module.exports = {
name: 'main', // if you don't have this already. must match the Rule below
module: {
rules: [
(info) => ({
test: /\.worklet\.(js|ts)x?$/,
// only apply to main compilation:
include: () => info.compiler === 'main',
loader: 'worker-plugin/loader'
})
]
}
} |
@stephanemagnenat any chance this issue went away? I noticed that the original issue was filed on May 11th, which is only one day after I released a hotfix that added |
I am positive I used the very-up-to-date version by then |
I'm still experiencing this crash issue. Using the webpack configuration and doing the direct import of worker file. I'm using latest 4.0.3. |
I think I know what is causing the crash, will try to reproduce so I can add a fix. |
@developit has there been any progress on this? |
I haven't been able to reproduce the issue. If anyone has a reproduction I can look at, that would be helpful. |
Using worker-plugin version 4.0.2, and trying to use the
worker-plugin/loader
syntax, I get the following error in Webpack:is the line:
The file
music.ts
imports the workermusic.worklet.ts
.I am using Webpack 4.42 and Typescript 3.8.3 (both latest).
While my configuration files have nothing exotic IMHO, I am aware that this problem still is likely the result of a complex interaction between Webpack and Typescript, and I will produce a minimal test case as soon as possible. I still post the issue already in case someone else meets the same problem.
The text was updated successfully, but these errors were encountered: