Commit 0d18be634c6 for woocommerce
commit 0d18be634c68632d5893dfaaf650ccfbf4ad5551
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date: Tue Oct 20 15:56:21 2026 +0300
Fix React dependency resolution in generated extensions (#70014)
* fix(create-woo-extension): Pin compatible React development dependencies
Generated extensions let npm choose React 19 through WordPress peers,
but WooCommerce components require React 18.3.x. Installation stops
with ERESOLVE before contributors can build the example.
Declare React and React DOM 18.3.x in the generated development
dependencies so npm resolves compatible peers. Keep the existing
webpack extraction of WordPress's runtime dependencies.
Refs #50420
* chore(create-woo-extension): Add React dependency fix changelog
Record the generated-extension installation fix for the next package release.
* docs(create-woo-extension): Name the source of the React pins
The `react` and `react-dom` pins in the generated development
dependencies copy the peer range of `@woocommerce/components`. Nothing
tied the two together, so a React major bump in that package would
bring back the npm ERESOLVE failure from the other side.
Point the comment at packages/js/components/package.json and note that
the pins must change with it.
Refs #50420
diff --git a/packages/js/create-woo-extension/changelog/fix-scaffold-react-peer-dependencies b/packages/js/create-woo-extension/changelog/fix-scaffold-react-peer-dependencies
new file mode 100644
index 00000000000..fdd40e3a92c
--- /dev/null
+++ b/packages/js/create-woo-extension/changelog/fix-scaffold-react-peer-dependencies
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix dependency installation for generated extensions by matching WooCommerce's React peer requirements.
diff --git a/packages/js/create-woo-extension/index.js b/packages/js/create-woo-extension/index.js
index 1c8e69b156a..e6414fc24b8 100644
--- a/packages/js/create-woo-extension/index.js
+++ b/packages/js/create-woo-extension/index.js
@@ -19,6 +19,13 @@ const defaultDevDependencies = {
'@woocommerce/eslint-plugin': '^4.0.0',
'@wordpress/prettier-config': 'latest',
'@wordpress/scripts': 'latest',
+ /*
+ * Match the `react` and `react-dom` peer range of `@woocommerce/components`
+ * (packages/js/components/package.json) instead of npm selecting React 19.
+ * Update these when that range changes.
+ */
+ react: '18.3.x',
+ 'react-dom': '18.3.x',
/*
* Without this, `@wordpress/prettier-config`'s `prettier: >=3` peer hoists plain
* prettier over wp-prettier. Pinned to match `@woocommerce/eslint-plugin`.