创建可与 SourceTextModule 构造函数的 cachedData 选项一起使用的代码缓存。 返回 Buffer。 在评估模块之前,可以多次调用此方法。

    Creates a code cache that can be used with the SourceTextModule constructor's cachedData option. Returns a Buffer. This method may be called any number of times before the module has been evaluated.

    // Create an initial module
    const module = new vm.SourceTextModule('const a = 1;');
    // Create cached data from this module
    const cachedData = module.createCachedData();
    // Create a new module using the cached data. The code must be the same.
    const module2 = new vm.SourceTextModule('const a = 1;', { cachedData });