This table shows how duel maps its CLI flag (--mode) to the options passed into @knighted/module during the two transform phases:
- Pre-
tsctransform (only whenmodulesis enabled): runs on copied sources to avoid TypeScript 58658 asymmetry. TS-like files intentionally captransformSyntaxat"globals-only"to avoid fightingtsc's type erasure and declaration emit; JS-like files honor full syntax lowering when requested. - Post-build rewrite: always runs to adjust specifiers/file extensions in the built output. When the dual target is CommonJS, this pass always uses
transformSyntax: trueregardless of the CLI mode so the CJS output is fully lowered; for ESM targets it uses the samesyntaxModevalue from the CLI.
| CLI input | modulesFinal | transformSyntaxFinal | Pre-tsc transformSyntax |
Post-build transformSyntax |
|---|---|---|---|---|
default / --mode none |
false | false | none (skipped) | dual CJS: true; dual ESM: "globals-only" |
--mode globals |
true | false | "globals-only" |
dual CJS: true; dual ESM: "globals-only" |
--mode full |
true | true | JS-like: true; TS-like: "globals-only" |
dual CJS: true; dual ESM: true |
Notes
- "TS-like" means
.ts,.tsx,.mts,.cts. WhentransformSyntaxistrue, those files use"globals-only"pre-tscto avoid stripping types and to keep declaration emit stable; JS-like files get full lowering. - When
modulesFinalisfalse, no pre-tsctransform runs; only the post-build rewrite runs (full lowering for dual CJS,"globals-only"for dual ESM). - Practical implication: Optional chaining (and other ESNext syntax) in TS will only be downleveled if your
tsconfigtarget lowers it or if you relax the TS guard; JS/JSX files and dual CJS outputs are fully lowered under--mode full.