Skip to content

chore: replace uuid with native crypto.randomUUID()#1866

Merged
PatelUtkarsh merged 1 commit into
developfrom
fix/XWPENG-29-remove-uuid-dep
May 12, 2026
Merged

chore: replace uuid with native crypto.randomUUID()#1866
PatelUtkarsh merged 1 commit into
developfrom
fix/XWPENG-29-remove-uuid-dep

Conversation

@PatelUtkarsh
Copy link
Copy Markdown
Member

Summary

Removes the uuid devDependency in favour of the built-in crypto.randomUUID().

Why

  • uuid was used in exactly one place (tests/e2e/editor-new-post.spec.js) to generate a unique post title for a Playwright test.

  • Node 22+ and all modern browsers expose crypto.randomUUID() globally β€” no dependency required.

  • Unblocks chore(deps): update dependency uuid to v14Β #1861 / XWPENG-29: uuid v14 ships ESM-only (drops the require export condition). The currently bundled eslint-import-resolver-node@0.3.9 (transitively via @wordpress/eslint-plugin@22.22.0) doesn't understand the exports field, so npm run lint:js fails with:

    Unable to resolve path to module 'uuid'  import/no-unresolved
    

    Removing uuid sidesteps the resolver upgrade entirely.

Changes

  • package.json: removed "uuid": "^11.1.1" from devDependencies.
  • package-lock.json: regenerated; uuid entry dropped.
  • tests/e2e/editor-new-post.spec.js: removed import { v4 as uuidv4 } from 'uuid'; replaced uuidv4() with crypto.randomUUID().

Verification

  • npm ci β€” OK
  • npm run lint:js β€” clean
  • npm run build β€” OK; build/select2/* and build/timeago/* assets present
  • node -e "console.log(crypto.randomUUID())" β€” OK on Node 22

Related

The uuid package was used in exactly one place (an E2E test) to generate
a unique post title. Node 22 (and all modern browsers) ship crypto.randomUUID()
natively, so the dependency is unnecessary.

Also unblocks XWPENG-29: uuid v14 dropped CJS exports, which broke
eslint-plugin-import's resolver chain (eslint-import-resolver-node 0.3.9
does not understand ESM-only "exports" maps). Removing uuid avoids
needing to upgrade the resolver chain.

Refs XWPENG-29
Supersedes #1861
@PatelUtkarsh PatelUtkarsh merged commit 8d4ce21 into develop May 12, 2026
2 checks passed
@PatelUtkarsh PatelUtkarsh deleted the fix/XWPENG-29-remove-uuid-dep branch May 12, 2026 12:00
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.

1 participant