Use new loadBundle function
This commit is contained in:
parent
a273276bd3
commit
7a9187d4dc
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 => {
|
||||
|
|
Loading…
Reference in New Issue