Skip to content

Switch the build process to @wordpress/scripts#1

Merged
jakemgold merged 2 commits into
mainfrom
switch-build-to-wp-scripts
Jun 6, 2026
Merged

Switch the build process to @wordpress/scripts#1
jakemgold merged 2 commits into
mainfrom
switch-build-to-wp-scripts

Conversation

@fabiankaegy
Copy link
Copy Markdown
Member

@fabiankaegy fabiankaegy commented May 19, 2026

Summary

Replaces 10up-toolkit with @wordpress/scripts as the bundler for the popup.

Why

I used toolkit in the beginning because it was just the tool I was the most familiar with. But with this living under the @WordPress org now we should use the default wp build tooling.

Details

  • Adds a small webpack.config.js that layers two extension-specific tweaks on top of the wp-scripts defaults:
    • Dual entry points — the shipping popup bundle plus the dev-only preview bundle used by popup/preview.html.
    • DependencyExtractionWebpackPlugin filtered out — wp-scripts assumes @wordpress/* packages are available on the wp.* global at runtime (true inside wp-admin, false in a browser extension), so we bundle them into popup.js instead.
  • Output stays in dist/ so popup.html, sync-safari.sh, package-chrome.sh, and the Safari Xcode project keep working without path changes.
  • Drops the now-unused 10up-toolkit config files (buildfiles.config.js, filenames.config.js, paths.config.js) and the popup.js.LICENSE.txt artifact (wp-scripts' Terser config strips license comments and doesn't extract them to a sidecar file).
  • Extends .gitignore to silence wp-scripts' unused auxiliary output (dist/*-rtl.css, dist/*.map) — popup.html doesn't reference them and the Chrome zip / Safari sync don't copy them.
  • The build/start scripts keep cross-env to force NODE_ENV, because wp-scripts build only sets it when unset and a contributor's shell may already have NODE_ENV=development exported.

Production bundle size: 397 KB minified for popup.js (down from 1.8 MB under 10up-toolkit).

Test plan

  • npm install
  • npm run build produces dist/popup.{js,css} and dist/preview.{js,css}
  • node test/smoke.js — all assertions pass
  • npm run package:chrome builds a Chrome zip with the expected layout (popup + dist + lib + icons + manifest)
  • Load the unpacked extension in Chrome; popup renders against a WordPress site (detected view) and a non-WordPress site (not-WP view)
  • npm run build:safari syncs into the Xcode Resources directory without errors

Replaces 10up-toolkit with @wordpress/scripts as the bundler. Adds a
custom webpack.config.js that layers two extension-specific tweaks on
top of the wp-scripts defaults:

  - Dual entry points — the shipping popup bundle and the dev-only
    preview bundle used by popup/preview.html.
  - DependencyExtractionWebpackPlugin filtered out — wp-scripts assumes
    @wordpress/* packages are available on the wp.* global at runtime
    (true inside wp-admin, false in a browser extension), so we bundle
    them into popup.js.

Output stays in dist/ so popup.html, sync-safari.sh, package-chrome.sh,
and the Safari Xcode project keep working without path changes. wp-
scripts emits a few unused auxiliary files (popup-rtl.css, source maps);
they're gitignored since the shipping zip and Safari Resources sync
don't include them.

Drops the now-unused 10up-toolkit config files
(buildfiles/filenames/paths.config.js) and the popup.js.LICENSE.txt
artifact (wp-scripts' Terser config strips license comments and doesn't
extract them to a sidecar file).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@fabiankaegy fabiankaegy requested a review from jakemgold as a code owner May 19, 2026 15:15
Copilot AI review requested due to automatic review settings May 19, 2026 15:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Switches the popup build pipeline from 10up-toolkit to @wordpress/scripts, keeping output paths compatible with the browser extension packaging and Safari sync flows.

Changes:

  • Adds a custom webpack.config.js with popup/preview entry points and bundled WordPress dependencies.
  • Updates npm scripts/dependencies and removes old 10up-toolkit config files.
  • Adjusts packaging/sync scripts and generated/ignored dist artifacts for wp-scripts output.

Reviewed changes

Copilot reviewed 7 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
webpack.config.js Adds wp-scripts-based webpack customization for extension output.
package.json Replaces 10up-toolkit scripts/dependency with wp-scripts and adds browserslist.
.gitignore Ignores wp-scripts auxiliary dist outputs.
scripts/package-chrome.sh Stops copying the removed license sidecar into Chrome packages.
scripts/sync-safari.sh Stops copying the removed license sidecar into Safari resources.
buildfiles.config.js Removes obsolete 10up-toolkit entry config.
filenames.config.js Removes obsolete 10up-toolkit filename config.
paths.config.js Removes obsolete 10up-toolkit path config.
dist/popup.css Updates generated popup stylesheet artifact.
dist/popup.js.LICENSE.txt Removes old extracted license sidecar artifact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/sync-safari.sh
The committed dist/popup.js was a 2.4 MB unminified development build
(~64k lines); a production wp-scripts build is 235 KB minified. Regenerate
dist/popup.{js,css} and the synced Safari Resources copies via
`npm run build:safari`, and drop the stale popup.js.LICENSE.txt under the
Safari Resources dir that the wp-scripts build no longer emits.

No source changes; this only corrects the shipped artifacts so the repo
stops carrying an oversized dev bundle.

Co-Authored-By: Claude <[email protected]>
Copy link
Copy Markdown
Collaborator

@jakemgold jakemgold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified end-to-end: all five test-plan steps pass (npm install, build, smoke.js, package:chrome, build:safari), plus manual smoke testing in Chrome and Safari. Added a follow-up commit replacing the committed dev-build dist/popup.js with the production-minified bundle (~64k-line diff reduction).

@jakemgold jakemgold merged commit a88afd1 into main Jun 6, 2026
@jakemgold jakemgold deleted the switch-build-to-wp-scripts branch June 6, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants