[v9.3.x] Build: Adds a fallback script to fix package.json main and types fields before packaging (#59639)

Co-authored-by: Esteban Beltran <academo@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-12-01 05:47:09 -05:00
committed by GitHub
co-authored by Esteban Beltran
parent 3b70755095
commit 95b7cabe00
7 changed files with 39 additions and 6 deletions
+21
View File
@@ -0,0 +1,21 @@
const fs = require('fs');
const cwd = process.cwd();
const packageJson = require(`${cwd}/package.json`);
const newPackageJson = {
...packageJson,
main: packageJson.publishConfig?.main ?? packageJson.main,
};
if (packageJson.publishConfig?.types) {
newPackageJson.types = packageJson.publishConfig.types;
}
if (packageJson.publishConfig?.module) {
newPackageJson.module = packageJson.publishConfig.module;
}
try {
fs.writeFileSync(`${cwd}/package.json`, JSON.stringify(newPackageJson, null, 2));
} catch (e) {}