feat!: add Deno support via node: protocol in ESM output#166
Open
watsonarw wants to merge 3 commits intothecodrr:masterfrom
Open
feat!: add Deno support via node: protocol in ESM output#166watsonarw wants to merge 3 commits intothecodrr:masterfrom
watsonarw wants to merge 3 commits intothecodrr:masterfrom
Conversation
- Split tsdown config for separate CJS and ESM builds - Update deprecated removeNodeProtocol option in tsdown config - Enable node: protocol in ESM output for cross-runtime compatibility - Bump minimum Node version to v12.20.0 (when node: protocol was added) This enables Deno support (without import maps) and protects against builtin package name squatting attacks. BREAKING CHANGE: Requires Node.js >=12.20.0
tsdown handles the node: protocol in build outputs, but making source consistent with ESM output will be less confusing
Author
|
I notice that #151 was proposing bumping the minimum node version to >=16. If you're happy to go to >=16 (which was EOL in Sept 2023), I can amend this to also use the |
|
@watsonarw Only add the https://www.electronjs.org/docs/latest/tutorial/electron-timelines |
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.
Closes #165
Summary
This PR adds Deno support by enabling the
node:protocol for Node.js builtin imports in ESM builds. This allows the library to work with Deno without requiring import maps.Changes
1. Upgrade tsdown to latest version
tsdownfrom0.12.5to0.18.1to access latest features and the updated API2. Enable
node:protocol in ESM outputremoveNodeProtocoloption tonodeProtocoloptionnode:protocol in ESM output while keeping CJS output unchanged12.20.0(whennode:protocol was introduced)3. Update source code to use node: prefix
node:prefix to all Node.js builtin imports in source files (16 imports across 12 files)Breaking Changes
12.20.0(previously12.0.0)This is required to support the
node:protocol for builtin imports.Benefits
Testing
master... This PR has not changed any functionality, just build outputs and import statements. The same tests failing on master fail on this branch, no new tests are failing. I actually tried fixing the tests, but realised that some might be actual bugs that I'm not familiar enough with the codebase to tackle properly, so I gave up...npm run buildbefore and after each change.0.18.1resulted in a few non-functional changes to the output filesifstatements now have{ }blocks where they previously didn'tnode:prefix to the built-in imports in the ESM output, nothing else compared to above