-
Notifications
You must be signed in to change notification settings - Fork 40
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
Not generating a web worker script #36
Comments
solved it. it was more of a webpack config problem, once i added a config.module.rules.push({
test: /\.worker\.(js|ts)$/i,
use: [
{
loader: "comlink-loader",
options: {
singleton: true,
},
},
/* below loader options section copied from node_modules/react-scripts@3.4.3/config/webpack.config.js#382 */
{
loader: require.resolve("babel-loader"),
options: {
customize: require.resolve("babel-preset-react-app/webpack-overrides"),
babelrc: false,
configFile: false,
presets: [require.resolve("babel-preset-react-app")],
cacheIdentifier: getCacheIdentifier(isEnvProduction ? "production" : isEnvDevelopment && "development", [
"babel-plugin-named-asset-import",
"babel-preset-react-app",
"react-dev-utils",
"react-scripts",
]),
cacheDirectory: true,
cacheCompression: false,
compact: isEnvProduction,
},
},
],
});
``` |
Just a comment, the original problem might have been that
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a setup with cra 3.4.3 with webpack 4.42.0 and storybook. I need the cra build to use comlink-loader and the storybook static build to ignore it (because when i run storyshots, the web worker loading fails with the following
Failed to construct Worker. Cannot be accessed from Origin null
, logical since the page gets loaded usingfile:///
I changed my setup as follows to use singleton mode since i figured it would be easier to use different webpack configs for cra and storybook
the module that will become a worker
I then call my worker as outlined in the documentation, with
await
my cra webpack config (using react-app-rewired)
and my storybook webpack config simply doesn't declare a comlink-loader therefore skipping the web worker wrapping altogether.
problem 1
I see no webworker in my sources tab, and fuseSearch runs on the main thread! comlink-loader does not generate a script for the worker.
Is the config i outlined above valid? why is not generating a web worker script?
problem 2
When i changed the config override to have
cofing.modules.rules.push
instead ofcofing.modules.rules.shift
I got the following error messagewhich i assume is logical? because the comlink-loader needs to run first?
Edit: specified webpack and react-scripts versions
The text was updated successfully, but these errors were encountered: