文本模块


🌐 Text modules

稳定性: 1.0 - 早期开发

文本模块可以在 --experimental-import-text 标志后面使用。

🌐 Text modules are available behind the --experimental-import-text flag.

文本文件可以用 import 引用:

🌐 Text files can be referenced by import:

import message from './message.txt' with { type: 'text' }; 

with { type: 'text' } 语法是必须的;请参见 导入属性

🌐 The with { type: 'text' } syntax is mandatory; see Import Attributes.

导入的文本只会暴露一个 default 导出,其值是模块源代码的字符串。

🌐 The imported text only exposes a default export whose value is the module source as a string.