src/transforms/build:microbundle-configure-outputs-esmodule.js
import update from '../lib/update.js';
export const description = 'Configure microbundle ESM modern output.';
export const commit = {
scope: 'package.json',
subject: description,
};
const key = 'esmodule';
const expected = 'dist/index.modern.mjs';
export async function postcondition({readPkg, assert}) {
const pkgjson = await readPkg();
assert(pkgjson[key] !== undefined);
}
export async function precondition({readPkg, assert}) {
const pkgjson = await readPkg();
assert(pkgjson[key] === undefined);
}
export async function apply({readPkg, writePkg, fixConfig, remove, install}) {
await update({
read: readPkg,
write: writePkg,
edit(pkgjson) {
pkgjson[key] = expected;
return pkgjson;
},
});
await remove(['dist/**']);
await fixConfig();
await install();
}
export const dependencies = ['config:lint-setup', 'build:use-microbundle'];