JSON 模块


\JSON modules

稳定性: 1 - 实验性的

\Stability: 1 - Experimental

import 可以引用 JSON 文件:

\JSON files can be referenced by import:

import packageConfig from './package.json' assert { type: 'json' }; 

assert { type: 'json' } 语法是强制性的;见 导入断言

\The assert { type: 'json' } syntax is mandatory; see Import Assertions.

导入的 JSON 只暴露一个 default 导出。不支持命名导出。在 CommonJS 缓存中创建缓存条目,以避免重复。如果 JSON 模块已经从同一路径导入,则在 CommonJS 中返回相同的对象。

\The imported JSON only exposes a default export. There is no support for named exports. A cache entry is created in the CommonJS cache to avoid duplication. The same object is returned in CommonJS if the JSON module has already been imported from the same path.

AltStyle によって変換されたページ (->オリジナル) /