Skip to content

Commit

Permalink
🔧 Fix esm build
Browse files Browse the repository at this point in the history
Closes #132
  • Loading branch information
torifat committed Nov 26, 2021
1 parent 675db32 commit a1cafc8
Show file tree
Hide file tree
Showing 6 changed files with 16,664 additions and 3,180 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-cups-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'better-ajv-errors': patch
---

:wrench: Fix esm build
18 changes: 18 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,25 @@ const config = {
outdir: './lib/cjs',
},
esm: {
format: 'esm',
outdir: './lib/esm',
outExtension: {
'.js': '.mjs',
},
bundle: true,
plugins: [
{
name: 'add-mjs',
setup(build) {
build.onResolve({ filter: /.*/ }, args => {
if (args.kind === 'entry-point') return;
let path = args.path;
if (path.startsWith('.') && !path.endsWith('.mjs')) path += '.mjs';
return { path, external: true };
});
},
},
],
},
};

Expand Down
Loading

0 comments on commit a1cafc8

Please sign in to comment.