mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
f7cdac091a
Set a default host-defined option for vm.compileFunction so that it's consistent with vm.Script. PR-URL: https://github.com/nodejs/node/pull/50137 Refs: https://github.com/nodejs/node/issues/35375 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
21 lines
549 B
JavaScript
21 lines
549 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { Script, compileFunction } = require('vm');
|
|
const assert = require('assert');
|
|
|
|
assert.rejects(async () => {
|
|
const script = new Script('import("fs")');
|
|
const imported = script.runInThisContext();
|
|
await imported;
|
|
}, {
|
|
code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING'
|
|
}).then(common.mustCall());
|
|
|
|
assert.rejects(async () => {
|
|
const imported = compileFunction('return import("fs")')();
|
|
await imported;
|
|
}, {
|
|
code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING'
|
|
}).then(common.mustCall());
|