Remove root uuid dependency#77960
Conversation
|
Size Change: 0 B Total Size: 7.94 MB ℹ️ View Unchanged
|
Follow up to #77848. v14 is ESM-only, so replace the remaining require('uuid') and import-from-uuid call sites with Node's built-in crypto.randomUUID(), and drop uuid from the root devDependencies (workspace packages keep their own). Update the Jest resolver to only strip pkg.exports when pkg.main exists, so nested v8 copies (e.g. @actions/core's uuid@8.3.2) keep their CJS fallback while v14 — which has no main — flows through to Babel via transformIgnorePatterns in test/unit/jest.config.js and test/native/jest.config.js.
85d0c52 to
3f94d5d
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 3f94d5d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25380794486
|
What?
Follow up to #77848.
Updates the monorepo root from
uuid@11.1.1touuid@14.0.0(matching the version already used by every workspace package), drops the now-unused rootuuiddevDependency, and removes the remaining direct consumers in favour of Node's built-incrypto.randomUUID().Why?
#77848 bumped every workspace package to
uuid@14, but kept the root pinned at11.1.1because v11 was the last release that shipped a CommonJS build. v14 is ESM-only:"type": "module"and nomainfield — only anexportsmap pointing at ESM bundles indist/anddist-node/.require('uuid')call sites throwERR_REQUIRE_ESM.test/unit/scripts/resolver.jsthat stripspkg.exportsand falls back topkg.mainno longer resolves anything (nomainfield exists), which silently breaks any unit/native test that imports a package depending onuuid.Upstream has deprecated all
uuidversions before 11 and signaled v11 will likely be deprecated in 2028, so getting the root onto v14 closes out the migration started in #77848.How?
1. Replaced direct root-level consumers with
crypto.randomUUID()Node ≥ 20.19 — already our minimum — ships it natively, returns the same v4-format string, no dependency required.
2. Fixed the Jest resolver for v14's exports-only layout:
pkg.exports-stripping branch intest/unit/scripts/resolver.jsto only strip whenpkg.mainexists. Older nesteduuidcopies (e.g.@actions/core's pinneduuid@8.3.2) keep the v8-era fallback to their CJSmain, while v14 (which has nomain) is left alone so the exports map resolves normally.uuidto thetransformIgnorePatternsallowlist in bothtest/unit/jest.config.jsandtest/native/jest.config.jsso Babel transforms uuid v14's ESM build to CJS at test time.3. Removed
uuidfrom rootdevDependenciesinpackage.json(no root-level imports remain; the hoisted copy innode_modules/uuidcontinues to come from the workspace packages that declare it).Testing Instructions
There should be no functional changes. Verify the build and tests:
E2E specs that previously used
require('uuid')for fake file names should still upload/manipulate media as expected.Testing Instructions for Keyboard
N/A — no UI changes.
Screenshots or screencast
N/A
Use of AI Tools
Authored with assistance from Claude Code (Opus 4.7) for analysis and edits; reviewed and tested by the PR author.