Skip to content
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

[BUGFIX lts] Fix transpilation issues (e.g. `_createSuper` is not a function) when used with Babel 7.9.0+. #18831

Merged
merged 2 commits into from Mar 23, 2020

Conversation

@rwjblue
Copy link
Member

rwjblue commented Mar 21, 2020

Due to the way Ember itself is compiled, we have custom versions of the @babel/helpers that we inline into the IIFE that contains Ember. This is obviously pretty unideal (largely because it forces us to be misaligned with Babel and therefore brittle to reasonable changes that they make).

These helpers have been pretty stable for quite a while, but recently Babel 7.9.0 introduced a couple of new helpers:

  • createSuper allows subclassing from native classes, even when partially transpiled).
  • createForOfIteratorHelperLoose

Versions of ember-source prior to 3.13 fully transpiled with the Babel version in emberjs/ember.jss own yarn.lock at publish time. The build process was significantly changed in ember-source@3.13.0 so that ember-source would behave just like a normal addon. This was a huge improvement!! Unfortunately, those changes also made us vulnerable to changes made to Babel (new helpers added).

We must resolve that issue (likely by removing these custom external helpers in favor of using includeExternalHelpers from ember-cli-babel), but in the meantime this commit adds the required helpers which should fix the reported issue in supported Ember versions.

Fixes #18827

@rwjblue rwjblue added the Bug label Mar 21, 2020
@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 22, 2020

Confirmed failure:

