# typescript-esm

> Tooling to enable interoperability between TypeScript and mjs for Node.js.

Latest version **2.0.0** (published 2021-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install typescript-esm
pnpm add typescript-esm
yarn add typescript-esm
bun add typescript-esm
```

Provides the command `tsc-esm`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-03-19 |
| First published | 2020-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 888.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kristofer Baxter |
| Maintainers | kristoferbaxter |

## Links

- npm: https://www.npmjs.com/package/typescript-esm
- npm.io page: https://npm.io/package/typescript-esm

## Dependencies (7)

- [mri](https://npm.io/package/mri.md) 1.1.6
- [acorn](https://npm.io/package/acorn.md) 8.1.0
- [fast-glob](https://npm.io/package/fast-glob.md) 3.2.5
- [typescript](https://npm.io/package/typescript.md) 4.2.3
- [magic-string](https://npm.io/package/magic-string.md) 0.25.7
- [promise.allsettled](https://npm.io/package/promise.allsettled.md) 1.0.4
- [@kristoferbaxter/estree-walker](https://npm.io/package/@kristoferbaxter/estree-walker.md) 2.0.2

## Recent versions

- 2.0.0 (latest) — 2021-03-19
- 1.0.1 — 2020-04-27
- 1.0.0 — 2020-04-27
- 0.0.6 — 2020-04-23
- 0.0.5 — 2020-04-22
- 0.0.4 — 2020-04-22
- 0.0.3 — 2020-04-22
- 0.0.2 — 2020-04-22
- 0.0.1 — 2020-04-22

## README

# Typescript ESM

This 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.

### Input
```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.

### Usage
```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'.

### Example
**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();
}
```

### For Contributors
[Volta](https://docs.volta.sh/guide/getting-started) is highly recommended to keep the node version and yarn version synced with other contributors.

---
_Source: https://npm.io/package/typescript-esm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
