加载器
🌐 Loaders
稳定性: 1 - 实验性
该 API 目前正在重新设计,仍可能会有所变动。
要自定义默认模块解析,可以通过向 Node.js 提供 --experimental-loader ./loader-name.mjs 参数来可选地提供加载器钩子。
🌐 To customize the default module resolution, loader hooks can optionally be
provided via a --experimental-loader ./loader-name.mjs argument to Node.js.
当使用 hooks 时,它们会应用于入口点和所有 import 调用。它们不会应用于 require 调用;这些仍然遵循 CommonJS 规则。
🌐 When hooks are used they apply to the entry point and all import calls. They
won't apply to require calls; those still follow CommonJS rules.
加载器遵循 --require 的模式:
🌐 Loaders follow the pattern of --require:
node \
--experimental-loader unpkg \
--experimental-loader http-to-https \
--experimental-loader cache-buster 这些按以下顺序调用:cache-buster 调用 http-to-https,然后调用 unpkg。
🌐 These are called in the following sequence: cache-buster calls
http-to-https which calls unpkg.