Skip to content

Commit

Permalink
Adjust file naming to match old bundle to avoid breaking translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
samueljseay committed Mar 26, 2024
1 parent 0def7ed commit 3688f6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion plugins/woocommerce-blocks/bin/webpack-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,20 @@ const getFrontConfig = ( options = {} ) => {
// translations which we must avoid.
// @see https://github.com/Automattic/jetpack/pull/20926
chunkFilename: `[name]-frontend${ fileSuffix }.js?ver=[contenthash]`,
filename: `[name]-frontend${ fileSuffix }.js`,
filename: ( pathData ) => {
// blocksCheckout and blocksComponents were moved from core bundle,
// retain their filenames to avoid breaking translations.
if (
pathData.chunk.name === 'blocksCheckout' ||
pathData.chunk.name === 'blocksComponents'
) {
return `${ paramCase(
pathData.chunk.name
) }${ fileSuffix }.js`;
}

return `[name]-frontend${ fileSuffix }.js`;
},
uniqueName: 'webpackWcBlocksFrontendJsonp',
library: [ 'wc', '[name]' ],
},
Expand Down
4 changes: 2 additions & 2 deletions plugins/woocommerce/src/Blocks/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public function register_assets() {
$this->api->register_script( 'wc-price-format', 'assets/client/blocks/price-format.js', array(), false );

$this->api->register_script( 'wc-blocks-vendors-frontend', $this->api->get_block_asset_build_path( 'wc-blocks-vendors-frontend' ), array(), false );
$this->api->register_script( 'wc-blocks-checkout', 'assets/client/blocks/blocksCheckout-frontend.js', array( 'wc-blocks-vendors-frontend' ) );
$this->api->register_script( 'wc-blocks-components', 'assets/client/blocks/blocksComponents-frontend.js', array( 'wc-blocks-vendors-frontend' ) );
$this->api->register_script( 'wc-blocks-checkout', 'assets/client/blocks/blocks-checkout.js', array( 'wc-blocks-vendors-frontend' ) );
$this->api->register_script( 'wc-blocks-components', 'assets/client/blocks/blocks-components.js', array( 'wc-blocks-vendors-frontend' ) );

// Register the interactivity components here for now.
$this->api->register_script( 'wc-interactivity-dropdown', 'assets/client/blocks/wc-interactivity-dropdown.js', array() );
Expand Down

0 comments on commit 3688f6b

Please sign in to comment.