You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading Vite from 4.3.9 (esbuild 0.17.19) to Vite 4.4.9 (esbuild 0.18.20), decorators that are static class members stop working when the decorated static method instantiates the class.
In this case, the class will be created as temporary variable (e.g. _Test), and will be decorated using the original class name (Test) before that variable will be defined (let Test = _Test).
Original test code (Test1 works as expected, Test2 fails with esbuild 0.18):
exportclassTest1{staticdeco(){}statictest(){}}__decorateClass([Test1.deco],Test1,"test",1);const_Test2=class{staticdeco(){}statictest(){returnnew_Test2();}};exportletTest2=_Test2;__decorateClass([Test2.deco],Test2,"test",1);// <============ works
esbuild 0.18.20
exportclassTest1{staticdeco(){}statictest(){}}__decorateClass([Test1.deco],Test1,"test",1);const_Test2=class_Test2{staticdeco(){}statictest(){returnnew_Test2();}};__decorateClass([Test2.deco],_Test2,"test",1);// <============= uses "Test2" instead of "_Test2"exportletTest2=_Test2;
Importing the module immediately fails with
ReferenceError: Cannot access 'Test2' before initialization
The text was updated successfully, but these errors were encountered:
I am having this issue as well. It looks like it occurs in any class with static members (which cause an underscore prefix rename on the class). It seems the problem is just that the renamed class is not used in the call to __decorateClass.
After upgrading Vite from 4.3.9 (esbuild 0.17.19) to Vite 4.4.9 (esbuild 0.18.20), decorators that are static class members stop working when the decorated static method instantiates the class.
In this case, the class will be created as temporary variable (e.g.
_Test
), and will be decorated using the original class name (Test
) before that variable will be defined (let Test = _Test
).Original test code (
Test1
works as expected,Test2
fails with esbuild 0.18):esbuild 0.17.19
esbuild 0.18.20
Importing the module immediately fails with
The text was updated successfully, but these errors were encountered: