1
0
Fork 0
mirror of synced 2024-07-15 03:05:57 +12:00

Use new loadBundle function

This commit is contained in:
Adria Navarro 2024-02-06 11:35:41 +01:00
parent a273276bd3
commit 7a9187d4dc
2 changed files with 7 additions and 2 deletions

View file

@ -2,12 +2,14 @@ import { utils } from "@budibase/shared-core"
import environment from "../../environment"
import fs from "fs"
export enum BundleType {
export const enum BundleType {
HELPERS = "helpers",
BSON = "bson",
}
const bundleSourceCode = {
[BundleType.HELPERS]: "../bundles/index-helpers.ivm.bundle.js",
[BundleType.BSON]: "../bundles/bson.ivm.bundle.js",
}
export function loadBundle(type: BundleType) {
@ -18,6 +20,8 @@ export function loadBundle(type: BundleType) {
switch (type) {
case BundleType.HELPERS:
return require("../bundles/index-helpers.ivm.bundle.js")
case BundleType.BSON:
return require("../bundles/bson.ivm.bundle.js")
default:
utils.unreachable(type)
}

View file

@ -1,6 +1,7 @@
import ivm from "isolated-vm"
import bson from "bson"
import { BundleType, loadBundle } from "../jsRunner/bundles"
const JS_TIMEOUT_MS = 1000
@ -53,7 +54,7 @@ class IsolatedVM {
}
set code(code: string) {
const bsonSource = require("../jsRunner/bundles/bson.ivm.bundle.js")
const bsonSource = loadBundle(BundleType.BSON)
this.#bsonModule = this.isolate.compileModuleSync(bsonSource)
this.#bsonModule.instantiateSync(this.vm, specifier => {