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
The decorators code in production build with optimization works as it is in serve mode.
😯 Current Behavior
The decorators code in production build runs into the following error:
Uncaught TypeError: Function expected
at r (index.0cb3d518.js:1:110)
at e (index.0cb3d518.js:1:811)
at index.0cb3d518.js:2:358
at index.0cb3d518.js:2:539
at index.0cb3d518.js:2:545
💁 Possible Solution
See below.
// part of code in parcel serveSymbol.metadata??=Symbol("Symbol.metadata");constCustomElement=(tag)=>{return(ctor,context)=>{context.addInitializer(function(){customElements.define(tag,this);console.log("metadata:",context.metadata);});returnctor;};};letA=(()=>{let_classDecorators=[CustomElement("component-a")];let_classDescriptor;let_classExtraInitializers=[];let_classThis;let_classSuper=HTMLElement;varA=classextends_classSuper{static #_ =(()=>{_classThis=this;})();static #_1 =(()=>{const_metadata=typeofSymbol==="function"&&Symbol.metadata ? Object.create(_classSuper[Symbol.metadata]??null) : void0;__esDecorate(null,_classDescriptor={value: _classThis},_classDecorators,{kind: "class",name: _classThis.name,metadata: _metadata},null,_classExtraInitializers);A=_classThis=_classDescriptor.value;if(_metadata)Object.defineProperty(_classThis,Symbol.metadata,{enumerable: true,configurable: true,writable: true,value: _metadata});__runInitializers(_classThis,_classExtraInitializers);})();constructor(){super();this.innerHTML="Component A is working";}};returnA=_classThis;})();console.log(newA().tagName);
// part of code in parcel buildSymbol.metadata??=Symbol("Symbol.metadata");consta=(e)=>(t,a)=>(a.addInitializer(function(){customElements.define(e,this),console.log("metadata:",a.metadata);}),t);console.log(new((()=>{letn,o,i=[a("component-a")],r=[],l=HTMLElement;// also missing class body and `this` context for class static initializersreturn((()=>{o=this;})(),(()=>{leta="function"==typeofSymbol&&Symbol.metadata ? Object.create(l[Symbol.metadata]??null) : void0;e(null,(n={value: o}),i,{kind: "class",name: o.name,metadata: a},null,r),(o=n.value),a&&Object.defineProperty(o,Symbol.metadata,{enumerable: !0,configurable: !0,writable: !0,value: a}),t(o,r);})(),o);})())().tagName);
🔦 Context
Same behavior with #8989 but with different versions of parcel and typescript.
🐛 bug report
The decorator metadata introduced in TypeScript 5.2 crashes in production build with optimization enabled. Perhaps same issue with #8989.
🎛 Configuration (.babelrc, package.json, cli command)
Detailed configuration can be found in the minimum example to reproduce:
https://github.com/DarrenDanielDay/parcel-issue-typescript-5-decorators
🤔 Expected Behavior
The decorators code in production build with optimization works as it is in serve mode.
😯 Current Behavior
The decorators code in production build runs into the following error:
💁 Possible Solution
See below.
🔦 Context
Same behavior with #8989 but with different versions of
parcel
andtypescript
.💻 Code Sample
https://github.com/DarrenDanielDay/parcel-issue-typescript-5-decorators
🌍 Your Environment
The text was updated successfully, but these errors were encountered: