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

babel helpers are incomplete #1323

Closed
aomarks opened this issue Apr 6, 2018 · 3 comments
Closed

babel helpers are incomplete #1323

aomarks opened this issue Apr 6, 2018 · 3 comments

Comments

@aomarks
Copy link
Member

aomarks commented Apr 6, 2018

At least these were needed for the shop#3.0 modules-based project, and probably more:

  • interopRequireDefault
  • interopRequireWildcard
  • wrapNativeSuper

(Even after adding these, I am still getting Uncaught TypeError: m.assertThisInitialized is not a function on shop#3.0 when compiling to ES5).

But it seems like we really need a better solution than a hard-coded list of helpers (https://github.com/Polymer/polymer-build/blob/master/gulpfile.js#L112). Babel figures out what helpers it needs, and optionally injects them inline. We don't rely on that, since that causes lots of redundant helpers in every script, and have our own set that we inject into the entrypoint instead.

Since we do whole program analysis, is there a way to ask Babel which helpers it needed, and create a final de-duped set?

@aomarks
Copy link
Member Author

aomarks commented Apr 12, 2018

Apparently Babel used to expose a usedHelpers object, which we could have used to generate a minimal set of application-wide babel helpers. However, it was removed in Babel 7 (babel/babel#6835). The much better solution will be to use the transform-runtime plugin which will transform helpers to be imports from the babel-runtime module. Filed #128 to do that.

In the short term, though, I'm just going to expand our current static global helpers list to include everything we seem to be missing at the moment.

@aomarks
Copy link
Member Author

aomarks commented Apr 12, 2018

Also, even when ES5 compilation is off, the AMD babel transform requires some helpers. Currently we don't inject any helpers unless ES5 compilation is on, so I will need to change that logic a bit too.

@aomarks
Copy link
Member Author

aomarks commented Apr 14, 2018

The fix for this issue introduced a new one: #147

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

No branches or pull requests

1 participant