-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Bug report
What is the current behavior?
Running files outputted by webpack containing a static initialization block that uses an imported binding throws ReferenceError. Running source files results in no error at runtime.
// foo.mjs
export default class Foo {}
// bar.mjs
import Foo from './foo.mjs';
export default class Bar {
static foo;
static {
// The following line will throw at runtime when running a file produced
// by webpack from this one.
this.foo = new Foo();
}
}If the current behavior is a bug, please provide the steps to reproduce.
I created a repository with reproduction of this bug: https://github.com/gebsh/webpack-static-blocks. It already contains files produced by webpack in the dist directory. If needed, they can be created by running start npm script.
What is the expected behavior?
ReferenceError should not be thrown when running files outputted by webpack.
Other relevant information:
webpack version: 5.73.0
Node.js version: 18.6.0
Operating System: macOS Monterey 12.4
Additional tools: -