Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
30 lines
844 B
JavaScript
30 lines
844 B
JavaScript
import path from 'path';
|
|
import * as fs from 'fs/promises';
|
|
import url from 'url';
|
|
|
|
const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
|
|
|
|
const BUILD_DIR = path.resolve(currentDirectory, '../build');
|
|
const TARGET_DIR_ESM = path.join(BUILD_DIR, 'esm');
|
|
|
|
async function run() {
|
|
await fs.writeFile(
|
|
path.resolve(TARGET_DIR_ESM, 'package.json'),
|
|
JSON.stringify({ type: 'module', sideEffects: false }),
|
|
'utf8',
|
|
);
|
|
const pkgJson = JSON.parse(await fs.readFile(path.join(BUILD_DIR, 'package.json'), 'utf8'));
|
|
delete pkgJson.scripts;
|
|
delete pkgJson.devDependencies;
|
|
delete pkgJson.publishConfig.directory;
|
|
pkgJson.main = 'index.js';
|
|
pkgJson.types = 'index.d.ts';
|
|
await fs.writeFile(
|
|
path.resolve(BUILD_DIR, 'package.json'),
|
|
`${JSON.stringify(pkgJson, null, 2)}\n`,
|
|
'utf8',
|
|
);
|
|
}
|
|
|
|
run();
|