[Feature Request] add `.mjs` extension to esm output
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
files:
```ts
// entry.ts
import { a } from './file'
// file.ts
export const a = 123
```
config:
```ts
export default defineConfig({
entry: ['./entry.ts', './file.ts'],
format: 'esm',
bundle: false,
})
```
current output
expected output
```ts
// entry.mjs
import { a } from "./file";
console.log(a);
// file.mjs
const a = 123;
export { a };
```
```ts
// entry.mjs
import { a } from "./file.mjs";
console.log(a);
// file.mjs
const a = 123;
export { a };
```
according to [the esm spec](https://nodejs.org/api/esm.html#mandatory-file-extensions), file extensions are mandatory
Contributor guide
Research direction
Start by reproducing the provided TypeScript configuration with ESM format and bundling disabled, then trace the output generation and import-specifier rewriting. Done means the generated entry file imports the sibling output with its .mjs extension while the other shown output remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100