Skip to content

Commit

Permalink
fix(repo) emit .d.mts file extension for esm
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbayley committed Jun 30, 2024
1 parent a780ec4 commit 41547e4
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions shared/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,21 @@ export function createConfig({ pkg, external = [] }) {
{
format: 'es',
file: pkg.module,
plugins: [emitModulePackageFile(), emitDeclarationFile()],
plugins: [emitDeclarationFile('m')],
sourcemap: true
}
],
plugins: [typescript({ sourceMap: true })]
};
}

export function emitModulePackageFile() {
return {
name: 'emit-module-package-file',
generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'package.json',
source: `{"type":"module"}`
});
}
};
}

export function emitDeclarationFile() {
export function emitDeclarationFile(m = '') {
return {
name: 'emit-declaration-file',
async generateBundle() {
this.emitFile({
type: 'asset',
fileName: 'index.d.ts',
fileName: `index.d.${m}ts`,
source: await fs.readFile('./types/index.d.ts')
});
}
Expand Down

0 comments on commit 41547e4

Please sign in to comment.