-
Notifications
You must be signed in to change notification settings - Fork 698
Closed
Copy link
Description
Reproduction link or steps
package.json:
{
"type": "module",
"dependencies": {
"rolldown": "^1.0.0-beta.33"
},
"scripts": {
"build": "rolldown -c"
}
}rolldown.config.js:
import { defineConfig } from 'rolldown'
export default defineConfig({
input: 'index.js',
output: {
file: 'bundle.js',
format: 'es',
topLevelVar: true
}
})index.js:
class Example {
static {
this.prop = new Example()
}
}Run npm run build to produce the bundle with the error.
What is expected?
For the Example constructor to be available in the class' static block, it must still be named, like this:
var Example = class Example {
static {
this.prop = new Example();
}
};This is also the same output as when topLevelVar is disabled.
What is actually happening?
The repro steps produce this bundle:
//#region index.js
var Example = class {
static {
this.prop = new Example();
}
};
//#endregionHere, Example is not available in the static block, causing a TypeError when running the bundle module.
System Info
System:
OS: Windows 11 10.0.26100
CPU: (12) x64 AMD Ryzen 5 PRO 4650G with Radeon Graphics
Memory: 2.06 GB / 15.39 GB
Binaries:
Node: 22.14.0 - C:\Program Files\nodejs\node.EXE
npm: 11.4.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (139.0.3405.111)
npmPackages:
rolldown: ^1.0.0-beta.33 => 1.0.0-beta.33Any additional comments?
No response
Reactions are currently unavailable