From 37dac46d9cf75d4ef8afec5b5810dd3332f8a94d Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Sun, 23 Sep 2018 17:27:56 +0300 Subject: [PATCH 1/7] Platform extensions are messing with Jest module resolution And module name mappings also mess with the platform module resolution if one removes the platform file extensions config. Instead, use local symlinks to Gutenberg's `src` packages and that that symlinks directory structure as a Jest moduleDirectories setting. Jest package resolution can now properly find the packages and resolve platform specific modules, depending on the defaultPlatform set in haste config or via the TEST_RN_PLATFORM env param. As a counterexample of what was going wrong before, a `.ios.js` file would be picked by by Jest even if the platform was set to `android`, if the `.android.js` is missing. The `.ios.js` module should not be picked up in that case. --- jest.config.js | 19 +-- package.json | 10 +- symlinked-packages/@wordpress/a11y | 1 + symlinked-packages/@wordpress/api-fetch | 1 + symlinked-packages/@wordpress/autop | 1 + symlinked-packages/@wordpress/blob | 1 + symlinked-packages/@wordpress/block-library | 1 + .../block-serialization-default-parser | 1 + symlinked-packages/@wordpress/blocks | 1 + symlinked-packages/@wordpress/components | 1 + symlinked-packages/@wordpress/compose | 1 + symlinked-packages/@wordpress/core-data | 1 + symlinked-packages/@wordpress/data | 1 + symlinked-packages/@wordpress/deprecated | 1 + symlinked-packages/@wordpress/editor | 1 + symlinked-packages/@wordpress/element | 1 + symlinked-packages/@wordpress/hooks | 1 + symlinked-packages/@wordpress/i18n | 1 + .../@wordpress/is-shallow-equal | 1 + symlinked-packages/@wordpress/keycodes | 1 + symlinked-packages/@wordpress/nux | 1 + symlinked-packages/@wordpress/redux-routine | 1 + symlinked-packages/@wordpress/url | 1 + symlinked-packages/@wordpress/viewport | 1 + yarn.lock | 130 +----------------- 25 files changed, 30 insertions(+), 151 deletions(-) create mode 120000 symlinked-packages/@wordpress/a11y create mode 120000 symlinked-packages/@wordpress/api-fetch create mode 120000 symlinked-packages/@wordpress/autop create mode 120000 symlinked-packages/@wordpress/blob create mode 120000 symlinked-packages/@wordpress/block-library create mode 120000 symlinked-packages/@wordpress/block-serialization-default-parser create mode 120000 symlinked-packages/@wordpress/blocks create mode 120000 symlinked-packages/@wordpress/components create mode 120000 symlinked-packages/@wordpress/compose create mode 120000 symlinked-packages/@wordpress/core-data create mode 120000 symlinked-packages/@wordpress/data create mode 120000 symlinked-packages/@wordpress/deprecated create mode 120000 symlinked-packages/@wordpress/editor create mode 120000 symlinked-packages/@wordpress/element create mode 120000 symlinked-packages/@wordpress/hooks create mode 120000 symlinked-packages/@wordpress/i18n create mode 120000 symlinked-packages/@wordpress/is-shallow-equal create mode 120000 symlinked-packages/@wordpress/keycodes create mode 120000 symlinked-packages/@wordpress/nux create mode 120000 symlinked-packages/@wordpress/redux-routine create mode 120000 symlinked-packages/@wordpress/url create mode 120000 symlinked-packages/@wordpress/viewport diff --git a/jest.config.js b/jest.config.js index 840c00dc7b9f0b..d09a5ac99000de 100644 --- a/jest.config.js +++ b/jest.config.js @@ -21,26 +21,9 @@ module.exports = { '/gutenberg/test/', '/gutenberg/packages/', ], - moduleFileExtensions: [ - 'native.js', - 'android.js', - 'ios.js', - 'js', - 'native.json', - 'android.json', - 'ios.json', - 'json', - 'native.jsx', - 'android.jsx', - 'ios.jsx', - 'jsx', - 'node', - ], modulePathIgnorePatterns: [ '/gutenberg/gutenberg-mobile' ], + moduleDirectories: [ 'node_modules', 'symlinked-packages' ], moduleNameMapper: { - '@wordpress\\/(block-serialization-default-parser|blocks|data|element|deprecated|editor|block-library|components|keycodes|url|a11y|viewport|core-data|api-fetch|nux)$': - '/gutenberg/packages/$1/src/index', - // Mock the CSS modules. See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets '\\.(scss)$': '/__mocks__/styleMock.js', }, diff --git a/package.json b/package.json index 245063e999a9ef..dcb884608aad12 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "react-native-sass-transformer": "^1.1.1", "react-test-renderer": "16.3.1", "remote-redux-devtools": "^0.5.12", + "rungen": "^0.3.2", "sprintf-js": "^1.1.1" }, "scripts": { @@ -71,15 +72,6 @@ "lint:fix": "yarn lint --fix" }, "dependencies": { - "@wordpress/autop": "^1.0.6", - "@wordpress/blob": "^2.0.0", - "@wordpress/compose": "^1.0.1", - "@wordpress/deprecated": "^1.0.0-alpha.2", - "@wordpress/element": "^1.0.2", - "@wordpress/hooks": "^1.2.1", - "@wordpress/i18n": "^1.1.0", - "@wordpress/is-shallow-equal": "^1.0.1", - "@wordpress/redux-routine": "^2.0.0", "babel-preset-es2015": "^6.24.1", "classnames": "^2.2.5", "dom-react": "^2.2.1", diff --git a/symlinked-packages/@wordpress/a11y b/symlinked-packages/@wordpress/a11y new file mode 120000 index 00000000000000..9d7cca9a3391fa --- /dev/null +++ b/symlinked-packages/@wordpress/a11y @@ -0,0 +1 @@ +../../gutenberg/packages/a11y/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/api-fetch b/symlinked-packages/@wordpress/api-fetch new file mode 120000 index 00000000000000..74d13fcb5a921b --- /dev/null +++ b/symlinked-packages/@wordpress/api-fetch @@ -0,0 +1 @@ +../../gutenberg/packages/api-fetch/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/autop b/symlinked-packages/@wordpress/autop new file mode 120000 index 00000000000000..5e0b9f61dffd93 --- /dev/null +++ b/symlinked-packages/@wordpress/autop @@ -0,0 +1 @@ +../../gutenberg/packages/autop/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/blob b/symlinked-packages/@wordpress/blob new file mode 120000 index 00000000000000..70bf5fce46affc --- /dev/null +++ b/symlinked-packages/@wordpress/blob @@ -0,0 +1 @@ +../../gutenberg/packages/blob/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/block-library b/symlinked-packages/@wordpress/block-library new file mode 120000 index 00000000000000..26832ee1f161da --- /dev/null +++ b/symlinked-packages/@wordpress/block-library @@ -0,0 +1 @@ +../../gutenberg/packages/block-library/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/block-serialization-default-parser b/symlinked-packages/@wordpress/block-serialization-default-parser new file mode 120000 index 00000000000000..d50a060d82a110 --- /dev/null +++ b/symlinked-packages/@wordpress/block-serialization-default-parser @@ -0,0 +1 @@ +../../gutenberg/packages/block-serialization-default-parser/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/blocks b/symlinked-packages/@wordpress/blocks new file mode 120000 index 00000000000000..4bfc2460e4fd4b --- /dev/null +++ b/symlinked-packages/@wordpress/blocks @@ -0,0 +1 @@ +../../gutenberg/packages/blocks/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/components b/symlinked-packages/@wordpress/components new file mode 120000 index 00000000000000..239bee5e78f004 --- /dev/null +++ b/symlinked-packages/@wordpress/components @@ -0,0 +1 @@ +../../gutenberg/packages/components/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/compose b/symlinked-packages/@wordpress/compose new file mode 120000 index 00000000000000..2a9ffd6dff7411 --- /dev/null +++ b/symlinked-packages/@wordpress/compose @@ -0,0 +1 @@ +../../gutenberg/packages/compose/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/core-data b/symlinked-packages/@wordpress/core-data new file mode 120000 index 00000000000000..ea84df9db43ca5 --- /dev/null +++ b/symlinked-packages/@wordpress/core-data @@ -0,0 +1 @@ +../../gutenberg/packages/core-data/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/data b/symlinked-packages/@wordpress/data new file mode 120000 index 00000000000000..41f3374499200c --- /dev/null +++ b/symlinked-packages/@wordpress/data @@ -0,0 +1 @@ +../../gutenberg/packages/data/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/deprecated b/symlinked-packages/@wordpress/deprecated new file mode 120000 index 00000000000000..e8d0377e77c93e --- /dev/null +++ b/symlinked-packages/@wordpress/deprecated @@ -0,0 +1 @@ +../../gutenberg/packages/deprecated/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/editor b/symlinked-packages/@wordpress/editor new file mode 120000 index 00000000000000..3c9bbbaa7c5ac6 --- /dev/null +++ b/symlinked-packages/@wordpress/editor @@ -0,0 +1 @@ +../../gutenberg/packages/editor/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/element b/symlinked-packages/@wordpress/element new file mode 120000 index 00000000000000..393773390de7aa --- /dev/null +++ b/symlinked-packages/@wordpress/element @@ -0,0 +1 @@ +../../gutenberg/packages/element/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/hooks b/symlinked-packages/@wordpress/hooks new file mode 120000 index 00000000000000..bb99805d489b9f --- /dev/null +++ b/symlinked-packages/@wordpress/hooks @@ -0,0 +1 @@ +../../gutenberg/packages/hooks/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/i18n b/symlinked-packages/@wordpress/i18n new file mode 120000 index 00000000000000..a884be356950eb --- /dev/null +++ b/symlinked-packages/@wordpress/i18n @@ -0,0 +1 @@ +../../gutenberg/packages/i18n/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/is-shallow-equal b/symlinked-packages/@wordpress/is-shallow-equal new file mode 120000 index 00000000000000..f78cd08ab1080b --- /dev/null +++ b/symlinked-packages/@wordpress/is-shallow-equal @@ -0,0 +1 @@ +../../gutenberg/packages/is-shallow-equal/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/keycodes b/symlinked-packages/@wordpress/keycodes new file mode 120000 index 00000000000000..72edd57417b694 --- /dev/null +++ b/symlinked-packages/@wordpress/keycodes @@ -0,0 +1 @@ +../../gutenberg/packages/keycodes/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/nux b/symlinked-packages/@wordpress/nux new file mode 120000 index 00000000000000..665eb3e0cd6e70 --- /dev/null +++ b/symlinked-packages/@wordpress/nux @@ -0,0 +1 @@ +../../gutenberg/packages/nux/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/redux-routine b/symlinked-packages/@wordpress/redux-routine new file mode 120000 index 00000000000000..caec77905d7979 --- /dev/null +++ b/symlinked-packages/@wordpress/redux-routine @@ -0,0 +1 @@ +../../gutenberg/packages/redux-routine/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/url b/symlinked-packages/@wordpress/url new file mode 120000 index 00000000000000..ddf7c884ab7f23 --- /dev/null +++ b/symlinked-packages/@wordpress/url @@ -0,0 +1 @@ +../../gutenberg/packages/url/src/ \ No newline at end of file diff --git a/symlinked-packages/@wordpress/viewport b/symlinked-packages/@wordpress/viewport new file mode 120000 index 00000000000000..f88b540bde2f5e --- /dev/null +++ b/symlinked-packages/@wordpress/viewport @@ -0,0 +1 @@ +../../gutenberg/packages/viewport/src/ \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 2d2e4301730588..05724f9494e6bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -445,19 +445,6 @@ pirates "^4.0.0" source-map-support "^0.4.2" -"@babel/runtime@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0.tgz#adeb78fedfc855aa05bc041640f3f6f98e85424c" - dependencies: - regenerator-runtime "^0.12.0" - -"@babel/runtime@^7.0.0-beta.52": - version "7.0.0-beta.54" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0-beta.54.tgz#39ebb42723fe7ca4b3e1b00e967e80138d47cadf" - dependencies: - core-js "^2.5.7" - regenerator-runtime "^0.12.0" - "@babel/template@7.0.0-beta.44": version "7.0.0-beta.44" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f" @@ -525,12 +512,6 @@ version "10.5.2" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.2.tgz#f19f05314d5421fe37e74153254201a7bf00a707" -"@wordpress/autop@^1.0.6": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@wordpress/autop/-/autop-1.1.1.tgz#00a4b91ef2feaf5dfb704383f2dd16b880604084" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - "@wordpress/babel-preset-default@^1.1.2": version "1.3.0" resolved "https://registry.yarnpkg.com/@wordpress/babel-preset-default/-/babel-preset-default-1.3.0.tgz#e5818a448812a2966d308e9f82097b9f81514b77" @@ -542,12 +523,6 @@ babel-plugin-transform-runtime "^6.23.0" babel-preset-env "^1.6.1" -"@wordpress/blob@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@wordpress/blob/-/blob-2.0.0.tgz#b310674a93f7484c0b4492e6698aba55a1e04f48" - dependencies: - "@babel/runtime" "^7.0.0" - "@wordpress/block-serialization-spec-parser@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@wordpress/block-serialization-spec-parser/-/block-serialization-spec-parser-1.0.0.tgz#a51a9276421629d4be398dfcc9bab52e303c3403" @@ -556,83 +531,6 @@ version "2.2.0" resolved "https://registry.yarnpkg.com/@wordpress/browserslist-config/-/browserslist-config-2.2.0.tgz#7fcc77db40d4d846dbb158e485a6badc143c76d2" -"@wordpress/compose@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@wordpress/compose/-/compose-1.0.1.tgz#fdfb24b27390ca97db432108c47188b4fc96dea8" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - "@wordpress/element" "^1.0.1" - "@wordpress/is-shallow-equal" "^1.1.1" - lodash "^4.17.10" - -"@wordpress/deprecated@^1.0.0-alpha.2", "@wordpress/deprecated@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@wordpress/deprecated/-/deprecated-1.0.1.tgz#8769d791b228022caef156dbbff0f21eb2b21f3e" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - -"@wordpress/deprecated@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@wordpress/deprecated/-/deprecated-1.0.2.tgz#ac69168d55b790d797946ef2dfd2eeda13bf1c56" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - -"@wordpress/element@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@wordpress/element/-/element-1.0.1.tgz#d9e31e437793655556816e6328bc67bfbecc4a27" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - "@wordpress/deprecated" "^1.0.1" - "@wordpress/is-shallow-equal" "^1.1.1" - lodash "^4.17.10" - react "^16.4.1" - react-dom "^16.4.1" - -"@wordpress/element@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@wordpress/element/-/element-1.0.2.tgz#1b2c8e245ce9e7d126d6521f2a93e69606d1c71c" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - "@wordpress/deprecated" "^1.0.2" - "@wordpress/is-shallow-equal" "^1.1.2" - lodash "^4.17.10" - react "^16.4.1" - react-dom "^16.4.1" - -"@wordpress/hooks@^1.2.1": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@wordpress/hooks/-/hooks-1.3.1.tgz#1ee50c777938060a96b202e22ca2e902eacce335" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - -"@wordpress/i18n@^1.1.0": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@wordpress/i18n/-/i18n-1.2.1.tgz#b5c7c52065db9fa13a3d1872ddb9a198bc8ea29a" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - gettext-parser "^1.3.1" - jed "^1.1.1" - lodash "^4.17.10" - memize "^1.0.5" - -"@wordpress/is-shallow-equal@^1.0.1", "@wordpress/is-shallow-equal@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@wordpress/is-shallow-equal/-/is-shallow-equal-1.1.1.tgz#377db18206afe2a6e787862106c3ff5c27d65e36" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - -"@wordpress/is-shallow-equal@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@wordpress/is-shallow-equal/-/is-shallow-equal-1.1.2.tgz#360a3d06a5805148d05e00cf92e5e42360baf0a2" - dependencies: - "@babel/runtime" "^7.0.0-beta.52" - -"@wordpress/redux-routine@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@wordpress/redux-routine/-/redux-routine-2.0.0.tgz#9ec9afa29abc69510c80f3c2d0d2a392d6c7604f" - dependencies: - "@babel/runtime" "^7.0.0" - abab@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e" @@ -2911,7 +2809,7 @@ encodeurl@~1.0.1, encodeurl@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" -encoding@^0.1.11, encoding@^0.1.12: +encoding@^0.1.11: version "0.1.12" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" dependencies: @@ -3643,13 +3541,6 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -gettext-parser@^1.3.1: - version "1.4.0" - resolved "https://registry.yarnpkg.com/gettext-parser/-/gettext-parser-1.4.0.tgz#f8baf34a292f03d5e42f02df099d301f167a7ace" - dependencies: - encoding "^0.1.12" - safe-buffer "^5.1.1" - glob-base@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" @@ -6362,7 +6253,7 @@ react-devtools-core@3.1.0: shell-quote "^1.6.1" ws "^2.0.3" -react-dom@^16.2.0, react-dom@^16.4.1: +react-dom@^16.2.0: version "16.4.1" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.4.1.tgz#7f8b0223b3a5fbe205116c56deb85de32685dad6" dependencies: @@ -6549,15 +6440,6 @@ react@^0.14.0: envify "^3.0.0" fbjs "^0.6.1" -react@^16.4.1: - version "16.4.1" - resolved "https://registry.yarnpkg.com/react/-/react-16.4.1.tgz#de51ba5764b5dbcd1f9079037b862bd26b82fe32" - dependencies: - fbjs "^0.8.16" - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.0" - read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -6646,10 +6528,6 @@ regenerator-runtime@^0.11.0: version "0.11.1" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" -regenerator-runtime@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.0.tgz#8052ac952d85b10f3425192cd0c53f45cf65c6cb" - regenerator-transform@^0.10.0: version "0.10.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" @@ -6952,6 +6830,10 @@ run-async@^2.2.0: dependencies: is-promise "^2.1.0" +rungen@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/rungen/-/rungen-0.3.2.tgz#400c09ebe914e7b17e0b6ef3263400fc2abc7cb3" + rx-lite-aggregates@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" From 8cc74252e031a840f4b61738ed0e1014a5958770 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Sun, 23 Sep 2018 23:04:07 +0300 Subject: [PATCH 2/7] symlinked-packages as extra packages dir for Flow --- .flowconfig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.flowconfig b/.flowconfig index 7dc024fb579665..765de705b7ea2e 100644 --- a/.flowconfig +++ b/.flowconfig @@ -74,6 +74,8 @@ libdefs.js emoji=true module.system=haste +module.system.node.resolve_dirname=node_modules +module.system.node.resolve_dirname=symlinked-packages module.file_ext=.js module.file_ext=.jsx @@ -84,10 +86,6 @@ module.file_ext=.scss munge_underscores=true module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' -module.name_mapper='@wordpress/block-library' -> '/gutenberg/packages/block-library/src' -module.name_mapper='@wordpress/blocks' -> '/gutenberg/packages/blocks/src' -module.name_mapper='@wordpress/element' -> '/gutenberg/packages/element/src' -module.name_mapper='@wordpress/components' -> '/gutenberg/packages/components/src' ; mock/ignore style files module.name_mapper='.*\(.scss\)' -> 'empty/object' From 231016191343f215ff4425b9284c1d248a8559f4 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Mon, 24 Sep 2018 00:22:14 +0300 Subject: [PATCH 3/7] Use all GB packages directly from source --- gutenberg | 2 +- rn-cli.config.js | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gutenberg b/gutenberg index dd25c7d0925221..42c250e5ee367e 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit dd25c7d09252219993331f99a1af9c502420a139 +Subproject commit 42c250e5ee367ee09fedfae335286bd6982f758d diff --git a/rn-cli.config.js b/rn-cli.config.js index 2cab5ae0491bc7..01f2f36e4bc80f 100644 --- a/rn-cli.config.js +++ b/rn-cli.config.js @@ -5,13 +5,9 @@ const enm = require( './extra-node-modules.config.js' ); module.exports = { extraNodeModules: enm, getBlacklistRE: function() { - // Blacklist the GB packages we want to consume from NPM (online) directly. - // On the other hand, GB packages that are loaded from the source tree directly - // are automagically resolved by Metro so, there is no list of them anywhere. - return blacklist( [ - /gutenberg\/packages\/(autop|compose|deprecated|hooks|i18n|is-shallow-equal|blob|redux-routine)\/.*/, - /gutenberg\/gutenberg-mobile\/.*/, - ] ); + // There's a nested checkout of the mobile code inside the Gutenberg repo + // as a submodule. Blacklist it to avoid errors due to duplicate modules. + return blacklist( [ /gutenberg\/gutenberg-mobile\/.*/ ] ); }, getTransformModulePath() { return require.resolve( './sass-transformer.js' ); From b55e77118f12d99203e32f2cd9f1f76f789318c8 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Mon, 24 Sep 2018 00:28:39 +0300 Subject: [PATCH 4/7] Upgrade JavascriptCore to fix "Can't find variable: Symbol" Need to bump minimum Android SDK version to 21 too. Apparently, that error message is caused because older JavascriptCore doesn't support "Symbol". More: https://github.com/mobxjs/mobx-react/issues/498#issuecomment-396182983 --- android/app/build.gradle | 8 +++++++- android/build.gradle | 4 ++++ package.json | 1 + yarn.lock | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 5a32a316e40149..a714990d26699a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -99,7 +99,7 @@ android { defaultConfig { applicationId "com.gutenberg" - minSdkVersion 16 + minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" @@ -157,6 +157,12 @@ repositories { maven { url "https://jitpack.io" } } +configurations.all { + resolutionStrategy { + force 'org.webkit:android-jsc:r224109' + } +} + dependencies { implementation project(':react-native-svg') implementation project(':react-native-aztec') diff --git a/android/build.gradle b/android/build.gradle index e4ecaed18af4c3..fc790fa6fd7ea8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -33,5 +33,9 @@ allprojects { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } + maven { + // Local Maven repo containing AARs with JSC library built for Android + url "$rootDir/../node_modules/jsc-android/dist" + } } } diff --git a/package.json b/package.json index dcb884608aad12..78454ed662484d 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "hpq": "^1.2.0", "jed": "^1.1.1", "js-beautify": "^1.7.5", + "jsc-android": "224109.x.x", "jsdom-jscore": "git+https://github.com/iamcco/jsdom-jscore-rn.git#6eac88dd5d5e7c21ce6382abde7dbc376d7f7f59", "jsx-to-string": "^1.3.1", "memize": "^1.0.5", diff --git a/yarn.lock b/yarn.lock index 05724f9494e6bc..100d698d5892d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4659,6 +4659,10 @@ jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" +jsc-android@224109.x.x: + version "224109.1.0" + resolved "https://registry.yarnpkg.com/jsc-android/-/jsc-android-224109.1.0.tgz#9749ec92f1e284b3c09befe7c47cc6e60b1f0cdf" + "jsdom-jscore@git+https://github.com/iamcco/jsdom-jscore-rn.git#6eac88dd5d5e7c21ce6382abde7dbc376d7f7f59": version "0.1.7" resolved "git+https://github.com/iamcco/jsdom-jscore-rn.git#6eac88dd5d5e7c21ce6382abde7dbc376d7f7f59" From 116d2ebf51261d4b1a44fc531d8c4c7ff81e7729 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Mon, 24 Sep 2018 02:01:24 +0300 Subject: [PATCH 5/7] Update the inside-gb setup to use symlinks for Jest --- .eslintignore | 1 + jest.config.js | 2 +- jest_gb.config.js | 8 +------- symlinked-packages-in-parent/@wordpress/a11y | 1 + symlinked-packages-in-parent/@wordpress/api-fetch | 1 + symlinked-packages-in-parent/@wordpress/autop | 1 + symlinked-packages-in-parent/@wordpress/blob | 1 + symlinked-packages-in-parent/@wordpress/block-library | 1 + .../@wordpress/block-serialization-default-parser | 1 + symlinked-packages-in-parent/@wordpress/blocks | 1 + symlinked-packages-in-parent/@wordpress/components | 1 + symlinked-packages-in-parent/@wordpress/compose | 1 + symlinked-packages-in-parent/@wordpress/core-data | 1 + symlinked-packages-in-parent/@wordpress/data | 1 + symlinked-packages-in-parent/@wordpress/deprecated | 1 + symlinked-packages-in-parent/@wordpress/editor | 1 + symlinked-packages-in-parent/@wordpress/element | 1 + symlinked-packages-in-parent/@wordpress/hooks | 1 + symlinked-packages-in-parent/@wordpress/i18n | 1 + symlinked-packages-in-parent/@wordpress/is-shallow-equal | 1 + symlinked-packages-in-parent/@wordpress/keycodes | 1 + symlinked-packages-in-parent/@wordpress/nux | 1 + symlinked-packages-in-parent/@wordpress/redux-routine | 1 + symlinked-packages-in-parent/@wordpress/url | 1 + symlinked-packages-in-parent/@wordpress/viewport | 1 + 25 files changed, 25 insertions(+), 8 deletions(-) create mode 120000 symlinked-packages-in-parent/@wordpress/a11y create mode 120000 symlinked-packages-in-parent/@wordpress/api-fetch create mode 120000 symlinked-packages-in-parent/@wordpress/autop create mode 120000 symlinked-packages-in-parent/@wordpress/blob create mode 120000 symlinked-packages-in-parent/@wordpress/block-library create mode 120000 symlinked-packages-in-parent/@wordpress/block-serialization-default-parser create mode 120000 symlinked-packages-in-parent/@wordpress/blocks create mode 120000 symlinked-packages-in-parent/@wordpress/components create mode 120000 symlinked-packages-in-parent/@wordpress/compose create mode 120000 symlinked-packages-in-parent/@wordpress/core-data create mode 120000 symlinked-packages-in-parent/@wordpress/data create mode 120000 symlinked-packages-in-parent/@wordpress/deprecated create mode 120000 symlinked-packages-in-parent/@wordpress/editor create mode 120000 symlinked-packages-in-parent/@wordpress/element create mode 120000 symlinked-packages-in-parent/@wordpress/hooks create mode 120000 symlinked-packages-in-parent/@wordpress/i18n create mode 120000 symlinked-packages-in-parent/@wordpress/is-shallow-equal create mode 120000 symlinked-packages-in-parent/@wordpress/keycodes create mode 120000 symlinked-packages-in-parent/@wordpress/nux create mode 120000 symlinked-packages-in-parent/@wordpress/redux-routine create mode 120000 symlinked-packages-in-parent/@wordpress/url create mode 120000 symlinked-packages-in-parent/@wordpress/viewport diff --git a/.eslintignore b/.eslintignore index b11ad29df58702..059df3f815c752 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ ; ignore the submodules gutenberg +symlinked-packages-in-parent react-native-aztec diff --git a/jest.config.js b/jest.config.js index d09a5ac99000de..194b937e279f8a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,7 +17,7 @@ module.exports = { testEnvironment: 'jsdom', testPathIgnorePatterns: [ '/node_modules/', - '/gutenberg/gutenberg-mobile/', + '/gutenberg/gutenberg-mobile/', '/gutenberg/test/', '/gutenberg/packages/', ], diff --git a/jest_gb.config.js b/jest_gb.config.js index 2d9076b676039e..64fd3485abd366 100644 --- a/jest_gb.config.js +++ b/jest_gb.config.js @@ -5,11 +5,5 @@ const main = require( './jest.config.js' ); module.exports = { ...main, - moduleNameMapper: { - '@wordpress\\/(blocks|data|element|deprecated|editor|block-library|components|keycodes|url|a11y|viewport|core-data|api-fetch|nux|block-serialization-default-parser)$': - '/../packages/$1/build/index', - - // Mock the CSS modules. See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets - '\\.(scss)$': '/__mocks__/styleMock.js', - }, + moduleDirectories: [ 'node_modules', 'symlinked-packages-in-parent' ], }; diff --git a/symlinked-packages-in-parent/@wordpress/a11y b/symlinked-packages-in-parent/@wordpress/a11y new file mode 120000 index 00000000000000..b0630f2f93d6eb --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/a11y @@ -0,0 +1 @@ +../../../packages/a11y/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/api-fetch b/symlinked-packages-in-parent/@wordpress/api-fetch new file mode 120000 index 00000000000000..732ce30ce7036d --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/api-fetch @@ -0,0 +1 @@ +../../../packages/api-fetch/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/autop b/symlinked-packages-in-parent/@wordpress/autop new file mode 120000 index 00000000000000..b698e02042b62f --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/autop @@ -0,0 +1 @@ +../../../packages/autop/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/blob b/symlinked-packages-in-parent/@wordpress/blob new file mode 120000 index 00000000000000..5113897bc945d0 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/blob @@ -0,0 +1 @@ +../../../packages/blob/src/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/block-library b/symlinked-packages-in-parent/@wordpress/block-library new file mode 120000 index 00000000000000..7f555d8d513fb5 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/block-library @@ -0,0 +1 @@ +../../../packages/block-library/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/block-serialization-default-parser b/symlinked-packages-in-parent/@wordpress/block-serialization-default-parser new file mode 120000 index 00000000000000..8e289b2dba490a --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/block-serialization-default-parser @@ -0,0 +1 @@ +../../../packages/block-serialization-default-parser/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/blocks b/symlinked-packages-in-parent/@wordpress/blocks new file mode 120000 index 00000000000000..46b87c52a20343 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/blocks @@ -0,0 +1 @@ +../../../packages/blocks/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/components b/symlinked-packages-in-parent/@wordpress/components new file mode 120000 index 00000000000000..d0a83f0641294f --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/components @@ -0,0 +1 @@ +../../../packages/components/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/compose b/symlinked-packages-in-parent/@wordpress/compose new file mode 120000 index 00000000000000..76957e416aa715 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/compose @@ -0,0 +1 @@ +../../../packages/compose/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/core-data b/symlinked-packages-in-parent/@wordpress/core-data new file mode 120000 index 00000000000000..d400c01496679c --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/core-data @@ -0,0 +1 @@ +../../../packages/core-data/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/data b/symlinked-packages-in-parent/@wordpress/data new file mode 120000 index 00000000000000..a94b80c363b19a --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/data @@ -0,0 +1 @@ +../../../packages/data/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/deprecated b/symlinked-packages-in-parent/@wordpress/deprecated new file mode 120000 index 00000000000000..6c82daaf32f9dd --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/deprecated @@ -0,0 +1 @@ +../../../packages/deprecated/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/editor b/symlinked-packages-in-parent/@wordpress/editor new file mode 120000 index 00000000000000..33223a58e6878c --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/editor @@ -0,0 +1 @@ +../../../packages/editor/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/element b/symlinked-packages-in-parent/@wordpress/element new file mode 120000 index 00000000000000..65673d34fd6c8b --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/element @@ -0,0 +1 @@ +../../../packages/element/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/hooks b/symlinked-packages-in-parent/@wordpress/hooks new file mode 120000 index 00000000000000..68da4f62a0f612 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/hooks @@ -0,0 +1 @@ +../../../packages/hooks/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/i18n b/symlinked-packages-in-parent/@wordpress/i18n new file mode 120000 index 00000000000000..13fc98e81ce53a --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/i18n @@ -0,0 +1 @@ +../../../packages/i18n/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/is-shallow-equal b/symlinked-packages-in-parent/@wordpress/is-shallow-equal new file mode 120000 index 00000000000000..e77e9362d194c7 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/is-shallow-equal @@ -0,0 +1 @@ +../../../packages/is-shallow-equal/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/keycodes b/symlinked-packages-in-parent/@wordpress/keycodes new file mode 120000 index 00000000000000..03d52867ea1675 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/keycodes @@ -0,0 +1 @@ +../../../packages/keycodes/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/nux b/symlinked-packages-in-parent/@wordpress/nux new file mode 120000 index 00000000000000..743ae3dd27a605 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/nux @@ -0,0 +1 @@ +../../../packages/nux/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/redux-routine b/symlinked-packages-in-parent/@wordpress/redux-routine new file mode 120000 index 00000000000000..492544c527163c --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/redux-routine @@ -0,0 +1 @@ +../../../packages/redux-routine/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/url b/symlinked-packages-in-parent/@wordpress/url new file mode 120000 index 00000000000000..e55007cf6f812d --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/url @@ -0,0 +1 @@ +../../../packages/url/build/ \ No newline at end of file diff --git a/symlinked-packages-in-parent/@wordpress/viewport b/symlinked-packages-in-parent/@wordpress/viewport new file mode 120000 index 00000000000000..628eeb4f68ea27 --- /dev/null +++ b/symlinked-packages-in-parent/@wordpress/viewport @@ -0,0 +1 @@ +../../../packages/viewport/build/ \ No newline at end of file From 955e7771034ad10e25f43ff20cba08b20daae7c5 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Mon, 24 Sep 2018 02:19:34 +0300 Subject: [PATCH 6/7] Fix ambiguity when running in the inside-gb setup When trying to run the non-inside-gb configuration while actually inside GB as parent, the blacklist is matching the actual mobile code so, need to have the full path in the regex to solve the ambiguity. --- rn-cli.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rn-cli.config.js b/rn-cli.config.js index 01f2f36e4bc80f..6234dcbe931e62 100644 --- a/rn-cli.config.js +++ b/rn-cli.config.js @@ -1,5 +1,6 @@ /** @format */ const blacklist = require( 'metro' ).createBlacklist; +const path = require( 'path' ); const enm = require( './extra-node-modules.config.js' ); module.exports = { @@ -7,7 +8,7 @@ module.exports = { getBlacklistRE: function() { // There's a nested checkout of the mobile code inside the Gutenberg repo // as a submodule. Blacklist it to avoid errors due to duplicate modules. - return blacklist( [ /gutenberg\/gutenberg-mobile\/.*/ ] ); + return blacklist( [ new RegExp( path.basename( __dirname ) + '/gutenberg/gutenberg-mobile/.*/' ) ] ); }, getTransformModulePath() { return require.resolve( './sass-transformer.js' ); From bbb9fe528e5e1ed1064feac4dea418e37b8f4041 Mon Sep 17 00:00:00 2001 From: Stefanos Togkoulidis Date: Mon, 24 Sep 2018 12:33:45 +0300 Subject: [PATCH 7/7] Update to GB master now that the GB PR got merged --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index 42c250e5ee367e..fd9bfa5b9884a7 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 42c250e5ee367ee09fedfae335286bd6982f758d +Subproject commit fd9bfa5b9884a7fe5993f4c19a431b32a17094e2