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

remove proposals polyfills from default import [skip ci] #8440

Merged
merged 1 commit into from Aug 9, 2018

Conversation

hzoo
Copy link
Member

@hzoo hzoo commented Aug 8, 2018

Q                       A
Fixed Issues? Fixes #8416
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

The default import is replaced with only polyfills that are Stage 4, instead of also including the Stage < 4 polyfills. This should be in alignment with how we have removed the Stage presets. This also would mean we would need to add new imports when necessary.

And it sounds like we desire to also add the polyfill proposals individually? There's a maintenance cost to that too (not that bad) but then I wonder why we aren't just linking to the polyfill to use (that would just mean removing babel/polyfill as a package, as people may want to use other polyfills too) since we are just aliasing it. So do we really want to do this?


For the proposals in v2:

```js // require('../modules/es7.array.includes'); require('../modules/es7.array.flat-map'); require('../modules/es7.array.flatten'); require('../modules/es7.string.at'); // require('../modules/es7.string.pad-start'); // require('../modules/es7.string.pad-end'); require('../modules/es7.string.trim-left'); require('../modules/es7.string.trim-right'); require('../modules/es7.string.match-all'); // require('../modules/es7.symbol.async-iterator'); require('../modules/es7.symbol.observable'); // require('../modules/es7.object.get-own-property-descriptors'); // require('../modules/es7.object.values'); // require('../modules/es7.object.entries'); require('../modules/es7.object.define-getter'); require('../modules/es7.object.define-setter'); require('../modules/es7.object.lookup-getter'); require('../modules/es7.object.lookup-setter'); require('../modules/es7.map.to-json'); require('../modules/es7.set.to-json'); require('../modules/es7.map.of'); require('../modules/es7.set.of'); require('../modules/es7.weak-map.of'); require('../modules/es7.weak-set.of'); require('../modules/es7.map.from'); require('../modules/es7.set.from'); require('../modules/es7.weak-map.from'); require('../modules/es7.weak-set.from'); require('../modules/es7.global'); require('../modules/es7.system.global'); require('../modules/es7.error.is-error'); require('../modules/es7.math.clamp'); require('../modules/es7.math.deg-per-rad'); require('../modules/es7.math.degrees'); require('../modules/es7.math.fscale'); require('../modules/es7.math.iaddh'); require('../modules/es7.math.isubh'); require('../modules/es7.math.imulh'); require('../modules/es7.math.rad-per-deg'); require('../modules/es7.math.radians'); require('../modules/es7.math.scale'); require('../modules/es7.math.umulh'); require('../modules/es7.math.signbit'); // require('../modules/es7.promise.finally'); require('../modules/es7.promise.try'); require('../modules/es7.reflect.define-metadata'); require('../modules/es7.reflect.delete-metadata'); require('../modules/es7.reflect.get-metadata'); require('../modules/es7.reflect.get-metadata-keys'); require('../modules/es7.reflect.get-own-metadata'); require('../modules/es7.reflect.get-own-metadata-keys'); require('../modules/es7.reflect.has-metadata'); require('../modules/es7.reflect.has-own-metadata'); require('../modules/es7.reflect.metadata'); require('../modules/es7.asap'); require('../modules/es7.observable'); ```

from logan:

// Stage 3
import "core-js/fn/string/trim-left";
import "core-js/fn/string/trim-right";
import "core-js/fn/string/match-all";
import "core-js/fn/array/flat-map";
import "core-js/fn/array/flatten";  // RENAMED
import "core-js/fn/global";

// Stage 1
import "core-js/fn/symbol/observable";
import "core-js/fn/promise/try";
import "core-js/fn/observable";

// Stage 1 Math Extensions
import "core-js/fn/math/clamp";
import "core-js/fn/math/deg-per-rad";
import "core-js/fn/math/degrees";
import "core-js/fn/math/fscale";
import "core-js/fn/math/iaddh";
import "core-js/fn/math/isubh";
import "core-js/fn/math/imulh";
import "core-js/fn/math/rad-per-deg";
import "core-js/fn/math/radians";
import "core-js/fn/math/scale";
import "core-js/fn/math/umulh";
import "core-js/fn/math/signbit";

