Repository navigation
feat: add automatic module extensions for bundless builds - #869
Merged
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.
Father's bundless builds normally emit
.jsand.d.ts, leaving consumers to account for package types and extensionless module references. Add explicit options to produce matching runtime and declaration filenames for native Node ESM and CommonJS consumers.esm.autoExtensionandcjs.autoExtensionuse the package type to select filenames:module.js/.d.ts.cjs/.d.ctscommonjsor absent.mjs/.d.mts.js/.d.tsThe filename policy and
autoExtensionname follow Rslib. Father matches declaration extensions at the same time. No package.json is generated or modified. Copied package scopes and relocated overrides are respected, and both formats can share an output directory when their extensions differ.redirect.js.extensionandredirect.dts.extensioncontrol relative module references independently, using Rslib's naming. They followautoExtensionby default and can be explicitly overridden. Rewriting covers imports, re-exports, literal dynamic imports, CJSrequire/require.resolve, and declaration references. Source map filenames, URLs and mappings follow the resulting output.esm.resolveDepSubpathremains independent and defaults to false, following the behavior of tsdown'sdeps.resolveDepSubpath: only resolvable subpaths of packages withoutexportsare completed. Public exports and package roots retain their specifiers.Compatibility: all new behavior is opt-in. Neither
exports.importnor roottypemetadata enables it. Without new options, existing Father 4 output remains unchanged. Users enabling automatic extensions must update their published runtime and type entry points. Chinese and English documentation includes both package-type policies and a dual-format publishing example.Related: react-component/father-plugin#27
Validation:
pnpm run buildandpnpm exec tsc --noEmitpnpm exec jest --maxWorkers=1 --workerIdleMemoryLimit=1MB— 17 suites, 183 tests and 1 snapshot passed2ca945c): all 9 transformer/metadata combinations produced byte-identical JS, declarations, maps, CJS and copied package metadata.git diff --check.