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

Update to Babel 7.4 and core-js 3 #15139

Merged
merged 14 commits into from
Apr 30, 2019
Merged
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
29 changes: 0 additions & 29 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,6 @@ module.exports = {
selector: 'CallExpression[callee.name="deprecated"] Property[key.name="version"][value.value=/' + majorMinorRegExp + '/]',
message: 'Deprecated functions must be removed before releasing this version.',
},
{
Copy link
Member

Choose a reason for hiding this comment

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

@aduth - this is the rule that causes ESLint to randomly throw errors when processing JSX code with the latest version of both Babel and ESLint. Any ideas about how to fix it?

Copy link
Member

Choose a reason for hiding this comment

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

@aduth - this is the rule that causes ESLint to randomly throw errors when processing JSX code with the latest version of both Babel and ESLint. Any ideas about how to fix it?

I think we avoided the error previously based on the fact that filtering to Literal would be applied before calling the nth-child, as it would occur when trying to access properties on specific types of nodes. I'm guessing something changed here with the order in how the filtering is applied.

I imagine if we were to move more of this implementation into JavaScript (i.e. not rely on this esquery AST selector syntax), it could work again. Not immediately sure how much effort might be involved, or if it's more worthwhile to consider moving it to its own proper custom rule in @wordpress/eslint-plugin.

Copy link
Member

Choose a reason for hiding this comment

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

Tried a few ideas briefly, but no luck so far.

As far as I can tell, there's no way to include JavaScript in the rule to implement logic around considering the selected value in no-restricted-syntax (reasonable considering ESLint configurations are often JSON). The only options are selector and message.

I tried a variation which opted for separate rules to test > :not(ArrayExpression) and > * + :not(ArrayExpression) for first and second arguments respectively, but puzzlingly the same error occurs (despite not using :nth-child).

{
	selector: (
		`CallExpression[callee.name=/^(${ [
			'property',
			'matchesProperty',
			'path',
		].join( '|' ) })$/] > :not(ArrayExpression)`
	),
	message: 'Always pass an array as the path argument',
},
{
	selector: (
		`CallExpression[callee.name=/^(${ [
			'invokeMap',
			'get',
			'has',
			'hasIn',
			'invoke',
			'result',
			'set',
			'setWith',
			'unset',
			'update',
			'updateWith',
		].join( '|' ) })$/] > * + :not(ArrayExpression)`
	),
	message: 'Always pass an array as the path argument',
},

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine to have this not considered a blocker for merge. The rule is good to have, but not critical, and can be reintroduced in the future.

// Builds a selector which handles CallExpression with path
// argument at varied position by function.
//
// See: https://github.com/WordPress/gutenberg/pull/9615
selector: map( {
1: [
'property',
'matchesProperty',
'path',
],
2: [
'invokeMap',
'get',
'has',
'hasIn',
'invoke',
'result',
'set',
'setWith',
'unset',
'update',
'updateWith',
],
}, ( functionNames, argPosition ) => (
`CallExpression[callee.name=/^(${ functionNames.join( '|' ) })$/] > Literal:nth-child(${ argPosition })`
) ).join( ',' ),
message: 'Always pass an array as the path argument',
},
{
selector: 'CallExpression[callee.name=/^(__|_x|_n|_nx)$/] Literal[value=/\\.{3}/]',
message: 'Use ellipsis character (…) in place of three dots',
Expand Down
1,288 changes: 855 additions & 433 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
"@wordpress/wordcount": "file:packages/wordcount"
},
"devDependencies": {
"@babel/core": "7.2.2",
"@babel/core": "7.4.4",
"@babel/plugin-syntax-jsx": "7.2.0",
"@babel/runtime-corejs2": "7.3.1",
"@babel/traverse": "7.2.3",
"@babel/runtime-corejs3": "7.4.4",
"@babel/traverse": "7.4.4",
"@wordpress/babel-plugin-import-jsx-pragma": "file:packages/babel-plugin-import-jsx-pragma",
"@wordpress/babel-plugin-makepot": "file:packages/babel-plugin-makepot",
"@wordpress/babel-preset-default": "file:packages/babel-preset-default",
Expand All @@ -84,7 +84,7 @@
"chalk": "2.4.1",
"concurrently": "3.5.0",
"copy-webpack-plugin": "4.5.2",
"core-js": "2.5.7",
"core-js": "3.0.1",
"cross-env": "3.2.4",
"cssnano": "4.1.10",
"deasync": "0.1.14",
Expand Down
2 changes: 1 addition & 1 deletion packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ When creating a new package, you need to provide at least the following:
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.0.0"
"@babel/runtime": "^7.4.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/dom-ready": "file:../dom-ready"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/annotations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/data": "file:../data",
"@wordpress/hooks": "file:../hooks",
"@wordpress/i18n": "file:../i18n",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/i18n": "file:../i18n",
"@wordpress/url": "file:../url"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/autop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1"
"@babel/runtime": "^7.4.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-makepot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"gettext-parser": "^1.3.1",
"lodash": "^4.17.11"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/babel-preset-default/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## 4.1.0 (unreleased)
## Unreleased

### New Feature
### New Features

- Handle `<></>` JSX Fragments with `@wordpress/element` `Fragment` ([#15120](https://github.com/WordPress/gutenberg/pull/15120)).
- The bundled `@babel/core` dependency has been updated from requiring `^7.2.2` to requiring `^7.4.4`. Babel preset is now using `core-js@3` instead of `core-js@2` (see [Migration Guide](https://babeljs.io/blog/2019/03/19/7.4.0#migration-from-core-js-2)).

## 4.0.0 (2019-03-06)

Expand Down
1 change: 1 addition & 0 deletions packages/babel-preset-default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = function( api ) {

if ( isTestEnv ) {
opts.useBuiltIns = 'usage';
opts.corejs = 3;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we enabled corejs v3 only for tests which is expected. Related discussion here: https://github.com/WordPress/gutenberg/pull/9171/files#r214595243

} else {
opts.modules = false;
opts.targets = {
Expand Down
10 changes: 5 additions & 5 deletions packages/babel-preset-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
],
"main": "index.js",
"dependencies": {
"@babel/core": "^7.2.2",
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-async-generator-functions": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@babel/runtime": "^7.3.1",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/runtime": "^7.4.4",
"@wordpress/babel-plugin-import-jsx-pragma": "file:../babel-plugin-import-jsx-pragma",
"@wordpress/browserslist-config": "file:../browserslist-config"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Babel preset default', function () {
return _context.stop();
}
}
}, _callee, this);
}, _callee);
}));
return _foo.apply(this, arguments);
}
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('Babel preset default', function () {
return _context2.stop();
}
}
}, _callee2, this);
}, _callee2);
})));
});"
`;
2 changes: 1 addition & 1 deletion packages/blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1"
"@babel/runtime": "^7.4.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.0.0",
"@babel/runtime": "^7.4.4",
"@wordpress/a11y": "file:../a11y",
"@wordpress/blob": "file:../blob",
"@wordpress/blocks": "file:../blocks",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/autop": "file:../autop",
"@wordpress/blob": "file:../blob",
"@wordpress/block-editor": "file:../block-editor",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-serialization-default-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1"
"@babel/runtime": "^7.4.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/autop": "file:../autop",
"@wordpress/blob": "file:../blob",
"@wordpress/block-serialization-default-parser": "file:../block-serialization-default-parser",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/compose": "file:../compose",
Expand Down
2 changes: 1 addition & 1 deletion packages/compose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/element": "file:../element",
"@wordpress/is-shallow-equal": "file:../is-shallow-equal",
"lodash": "^4.17.11"
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/data": "file:../data",
"@wordpress/deprecated": "file:../deprecated",
Expand Down
2 changes: 1 addition & 1 deletion packages/custom-templated-path-webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"escape-string-regexp": "^1.0.5"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/compose": "file:../compose",
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/element": "file:../element",
Expand Down
2 changes: 1 addition & 1 deletion packages/date/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"moment": "^2.22.1",
"moment-timezone": "^0.5.16"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/deprecated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/hooks": "file:../hooks"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dom-ready/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
"@babel/runtime": "^7.3.1"
"@babel/runtime": "^7.4.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"lodash": "^4.17.11"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/url": "file:../url",
"lodash": "^4.17.11",
Expand Down
4 changes: 0 additions & 4 deletions packages/e2e-tests/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ module.exports = {
'<rootDir>/config/setup-test-framework.js',
'expect-puppeteer',
],
transformIgnorePatterns: [
'node_modules',
'scripts/config/puppeteer.config.js',
],
};
2 changes: 1 addition & 1 deletion packages/e2e-tests/specs/preview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe( 'Preview', () => {

// When autosave completes for a new post, the URL of the editor should
// update to include the ID. Use this to assert on preview URL.
const [ , postId ] = await( await editorPage.waitForFunction( () => {
const [ , postId ] = await ( await editorPage.waitForFunction( () => {
return window.location.search.match( /[\?&]post=(\d+)/ );
} ) ).jsonValue();

Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/block-editor": "file:../block-editor",
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.0.0",
"@babel/runtime": "^7.4.4",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/components": "file:../components",
"@wordpress/element": "file:../element",
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/blob": "file:../blob",
"@wordpress/block-editor": "file:../block-editor",
Expand Down
2 changes: 1 addition & 1 deletion packages/element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/escape-html": "file:../escape-html",
"lodash": "^4.17.11",
"react": "^16.8.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/escape-html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1"
"@babel/runtime": "^7.4.4"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"url": "https://github.com/WordPress/gutenberg/issues"
},
"dependencies": {
"babel-eslint": "^8.0.3",
"babel-eslint": "^10.0.1",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/format-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1",
"@babel/runtime": "^7.4.4",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/components": "file:../components",
"@wordpress/editor": "file:../editor",
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {
"@babel/runtime": "^7.3.1"
"@babel/runtime": "^7.4.4"
},
"publishConfig": {
"access": "public"
Expand Down
Loading