Search Terms
Suggestion
It is very useful if you can customize the output extension.
But mapping extension is boring and painful.
Maybe there is another way to make this easier.
If we don't map the extension, we just erase the .ts or .tsx extension to achieve it.
A compilerOptions is needed to prevent break existing TypeScript code.
Use Cases
- Output the
.mjs file for Node Module,
- Output
.es or other file extensions without additional steps. (e.g. useful for tsc watching mode)
Examples
input:
// src/lib.js.ts
export const result = 42;
// src/index.js.ts
import { result } from "./lib.js";
console.log(result);
output:
// build/lib.js
export const result = 42;
// build/index.js
import { result } from "./lib.js";
console.log(result);
input:
// src/lib.mjs.ts
export const result = 42;
// src/index.mjs.ts
import { result } from "./lib.mjs";
console.log(result);
output:
// build/lib.mjs
export const result = 42;
// build/index.mjs
import { result } from "./lib.mjs";
console.log(result);
input:
// src/lib.myext.ts
export const result = 42;
// src/index.myext.ts
import { result } from "./lib.myext";
console.log(result);
output:
// build/lib.myext
export const result = 42;
// build/index.myext
import { result } from "./lib.myext";
console.log(result);
Checklist
My suggestion meets these guidelines:
Search Terms
Suggestion
It is very useful if you can customize the output extension.
But mapping extension is boring and painful.
Maybe there is another way to make this easier.
If we don't map the extension, we just erase the
.tsor.tsxextension to achieve it.A compilerOptions is needed to prevent break existing TypeScript code.
Use Cases
.mjsfile for Node Module,.esor other file extensions without additional steps. (e.g. useful for tsc watching mode)Examples
input:
output:
input:
output:
input:
output:
Checklist
My suggestion meets these guidelines: