piral-cli
Version:
The standard CLI for creating and building a Piral instance or a Pilet.
58 lines • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const envs_1 = require("../common/envs");
let handler;
function run(root, piralInstances, emulator, standalone, sourceMaps, watch, contentHash, minify, externals, publicUrl, outFile, outDir, entryFiles, logLevel, args) {
(0, envs_1.setStandardEnvs)({
production: !emulator,
root,
publicPath: publicUrl,
debugPiral: emulator,
debugPilet: emulator || standalone,
piralInstances,
dependencies: externals,
});
return handler.create({
root,
entryFiles,
outFile,
outDir,
externals,
emulator,
sourceMaps,
contentHash,
minify,
publicUrl,
hmr: false,
logLevel,
watch,
args,
});
}
process.on('message', async (msg) => {
try {
switch (msg.type) {
case 'init':
handler = require(msg.path);
break;
case 'start':
const bundler = await run(process.cwd(), msg.piralInstances, msg.emulator, msg.standalone, msg.sourceMaps, msg.watch, msg.contentHash, msg.minify, msg.externals, msg.publicUrl, msg.outFile, msg.outDir, msg.entryFiles, msg.logLevel, msg);
const result = await bundler.bundle();
if (result && !msg.watch) {
process.send({
type: 'done',
outDir: result.outDir,
outFile: result.outFile,
});
}
break;
}
}
catch (error) {
process.send({
type: 'fail',
error: error?.message,
});
}
});
//# sourceMappingURL=run-build-piral.js.map