Skip to content

Commit

Permalink
Build runtime regardless
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Sep 6, 2024
1 parent 7f6ac84 commit 92f9db5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ function gutenberg_register_packages_scripts( $scripts ) {
$dependencies = isset( $asset['dependencies'] ) ? $asset['dependencies'] : array();
$version = isset( $asset['version'] ) ? $asset['version'] : $default_version;

// Register the runtime dependency for each entry point.
$dependencies[] = 'wp-runtime';

// Register HMR dependencies for each entry point in development mode.
if ( gutenberg_is_hmr_enabled() ) {
$dependencies[] = '🔥hot';
Expand Down
8 changes: 8 additions & 0 deletions packages/dependency-extraction-webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class DependencyExtractionWebpackPlugin {
injectPolyfill,
outputFormat,
outputFilename,
additionalDependencies,
} = this.options;

// Dump actually externalized dependencies to a report file.
Expand Down Expand Up @@ -232,6 +233,13 @@ class DependencyExtractionWebpackPlugin {
chunkStaticDeps.add( 'wp-polyfill' );
}

if ( typeof additionalDependencies === 'function' ) {
const dependencies = additionalDependencies( chunk );
dependencies.forEach( ( dependency ) => {
chunkStaticDeps.add( dependency );
} );
}

/**
* @param {webpack.Module} m
*/
Expand Down
5 changes: 4 additions & 1 deletion tools/webpack/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ const config = {
},
plugins: [
...plugins,
new DependencyExtractionWebpackPlugin( { injectPolyfill: true } ),
new DependencyExtractionWebpackPlugin( {
injectPolyfill: true,
additionalDependencies: () => [ 'wp-runtime' ],
} ),
new CopyWebpackPlugin( {
patterns: bundledPackagesPhpConfig.concat(
Object.entries( copiedVendors ).map( ( [ to, from ] ) => ( {
Expand Down

0 comments on commit 92f9db5

Please sign in to comment.