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

Add necessary polyfills to support transpiled features. #702

Closed
tech4him1 opened this issue Oct 16, 2017 · 8 comments
Closed

Add necessary polyfills to support transpiled features. #702

tech4him1 opened this issue Oct 16, 2017 · 8 comments

Comments

@tech4him1
Copy link
Contributor

We transpile our JS code, but it doesn't necessarily support everything (see https://babeljs.io/docs/usage/caveats/). When babel-preset-env v7 is released, we can use useBuiltIns: "usage" to automatically add any polyfills needed after transpilation.

@tech4him1
Copy link
Contributor Author

We can also remove the browser targets from the .babelrc, when we upgrade to v7, because they added support for using the browserslist in package.json.

tech4him1 added a commit that referenced this issue Oct 30, 2017
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
tech4him1 added a commit that referenced this issue Nov 12, 2017
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
tech4him1 added a commit that referenced this issue Nov 12, 2017
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
tech4him1 added a commit that referenced this issue Nov 21, 2017
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
tech4him1 added a commit that referenced this issue Dec 8, 2017
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
@tech4him1
Copy link
Contributor Author

I also think we should remove the stage-* presets and use the specific plugins we want directly.

tech4him1 added a commit that referenced this issue Dec 20, 2017
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
tech4him1 added a commit that referenced this issue Jan 23, 2018
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
erquhart pushed a commit that referenced this issue Jan 24, 2018
This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.
erquhart pushed a commit that referenced this issue Jan 25, 2018
* Add supported browsers list to babel-preset-env.

This was fixed in v7 of babel-preset-env so that you could use the
browserslist directly from package.json. We'll have to wait until Babel
v7 is release, see #702.

* add node 6 to babel-preset-env targets

* Only build for Node during testing.
@tech4him1
Copy link
Contributor Author

tech4him1 commented Jan 25, 2018

Babel 7 also affects the transform-runtime plugin: useBuiltIns is added, which means we can stop using polyfilled Map, Symbol, etc, by setting it to true.

EDIT: Actually the new useBuiltIns: "usage" setting in the ENV preset is the same as that part of transform-runtime, so we would want to have both settings on, which turns the transform-runtime one off, and leaves the ENV one on.

EDIT: Actually, they're not exactly the same. The ENV one pulls in only the polyfills that are needed for the supported browsers, but it adds them to the global scope. Transform-runtime adds them for everything, even when supported, but only adds them to the module scope. See babel/babel#7267 for details.

@tech4him1
Copy link
Contributor Author

If the discussion in babel/babel#6628 takes off, that would be nice.

@tech4him1
Copy link
Contributor Author

tech4him1 commented Jan 26, 2018

Just did some testing with Babel v7.0.0-beta.38. transform-runtime has the benefit of not polluting the global scope, but IMO it's not the most maintainable/minimal option, since it polyfills everything, even if the browser supports it.

I propose that we do:

["@babel/preset-env", {
  "modules": false,
  "useBuiltIns": "usage" // Add necessary polyfills to the global scope.
}]

Only use the runtime transform for helpers. We probably don't really need this anyway -- we're not transpiling much anyway with only the last 2 versions of browsers -- so it probably won't really change size.

["@babel/plugin-transform-runtime", {
  "helpers": true,
  "useBuiltIns": true,
  "useESModules": true,
  "polyfill": false,
  "regenerator": false
}]

@erquhart
Copy link
Contributor

I'm with that.

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Oct 29, 2019
@erezrokah
Copy link
Contributor

Closing this as outdated. Please re-open if necessary.

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

3 participants