From f5e2162648276d8cf37b7597636cbd189a740283 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 10 Sep 2024 19:57:24 +0200 Subject: [PATCH] Use URLs for improved cross platform support --- tools/webpack/script-modules.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/webpack/script-modules.js b/tools/webpack/script-modules.js index a800beffe20ee2..0385372c846a7e 100644 --- a/tools/webpack/script-modules.js +++ b/tools/webpack/script-modules.js @@ -16,7 +16,7 @@ const { baseConfig, plugins } = require( './shared' ); const WORDPRESS_NAMESPACE = '@wordpress/'; const { createRequire } = require( 'node:module' ); -const rootPath = `${ __dirname }/../../`; +const rootPath = new URL( '..', `file://${ __dirname }` ); const fromRootRequire = createRequire( rootPath ); /** @type {Iterable<[string, string]>} */ @@ -35,7 +35,7 @@ for ( const [ packageName, versionSpecifier ] of iterableDeps ) { continue; } const packageRequire = createRequire( - `${ rootPath }/${ versionSpecifier.substring( 5 ) }/` + new URL( `${ versionSpecifier.substring( 5 ) }/`, rootPath ) ); const depPackageJson = packageRequire( './package.json' ); if ( ! Object.hasOwn( depPackageJson, 'wpScriptModuleExports' ) ) {