Commit 2ecd404e21a for woocommerce
commit 2ecd404e21ac5aee014fd37e1136df84fb608e64
Author: Raluca Stan <ralucastn@gmail.com>
Date: Mon Jun 15 16:11:51 2026 +0200
Fix WooCommerce Blocks build warnings and a Sass build error (#65749)
* Fix WooCommerce Blocks build error and dead block.json declaration
- Replace invalid breakpoint(">781px") with ">782px" in the Cart
proceed-to-checkout block; 781px is not a valid breakpoint and raised a
Sass build error.
- Remove the dead viewScriptModule "product-price" from the Product Price
block.json. No such script module is built; the block's interactivity is
served by the shared woocommerce/product-elements module enqueued in
ProductPrice.php.
* Fix false-positive asset warnings in the interactivity blocks build
The build warned for blocks whose block.json declarations are valid:
- viewScriptModule built from a frontend.js, not only frontend.ts.
- viewScriptModule pointing at a shared module built from another entry
(e.g. woocommerce/product-elements), so the block has no local
frontend file by design.
- style referenced via a file: path to a CSS file built elsewhere
(e.g. compiled from a shared base component).
Only warn when a block's own frontend/style source is genuinely
missing.
* Rename accordion-group frontend.js to frontend.ts instead of relaxing the check
Keep the viewScriptModule check strict on frontend.ts. accordion-group was
the only interactive block shipping a frontend.js; rename it (with types) so
it satisfies the check rather than loosening the rule for every block.
* Add changelog entry
* Handle array style values in the interactivity asset check
block.json style can be an array of references. The previous check relied on
String(style) coercion, which only detected a file: reference when it was the
first array element. Check each entry instead.
diff --git a/plugins/woocommerce/changelog/65749-fix-blocks-build-warnings b/plugins/woocommerce/changelog/65749-fix-blocks-build-warnings
new file mode 100644
index 00000000000..bbd17de1744
--- /dev/null
+++ b/plugins/woocommerce/changelog/65749-fix-blocks-build-warnings
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix a Sass build error in the Cart proceed-to-checkout block and remove an invalid script module declaration from the Product Price block.
diff --git a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/price/block.json b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/price/block.json
index 67277dec458..274b73cc1f0 100644
--- a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/price/block.json
+++ b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/price/block.json
@@ -50,7 +50,6 @@
"woocommerce/product-template",
"core/post-template"
],
- "viewScriptModule": "product-price",
"style": "file:../product-price.css",
"$schema": "https://schemas.wp.org/trunk/block.json"
}
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/frontend.js b/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/frontend.ts
similarity index 68%
rename from plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/frontend.js
rename to plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/frontend.ts
index 425350aad72..d3bead54887 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/frontend.js
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/accordion/accordion-group/frontend.ts
@@ -3,16 +3,23 @@
*/
import { store, getContext } from '@wordpress/interactivity';
+type AccordionContext = {
+ isOpen: string[];
+ id: string;
+ autoclose: boolean;
+ openByDefault: boolean;
+};
+
const { state } = store( 'woocommerce/accordion', {
state: {
- get isOpen() {
- const { isOpen, id } = getContext();
+ get isOpen(): boolean {
+ const { isOpen, id } = getContext< AccordionContext >();
return isOpen.includes( id );
},
},
actions: {
toggle: () => {
- const context = getContext();
+ const context = getContext< AccordionContext >();
const { id, autoclose } = context;
if ( autoclose ) {
@@ -28,7 +35,7 @@ const { state } = store( 'woocommerce/accordion', {
},
callbacks: {
initIsOpen: () => {
- const context = getContext();
+ const context = getContext< AccordionContext >();
const { id, openByDefault } = context;
if ( openByDefault ) {
context.isOpen.push( id );
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/style.scss b/plugins/woocommerce/client/blocks/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/style.scss
index 0f6afb12f6e..d23a923f76f 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/style.scss
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/cart/inner-blocks/proceed-to-checkout-block/style.scss
@@ -54,7 +54,7 @@
}
}
-@include breakpoint(">781px") {
+@include breakpoint(">782px") {
.wc-block-cart .wc-block-cart__submit-container--sticky {
display: none;
}
diff --git a/plugins/woocommerce/client/blocks/bin/webpack-interactivity-entries.js b/plugins/woocommerce/client/blocks/bin/webpack-interactivity-entries.js
index de4db8f1efa..b6ed4c12bea 100644
--- a/plugins/woocommerce/client/blocks/bin/webpack-interactivity-entries.js
+++ b/plugins/woocommerce/client/blocks/bin/webpack-interactivity-entries.js
@@ -33,26 +33,40 @@ function findInteractivityBlockAssets( dir = [] ) {
// For block.json's viewScriptModule, style, editorStyle, check if the file exists and warn
// if it doesn't, so we don't try enqueue non-existent assets.
- if ( blockJson.viewScriptModule ) {
- if (
- ! fs.existsSync( path.join( blockDir, 'frontend.ts' ) )
- ) {
- // eslint-disable-next-line no-console
- console.warn(
- `viewScriptModule was declared in ${ blockJson.name } block.json but no frontend.ts file exists.`
- );
- }
+
+ // A viewScriptModule pointing at a name other than the block's own
+ // references a shared module built from another entry, so there's
+ // nothing local to check. Otherwise, the module is built from this
+ // block's own frontend.ts, which must exist.
+ if (
+ blockJson.viewScriptModule &&
+ blockJson.viewScriptModule === blockJson.name &&
+ ! fs.existsSync( path.join( blockDir, 'frontend.ts' ) )
+ ) {
+ // eslint-disable-next-line no-console
+ console.warn(
+ `viewScriptModule was declared in ${ blockJson.name } block.json but no frontend.ts file exists.`
+ );
}
- if ( blockJson.style ) {
- if (
- ! fs.existsSync( path.join( blockDir, 'style.scss' ) )
- ) {
- // eslint-disable-next-line no-console
- console.warn(
- `style was declared in ${ blockJson.name } block.json but no style.scss file exists.`
- );
- }
+ // A `file:` style references a CSS file built elsewhere (e.g.
+ // compiled from a shared base component), so only warn when a
+ // local style.scss source is expected but missing. `style` may
+ // be a single reference or an array of them.
+ const styleRefs = Array.isArray( blockJson.style )
+ ? blockJson.style
+ : [ blockJson.style ];
+ if (
+ blockJson.style &&
+ ! styleRefs.some( ( ref ) =>
+ String( ref ).startsWith( 'file:' )
+ ) &&
+ ! fs.existsSync( path.join( blockDir, 'style.scss' ) )
+ ) {
+ // eslint-disable-next-line no-console
+ console.warn(
+ `style was declared in ${ blockJson.name } block.json but no style.scss file exists.`
+ );
}
if ( blockJson.editorStyle ) {