Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug/issue #68368 - SCRIPT_DEBUG not working properly in gutenberg plugin #68527

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,15 @@ function gutenberg_register_vendor_scripts( $scripts ) {
* @since 19.3.0
*/
function gutenberg_default_script_modules() {
$suffix = wp_scripts_get_suffix();
/*
* Expects multidimensional array like:
*
* 'interactivity/index.min.js' => array('dependencies' => array(…), 'version' => '…'),
* 'interactivity/debug.min.js' => array('dependencies' => array(…), 'version' => '…'),
* 'interactivity-router/index.min.js' => …
*/
$assets = include gutenberg_dir_path() . '/build-module/assets.php';
$assets = include gutenberg_dir_path() . "/build-module/assets{$suffix}.php";

foreach ( $assets as $file_name => $script_module_data ) {
/*
Expand All @@ -634,7 +635,7 @@ function gutenberg_default_script_modules() {
* - interactivity/debug.min.js => @wordpress/interactivity/debug
* - block-library/query/view.js => @wordpress/block-library/query/view
*/
$script_module_id = '@wordpress/' . preg_replace( '~(?:/index)?\.min\.js$~D', '', $file_name, 1 );
$script_module_id = '@wordpress/' . preg_replace( '~(?:/index)?(?:\.min)?\.js$~D', '', $file_name, 1 );
switch ( $script_module_id ) {
/*
* Interactivity exposes two entrypoints, "/index" and "/debug".
Expand Down
68 changes: 36 additions & 32 deletions tools/webpack/script-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,42 @@ for ( const packageDir of packageDirs ) {
);
}
}
module.exports = function () {
const suffix = baseConfig.mode === 'production' ? '.min' : '';

module.exports = {
...baseConfig,
name: 'script-modules',
entry: Object.fromEntries( gutenbergScriptModules.entries() ),
experiments: {
outputModule: true,
},
output: {
devtoolNamespace: 'wp',
filename: '[name].min.js',
library: {
type: 'module',
const config = {
...baseConfig,
name: 'script-modules',
entry: Object.fromEntries( gutenbergScriptModules.entries() ),
experiments: {
outputModule: true,
},
path: join( __dirname, '..', '..', 'build-module' ),
environment: { module: true },
module: true,
chunkFormat: 'module',
asyncChunks: false,
},
resolve: {
extensions: [ '.js', '.ts', '.tsx' ],
},
plugins: [
...plugins,
new DependencyExtractionWebpackPlugin( {
combineAssets: true,
combinedOutputFile: `./assets.php`,
} ),
],
watchOptions: {
ignored: [ '**/node_modules' ],
aggregateTimeout: 500,
},
output: {
devtoolNamespace: 'wp',
filename: `[name]${ suffix }.js`,
library: {
type: 'module',
},
path: join( __dirname, '..', '..', 'build-module' ),
environment: { module: true },
module: true,
chunkFormat: 'module',
asyncChunks: false,
},
resolve: {
extensions: [ '.js', '.ts', '.tsx' ],
},
plugins: [
...plugins,
new DependencyExtractionWebpackPlugin( {
combineAssets: true,
combinedOutputFile: `./assets${ suffix }.php`,
} ),
],
watchOptions: {
ignored: [ '**/node_modules' ],
aggregateTimeout: 500,
},
};
return config;
};
Loading