Skip to content

Comments

Temporarily add "node" entries to exports in package.json files#5650

Merged
iclanton merged 8 commits intomicrosoft:mainfrom
iclanton:remove-package.json-exports-imports
Feb 20, 2026
Merged

Temporarily add "node" entries to exports in package.json files#5650
iclanton merged 8 commits intomicrosoft:mainfrom
iclanton:remove-package.json-exports-imports

Conversation

@iclanton
Copy link
Member

Mitigates #5644 for now.

The "import" condition in "exports" maps was added in 6d669f1, but it
breaks scenarios where the lib-esm/ output doesn't exist or has
incompatibilities. Remove all "import" entries from 78 published
project package.json files to fix issue microsoft#5644.
…#5644)

The "import" condition in "exports" maps points to lib-esm/ files which
have extensionless imports. Node.js ESM requires explicit .js extensions,
so importing these packages from a "type": "module" project fails with
ERR_MODULE_NOT_FOUND.

Fix by adding a "node" condition before "import" in exports. Node.js
matches "node" first and uses CJS (which handles extensionless requires),
while bundlers skip "node" and use "import" for ESM.

Also adds an esm-node-import-test build-test project to exercise this
scenario.
…#5644)

The "import" condition in "exports" maps points to lib-esm/ files which
have extensionless imports. Node.js ESM requires explicit .js extensions,
so importing these packages from a "type": "module" project fails with
ERR_MODULE_NOT_FOUND.

Fix by adding a "node" condition before "import" in exports. Node.js
matches "node" first and uses CJS (which handles extensionless requires),
while bundlers skip "node" and use "import" for ESM.

Also adds an esm-node-import-test build-test project that exercises
this scenario by spawning a Node.js ESM subprocess that imports
@rushstack/node-core-library.
@iclanton iclanton changed the title Temporarily remove "import" entries from exports in package.json files Temporarily add "node" entries to exports in package.json files Feb 19, 2026
@iclanton iclanton merged commit 7e14cda into microsoft:main Feb 20, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Feb 20, 2026
@iclanton iclanton deleted the remove-package.json-exports-imports branch February 20, 2026 00:00
iclanton added a commit to iclanton/rushstack that referenced this pull request Feb 20, 2026
iclanton added a commit to iclanton/rushstack that referenced this pull request Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

[api-extractor] v7.57.0 lib-esm has extensionless imports, breaking Node.js ESM resolution

3 participants