A nodejs loader for loading modules over the network with http/https.
npm install --save @node-loader/http
# Or, if you prefer Yarn
yarn add --save @node-loader/http
NodeJS 16.12 changed the Node Loader API. If using NodeJS@<16.12, please use @node-loader/http@1
. Otherwise, use @node-loader/http@latest
.
Create a file that imports a module over http:
import * as singleSpa from "http://unpkg.com/[email protected]/lib/esm/single-spa.dev.js";
Now run node with the --experimental-loader
flag:
node --experimental-loader @node-loader/http file.js
This project uses node-fetch to implement familiar HTTP semantics, including http redirects, https redirects, HTTP status checks, etc. Customizing the behavior of node-fetch is planned, but not yet implemented.
If you wish to combine http loader with other NodeJS loaders, you may do so by using node-loader-core.