Bug report
What is the current behavior?
The calls to static members of the class fail inside the class body when the name of the class in a class expression shadow a import name.
If the current behavior is a bug, please provide the steps to reproduce.
a.mjs:
index.mjs:
import { a as C } from "./a.mjs"
let CV = class C {
static name = "test";
static test() {
console.log(C.name);
}
}
console.log(C);
CV.test();
Bundled code snippet in none mode:
let CV = class C {
static name = "test";
static test() {
console.log(_a_mjs__WEBPACK_IMPORTED_MODULE_0__.a.name);
}
}
console.log(_a_mjs__WEBPACK_IMPORTED_MODULE_0__.a);
CV.test();
})();
Bundled code in production mode:
(()=>{"use strict";console.log(1),class{static name="test";static test(){console.log(1..name)}}.test()})();
Running dist output in either mode:
> node dist/index.js
1
undefined
What is the expected behavior?
Running src code:
> node src/index.mjs
1
test
Other relevant information:
webpack version: 5.75.0
Node.js version: 19.7.0
Operating System:
Additional tools:
This code pattern came about as a result of the changes in Rollup PR rollup/rollup#4827 and how Terser will shadow the import when possible when mangling.