file: URL


file: URLs】

如果用于解析模块的 import 指定符具有不同的查询或片段,模块会被多次加载。

【Modules are loaded multiple times if the import specifier used to resolve them has a different query or fragment.】

import './foo.mjs?query=1'; // loads ./foo.mjs with query of "?query=1"
import './foo.mjs?query=2'; // loads ./foo.mjs with query of "?query=2" 

卷宗根可以通过 ///file:/// 引用。鉴于 网址 与路径解析之间的差异(例如百分比编码的细节),建议在导入路径时使用 url.pathToFileURL

【The volume root may be referenced via /, //, or file:///. Given the differences between URL and path resolution (such as percent encoding details), it is recommended to use url.pathToFileURL when importing a path.】