Skip to content

fix(node-protocol): respect alias and tsconfig paths when stripping node: prefix#773

Merged
sxzz merged 4 commits intorolldown:mainfrom
lazuee:main
Feb 26, 2026
Merged

fix(node-protocol): respect alias and tsconfig paths when stripping node: prefix#773
sxzz merged 4 commits intorolldown:mainfrom
lazuee:main

Conversation

@lazuee
Copy link
Contributor

@lazuee lazuee commented Feb 19, 2026

Description

When nodeProtocol: "strip" is configured, the NodeProtocolPlugin runs with order: 'pre' and immediately marks stripped node: imports as external: true. This short-circuits the entire resolution chain, so alias and tsconfig paths configurations that map the stripped module name (e.g., crypto) to a polyfill are never consulted.

The fix changes the strip handler to call this.resolve() with the stripped ID before marking it as external. If another resolver (alias, tsconfig paths) resolves it to a non-external module, that resolution is used instead.

Linked Issues

Fixes #772

Additional context

The test covers both resolution methods in a single case:

  • alias: node:path → stripped to path → resolved via alias to a polyfill
  • tsconfig paths: node:crypto → stripped to crypto → resolved via paths to a polyfill

@netlify
Copy link

netlify bot commented Feb 19, 2026

Deploy Preview for tsdown-main ready!

Name Link
🔨 Latest commit c8aa040
🔍 Latest deploy log https://app.netlify.com/projects/tsdown-main/deploys/6999e6262131e90008347df1
😎 Deploy Preview https://deploy-preview-773--tsdown-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

Open in StackBlitz

tsdown

pnpm add https://pkg.pr.new/tsdown@773 -D
npm i https://pkg.pr.new/tsdown@773 -D
yarn add https://pkg.pr.new/[email protected] -D

create-tsdown

pnpm add https://pkg.pr.new/create-tsdown@773 -D
npm i https://pkg.pr.new/create-tsdown@773 -D
yarn add https://pkg.pr.new/[email protected] -D

tsdown-migrate

pnpm add https://pkg.pr.new/tsdown-migrate@773 -D
npm i https://pkg.pr.new/tsdown-migrate@773 -D
yarn add https://pkg.pr.new/[email protected] -D

commit: c8aa040

@lazuee
Copy link
Contributor Author

lazuee commented Feb 21, 2026

Using https://pkg.pr.new/tsdown@773 with an alias, this.resolve() returns null unexpectedly,
tsconfig paths works as expected tho,. And also doing pnpm test with this PR, test#772 works as expected.

Idk, why this.resolve() returns null when using alias 🤔
https://github.com/lazuee-dev/repro-tsdown-paths-nodeProtocol-strip

@sxzz sxzz merged commit b1dd232 into rolldown:main Feb 26, 2026
16 checks passed
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.

nodeProtocol: "strip" ignores paths resolution for stripped node: imports

2 participants