Skip to content

feat(compiler): support new URL(url, base) with string literals - #43

Open
3kaiu wants to merge 1 commit into
vercel-labs:mainfrom
3kaiu:url-two-arg
Open

feat(compiler): support new URL(url, base) with string literals#43
3kaiu wants to merge 1 commit into
vercel-labs:mainfrom
3kaiu:url-two-arg

Conversation

@3kaiu

@3kaiu 3kaiu commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Support the two-argument new URL(url, base) form when both arguments are compile-time string literals. The URL is resolved at compile time using Node's built-in URL class, and a single url.new libcall is emitted with the resolved href.

Details

Previously, any new URL call with more than one argument was fenced with noLowering. This PR:

  • Detects when both url and base are string literals → resolves at compile time
  • Preserves the fence for non-literal arguments with an improved error message
  • For invalid base URLs, emits a diagnostic similar to Node's TypeError

The non-literal case (e.g. new URL(request.url, \"http://localhost\")) remains unsupported and suggests --dynamic as a workaround.

Testing

All existing tests pass: 251 passed, 7 skipped (12 files).

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@3kaiu is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread packages/compiler/src/frontend/resolve.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant