-
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
Webpack 5: ParserHelpers.addParsedVariableToModule is not a function #88
Comments
The function was removed in webpack/webpack#7781 (commit webpack/webpack@5553166) |
Yikes - I didn't know about this removal, thanks for looking into this. I believe the following should work as a replacement for the usage, to support both Webpack 4 and 5: let ModuleDecoratorDependency;
try {
ModuleDecoratorDependency = require("./dependencies/ModuleDecoratorDependency");
} catch (e) {}
// ... then replacing the above lines:
} else if (ModuleDecoratorDependency) {
const dep = new ModuleDecoratorDependency(
ParserHelpers.getModulePath(parser.state.module.context, loaderRequest),
parser.state.module
);
dep.loc = expr.loc;
parser.state.module.addDependency(dep);
}
} else {
// For CommonJS/Auto
const req = `require(${JSON.stringify(loaderRequest)})`;
ParserHelpers.toConstantDependency(parser, id)(expr.arguments[0]);
ParserHelpers.addParsedVariableToModule(parser, id, req);
} |
This is also an issue for me. I attempted to add your above code however the error persists. |
I wound up with a fresh error after making that change:
Did a little digging in the Webpack sources; couldn't find anything germane. |
FWIW Webpack 5 seems to have landed its own |
For people exploring the Webpack 5 syntax: const worker = new Worker(new URL("./my_worker.js", import.meta.url)); No extra plugin loading is required. |
Oh wow, thanks! Totally missed that. |
I was playing around with Webpack 5 + esbuild and now I think I'm clearly missing this plugin. The issue is that Webpack is now relying on |
Same for typescript const worker = new Worker(new URL('./workers/foo.worker.ts', import.meta.url)); https://github.com/azangru/web-worker-ts-webpack-test/blob/master/src/index.ts#L11 |
Unfortunately, Webpack5's Web Worker solution relies on |
Using Webpack 5 beta 25 (latest as of today) and worker plugin 5.0.0.
Initially reported at #84 (comment) but realized should have opened an issue.
Webpack 5 source for ParserHelpers does indeed not contain that function. Searching the Webpack 5 codebase also doesn't find it 🤔
I tried using the Webpack 4 definition on Webpack 5 does bundle, but doesn't work:
original source of above code (which works on webpack 4)
The text was updated successfully, but these errors were encountered: