From 3894c67212d2c7f73f98b67360dfcafe94ec3233 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 23 Jul 2018 12:29:29 +0200 Subject: [PATCH 1/2] Update is-shallow-equal to use ES5 code as before --- packages/is-shallow-equal/.eslintrc.json | 5 +++++ packages/is-shallow-equal/{src => }/arrays.js | 8 ++++++-- packages/is-shallow-equal/{src => }/index.js | 15 +++++++-------- .../is-shallow-equal/{src => }/objects.js | 19 ++++++++++--------- packages/is-shallow-equal/package.json | 7 +++++-- .../is-shallow-equal/{src => }/test/index.js | 0 webpack.config.js | 2 +- 7 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 packages/is-shallow-equal/.eslintrc.json rename packages/is-shallow-equal/{src => }/arrays.js (81%) rename packages/is-shallow-equal/{src => }/index.js (73%) rename packages/is-shallow-equal/{src => }/objects.js (73%) rename packages/is-shallow-equal/{src => }/test/index.js (100%) diff --git a/packages/is-shallow-equal/.eslintrc.json b/packages/is-shallow-equal/.eslintrc.json new file mode 100644 index 00000000000000..118dc091c3c8a3 --- /dev/null +++ b/packages/is-shallow-equal/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-var": 0 + } +} diff --git a/packages/is-shallow-equal/src/arrays.js b/packages/is-shallow-equal/arrays.js similarity index 81% rename from packages/is-shallow-equal/src/arrays.js rename to packages/is-shallow-equal/arrays.js index b11693ce1e8654..950224a8c8c50a 100644 --- a/packages/is-shallow-equal/src/arrays.js +++ b/packages/is-shallow-equal/arrays.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Returns true if the two arrays are shallow equal, or false otherwise. * @@ -7,6 +9,8 @@ * @return {boolean} Whether the two arrays are shallow equal. */ function isShallowEqualArrays( a, b ) { + var i; + if ( a === b ) { return true; } @@ -15,7 +19,7 @@ function isShallowEqualArrays( a, b ) { return false; } - for ( let i = 0; i < a.length; i++ ) { + for ( i = 0; i < a.length; i++ ) { if ( a[ i ] !== b[ i ] ) { return false; } @@ -24,4 +28,4 @@ function isShallowEqualArrays( a, b ) { return true; } -export default isShallowEqualArrays; +module.exports = isShallowEqualArrays; diff --git a/packages/is-shallow-equal/src/index.js b/packages/is-shallow-equal/index.js similarity index 73% rename from packages/is-shallow-equal/src/index.js rename to packages/is-shallow-equal/index.js index 8ccdec24924335..8ab40b0cf25d73 100644 --- a/packages/is-shallow-equal/src/index.js +++ b/packages/is-shallow-equal/index.js @@ -1,13 +1,12 @@ -/** - * Internal dependencies - */ -import isShallowEqualObjects from './objects'; -import isShallowEqualArrays from './arrays'; +'use strict'; /** - * Local variables + * Internal dependencies; */ -const { isArray } = Array; +var isShallowEqualObjects = require( './objects' ); +var isShallowEqualArrays = require( './arrays' ); + +var isArray = Array.isArray; /** * Returns true if the two arrays or objects are shallow equal, or false @@ -30,4 +29,4 @@ function isShallowEqual( a, b ) { return a === b; } -export default isShallowEqual; +module.exports = isShallowEqual; diff --git a/packages/is-shallow-equal/src/objects.js b/packages/is-shallow-equal/objects.js similarity index 73% rename from packages/is-shallow-equal/src/objects.js rename to packages/is-shallow-equal/objects.js index e02ed8469367e7..12df62d2a04075 100644 --- a/packages/is-shallow-equal/src/objects.js +++ b/packages/is-shallow-equal/objects.js @@ -1,7 +1,6 @@ -/** - * Local variables - */ -const { keys } = Object; +'use strict'; + +var keys = Object.keys; /** * Returns true if the two objects are shallow equal, or false otherwise. @@ -12,21 +11,23 @@ const { keys } = Object; * @return {boolean} Whether the two objects are shallow equal. */ function isShallowEqualObjects( a, b ) { + var aKeys, bKeys, i, key; + if ( a === b ) { return true; } - const aKeys = keys( a ); - const bKeys = keys( b ); + aKeys = keys( a ); + bKeys = keys( b ); if ( aKeys.length !== bKeys.length ) { return false; } - let i = 0; + i = 0; while ( i < aKeys.length ) { - const key = aKeys[ i ]; + key = aKeys[ i ]; if ( a[ key ] !== b[ key ] ) { return false; } @@ -37,4 +38,4 @@ function isShallowEqualObjects( a, b ) { return true; } -export default isShallowEqualObjects; +module.exports = isShallowEqualObjects; diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index 9de339c3178cd4..0e96acbe732a0d 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -18,8 +18,11 @@ "bugs": { "url": "https://github.com/WordPress/gutenberg/issues" }, - "main": "build/index.js", - "module": "build-module/index.js", + "main": "index.js", + "files": [ + "arrays.js", + "objects.js" + ], "dependencies": { "@babel/runtime": "^7.0.0-beta.52" }, diff --git a/packages/is-shallow-equal/src/test/index.js b/packages/is-shallow-equal/test/index.js similarity index 100% rename from packages/is-shallow-equal/src/test/index.js rename to packages/is-shallow-equal/test/index.js diff --git a/webpack.config.js b/webpack.config.js index fcb61fd7487d19..49528634399c4b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -163,6 +163,7 @@ const config = { test: /\.js$/, exclude: [ /block-serialization-spec-parser/, + /is-shallow-equal/, /node_modules/, ], use: 'babel-loader', @@ -233,7 +234,6 @@ const config = { 'api-fetch', 'deprecated', 'dom-ready', - 'is-shallow-equal', ].map( camelCaseDash ) ), ], stats: { From d2db9d2ae70468f85dbfa873fccfa996bac45e66 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Mon, 23 Jul 2018 15:31:47 +0200 Subject: [PATCH 2/2] Fix order of properties in package.json of is-shallow-equal --- packages/is-shallow-equal/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index 0e96acbe732a0d..722049d5a4fb93 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -18,11 +18,11 @@ "bugs": { "url": "https://github.com/WordPress/gutenberg/issues" }, - "main": "index.js", "files": [ "arrays.js", "objects.js" ], + "main": "index.js", "dependencies": { "@babel/runtime": "^7.0.0-beta.52" },