Fix TypeScript native module transforms - #23
Merged
Conversation
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.
Summary
Fix TypeScript native-wrapper transforms without regressing direct
.nodeESM imports. The resolver still runs before Vite's asset handling, while the source transform runs after Vite transpiles TypeScript.What This PR Does
resolveIdpre-ordered instead of pre-ordering the entire plugin.addon.nodefile throughrequireandcreateRequire.2.4.1.What This Improves
.nodeESM imports continue to resolve before Vite classifies them as generic assets.What This Does Not Do
Important Context
enforce: "pre"caused the native source transform to parse raw TypeScript.Code To Review Closely
src/index.ts:1934The resolver retains pre-ordering to intercept direct native ESM imports, while
transformkeeps Vite's normal ordering.Gotchas, Risks, And Edge Cases
Tests And Regression Coverage
Validation Run
pnpm test: passed (204 tests).pnpm lint: passed (format, lint, and type checks).pnpm build: passed.pnpm precommit: unavailable; this package does not define that script.Coverage Assessment
Sufficient. The new fixtures exercise both conventional and
createRequireTypeScript native wrappers with Vite 7 and Vite 8, and assert that the hashed native asset is emitted and referenced.Regressions These Tests Should Catch
transformand parsing TypeScript before Vite transpiles it..nodeESM import compatibility on Vite 7 or Vite 8.Gaps And Recommended Follow-Up Tests
Follow-Up Work