[Feature]: Allow esm https network imports
🚀 Feature Proposal
Add https: support for esm imports.
Motivation
Experimental esm https network imports was added in node.js v17 https://nodejs.org/api/esm.html#https-and-http-imports
It is currently behind a --experimental-network-imports flag.
Code using this feature is not testable as of Jest v28.1.0.
Example
The following is not testable using Jest, but can be run in node.js with --experimental-network-imports
import capitalize from "https://cdn.skypack.dev/pin/[email protected]/mode=imports/unoptimized/capitalize.js";
console.log(
capitalize(
"this string should be capitalized using an https import of lodash.capitalize"
)
);
Pitch
ESM imports is core functionality in node.js and https: imports just another feature of it.
Jest should support https: imports as tools like deno and vite are popularizing using esm https imports directly.
Implementing this feature should be fairly simple by adding another case to: https://github.com/facebook/jest/blob/811228d6ae73a6563a98b0ee36b73f453e644f2f/packages/jest-runtime/src/index.ts#L543
For those already using vite and esm https imports, you can use deno test as a workaround. Deno natively supports esm https imports, so the test runner would as well.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.