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