Dependency builds for plugos

This commit is contained in:
Zef Hemel
2022-05-13 14:36:26 +02:00
parent 8c974161c3
commit 3c5048ac25
29 changed files with 309 additions and 76 deletions
+10 -4
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { readFile, unlink, watch, writeFile } from "fs/promises";
import { readFile, watch, writeFile } from "fs/promises";
import path from "path";
import yargs from "yargs";
@@ -8,7 +8,7 @@ import { hideBin } from "yargs/helpers";
import { Manifest } from "../types";
import YAML from "yaml";
import { mkdirSync } from "fs";
import { compile } from "../compile";
import { compile, sandboxCompileModule } from "../compile";
async function bundle(
manifestPath: string,
@@ -24,7 +24,13 @@ async function bundle(
throw new Error(`Missing 'name' in ${manifestPath}`);
}
for (let [name, def] of Object.entries(manifest.functions)) {
let allModulesToExclude = excludeModules.slice();
for (let [name, moduleSpec] of Object.entries(manifest.dependencies || {})) {
manifest.dependencies![name] = await sandboxCompileModule(moduleSpec);
allModulesToExclude.push(name);
}
for (let [name, def] of Object.entries(manifest.functions || {})) {
let jsFunctionName = "default",
filePath = path.join(rootPath, def.path!);
if (filePath.indexOf(":") !== -1) {
@@ -35,7 +41,7 @@ async function bundle(
filePath,
jsFunctionName,
sourceMaps,
excludeModules
allModulesToExclude
);
delete def.path;
}