ethers.js/misc/admin/lib/build.js

36 lines
1.3 KiB
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2021-03-31 02:55:25 +03:00
exports.setupBuild = void 0;
const path_1 = require("./path");
const utils_1 = require("./utils");
function setupConfig(outDir, moduleType, targetType) {
// Configure the tsconfit.package.json...
2021-10-16 09:29:27 +03:00
const path = (0, path_1.resolve)("tsconfig.package.json");
const content = (0, utils_1.loadJson)(path);
content.compilerOptions.module = moduleType;
content.compilerOptions.target = targetType;
2021-10-16 09:29:27 +03:00
(0, utils_1.saveJson)(path, content, true);
// Configure the browser field for every pacakge, copying the
// browser.umd filed for UMD and browser.esm for ESM
path_1.dirnames.forEach((dirname) => {
2021-10-16 09:29:27 +03:00
const filename = (0, path_1.getPackageJsonPath)(dirname);
const info = (0, utils_1.loadJson)(filename);
if (info._ethers_nobuild) {
return;
}
2021-10-16 09:29:27 +03:00
let path = (0, path_1.resolve)("packages", dirname, "tsconfig.json");
let content = (0, utils_1.loadJson)(path);
content.compilerOptions.outDir = outDir;
2021-10-16 09:29:27 +03:00
(0, utils_1.saveJson)(path, content, true);
});
}
function setupBuild(buildModule) {
if (buildModule) {
2020-11-15 01:42:36 +03:00
setupConfig("./lib._esm/", "es2015", "es2015");
}
else {
setupConfig("./lib/", "commonjs", "es5");
}
}
exports.setupBuild = setupBuild;