Instantiate module

This commit is contained in:
Adria Navarro 2024-02-07 13:47:43 +01:00
parent 395e4b9484
commit 6cafbbf036
1 changed files with 6 additions and 8 deletions

View File

@ -94,15 +94,13 @@ class IsolatedVM {
} }
runScript(): void { runScript(): void {
if (this.#bsonModule) { this.#script.instantiateSync(this.#vm, specifier => {
this.#script.instantiateSync(this.#vm, specifier => { if (specifier === "compiled_module" && this.#bsonModule) {
if (specifier === "compiled_module") { return this.#bsonModule!
return this.#bsonModule! }
}
throw new Error(`"${specifier}" import not allowed`) throw new Error(`"${specifier}" import not allowed`)
}) })
}
this.#script.evaluateSync({ timeout: JS_TIMEOUT_MS }) this.#script.evaluateSync({ timeout: JS_TIMEOUT_MS })
} }