Uncaught TypeError: (0 , _emberBabel.createSuper) is not a function
TypeError: (0 , _emberBabel.createSuper) is not a function
    at http://localhost:13141/ember-template-compiler.js:6962:46
    at http://localhost:13141/ember-template-compiler.js:7303:4
    at internalRequire (http://localhost:13141/tests/ember.js:64:14)
    at internalRequire (http://localhost:13141/tests/ember.js:60:22)
    at internalRequire (http://localhost:13141/tests/ember.js:60:22)
    at internalRequire (http://localhost:13141/tests/ember.js:60:22)
    at internalRequire (http://localhost:13141/tests/ember.js:60:22)
    at internalRequire (http://localhost:13141/tests/ember.js:60:22)
    at require (http://localhost:13141/tests/ember.js:97:14)
    at http://localhost:13141/ember-template-compiler.js:17947:92", source:  (52)
Due to the way Ember itself is compiled, we have custom versions of the
`@babel/helpers` that we inline into the IIFE that contains Ember. This
is obviously pretty unideal (largely because it forces us to be
misaligned with Babel and therefore brittle to reasonable changes that
they make).

These helpers have been pretty stable for quite a while, but recently
Babel 7.9.0 introduced a couple of new helpers:

* `createSuper` allows subclassing from native classes, even when
  partially transpiled).
* `createForOfIteratorHelperLoose`

Versions of `ember-source` prior to 3.13 fully transpiled with the Babel
version in `emberjs/ember.js`s _own_ `yarn.lock` at publish time. The
build process was significantly changed in `ember-source@3.13.0` so that
`ember-source` would behave just like a normal addon. This was a
**huge** improvement!! Unfortunately, those changes also made us
vulnerable to changes made to Babel (new helpers added).

We **must** resolve that issue (likely by removing these custom external
helpers in favor of using `includeExternalHelpers` from
`ember-cli-babel`), but in the meantime this commit adds the required
helpers which should fix the reported issue in supported Ember versions.
@rwjblue rwjblue requested a review from pzuraq Mar 22, 2020
@rwjblue rwjblue changed the title WIP: Update babel related packages to latest. Fix transpilation issues (e.g. `_createSuper` is not a function) when used with Babel 7.9.0+. Mar 22, 2020
@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 22, 2020

FYI - These changes will need to be backported for 3.16 (affected LTS), 3.17 (current release), and 3.18 (current beta).

@rwjblue rwjblue changed the title Fix transpilation issues (e.g. `_createSuper` is not a function) when used with Babel 7.9.0+. [BUGFIX lts] Fix transpilation issues (e.g. `_createSuper` is not a function) when used with Babel 7.9.0+. Mar 22, 2020
@locks
locks approved these changes Mar 22, 2020
@pzuraq
pzuraq approved these changes Mar 22, 2020
nickschot added a commit to nickschot/ember-mobile-menu that referenced this pull request Mar 22, 2020
MarcoUmpierrez added a commit to MarcoUmpierrez/fitness that referenced this pull request Mar 22, 2020
@Turbo87

This comment has been minimized.

Copy link
Member

Turbo87 commented Mar 22, 2020

to avoid such issues in the future would it make sense for use to switch to ~ constraints for Babel?

@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 23, 2020

to avoid such issues in the future would it make sense for use to switch to ~ constraints for Babel?

@Turbo87 - It would not have made a difference in this case. The drift is from ember-cli-babel itself, I suppose we could pin it with ~ instead of ^ (on @babel/preset-env), but that also seems pretty bad. The real issue is what I described above: we shouldn't "custom override" the babel helpers like this.

@rwjblue rwjblue merged commit 8ba9596 into master Mar 23, 2020
2 checks passed
2 checks passed
WIP Ready for review
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@rwjblue rwjblue deleted the update-babel branch Mar 23, 2020
@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 23, 2020

FYI - I've just queued up the CI jobs that will publish 3.17.1 and 3.16.4 (the next beta should be published tomorrow).

To follow along:

If either of these are red, it means the release didn't publish so please ping me and let me know!

@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 23, 2020

v3.17.1 is published with this fix (should resolve things for folks generating new apps), but I made a mistake when pulling back these changes for 3.16 (just forgot to include the commits when cherry-picking other fixes 🤦‍♂) and v3.16.4 does not include this fix.

I have kicked off a publishing of v3.16.5 (definitely with these changes) and it is working its way through CI now:

https://travis-ci.org/github/emberjs/ember.js/builds/665843150

@jherdman

This comment has been minimized.

Copy link
Contributor

jherdman commented Mar 23, 2020

@rwjblue by any chance has this been upstreamed to beta yet?

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 23, 2020 — with Octobox

@jherdman - It is in beta branch, but a beta hasn't been tagged / released yet. Should happen today.

@jherdman

This comment has been minimized.

Copy link
Contributor

jherdman commented Mar 24, 2020

Much, love! Thank you so much for all that you do.

@poplevente

This comment has been minimized.

Copy link

poplevente commented Mar 24, 2020

@rwjblue do you know when will be published to npm?

@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 24, 2020

@poplevente - v3.18.0-beta.3 was published yesterday (roughly 17 hours ago).

@poplevente

This comment has been minimized.

Copy link

poplevente commented Mar 24, 2020

@rwjblue i don't see that on npmjs

@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 24, 2020

@poplevente

This comment has been minimized.

Copy link

poplevente commented Mar 25, 2020

@rwjblue i mean update ember-cli
on our build machine we install ember-cli as a global and that fails now with the error from this ticket

@poplevente

This comment has been minimized.

Copy link

poplevente commented Mar 25, 2020

@rwjblue our problem is that we have a project which was running with ember-source@3.13
worked well before a few days ago. now we receive the _createSuper error. if we go to 3.17.1 it works, but we receive errors and warning with deprecation messages.
is there a version we can go back which was similar to the old 3.13? i've tried 3.12.3, and it works, but will it have any impact? or we better do an updage to 3.17.1 and do the deprecation? (which is time and money :( )

@rwjblue

This comment has been minimized.

Copy link
Member Author

rwjblue commented Mar 25, 2020

3.13 is unsupported (contains loads of bugs fixed in more recent versions), 3.12 works well and is a supported LTS that is unaffected by the issue this PR fixes (though it does not contain all of the octane features, e.g. tracked).

As far as I see it, you have a few options:

  • upgrade to supported Ember versions (either 3.16 which is an LTS or 3.17 which is the current release)
  • downgrade to 3.12 (supported for security fixes for a bit longer)
  • fix your applications lock file such that you are not picking up Babel 7.9
@poplevente

This comment has been minimized.

Copy link

poplevente commented Mar 25, 2020

@rwjblue awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.