function fetchRemote
fetchRemote(
url: string,
cache: Map<string, string>
): Promise<string>

The text at a URL, fetched once per cache.

The cache is passed in rather than kept here, so its lifetime belongs to whoever owns the build: a bundle fetches each module once however many times it is imported, and a fresh run fetches again. A module-level cache would mean a --watch session never seeing a remote file change.

Failures come back as RemoteUnreadable with the reason in words — fetch says TypeError: fetch failed for a refused connection, a wrong host and an expired certificate alike, and none of those three is helped by being told the other two are possible.

import { fetchRemote } from './remote-inputs.ts';

// Defined, not invoked: it opens a socket.
function example() {
  return fetchRemote('https://example.com/tests/cart-test.js', new Map());
}

Parameters

url: string
cache: Map<string, string>

Return Type

Promise<string>

Usage

import { fetchRemote } from "lib/setup/remote-inputs.ts";