forked from wordpress-mobile/gutenberg-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metro.config.js
40 lines (34 loc) · 1.08 KB
/
metro.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const path = require( 'path' );
const fs = require( 'fs' );
const gutenbergMetroConfigCopy = {
...require( './gutenberg/packages/react-native-editor/metro.config.js' ),
};
gutenbergMetroConfigCopy.resolver.extraNodeModules = new Proxy(
{},
{
get: ( target, name ) => {
// Try to find the module in the Gutenberg submodule.
const gutenbergFolder = path.join(
process.cwd(),
`gutenberg/node_modules/${ name }`
);
if ( fs.existsSync( gutenbergFolder ) ) {
return gutenbergFolder;
}
// Try to find the module in Jetpack's .pnpm folder.
const moduleFolderPnpm = path.join(
process.cwd(),
`./jetpack/node_modules/.pnpm/node_modules/${ name }`
);
if ( fs.existsSync( moduleFolderPnpm ) ) {
// pnpm uses symlinks so, let's find the target
const symlinkTarget = fs.readlinkSync( moduleFolderPnpm );
// the target is still using paths relative to the parent folder of the module, let's find the real path.
return path.resolve(
moduleFolderPnpm + '/../' + symlinkTarget
);
}
},
}
);
module.exports = gutenbergMetroConfigCopy;