new vm.SyntheticModule(exportNames, evaluateCallback[, options])


  • exportNames <string[]> 将从模块导出的名称数组。

    ¥exportNames <string[]> Array of names that will be exported from the module.

  • evaluateCallback <Function> 在评估模块时调用。

    ¥evaluateCallback <Function> Called when the module is evaluated.

  • options

    • identifier <string> 用于堆栈跟踪的字符串。默认值:'vm:module(i)',其中 i 是上下文特定的升序索引。

      ¥identifier <string> String used in stack traces. Default: 'vm:module(i)' where i is a context-specific ascending index.

    • context <Object> vm.createContext() 方法返回的 contextified 对象,用于编译和评估此 Module 中的对象。

      ¥context <Object> The contextified object as returned by the vm.createContext() method, to compile and evaluate this Module in.

创建新的 SyntheticModule 实例。

¥Creates a new SyntheticModule instance.

分配给此实例导出的对象可能允许模块的导入者访问指定 context 之外的信息。使用 vm.runInContext() 在特定上下文中创建对象。

¥Objects assigned to the exports of this instance may allow importers of the module to access information outside the specified context. Use vm.runInContext() to create objects in a specific context.