|
1 | 1 | /** @format */
|
2 |
| -const path = require( 'path' ); |
3 |
| - |
4 |
| -const enm = require( 'node-libs-react-native' ); |
5 |
| -enm.fs = __dirname + '/__mocks__/nodejsMock.js'; |
6 |
| -enm.net = __dirname + '/__mocks__/nodejsMock.js'; |
7 |
| -enm.canvas = __dirname + '/__mocks__/nodejsMock.js'; |
8 |
| - |
9 |
| -const { lstatSync, readdirSync } = require( 'fs' ); |
10 |
| -const getDirectoryNames = dir => |
11 |
| - readdirSync( dir ).filter( name => lstatSync( path.resolve( dir, name ) ).isDirectory() ); |
12 |
| - |
13 |
| -const wppackagenames = getDirectoryNames( path.resolve( __dirname, '../packages/' ) ); |
14 |
| - |
15 |
| -const mapper = function( accu, v ) { |
16 |
| - accu[ '@wordpress/' + v ] = path.resolve( __dirname, '../packages/' + v ); |
17 |
| - return accu; |
18 |
| -}; |
19 |
| - |
20 |
| -const wppackages = wppackagenames.reduce( mapper, {} ); |
| 2 | +const blacklist = require( 'metro' ).createBlacklist; |
| 3 | +const enm = require( './extra-node-modules.config.js' ); |
21 | 4 |
|
22 | 5 | module.exports = {
|
23 |
| - extraNodeModules: Object.assign( enm, wppackages ), |
24 |
| - getProjectRoots() { |
25 |
| - const roots = [ __dirname, path.resolve( __dirname, '../node_modules' ) ].concat( |
26 |
| - Object.values( wppackages ) |
27 |
| - ); |
28 |
| - return roots; |
| 6 | + extraNodeModules: enm, |
| 7 | + getBlacklistRE: function() { |
| 8 | + // Blacklist the GB packages we want to consume from NPM (online) directly. |
| 9 | + // On the other hand, GB packages that are loaded from the source tree directly |
| 10 | + // are automagically resolved by Metro so, there is no list of them anywhere. |
| 11 | + return blacklist( [ |
| 12 | + /gutenberg\/packages\/(autop|compose|deprecated|hooks|i18n|is-shallow-equal)\/.*/, |
| 13 | + ] ); |
29 | 14 | },
|
30 | 15 | getTransformModulePath() {
|
31 |
| - return require.resolve( './sass-transformer-inside-gb.js' ); |
| 16 | + return require.resolve( './sass-transformer.js' ); |
32 | 17 | },
|
33 | 18 | getSourceExts() {
|
34 | 19 | return [ 'js', 'json', 'scss', 'sass' ];
|
35 | 20 | },
|
36 |
| - getProvidesModuleNodeModules() { |
37 |
| - return [ 'react-native-svg', 'react-native' ]; |
38 |
| - }, |
39 | 21 | };
|
0 commit comments