Skip to content

Commit

Permalink
updating formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed May 27, 2024
1 parent f25cb99 commit d113115
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,18 @@ export default defineConfig({
format: ['cjs', 'esm'],
dts: true,
tsconfig: './tsconfig.json',
plugins: [
{
// https://github.com/egoist/tsup/issues/953#issuecomment-2132576167
// ensuring that all local requires in `.cjs` files import from `.cjs` files.
// require('./path') → require('./path.cjs') in `.cjs` files
name: 'fix-cjs-require',
renderChunk(_, { code }) {
if (this.format === 'cjs') {
const regex = /require\("(?<import>\.\/.+)"\)/g;
return { code: code.replace(regex, "require('$<import>.cjs')") };
}
},
},
],
});

0 comments on commit d113115

Please sign in to comment.