加载器
¥Loaders
¥Stability: 1 - Experimental
此 API 目前正在重新设计,并且仍会发生变化。
¥This API is currently being redesigned and will still change.
要自定义默认的模块解析,则可以选择通过 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.
使用钩子时,它们适用于入口点和所有 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
,http-to-https
调用 unpkg
。
¥These are called in the following sequence: cache-buster
calls
http-to-https
which calls unpkg
.