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

Use babel-polyfill and babel-preset-env #3790

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
{
"only": "*.js",
"env": {
"pre-node5": {
"presets": ["es2015-node4"],
"node4": {
"plugins": [
["array-includes"],
["transform-inline-imports-commonjs"],
["transform-runtime", { "polyfill": true, "regenerator": false }]
]
"transform-flow-strip-types",
"transform-object-rest-spread",
"transform-class-properties",
"transform-inline-imports-commonjs"
],
"presets": [["env", {
"targets": {
"node": 4
},
"useBuiltIns": true
}]]
},
"node6": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to what @Volune said, maybe this can be "development", which babel uses as default.

"plugins": [
"transform-flow-strip-types",
"transform-object-rest-spread",
"transform-class-properties",
"transform-inline-imports-commonjs"
],
"presets": [["env", {
"targets": {
"node": 6
},
"useBuiltIns": true
}]]
},
"test": {
"presets": ["es2015-node4"],
"plugins": [
["transform-inline-imports-commonjs"]
]
"transform-flow-strip-types",
"transform-object-rest-spread",
"transform-class-properties",
"transform-inline-imports-commonjs"
],
"presets": [["env", {
"targets": {
"node": 4
},
"useBuiltIns": true
}]]
}
},
"presets": ["node5", "stage-0"],
"plugins": [
["transform-inline-imports-commonjs"],
["transform-runtime", { "polyfill": false, "regenerator": true }]
]
}
}
67 changes: 67 additions & 0 deletions flow-typed/npm/babel-polyfill_vx.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// flow-typed signature: cbd31882f6edff2e4390624598ed8b77
// flow-typed version: <<STUB>>/babel-polyfill_v^6.6.1/flow_v0.32.0

/**
* This is an autogenerated libdef stub for:
*
* 'babel-polyfill'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'babel-polyfill' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'babel-polyfill/browser' {
declare module.exports: any;
}

declare module 'babel-polyfill/dist/polyfill' {
declare module.exports: any;
}

declare module 'babel-polyfill/dist/polyfill.min' {
declare module.exports: any;
}

declare module 'babel-polyfill/lib/index' {
declare module.exports: any;
}

declare module 'babel-polyfill/scripts/postpublish' {
declare module.exports: any;
}

declare module 'babel-polyfill/scripts/prepublish' {
declare module.exports: any;
}

// Filename aliases
declare module 'babel-polyfill/browser.js' {
declare module.exports: $Exports<'babel-polyfill/browser'>;
}
declare module 'babel-polyfill/dist/polyfill.js' {
declare module.exports: $Exports<'babel-polyfill/dist/polyfill'>;
}
declare module 'babel-polyfill/dist/polyfill.min.js' {
declare module.exports: $Exports<'babel-polyfill/dist/polyfill.min'>;
}
declare module 'babel-polyfill/lib/index.js' {
declare module.exports: $Exports<'babel-polyfill/lib/index'>;
}
declare module 'babel-polyfill/scripts/postpublish.js' {
declare module.exports: $Exports<'babel-polyfill/scripts/postpublish'>;
}
declare module 'babel-polyfill/scripts/prepublish.js' {
declare module.exports: $Exports<'babel-polyfill/scripts/prepublish'>;
}
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ gulp.task('default', ['build']);
gulp.task('build', ['build-modern', 'build-legacy']);

gulp.task('build-modern', () =>
build('lib', babelRc.env.node5)
build('lib', babelRc.env.node6)
);

gulp.task('build-legacy', () =>
build('lib-legacy', babelRc.env['pre-node5'])
build('lib-legacy', babelRc.env.node4)
);

gulp.task('watch', ['build'], () => {
Expand Down
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"preferGlobal": true,
"description": "📦🐈 Fast, reliable, and secure dependency management.",
"dependencies": {
"babel-polyfill": "^6.23.0",
"babel-runtime": "^6.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

babel-runtime can probably be removed now.

"bytes": "^2.4.0",
"camelcase": "^4.0.0",
Expand Down Expand Up @@ -42,18 +43,15 @@
"validate-npm-package-license": "^3.0.1"
},
"devDependencies": {
"babel-core": "^6.24.1",
"babel-core": "^6.25.0",
"babel-eslint": "^6.1.2",
"babel-jest": "^19.0.0",
"babel-jest": "^20.0.3",
"babel-loader": "^6.2.5",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-es2015-typeof-symbol": "^6.8.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-plugin-transform-inline-imports-commonjs": "^1.0.0",
"babel-plugin-transform-runtime": "^6.4.3",
"babel-preset-es2015-node4": "^2.1.0",
"babel-preset-node5": "^10.2.0",
"babel-preset-stage-0": "^6.0.0",
"babylon": "^6.5.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.5.2",
"eslint": "^3.19.0",
"eslint-config-fb-strict": "^20.0.1",
"eslint-plugin-babel": "^3.3.0",
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const compiler = webpack({
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: babelRc.env.node6,
},
],
},
Expand Down Expand Up @@ -58,7 +59,7 @@ const compilerLegacy = webpack({
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: babelRc.env['pre-node5'],
query: babelRc.env.node4,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be done by defining process.env.BABEL_ENV in https://webpack.js.org/plugins/environment-plugin/ so we don't have to parse the babelrc manually in the file, esp. since query field has been replaced with options w/ webpack2. Gulp probably has something similar as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if we open another issue/pull request on that? This pr is becoming too big imho.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaylieEB can you open the issue? Because I don't fully understand your comment, I am afraid to write something wrong

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np :) #3809

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks :D

},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
const rootDep = packagePath[0];
const packageName = packagePath[1] || packageJson.name;

const bundledDep = bundledDeps[rootDep] && bundledDeps[rootDep].indexOf(packageName) !== -1;
const bundledDep = bundledDeps[rootDep] && bundledDeps[rootDep].includes(packageName);
if (
!bundledDep &&
(packageJson.version === depPkg.version ||
Expand Down
1 change: 1 addition & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* @flow */

import 'babel-polyfill';
import {ConsoleReporter, JSONReporter} from '../reporters/index.js';
import {registries, registryNames} from '../registries/index.js';
import commands from './commands/index.js';
Expand Down
2 changes: 1 addition & 1 deletion src/util/execute-lifecycle-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export async function executeLifecycleScript(
// Add global bin folder if it is not present already, as some packages depend
// on a globally-installed version of node-gyp.
const globalBin = getGlobalBinFolder(config, {});
if (pathParts.indexOf(globalBin) === -1) {
if (!pathParts.includes(globalBin)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the advantage of this change?

pathParts.unshift(globalBin);
}

Expand Down
Loading