-
-
Notifications
You must be signed in to change notification settings - Fork 738
Open
Description
Version
System:
OS: Linux 6.12 cpe:/o:nixos:nixos:25.11 25.11 (Xantusia)
CPU: (6) x64 AMD Ryzen 5 4500U with Radeon Graphics
Memory: 4.16 GB / 15.00 GB
Container: Yes
Shell: 5.9 - /run/current-system/sw/bin/zsh
Browsers:
Firefox: 143.0.1
Firefox Developer Edition: 143.0.1
npmPackages:
@rspack/cli: ^1.5.8 => 1.5.8
@rspack/core: ^1.5.8 => 1.5.8Details
Input
In a.ts we export a function f.
In index.ts, we import f, define a random 2203 decorator id, define a class Test decorated by id referencing f and call f.
// a.ts
export const f = () => console.log('f() called')// index.ts
import { f } from './a'
const id = <T>(x: T): T => x
@id
export class Test {
method() {
f()
}
}
f()The correct output should be:
// ...
const f = ()=>console.log('f() called');
// ...
const id = (x)=>x;
let _Test;
class Test {
method() {
f();
}
}
({ c: [_Test, _initClass] } = _apply_decs_2203_r(Test, [], [
id
]));
_initClass();
f();However, when target is set to 'es2022' or higher, the output becomes:
// ...
const a_f = ()=>console.log('f() called');
// ...
const id = (x)=>x;
let _Test;
class Test {
static{
({ c: [_Test, _initClass] } = _apply_decs_2203_r(this, [], [
id
]));
}
method() {
f(); // !
}
static{
_initClass();
}
}
a_f();And if we remove the call to f from index.ts, const a_f = ... disappears;
if we remove the decorator id, it compiles correctly.
In other words, imports used inside class with decorator 2203 aren't recognized correctly under this target.
Reproduce link
https://github.com/ForkKILLET/rslib-repro-deco-2203
Reproduce Steps
- Clone the reproduction repo.
- Run
pnpm i - Modify target to
'es2022'or higher in code. - Run
pnpm exec rspack build. - See the output in
dist-rspack/.