Skip to content

Commit

Permalink
maint/dev ~ add Rollup support (for generation of ESM with correct ex…
Browse files Browse the repository at this point in the history
…tensions)

- TypeScript fails to correctly generate an ESM module with correct file extensions
  - ref: <microsoft/TypeScript#18442 (comment)>
  - ref: <microsoft/TypeScript#18442>
  - ref: <microsoft/TypeScript#37582>
  - ref: <microsoft/TypeScript#35148>
  • Loading branch information
rivy committed Jan 26, 2021
1 parent 6d7de51 commit 11a43a0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ref: <https://devhints.io/rollup>
// setup: `npm i rollup @rollup/plugin-typescript` or `npm i rollup rollup-plugin-typescript2` (for visible TS error output)

// import typescript from '@rollup/plugin-typescript';
import typescript from 'rollup-plugin-typescript2';

export default [
// ES module build (replaces broken basic TypeScript compilation)
// * ref: <https://github.com/microsoft/TypeScript/issues/18442> , <https://github.com/alshdavid/rxjs/blob/main/rollup.config.js#L10>
// * ref: <https://github.com/microsoft/TypeScript/pull/35148>
// * ref: <https://github.com/microsoft/TypeScript/issues/37582>
{
preserveModules: true,
input: ['src/index.ts'],
external: ['path', 'os', 'os-paths'],
output: [{ exports: 'auto', dir: 'build/esm', format: 'esm', entryFileNames: '[name].mjs' }],
plugins: [typescript({ tsconfig: './tsconfig/tsconfig.esm.json' })],
},
];

0 comments on commit 11a43a0

Please sign in to comment.