Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
fix: rewrite bundled extensions to mjs for esm build
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinraja committed Nov 4, 2023
1 parent 4ea5cbd commit 98094a5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,20 @@ export default defineConfig({
entry: ["src/**/*.ts", "!src/**/*.test.*"],
format: ["cjs", "esm"],
outDir: "lib",
plugins: [
{
name: "fix-cjs",
renderChunk(_, chunk) {
if (this.format === "esm") {
// replace `from '...js'` with `from '...mjs'` for mjs imports & exports
const code = chunk.code.replace(
/from ['"](.*)\.js['"]/g,
"from '$1.mjs'",
);
return { code };
}
},
},
],
sourcemap: true,
});

0 comments on commit 98094a5

Please sign in to comment.