From 78ad982b9206ff58b5a8c95e68688120260a59b8 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Thu, 24 Jun 2021 12:53:12 +0200 Subject: [PATCH 1/3] Update extra node modules resolver Gutenberg mobile dependencies were resolved using the Jetpack path, so now we check first if the module exists in the Jetpack submodule before solving it with that path. --- metro.config.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/metro.config.js b/metro.config.js index 5a294e105b..4bde9c843a 100644 --- a/metro.config.js +++ b/metro.config.js @@ -9,6 +9,7 @@ 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 }` @@ -17,17 +18,21 @@ gutenbergMetroConfigCopy.resolver.extraNodeModules = new Proxy( return gutenbergFolder; } - // let's try find the module in the Jetpack submodule. We'll try the .pnpm folder. + // If not exists, let's try find the module in the Jetpack submodule. We'll try the .pnpm folder. const moduleFolderPnpm = path.join( process.cwd(), `./jetpack/node_modules/.pnpm/node_modules/${ name }` ); - // pnpm uses symlinks so, let's find the target - const symlinkTarget = fs.readlinkSync( moduleFolderPnpm ); + 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 ); + // 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 + ); + } }, } ); From 0837df742146a78fbcf62b1964e2c00a679cab5b Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Thu, 24 Jun 2021 13:13:48 +0200 Subject: [PATCH 2/3] Remove email-validator dependency This dependency is already defined in Jetpack submodule and it's only used there. --- package-lock.json | 5 ----- package.json | 4 +--- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index ef7bcc6414..668c712f1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15835,11 +15835,6 @@ "integrity": "sha512-QPrWNYeE/A0xRvl/QP3E0nkaEvYUvH3gM04ZWYtIa6QlSpEetRlRI1xvQ7hiMIySHHEV+mwDSX8Kj4YZY6ZQAw==", "dev": true }, - "email-validator": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/email-validator/-/email-validator-2.0.4.tgz", - "integrity": "sha512-gYCwo7kh5S3IDyZPLZf6hSS0MnZT8QmJFqYvbqlDZSbwdZlY6QZWxJ4i/6UhITOJ4XzyI647Bm2MXKCLqnJ4nQ==" - }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", diff --git a/package.json b/package.json index e0cdf0ec67..d6ea2ad92a 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,5 @@ "lint:fix": "npm run lint -- --fix", "version": "npm run bundle && git add -A bundle" }, - "dependencies": { - "email-validator": "2.0.4" - } + "dependencies": {} } From 2d317c0d62aa560aefb028cc79b12c965f6be909 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Thu, 24 Jun 2021 15:21:32 +0200 Subject: [PATCH 3/3] Clarify comment in extra node modules resolver --- metro.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metro.config.js b/metro.config.js index 4bde9c843a..a498f5a209 100644 --- a/metro.config.js +++ b/metro.config.js @@ -18,7 +18,7 @@ gutenbergMetroConfigCopy.resolver.extraNodeModules = new Proxy( return gutenbergFolder; } - // If not exists, let's try find the module in the Jetpack submodule. We'll try the .pnpm folder. + // Try to find the module in Jetpack's .pnpm folder. const moduleFolderPnpm = path.join( process.cwd(), `./jetpack/node_modules/.pnpm/node_modules/${ name }`