diff --git a/packages/is-shallow-equal/.eslintrc.json b/packages/is-shallow-equal/.eslintrc.json new file mode 100644 index 0000000000000..118dc091c3c8a --- /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 b11693ce1e865..950224a8c8c50 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 8ccdec2492433..8ab40b0cf25d7 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 e02ed8469367e..12df62d2a0407 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 9de339c3178cd..722049d5a4fb9 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", + "files": [ + "arrays.js", + "objects.js" + ], + "main": "index.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 fcb61fd7487d1..49528634399c4 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: {