load 返回的最终接受格式


🌐 Accepted final formats returned by load

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

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

formatDescriptionAcceptable types for source returned by load
'addon'Load a Node.js addon<null>
'builtin'Load a Node.js builtin module<null>
'commonjs-typescript'Load a Node.js CommonJS module with TypeScript syntax<string> | <ArrayBuffer> | <TypedArray> | <null> | <undefined>
'commonjs'Load a Node.js CommonJS module<string> | <ArrayBuffer> | <TypedArray> | <null> | <undefined>
'json'Load a JSON file<string> | <ArrayBuffer> | <TypedArray>
'module-typescript'Load an ES module with TypeScript syntax<string> | <ArrayBuffer> | <TypedArray>
'module'Load an ES module<string> | <ArrayBuffer> | <TypedArray>
'wasm'Load a WebAssembly module<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.