Skip to content

Commit a1cafc8

Browse files
committed
🔧 Fix esm build
Closes #132
1 parent 675db32 commit a1cafc8

File tree

6 files changed

+16664
-3180
lines changed

6 files changed

+16664
-3180
lines changed

.changeset/funny-cups-repeat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'better-ajv-errors': patch
3+
---
4+
5+
:wrench: Fix esm build

build.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,25 @@ const config = {
1515
outdir: './lib/cjs',
1616
},
1717
esm: {
18+
format: 'esm',
1819
outdir: './lib/esm',
20+
outExtension: {
21+
'.js': '.mjs',
22+
},
23+
bundle: true,
24+
plugins: [
25+
{
26+
name: 'add-mjs',
27+
setup(build) {
28+
build.onResolve({ filter: /.*/ }, args => {
29+
if (args.kind === 'entry-point') return;
30+
let path = args.path;
31+
if (path.startsWith('.') && !path.endsWith('.mjs')) path += '.mjs';
32+
return { path, external: true };
33+
});
34+
},
35+
},
36+
],
1937
},
2038
};
2139

0 commit comments

Comments
 (0)