From fd250ae4f087f729396c99386f2689c2e6fd0a87 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sat, 9 May 2026 10:39:28 +0100 Subject: [PATCH] perf(rollup): skip URI-scheme ids before `this.resolve()` --- src/rollup/plugins/externals.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rollup/plugins/externals.ts b/src/rollup/plugins/externals.ts index 1cfd447c31..3841dc1acb 100644 --- a/src/rollup/plugins/externals.ts +++ b/src/rollup/plugins/externals.ts @@ -17,6 +17,8 @@ import { readPackageJSON, writePackageJSON } from "pkg-types"; import type { Plugin } from "rollup"; import semver from "semver"; +const URI_SCHEME_RE = /^[a-z0-9]{2,}:/; + export function externals(opts: NodeExternalsOptions): Plugin { const trackedExternals = new Set(); @@ -83,6 +85,16 @@ export function externals(opts: NodeExternalsOptions): Plugin { return null; } + if (URI_SCHEME_RE.test(originalId)) { + if ( + originalId.startsWith("node:") && + !isExplicitInline(originalId, importer) + ) { + return { id: originalId, external: true }; + } + return null; + } + // Normalize path (windows) const id = normalize(originalId);