Build: Fix ESM declaration resolution - #82022
Conversation
|
Size Change: 0 B Total Size: 7.91 MB |
|
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 193c6bc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/32959355605 should be disabled when post is being saved in
|
6ef7ec7 to
8e69f72
Compare
manzoorwanijk
left a comment
There was a problem hiding this comment.
Two minor things. Looks good otherwise.
8e69f72 to
9431677
Compare
This reverts commit 9431677.
|
@manzoorwanijk before merging, just double-checking: do we have any policies areound min supported TS version? The changes from this PR will cause errors on TS < 5 . I assumed it's fine, since latest version is 7, and version 5 was introduced in 2023 — but wanted to double-check |
|
We don’t have any such policy and it should be fine. |
|
If we're adding all these extensions, should we also update the package's TypeScript configs to specify
|
|
Good point, opened #82088 to address |
Closes #80206
Supersedes #80606
What?
Fixes the published TypeScript declarations for the four ESM packages that emitted extensionless relative specifiers:
@wordpress/design-system-mcp@wordpress/theme@wordpress/video-conversion@wordpress/vipsIt also adds final-package validation for current and future published ESM packages.
Why?
TypeScript preserves source import specifiers in declaration output. Extensionless specifiers work with
moduleResolution: "bundler", but they fail Node-style ESM resolution.Declaration files are exempt from TypeScript's
allowImportingTsExtensionsrestriction. A published declaration can therefore import./types.ts, resolve it totypes.d.tsunder Node16 or NodeNext, and work without that flag in the consumer project.TypeScript 4.x rejects these explicit source extensions in declaration files. This change therefore establishes TypeScript 5 as the minimum for TypeScript consumers of the four affected packages, and their changelogs classify the change as breaking.
How?
The affected production sources now use explicit
.tsand.tsxrelative specifiers, and their declaration-build projects enableallowImportingTsExtensions. The runtime build continues to convert these specifiers to.mjs.After the production build, the declaration check packs each public ESM package once. For packages that publish declarations, it mirrors only the packed files into an isolated package tree and checks those declarations under NodeNext with the repository TypeScript compiler. It reuses the same archive for
@arethetypeswrong/clichecks under Node16 ESM and bundler resolution. CSS-only exports are excluded because TypeScript cannot resolve CSS assets.Testing Instructions
npm run test:unit tools/build-scripts/test/check-esm-package-types.test.js.npm run typecheck.npm run build.npm run check:type-declarations.Testing Instructions for Keyboard
Not applicable. This PR does not change the UI.
Use of AI Tools
Codex was used to implement the changes, run verification, and draft this PR description.