diff --git a/packages/wp-build/CHANGELOG.md b/packages/wp-build/CHANGELOG.md index 23e33c1cdca137..d801aa55d1c6ae 100644 --- a/packages/wp-build/CHANGELOG.md +++ b/packages/wp-build/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bug Fixes +- Preserve the non-enumerable `__esModule` marker on `window.wp.*` IIFE globals so that external webpack consumers (e.g. WooCommerce) can still default-import `@wordpress/*` packages exposed as webpack externals. - Remove the incorrect `#wpwrap` background from wp-admin critical CSS to prevent a black flash before hydration; rely on the existing `body` background instead ([#78493](https://github.com/WordPress/gutenberg/pull/78493)). ## 0.15.0 (2026-05-27) diff --git a/packages/wp-build/lib/build.mjs b/packages/wp-build/lib/build.mjs index 0ae6c549245942..e35dc30054a4df 100755 --- a/packages/wp-build/lib/build.mjs +++ b/packages/wp-build/lib/build.mjs @@ -585,10 +585,14 @@ async function bundlePackage( packageName, options = {} ) { } if ( globalName ) { // esbuild marks the getters non-configurable, so we can't rewrite - // them in place; replacing the whole namespace with a shallow - // copy is the simplest way to materialize each value once. + // them in place; replacing the whole namespace with a shallow copy + // is the simplest way to materialize each value once. + // + // Seed the copy with a non-enumerable `__esModule` flag so that + // bundlers treat it as an ESM module, triggering interop + // conventions for default exports. footerParts.push( - `if(${ globalName }&&typeof ${ globalName }==='object'){${ globalName }=Object.assign({},${ globalName });}` + `if(${ globalName }&&typeof ${ globalName }==='object'){${ globalName }=Object.assign(Object.defineProperty({},'__esModule',{value:true,writable:true}),${ globalName });}` ); } if ( footerParts.length ) {