-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@property
/ static get properties
break in certain webpack/babel configurations
#1135
Comments
static get properties
@property
/ static get properties
break in certain webpack/babel configurations
Just to confirm... you're authoring in TS, but are you using TS's decorator transform, or relying on babel for that? The root cause looks to be a flavor of https://github.com/Polymer/lit-element/issues/1030 (and an issue with transforming class field initializers to the Looking at the compiled source, we see the working one uses assignment, the failing one uses function ThingA() {
...
// GOOD ======================
_this3.isOn = void 0;
...
} var ThingB = (_dec3 = Object(lit_element__WEBPACK_IMPORTED_MODULE_2__["customElement"])('thing-b'), _dec4 = Object(lit_element__WEBPACK_IMPORTED_MODULE_2__["property"])({
type: Boolean
}), _dec3(_class5 = (_class6 = (_temp3 = /*#__PURE__*/function (_LitElement3) {
...
// BAD ======================
_initializerDefineProperty(_this4, "isOn", _descriptor, _assertThisInitialized(_this4));
...
} Compiling with TS and ensuring |
Yes, I'm running the Ts through babel-loader via storybook's webpack config. It sounds like switching to And when publishing as ES2017, it looks like typescript transforms away the decorators into a more compatible syntax. |
I think this is causing issues with the default setup on codesandbox.io repro with https://codesandbox.io/s/cool-voice-mnwxv?file=/src/App.tsx I also think this is the cause of another issue reported by a community member on slack. I was able to make a glitch repo of their project. The issue is that https://glitch.com/edit/#!/enchanted-wax-drum?path=src%2Fcomponents%2Ftun-player.ts%3A25%3A0 users' solution on the second one was to add the following (which throws a warning at build for having both Regardless, this leads to issues with projects where you cannot access the babel config like the codesandbox example EDIT: I have a minimal repro https://glitch.com/edit/#!/auspicious-handsomely-scabiosa?path=babel.config.json%3A8%3A63 |
This is certainly a weird issue. I spent most of yesterday and today debugging this and narrowing it down in a repro. Apologies for the complexity, but it involves babel and webpack and storybook. I have not been able to reduce it further, but I would appreciate help in doing so, or perhaps this is enough.
In essence, it looks like code transpilation can disable
@property
andstatic get properties
and make them not function. I'm making this issue to perhaps help people who might also run into this, and myself of course. It would be worth documenting as a caveat whatever the root cause turns out to be.Description
I'm seeing an issue where
@property
decorator fails to work, compared to tostatic get properties
.static get properties
fails to work, but@property
works.By "work" I mean trigger component re-render when the property changes.
Live Demo
https://codesandbox.io/s/loving-violet-rfk7c?file=/stories/Example.stories.ts
This is a barebones
@storybook/html
setup. Storybook uses its own webpack config for transpiling the story code. I was unable to repro with plain webpack (attempt). So maybe this is caused by a bad combination of babel plugins or options.Steps to Reproduce
Expected Results
All three elements It should cycle between on and off.
Actual Results
The "B" component does not update.
In
.storybook/main.js
you can uncomment a babel configuration that follows the recommendations in Build for production. However, once applied, component "A" now breaks and "B" starts working. Happy Wednesday.Browsers Affected
@storybook/web-components
Versions
Note: the repro uses
@storybook/html
instead of@storybook/web-components
because I had dependency issues with the latter. Maybe I should give it another shot? Anyway, this issue seems worth reporting regardless.The text was updated successfully, but these errors were encountered: