reflow build/serve of alt, update app-server dep for proper fallthrough handling
This commit is contained in:
parent
b046ae2fa8
commit
fc63f395a4
3 changed files with 54 additions and 86 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { build, transform } from 'esbuild';
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import glob from 'fast-glob';
|
||||
|
||||
// Get build mode from command line argument
|
||||
|
|
@ -38,6 +39,30 @@ async function appendExtraModules(extras, outfile, minify = false) {
|
|||
console.log(`Appended ${files.length} module(s) to ${outfile}`);
|
||||
}
|
||||
|
||||
async function generateDevices(dir = '') {
|
||||
let root = path.join(dir, "src", "kiri", "dev");
|
||||
let devs = {};
|
||||
let files = await fs.readdir(root);
|
||||
for (let type of files) {
|
||||
let map = devs[type] = devs[type] || {};
|
||||
let devices = await fs.readdir(path.join(root, type));
|
||||
for (let device of devices) {
|
||||
let deviceName = device.endsWith('.json')
|
||||
? device.substring(0, device.length - 5)
|
||||
: device;
|
||||
map[deviceName] = JSON.parse(await fs.readFile(path.join(root, type, device)));
|
||||
}
|
||||
}
|
||||
let dstr = JSON.stringify(devs);
|
||||
fs.mkdir(path.join(dir, "src", "pack"), { recursive: true });
|
||||
await fs.writeFile(path.join(dir, "src", "pack", "kiri-devs.js"), `export const devices = ${dstr};`);
|
||||
if (true) {
|
||||
// create alt artifacts
|
||||
await fs.mkdir('alt/pack', { recursive: true });
|
||||
await fs.writeFile(path.join(dir, "alt", "pack", "kiri-devs.js"), `export const devices = ${dstr};`);
|
||||
}
|
||||
}
|
||||
|
||||
const logOverride = {
|
||||
'duplicate-class-member': 'silent',
|
||||
'duplicate-object-key': 'silent',
|
||||
|
|
@ -72,6 +97,9 @@ const rec = {
|
|||
|
||||
async function buildApp() {
|
||||
try {
|
||||
// Concatenate kiri devices
|
||||
generateDevices();
|
||||
|
||||
// Bundle mesh main app
|
||||
await build(Object.assign({}, rec, {
|
||||
entryPoints: [ 'src/main/mesh.js' ],
|
||||
|
|
|
|||
Loading…
Reference in a new issue