You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,6 +125,7 @@ type ModuleOptions = {
125
125
|'.mts'
126
126
|'.cts'
127
127
| ((value:string) => string |null|undefined)
128
+
rewriteTemplateLiterals?:'allow'|'static-only'
128
129
dirFilename?:'inject'|'preserve'|'error'
129
130
importMeta?:'preserve'|'shim'|'error'
130
131
importMetaMain?:'shim'|'warn'|'error'
@@ -151,6 +152,7 @@ type ModuleOptions = {
151
152
- `appendJsExtension` (`relative-only` when targeting ESM): append `.js` to relative specifiers; never touches bare specifiers.
152
153
- `appendDirectoryIndex` (`index.js`): when a relative specifier ends with a slash, append this index filename (set `false` to disable).
153
154
- `appenders` precedence: `rewriteSpecifier` runs first; if it returns a string, that result is used. If it returns `undefined` or `null`, `appendJsExtension` and `appendDirectoryIndex` still run. Bare specifiers are never modified by appenders.
155
+
- `rewriteTemplateLiterals` (`allow`): when `static-only`, interpolated template literals are left untouched by specifier rewriting; string literals and non-interpolated templates still rewrite.
154
156
- `dirFilename` (`inject`): inject `__dirname`/`__filename`, preserve existing, or throw.
155
157
- `importMeta` (`shim`): rewrite `import.meta.*` to CommonJS equivalents.
156
158
- `importMetaMain` (`shim`): gate `import.meta.main` with shimming/warning/error when Node support is too old.
- `detectDualPackageHazard` (`warn`): flag when `import` and `require` mix for the same package or root/subpath are combined in ways that can resolve to separate module instances (dual packages). Set to `error` to fail the transform.
161
163
- `dualPackageHazardScope` (`file`): `file` preserves the legacy per-file detector; `project` aggregates package usage across all CLI inputs (useful in monorepos/hoisted installs) and emits one diagnostic per package.
162
-
- `topLevelAwait` (`error`): throw, wrap, or preserve when TLA appears in CommonJS output.
164
+
- `topLevelAwait` (`error`): throw, wrap, or preserve when TLA appears in CommonJS output.`wrap` runs the file body inside an async IIFE (exports may resolve after the initial tick); `preserve` leaves `await` at top level, which Node will reject for CJS.
163
165
- `rewriteSpecifier` (off): rewrite relative specifiers to a chosen extension or via a callback. Precedence: the callback (if provided) runs first; if it returns a string, that wins. If it returns `undefined` or `null`, the appenders still apply.
164
166
- `requireSource` (`builtin`): whether `require` comes from Node or `createRequire`.
165
167
- `cjsDefault` (`auto`): bundler-style default interop vs direct `module.exports`.
- Template literal specifier rewriting: if we ever default to skipping interpolated `TemplateLiteral` specifiers, it would change outputs. Current implementation is opt-in via `rewriteTemplateLiterals: 'static-only'` (non-breaking); future default flips would need a major/minor note.
28
+
- Cycle detection hardening: expanding extensions (.ts/.tsx/.mts/.cts) and normalize/realpath paths may surface new cycle warnings/errors, especially on Windows or mixed TS/JS projects.
0 commit comments