function loaderFor
loaderFor(url: string): Loader

Which loader a URL's extension asks for.

Extension rather than content type, because a server's idea of what JavaScript is called varies and a filename's does not — and an extensionless URL is JavaScript far more often than it is anything else, which is the same guess a browser makes.

An extension that is plainly not a module is refused BY NAME. esbuild's own answer is No loader is configured for ".html" files, which does not say which of the run's inputs it came from.

import { loaderFor } from './remote-module-plugin.ts';

loaderFor('https://x/a-test.ts'); // 'ts'
loaderFor('https://x/a-test.js?v=2'); // 'js' — a query is not an extension
loaderFor('https://x/api/tests'); // 'js'

Parameters

url: string

Return Type

Loader

Usage

import { loaderFor } from "lib/setup/remote-module-plugin.ts";