Merged
Conversation
- Add nodeProtocol option to config-options.md - Document new feature in migrate-from-tsup.md (EN and zh-CN) - Mark removeNodeProtocol as deprecated in favor of nodeProtocol: strip
✅ Deploy Preview for tsdown ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
sxzz
reviewed
Jun 20, 2025
src/features/node-protocol.ts
Outdated
Comment on lines
+12
to
+16
| const nodeProtocolOption = | ||
| options.nodeProtocol ?? | ||
| // `removeNodeProtocol: true` means stripping the `node:` protocol which equales to `nodeProtocol: 'strip'` | ||
| // `removeNodeProtocol: false` means keeping the `node:` protocol which equales to `nodeProtocol: false` (ignore it) | ||
| (options.removeNodeProtocol ? 'strip' : false) |
Member
There was a problem hiding this comment.
Move it to resolveOptions, and remove removeNodeProtocol from ResolvedOptions
src/features/node-protocol.ts
Outdated
| */ | ||
| export function NodeProtocolPlugin(): Plugin { | ||
| export function NodeProtocolPlugin( | ||
| options: Pick<ResolvedOptions, 'nodeProtocol' | 'removeNodeProtocol'>, |
src/index.ts
Outdated
|
|
||
| if (removeNodeProtocol) { | ||
| plugins.push(NodeProtocolPlugin()) | ||
| if (removeNodeProtocol || nodeProtocol) { |
Member
There was a problem hiding this comment.
Suggested change
| if (removeNodeProtocol || nodeProtocol) { | |
| if (nodeProtocol) { |
src/index.ts
Outdated
| @@ -211,15 +211,16 @@ async function getBuildOptions( | |||
| report, | |||
| env, | |||
| removeNodeProtocol, | |||
Member
There was a problem hiding this comment.
Suggested change
| removeNodeProtocol, |
| @@ -366,6 +385,7 @@ export type ResolvedOptions = Omit< | |||
| | 'outExtensions' | |||
| | 'hooks' | |||
| | 'removeNodeProtocol' | |||
| @@ -0,0 +1,200 @@ | |||
| import { describe, expect, test } from 'vitest' | |||
Contributor
Author
|
Okay I'll remove it |
Move backward compatibility logic from NodeProtocolPlugin to resolveOptions function This centralizes option resolution and simplifies plugin interface
Remove removeNodeProtocol from excluded fields Add nodeProtocol to overwrite section with proper type
Remove complex options parameter and backward compatibility logic Plugin now accepts single nodeProtocolOption parameter directly
Remove removeNodeProtocol from destructuring Update condition to only check nodeProtocol Pass resolved nodeProtocol directly to plugin
Remove references to the deprecated removeNodeProtocol option from both English and Chinese configuration documentation, as the function has been removed from the codebase in favor of nodeProtocol: "strip"
sxzz
approved these changes
Jun 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new
nodeProtocoloption that provides more flexible control over Node.js built-in module imports. It consolidates and enhancesthe functionality of the existing
removeNodeProtocoloption.fixes: #331
What this PR adds:
nodeProtocoloption with three modes:true: Addsnode:prefix to built-in modules (e.g.,fs→node:fs)'strip': Removesnode:prefix from imports (e.g.,node:fs→fs)false: Keeps imports unchanged (default)removeNodeProtocolin favor ofnodeProtocol: 'strip'removeNodeProtocoloptionImplementation details:
NodeProtocolPluginto handle both adding and stripping node: prefixesbuiltinModulesfrom Node.js to accurately identify built-in modulesLinked Issues
N/A
Additional context
The implementation prioritizes the new
nodeProtocoloption when bothnodeProtocolandremoveNodeProtocolare specified. This ensures a smoothmigration path for users while maintaining backward compatibility.
All tests pass successfully, including comprehensive new tests covering various import scenarios (static imports, dynamic imports, subpath imports,
mixed imports with external packages).