Tooling to enable interoperability between TypeScript and mjs for Node.js.
npm install typescript-esmThis project aims to make it more straightforward to output valid '.mjs' content from an existing TypeScript Project. All work is done post TypeScript compilation to avoid wrapping the TypeScript API.
bash
tsc -p tsconfig.json
`This is likely how you're configuring TypeScript to execute if you're looking at using this package. Right now when using the TypeScript Compiler directly, your output will be '.js' files.
$3
`bash
tsc -p tsconfig.json; tsc-esm -p tsconfig.json
`When you add the
tsc-esm compiler following the conclusion of TypeScript's output, this compiler will remap all generated files to use '.mjs' extensions for locally resolved items and rename every output's extension to '.mjs'.$3
direct.ts in a TypeScript Project.Before direct.js
`typescript
import {imported} from './imported';type Bar = string;
export default function() {
const bar: Bar = 'bar';
console.log(bar);
imported();
}
`After direct.mjs
`javascript
import { imported } from './imported.mjs';
export default function () {
const bar = 'bar';
console.log(bar);
imported();
}
``