[backport request] Backport fix of an already-fixed bug of next-swc
Link to the code that reproduces this issue
https://stackblitz.com/edit/nextjs-wzyqzn?file=app%2Fpage.tsx
To Reproduce
just open the stackblize online reproduce
Current vs. Expected behavior
class Father {
static instance = {};
static register() {
return (target) => {
class Wrapper extends target {
constructor(props) {
super({
...props,
});
}
}
this.instance = new Wrapper();
};
}
private _a = 1;
constructor() {
this._a = 2;
}
}
@Father.register()
class Son {}
console.log(Father.instance._a); // 1, but why ???
expect
should compile correct
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: Ubuntu 20.04.0 LTS Wed May 22 2024 23:45:04 GMT+0800 (中国标准时间)
Binaries:
Node: 18.20.3
npm: 10.2.3
Yarn: 1.22.19
pnpm: 8.15.6
Relevant Packages:
next: 14.1.0
eslint-config-next: 13.5.1
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
SWC
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
The latest canary version fix this issue, but I can find a good way to fix it now.
I want to use canary but it require react19. I try use yarn1 resolution to lock the next swc version, but yarn1 seems can't correctly deal with resolution with optionalDependencies:
So, I thing the best method way to fix this is the nextjs official release a new 14.x version.
I think the compile error is a serious error and cost me one day to locate it.
more context:
- https://x.com/YuTengjing/status/1793270230531395826
- https://github.com/swc-project/swc/pull/8835
So you are requesting a backport?
@kdy1 I recently upgrade my company project next from 12 to 14, next12 no this bug. The latest nextjs still has this bug but canary version had fixed it.
I don't know when the next will release the new version to fix it, But now there is no good way to fix it.
Yeap I understood. If we want to publish a new version that uses react@18 and recent SWC, we need to revert many commits before publishing and it should be a backport
I see that issue is related with swc loose setting, any way to config swc not to use losse?
ref: https://github.com/swc-project/swc/issues/8830#issuecomment-2044727551
next-swc does not use loose mode
@kdy1 I see there is a new 14.x update, but this issue is still not fixed
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
https://github.com/vercel/next.js/blob/v14.2.4/Cargo.lock#L5431
It's 0.90.30 and but the fix is 0.90.31
This issue has been automatically marked as stale due to inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.
This issue has been automatically closed due to inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!