Skip to content

fix: remove workspaces field from package.json and update uuid to v14 - #410

Merged
fabiankaegy merged 3 commits into
developfrom
fix/remove-workspaces-from-published-package
Jul 23, 2026
Merged

fix: remove workspaces field from package.json and update uuid to v14#410
fabiankaegy merged 3 commits into
developfrom
fix/remove-workspaces-from-published-package

Conversation

@fabiankaegy

@fabiankaegy fabiankaegy commented Jul 20, 2026

Copy link
Copy Markdown
Member

Description of the Change

Fixes #408.

The published npm package shipped "workspaces": ["example/"] in its package.json. While the example/ directory itself was already excluded from the tarball by the files allowlist, the workspaces field persisted in the published package.json, making npm treat the installed package as workspace-aware during dependency resolution in consuming projects — which breaks npm overrides for any transitive dependency of this package.

Changes

  • Remove the workspaces field from package.json (the actual fix from the issue).
  • Rewire the test-env scripts: example/ is now a standalone npm project. build-test-env builds the root package, runs npm install --prefix example, then builds the example plugin; start-test-env uses --prefix example instead of -w example/. This keeps the e2e CI workflow working, since root npm ci no longer installs example's dependencies.
  • Add jest-environment-jsdom as an explicit devDependency — regression fix uncovered while testing: it was previously only available through workspace hoisting from example's @wordpress/scripts tree, so removing workspaces silently broke npm test (10up-toolkit hardcodes testEnvironment: 'jsdom').
  • Update uuid from ^9.0.1 to ^14.0.1 so consumers get a current uuid without resorting to overrides at all. Dropped @types/uuid (uuid ships its own types since v7). Both usage sites (content-picker, repeater) use the unchanged v4 named export — no code changes needed.
  • Add jest-unit.config.js (10up-toolkit's project-root override mechanism) widening transformIgnorePatterns so Jest transforms uuid's ESM-only build. uuid v13+ ships no CommonJS export condition; webpack-based consumer builds handle this transparently (verified below), but Jest needs the transform.
  • Regenerate lockfiles: root package-lock.json loses the example workspace tree (verified semantically: 0 unexpected additions or version changes besides uuid and the jest-environment-jsdom tree); example/package-lock.json is newly committed for the now-standalone example project.
  • Update CONTRIBUTING.md for the new two-project setup.

CI fixes (follow-up commits)

  • Regenerate the lockfile with npm 10 (matching .nvmrc's node 20 used by CI): npm 10's resolver requires a nested stylelint@16 subtree under @wordpress/ui that npm 11 prunes, so the initially npm 11-written lockfile failed npm ci on the runners. Additions only, no version changes; validated with npm ci --dry-run under both npm 10 and npm 11.
  • Pin the publish workflow's npm upgrade to npm@11: npm@12 requires node >= 22, so npm install -g npm@latest now fails on the node 20 runners — this release_testing breakage predates this PR and hits every PR.

Known unrelated failure

The Cypress e2e job fails with Cannot destructure property 'documentElement' of 'z' as it is null in every spec — the identical failure exists on develop (first seen in the July 16 run of the 1.22.3 release commit, a version-bump-only change), so it's pre-existing environment drift (likely wp-env pulling a newer WordPress), not caused by this PR. The rewired build-test-env/start-test-env scripts themselves work: the CI run builds the example plugin, boots the environment, and executes all 35 tests.

How to test the Change

  1. npm ci && npm test && npm run build — unit tests and build pass.
  2. npm run build-test-env — full clean pipeline (root build → example install → example webpack build) succeeds, confirming a webpack consumer bundles ESM-only uuid@14 through the CJS dist output.
  3. Repro from the issue: npm pack, then in a fresh project add the tarball as a dependency with "overrides": { "uuid": "^14.0.0" } and run npm install && npm ls uuid. The extracted tarball's package.json has no workspaces field, and npm ls uuid shows a single deduped uuid@14.0.1 — no nested stale copy. (With this change, no override is needed in the first place.)

Changelog Entry

Fixed - remove workspaces field from the published package.json, which broke npm overrides for transitive dependencies in consuming projects
Changed - update uuid dependency from v9 to v14

Credits

Props @mattradford-sage (issue report and suggested fix), @fabiankaegy

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change where applicable.
  • All new and existing tests pass.

🤖 Generated with Claude Code

the published npm package shipped "workspaces": ["example/"], which
makes npm treat the installed package as workspace-aware during
dependency resolution and breaks npm overrides for transitive
dependencies in consuming projects.

- remove the workspaces field; example/ is now a standalone npm
  project installed via --prefix in the test-env scripts
- add jest-environment-jsdom as an explicit devDependency (it was
  previously only available through workspace hoisting from example/)
- update uuid from ^9.0.1 to ^14.0.1 and drop @types/uuid (uuid ships
  its own types); add jest-unit.config.js so jest transforms uuid's
  esm-only build

fixes #408

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 20, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an npm packaging issue where the published package.json included a workspaces field (breaking npm overrides in consuming projects), and updates the uuid dependency to a newer major version while keeping local e2e workflows working without npm workspaces.

Changes:

  • Removed "workspaces" from the published package.json and rewired test-env scripts to use a standalone example/ project.
  • Updated uuid to ^14.0.1, removed @types/uuid, and added jest-environment-jsdom as an explicit devDependency.
  • Added jest-unit.config.js to ensure Jest transforms uuid (ESM) under node_modules, and updated CONTRIBUTING.md to reflect the new setup.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 3 comments.

File Description
package.json Removes workspace config, updates dependencies, and updates env scripts to run against the standalone example/ project.
jest-unit.config.js Extends 10up-toolkit Jest config to transform uuid (ESM) instead of ignoring it under node_modules.
CONTRIBUTING.md Updates contributor workflow docs for separate root + example/ installs/builds.

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

Comment thread package.json
Comment on lines +73 to +74
"build-test-env": "npm run build && npm install --prefix example && npm run build --prefix example",
"start-test-env": "npm run start-env --prefix example && npm run import-media --prefix example",
Comment thread CONTRIBUTING.md

```bash
npm run build
npm install --prefix example
Comment thread CONTRIBUTING.md

```bash
npm run start
npm run build --prefix example
fabiankaegy and others added 2 commits July 20, 2026 15:40
regenerate package-lock.json with npm 10 (the version matching
.nvmrc's node 20 used by CI): npm 10's resolver requires the nested
stylelint@16 subtree under @wordpress/ui that npm 11 prunes, so a
lockfile written by npm 11 fails `npm ci` on npm 10. additions only,
no version changes; validated with `npm ci --dry-run` on both npm 10
and npm 11

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
npm@12 requires node >= 22, so `npm install -g npm@latest` now fails
on the node 20 runners used by the publish workflow (pre-existing
breakage on every pr)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cypress

cypress Bot commented Jul 20, 2026

Copy link
Copy Markdown

10up Block Components    Run #1077

Run Properties:  status check failed Failed #1077  •  git commit 7047228532: fix: pin publish workflow npm upgrade to npm@11
Project 10up Block Components
Branch Review fix/remove-workspaces-from-published-package
Run status status check failed Failed #1077
Run duration 02m 13s
Commit git commit 7047228532: fix: pin publish workflow npm upgrade to npm@11
Committer Fabian Kägy
View all properties for this run ↗︎

Test results
Tests that failed  Failures 12
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 23
Tests that passed  Passing 0
View all changes introduced in this branch ↗︎

Tests for review

Failed  ColorSettings.spec.js • 1 failed test

View Output

Test Artifacts
ColorSettings > Allows the user to pick the block and displays it Test Replay Screenshots
Failed  Counter.spec.js • 1 failed test

View Output

Test Artifacts
Counter > Allows the user to pick the block and displays it Test Replay Screenshots
Failed  IconPicker.spec.js • 1 failed test

View Output

Test Artifacts
IconPicker > allows the user to use the post picker to change an icon and displays it Test Replay Screenshots
Failed  Image.spec.js • 1 failed test

View Output

Test Artifacts
Image > allows the user to pick an image from the media library and displays it inline Test Replay Screenshots
Failed  Link.spec.js • 1 failed test

View Output

Test Artifacts
Link > allows the editor to pick a link directly inline Test Replay Screenshots

The first 5 failed specs are shown, see all 11 specs in Cypress Cloud.

@github-actions

Copy link
Copy Markdown

🎉 A new testing version of this package has been published to NPM. You can install it with npm install @10up/block-components@testing-410

@fabiankaegy
fabiankaegy merged commit 3c9b693 into develop Jul 23, 2026
9 of 11 checks passed
@fabiankaegy
fabiankaegy deleted the fix/remove-workspaces-from-published-package branch July 23, 2026 07:01
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.

Published package includes workspaces field, preventing npm overrides from working

2 participants