From 0a71b7dd74273501a52faf1c041f8addfdfedaea Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 11 Sep 2024 11:20:09 +0200 Subject: [PATCH] URL renames and cleanup --- tools/webpack/script-modules.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/webpack/script-modules.js b/tools/webpack/script-modules.js index 0385372c846a7..57652e0be28e2 100644 --- a/tools/webpack/script-modules.js +++ b/tools/webpack/script-modules.js @@ -16,8 +16,8 @@ const { baseConfig, plugins } = require( './shared' ); const WORDPRESS_NAMESPACE = '@wordpress/'; const { createRequire } = require( 'node:module' ); -const rootPath = new URL( '..', `file://${ __dirname }` ); -const fromRootRequire = createRequire( rootPath ); +const rootURL = new URL( '..', `file://${ __dirname }` ); +const fromRootRequire = createRequire( rootURL ); /** @type {Iterable<[string, string]>} */ const iterableDeps = Object.entries( @@ -34,9 +34,12 @@ for ( const [ packageName, versionSpecifier ] of iterableDeps ) { ) { continue; } + const packageRequire = createRequire( - new URL( `${ versionSpecifier.substring( 5 ) }/`, rootPath ) + // Remove the leading "file:" specifier to build a package URL. + new URL( `${ versionSpecifier.substring( 5 ) }/`, rootURL ) ); + const depPackageJson = packageRequire( './package.json' ); if ( ! Object.hasOwn( depPackageJson, 'wpScriptModuleExports' ) ) { continue;