package
make a local copy of https imports and output a policy file
npm install local-fs-https-importsGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
local-fs-https-imports app.js > policy.json
node --experimental-policy policy.json app.jsWould allow an app.js with:
import 'https://flavio-es-modules-example.glitch.me/script.js';To run.
It parses an entry module and crawls the source text looking for imports. When it finds an import it tries to resolve the URL it points to. If it finds a https: URL it saves it to disk under node_modules/.https/. After it is done crawling the entry module graph it creates a Node.js Policy Manifest to redirect requests to those URLs to the files on disk instead and prints it to STDOUT.
Maybe? I am biased though. The resolver isn't as feature complete as the Node builtin resolver.
PR it, this is mostly a proof of concept to help get HTTPS imports rolling in Node.js core by showing a potential set of semantics we can experiment with.
| Feature | Status | Notes |
|---|---|---|
content-type header | working | only JavaScript MIMEs are supported, saves as .mjs files to disambiguate regardless of package "type" |
| CORS | missing | could be implemented, but really unclear given the same origin model on what the "base" origin should be. Node PR uses multiple origins to solve this, could do so here |
authorization header | missing | no cookie jar implemented here currently to do so |
http: | won't fix | use https: |
| cache-control | won't fix | this saves the state at the time of running the script, expiration won't break your program |
import.meta.url | won't fix | this points to the local file, it won't point to a dynamic server URL. This means some asset management won't work such as using . This however prevents potential problems with missing assets only working sometimes or being vulnerable to manipulation compared to the cache |
fetchEstimated unpacked size across 16 packages.
3.2 MB
Includes dependencies.
3 direct · 3 outdated
^7.12.12
8.1.2
^7.12.11
8.1.2
^7.12.12
8.1.2