1.1.0 • Published 2 years ago
typescript-transformer-esm v1.1.0
typescript-transformer-esm
Inspired by
@zoltu/typescript-transformer-append-js-extensionand@nvandamme/typescript-transformer-append-js-extension
Make import/export ESM compatible by appending .js (file) or /index.js (directory).
Why? TypeScript's issues 783 and 16577 have been closed.
Example
Source (TypeScript):
import a from "./file";
import b from "./directory";Compiled (JavaScript):
import a from "./file.js";
import b from "./directory/index.js";Usage
Warning: Make sure
"module": "esnext"is present intsconfig.jsonNote: Compatible with
typescript-transform-paths
Install
npm install --save-dev typescript-transformer-esmInstall dependencies
ts-patchnpm install --save-dev ts-patch && npx ts-patch install -sttypescriptnpm install --save-dev ttypescript
Update
tsconfig.json{ "compilerOptions": { "module": "esnext", // ... "plugins": [ { "transform": "typescript-transformer-esm", "after": true } ] } }Compile
ts-patchnpx tsc --build tsconfig.jsonttypescriptnpx ttsc --build tsconfig.json
Contributing
I would love to see your contribution :heart:
See CONTRIBUTING guidelines.
License
This project is licensed under the MIT License. \ See LICENSE file for details.