Build: Add vendorScripts config to build packages from node_modules #74343
+238
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note This is fully vibe-coded with my own instructions about how it should be API wise. I also didn't test it yet.
Summary
Adds support for building vendor packages (like React) directly from
node_modulesinstead of relying on pre-built UMD bundles. This addresses the React 19 upgrade blocker where UMD builds are no longer shipped.Changes
vendorScriptsconfig inwpPlugin(package.json)bundleVendorScript()function that bundles packages from node_modules into IIFE formatwordpress-externals-pluginto accept vendor scripts config while preserving defaults for third-party pluginsConfiguration
Build Output
build/scripts/react/index.min.js (~7KB) - exposes window.React
build/scripts/react-dom/index.min.js (~135KB) - exposes window.ReactDOM
build/scripts/react-jsx-runtime/index.min.js (~1KB) - exposes window.ReactJSXRuntime
Test plan
Build completes successfully with npm run build
Vendor scripts are bundled and registered in build/scripts/index.php
Asset files have correct dependencies
Test in browser that React globals are exposed correctly