Skip to content

Commit

Permalink
URL renames and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Sep 11, 2024
1 parent 30d64d3 commit 0a71b7d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/webpack/script-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
Expand Down

0 comments on commit 0a71b7d

Please sign in to comment.