// Stage 1 "of and from on collection constructors"
import "core-js/fn/map/of";
import "core-js/fn/set/of";
import "core-js/fn/weak-map/of";
import "core-js/fn/weak-set/of";
import "core-js/fn/map/from";
import "core-js/fn/set/from";
import "core-js/fn/weak-map/from";
import "core-js/fn/weak-set/from";

// Stage 0
import "core-js/fn/string/at";

// Nonstandard
import "core-js/fn/object/define-getter";
import "core-js/fn/object/define-setter";
import "core-js/fn/object/lookup-getter";
import "core-js/fn/object/lookup-setter";
// import "core-js/fn/map/to-json"; // Not available standalone
// import "core-js/fn/set/to-json"; // Not available standalone

import "core-js/fn/system/global";
import "core-js/fn/error/is-error";
import "core-js/fn/asap";


// Decorator metadata? Not sure of stage/proposal
import "core-js/fn/reflect/define-metadata";
import "core-js/fn/reflect/delete-metadata";
import "core-js/fn/reflect/get-metadata";
import "core-js/fn/reflect/get-metadata-keys";
import "core-js/fn/reflect/get-own-metadata";
import "core-js/fn/reflect/get-own-metadata-keys";
import "core-js/fn/reflect/has-metadata";
import "core-js/fn/reflect/has-own-metadata";
import "core-js/fn/reflect/metadata";

write-polyfills.js

var a = ["core-js/fn/string/trim-left",
"core-js/fn/string/trim-right",
"core-js/fn/string/match-all",
"core-js/fn/array/flat-map",
"core-js/fn/array/flatten",
"core-js/fn/global",
"core-js/fn/symbol/observable",
"core-js/fn/promise/try",
"core-js/fn/observable",
"core-js/fn/math/clamp",
"core-js/fn/math/deg-per-rad",
"core-js/fn/math/degrees",
"core-js/fn/math/fscale",
"core-js/fn/math/iaddh",
"core-js/fn/math/isubh",
"core-js/fn/math/imulh",
"core-js/fn/math/rad-per-deg",
"core-js/fn/math/radians",
"core-js/fn/math/scale",
"core-js/fn/math/umulh",
"core-js/fn/math/signbit",
"core-js/fn/map/of",
"core-js/fn/set/of",
"core-js/fn/weak-map/of",
"core-js/fn/weak-set/of",
"core-js/fn/map/from",
"core-js/fn/set/from",
"core-js/fn/weak-map/from",
"core-js/fn/weak-set/from",
"core-js/fn/string/at"];

const fse = require('fs-extra');

Promise.all(a.map((file) => {
	return fse.outputFile(`${file.slice(11)}.js`, `import "${file}";`)
	.catch((error) => {
	    console.log(error)
	});
}))

@hzoo hzoo added the PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release label Aug 8, 2018
@babel-bot
Copy link
Collaborator

babel-bot commented Aug 9, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8779/

@hzoo hzoo added this to the Babel 7 RC milestone Aug 9, 2018
@hzoo hzoo merged commit c8bb450 into master Aug 9, 2018
@hzoo
Copy link
Member Author

hzoo commented Aug 9, 2018

We should also update polyfill docs and also add this change to the upgrade doc.

@hzoo hzoo deleted the rm-proposals-in-polyfill branch August 9, 2018 20:27
@stnwk
Copy link

stnwk commented Aug 21, 2018

So, how do we include polyfills for @babel/plugin-proposal-x now? There is no documentation for this yet + the blog post https://babeljs.io/docs/en/next/v7-migration is too unspecific :/

Any input would be great! @hzoo

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Aug 21, 2018

You should import then directy from the core-js package.

e.g.

import "core-js/fn/array/flatMap";

@hzoo
Copy link
Member Author

hzoo commented Aug 21, 2018

Ok I updated it a bit as well babel/website@3db6772

@stnwk
Copy link

stnwk commented Aug 21, 2018

Awesome, thank you both!

facebook-github-bot pushed a commit to magma/magma that referenced this pull request May 14, 2019
Summary:
This diff is fixing the UI on old Chrome versions / IE. Apparently Array.flat is not included in babel plyfill and need to be included manually - see:
babel/babel#8440
https://babeljs.io/docs/en/v7-migration

Reviewed By: elys1um

Differential Revision: D15334182

fbshipit-source-id: f7704a898ede36a8352b916771574dbba8721f22
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure out plan for polyfilling library functionality stage < 4
4 participants