-
Notifications
You must be signed in to change notification settings - Fork 200
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
Pin @babel/plugin-transform-classes to v7.0.0-beta.35 #216
Conversation
…m-classes can be pinned to v7.0.0-beta.35 .
packages/build/src/js-transform.ts
Outdated
[require('@babel/preset-es2015'), {modules: false}]; | ||
const customBabelPresetEs2015 = { | ||
plugins: [ | ||
[require("@babel/plugin-transform-template-literals"), { loose: false, spec: false }], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of these parameters are default false except for the regenerator ones? Could just leave off the ones that aren't changing a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were right, almost all of these were the defaults.
packages/build/src/js-transform.ts
Outdated
@@ -29,8 +29,30 @@ import isWindows = require('is-windows'); | |||
// minifying but not compiling? | |||
|
|||
// Syntax and transform plugins for ES2015. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add note linking to bug about class plugin and mention its why we aren't using the preset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -168,7 +190,7 @@ export function jsTransform(js: string, options: JsTransformOptions): string { | |||
} | |||
if (options.compileToEs5) { | |||
doBabelTransform = true; | |||
presets.push(babelPresetEs2015NoModules); | |||
presets.push(customBabelPresetEs2015); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plugins.push(...
? Probably works either way, but seems more clear now that it's not technically a preset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, this would change the order? https://babeljs.io/docs/plugins/#pluginpreset-ordering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://babeljs.io/docs/plugins/#creating-a-preset kinda makes it sound like this counts as a preset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a preset is just an array of plugins, and yes it does affect ordering (if you look above in the transform functions I mentioned how things are ordered). I guess this is fine, and it definitely won't change the ordering!
Also mind adding a CHANGELOG entry? Should probably mention it on build, CLI, and polyserve since the bug affects all of those end uses, and each will need to be released to pick it up because we do = pinning on build and the other pre- packages. |
If there's a straightforward way to check that the bad transform is not happening, mind adding a regression test in js-transform_test? |
I've added a test that checks for whether or not the empty function on this line (the broken constructor) is injected into the output when creating a class that extends from |
packages/build/package.json
Outdated
"@babel/plugin-external-helpers": "^7.0.0-beta.46", | ||
"@babel/plugin-proposal-async-generator-functions": "^7.0.0-beta.46", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.46", | ||
"@babel/plugin-syntax-async-generators": "^7.0.0-beta.46", | ||
"@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.43", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to bump this one to 46 also, just to keep everything else at the same version.
…ther babel dependencies.
`); | ||
const result = jsTransform(input, {compileToEs5: true}); | ||
|
||
assert.notInclude(result, "function Wrapper() {}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about checking for wrapNativeSuper
, since it's the name of the helper function that contains this line? Maybe less brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a better idea; the whitespace in this string was making me a bit worried: function Wrapper() {}
vs. function Wrapper(){}
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about checking for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the wrapper function thing and wrapNativeSuper
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just wrapNativeSuper is fine. If you did do both, make sure it's an or, since an and would be more brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll just do wrapNativeSuper
then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
We should probably test with shop or something, just to make sure it actually works at runtime. Like I could imagine a breakage due to the helpers and the transformer being out of sync. |
I've been trying with a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested branch locally, LGTM
@keanulee thanks! I was just about to walk over and ask. :) |
722388e
to
e04cf2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis looks good. Only a couple of uncorrelated WCT test timed out on different VMs. Definite transient errors; doesn't warrant another run at CI if there's no more changes for this PR.
I'm going to revert the last commit. I was hoping it was going to make these pass but since it's not helping here I don't see any reason to include it. |
e04cf2f
to
2db915c
Compare
if you merge in master you'll get unit and integration tests split out. maybe easier to see whats going on |
Ok, I'll try that. |
Russell, I updated travis.yml on master to reduce sauce session contention and got 4 green travis runs on the first try in a long time. Merge master again for that goodness. |
@bicknellr I went ahead and merged master into this branch to get that effect. Hopefully will just see green CI in 20 minutes here. |
@usergenic I just saw that PR - awesome! Anxiously awaiting the Travis results: so far 3 for 3. |
Thanks so much for figuring that out! |
Pls unpin. |
…cates (#216) * Properly key converted documents by original url, correct destination * remove unneccesary template string wrapper * respond to justin review feedback * handle ConvertedDocumentFilePath conversion better * create shouldConvertDocument() method * update upsteam test format
babel/babel#7020 (included in v7.0.0-beta.36) breaks our assumptions about how babel will transform ES6 classes. Particularly, it changes the way that compiled ES6 classes which extend (what babel assumes to be) native constructors such that the subclasses no longer call into the parent classes' constructors. This is allows the transformation to avoid a specific type of error when extending native constructors: most must be constructed with
new
(orsuper
/Reflect.construct
, which aren't available inES2015
) and will throw when called usingcall
orapply
. However, the polyfill needs the user to call into the polyfilled constructor to retrieve the exact element which is being upgraded and so that the user's constructors are called with that specific element asthis
.This PR manually assembles the set of transforms in
@babel/preset-es2015
(with our particular configuration) for the purpose of being able to pin@babel/plugin-transform-classes
to v7.0.0-beta.35 .babel/babel#7506 - a bug about this issue
babel/babel#7533 - related PR to fix bug above