Skip to content

Commit

Permalink
Redo script modules build
Browse files Browse the repository at this point in the history
- Better modules
- Parse wp modules from package.json
- Combine asset file
  • Loading branch information
sirreal committed Sep 17, 2024
1 parent 288a48b commit 5d02179
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/webpack/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ const {
getBaseConfig,
normalizeJoin,
MODULES,
SCRIPT_AND_MODULE_DUAL_PACKAGES,
WORDPRESS_NAMESPACE,
} = require( './shared' );

/** @type {Map<string, string>} */
const scriptModules = new Map();
for ( const packageName of MODULES ) {
for ( const packageName of MODULES.concat( SCRIPT_AND_MODULE_DUAL_PACKAGES ) ) {
const packageRequire = createRequire(
`${dirname( require.resolve( `${ packageName }/package.json` ) )}/`
);
Expand Down Expand Up @@ -102,6 +103,8 @@ module.exports = function (
...baseConfig.plugins,
new DependencyExtractionPlugin( {
injectPolyfill: false,
combineAssets: true,
combinedOutputFile: `../../../assets/script-modules-packages${ suffix }.php`,
} ),
],
};
Expand Down
3 changes: 3 additions & 0 deletions tools/webpack/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const MODULES = [
'@wordpress/interactivity',
'@wordpress/interactivity-router',
];
const SCRIPT_AND_MODULE_DUAL_PACKAGES = [
];
const WORDPRESS_NAMESPACE = '@wordpress/';

module.exports = {
Expand All @@ -111,5 +113,6 @@ module.exports = {
stylesTransform,
BUNDLED_PACKAGES,
MODULES,
SCRIPT_AND_MODULE_DUAL_PACKAGES,
WORDPRESS_NAMESPACE,
};

0 comments on commit 5d02179

Please sign in to comment.