load 返回的最终接受格式


🌐 Accepted final formats returned by load

format 的最终值必须是以下之一:

🌐 The final value of format must be one of the following:

format描述load 返回的 source 可接受类型
'addon'加载 Node.js 插件<null>
'builtin'加载 Node.js 内置模块<null>
'commonjs-typescript'加载带有 TypeScript 语法的 Node.js CommonJS 模块<string> | <ArrayBuffer> | <TypedArray> | <null> | <undefined>
'commonjs'加载 Node.js CommonJS 模块<string> | <ArrayBuffer> | <TypedArray> | <null> | <undefined>
'json'加载 JSON 文件<string> | <ArrayBuffer> | <TypedArray>
'module-typescript'加载带有 TypeScript 语法的 ES 模块<string> | <ArrayBuffer> | <TypedArray>
'module'加载 ES 模块<string> | <ArrayBuffer> | <TypedArray>
'wasm'加载 WebAssembly 模块<ArrayBuffer> | <TypedArray>

source 的值在格式 'builtin' 中被忽略,因为目前无法替换 Node.js 内置(核心)模块的值。

🌐 The value of source is ignored for format 'builtin' because currently it is not possible to replace the value of a Node.js builtin (core) module.

这些类型都对应于 ECMAScript 中定义的类。

如果基于文本的格式(即 'json''module')的源值不是字符串,它将使用 util.TextDecoder 转换为字符串。

🌐 If the source value of a text-based format (i.e., 'json', 'module') is not a string, it is converted to a string using util.TextDecoder.