Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/rollup/plugins/externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();

Expand Down Expand Up @@ -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);

Expand Down
Loading