Skip to content

Commit

Permalink
Framework: Update code to work with Babel 7 (#7832)
Browse files Browse the repository at this point in the history
* Framework: Update code to work with Babel 7

* Testing: Fix failing test caused by Babel and Jest upgrade

* Packages: Use consistent version of babel-core package

* Build: Execute `npm run build` only on one container on Travis

* Packages: Minor tweaks to the configuration of packages

* Packages: Prepare changelogs for the upcoming release

* Tests: Fix failing tests after Babel 7 migration

* Packages: Follow sem for internal packages

* Packages: Update CHANGELOG files with heading tweaks
  • Loading branch information
gziolo authored and aduth committed Jul 11, 2018
1 parent 804db6d commit f3b6379
Show file tree
Hide file tree
Showing 56 changed files with 9,527 additions and 7,025 deletions.
29 changes: 29 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = function( api ) {
api.cache( true );

return {
presets: [ '@wordpress/babel-preset-default' ],
plugins: [
[
'@wordpress/babel-plugin-import-jsx-pragma',
{
scopeVariable: 'createElement',
source: '@wordpress/element',
isDefault: false,
},
],
],
env: {
production: {
plugins: [
[
'@wordpress/babel-plugin-makepot',
{
output: 'languages/gutenberg.pot',
},
],
],
},
},
};
};
2 changes: 1 addition & 1 deletion bin/packages/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const fs = require( 'fs' );
const path = require( 'path' );
const glob = require( 'glob' );
const babel = require( 'babel-core' );
const babel = require( '@babel/core' );
const chalk = require( 'chalk' );
const mkdirp = require( 'mkdirp' );

Expand Down
20 changes: 9 additions & 11 deletions bin/packages/get-babel-config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* External dependencies
*/
const { isArray, map } = require( 'lodash' );
const babelPresetEnv = require( 'babel-preset-env' );
const { get, map } = require( 'lodash' );
const babel = require( '@babel/core' );

/**
* WordPress dependencies
*/
const babelDefaultConfig = require( '@wordpress/babel-preset-default' );

const { options: babelDefaultConfig } = babel.loadPartialConfig( {
configFile: '@wordpress/babel-preset-default',
} );
const plugins = babelDefaultConfig.plugins;

if ( ! process.env.SKIP_JSX_PRAGMA_TRANSFORM ) {
plugins.push( [ require( '@wordpress/babel-plugin-import-jsx-pragma' ).default, {
plugins.push( [ '@wordpress/babel-plugin-import-jsx-pragma', {
scopeVariable: 'createElement',
source: '@wordpress/element',
isDefault: false,
Expand All @@ -24,13 +24,12 @@ const babelConfigs = {
{},
babelDefaultConfig,
{
babelrc: false,
plugins,
presets: map( babelDefaultConfig.presets, ( preset ) => {
if ( isArray( preset ) && preset[ 0 ] === babelPresetEnv ) {
return [ babelPresetEnv, Object.assign(
if ( get( preset, [ 'file', 'request' ] ) === '@babel/preset-env' ) {
return [ '@babel/preset-env', Object.assign(
{},
preset[ 1 ],
preset.options,
{ modules: 'commonjs' }
) ];
}
Expand All @@ -42,7 +41,6 @@ const babelConfigs = {
{},
babelDefaultConfig,
{
babelrc: false,
plugins,
}
),
Expand Down
4 changes: 0 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@ coverage:
patch: off

comment: false

ignore:
- "packages/is-shallow-equal/benchmark/*"

4 changes: 2 additions & 2 deletions editor/components/block-edit/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe( 'Edit', () => {

const wrapper = shallow( <Edit name="core/test-block" /> );

expect( wrapper.find( edit ) ).toBePresent();
expect( wrapper.find( edit ) ).toExist();
} );

it( 'should use save implementation of block as fallback', () => {
Expand All @@ -55,7 +55,7 @@ describe( 'Edit', () => {

const wrapper = shallow( <Edit name="core/test-block" /> );

expect( wrapper.find( save ) ).toBePresent();
expect( wrapper.find( save ) ).toExist();
} );

it( 'should combine the default class name with a custom one', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe( 'SharedBlockConvertButton', () => {
const wrapper = shallow(
<SharedBlockConvertButton isVisible={ false } />
);
expect( wrapper.children() ).toBeEmpty();
expect( wrapper.children() ).not.toExist();
} );

it( 'should allow converting a static block to a shared block', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ exports[`DefaultBlockAppender should append a default block when input focused 1
"calls": Array [
Array [],
],
"results": undefined,
}
}
onFocus={
[MockFunction] {
"calls": Array [
Array [],
],
"results": undefined,
}
}
onKeyDown={
[MockFunction] {
"calls": Array [
Array [],
],
"results": undefined,
}
}
readOnly={true}
Expand Down
8 changes: 4 additions & 4 deletions editor/components/inserter/test/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe( 'InserterMenu', () => {
expect( visibleBlocks.at( 1 ).text() ).toBe( 'A Text Embed' );

const noResultsMessage = wrapper.find( '.editor-inserter__no-results' );
expect( noResultsMessage ).toBeEmpty();
expect( noResultsMessage ).not.toExist();
} );

it( 'should show shared items in the shared tab', () => {
Expand Down Expand Up @@ -222,7 +222,7 @@ describe( 'InserterMenu', () => {
expect( visibleBlocks.at( 0 ).text() ).toBe( 'My shared block' );

const noResultsMessage = wrapper.find( '.editor-inserter__no-results' );
expect( noResultsMessage ).toBeEmpty();
expect( noResultsMessage ).not.toExist();
} );

it( 'should show the common category blocks', () => {
Expand Down Expand Up @@ -253,7 +253,7 @@ describe( 'InserterMenu', () => {
expect( visibleBlocks.at( 2 ).text() ).toBe( 'Some Other Block' );

const noResultsMessage = wrapper.find( '.editor-inserter__no-results' );
expect( noResultsMessage ).toBeEmpty();
expect( noResultsMessage ).not.toExist();
} );

it( 'should disable items with `isDisabled`', () => {
Expand Down Expand Up @@ -308,7 +308,7 @@ describe( 'InserterMenu', () => {
expect( visibleBlocks.at( 2 ).text() ).toBe( 'A Text Embed' );

const noResultsMessage = wrapper.find( '.editor-inserter__no-results' );
expect( noResultsMessage ).toBeEmpty();
expect( noResultsMessage ).not.toExist();
} );

it( 'should trim whitespace of search terms', () => {
Expand Down
Loading

0 comments on commit f3b6379

Please sign in to comment.