-
Notifications
You must be signed in to change notification settings - Fork 1
/
build:microbundle-fix-cjs.js
40 lines (34 loc) · 1.05 KB
/
build:microbundle-fix-cjs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import update from '../lib/update.js';
import * as pkg from '../lib/pkg.js';
export const description = 'Fix main output file extension.';
export const commit = {
type: 'build',
subject: description,
};
export async function postcondition({readPkg, assert}) {
const pkgjson = await readPkg();
assert(pkgjson.main !== 'dist/index.js');
assert(pkgjson.exports?.['.']?.require !== './dist/index.js');
}
export async function precondition({readPkg, assert}) {
const pkgjson = await readPkg();
const devDeps = pkg.devDeps(pkgjson);
assert(devDeps.has('microbundle'));
assert(pkgjson.main === 'dist/index.js');
assert(pkgjson.exports?.['.']?.require === './dist/index.js');
}
export async function apply({readPkg, writePkg, remove, fixConfig, install}) {
await update({
read: readPkg,
write: writePkg,
edit: (pkgjson) => {
pkgjson.main = 'dist/index.cjs';
pkgjson.exports['.'].require = './dist/index.cjs';
return pkgjson;
},
});
await remove(['dist/**']);
await fixConfig();
await install();
}
export const dependencies = ['config:lint-setup'];