1'use strict'; 2 3const common = require('../common'); 4const { Script, compileFunction } = require('vm'); 5const assert = require('assert'); 6 7assert( 8 !process.execArgv.includes('--experimental-vm-modules'), 9 'This test must be run without --experimental-vm-modules'); 10 11assert.rejects(async () => { 12 const script = new Script('import("fs")', { 13 importModuleDynamically: common.mustNotCall(), 14 }); 15 const imported = script.runInThisContext(); 16 await imported; 17}, { 18 code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG' 19}).then(common.mustCall()); 20 21assert.rejects(async () => { 22 const imported = compileFunction('return import("fs")', [], { 23 importModuleDynamically: common.mustNotCall(), 24 })(); 25 await imported; 26}, { 27 code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG' 28}).then(common.mustCall()); 29