Repository navigation
TypeScript-first absolute imports - #2
Merged
Merged
Conversation
Relative specifiers now name the files that exist, not the files emit would produce. rewriteRelativeImportExtensions keeps any tsc emit runtime-correct, tsdown resolves the specifiers when bundling (dist is unchanged), and bare Node can now execute the source directly via type stripping — the property erasableSyntaxOnly was adopted for. The generated Emscripten module keeps its .js specifier: that file really is JavaScript.
package.json "imports" maps #* to ./src/*, so every internal specifier is absolute (#engine/session.ts) instead of relative, named by its real .ts file. Node, tsc (NodeNext), vitest, and tsdown resolve the # map natively — bare Node still executes the source via type stripping, and the bundled dist is unchanged. rewriteRelativeImportExtensions is gone: with no relative imports left it only produced TS2877 on # specifiers.
Both the TypeScript team's module guidance and the prevailing package guides recommend declaration maps so a consumer's go-to-definition lands in real .ts source rather than a declaration bundle. tsdown emits .d.ts.map and .js.map (sourcesContent embedded); src ships in the tarball so the maps resolve. Size cost is negligible next to the bundled models.
|
🎉 This PR is included in version 0.2.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Two mechanical steps, same intent:
#*to./src/*, so../types.jsis now#types.ts,./ringBuffer.jsis#engine/ringBuffer.ts, and tests/demo import#index.ts.Node, tsc (NodeNext), vitest, and tsdown all resolve the
#map natively — no alias/rewrite layer. Barenode src/index.tsnow runs via type stripping (the property erasableSyntaxOnly was adopted for), and dist is bundled as before with no specifiers to leak. The vendored Emscripten module keeps its.jsname — that file is actual JavaScript. Full gate green; refactor-only, no release.