Skip to content

[Feature Request]: A way to opt-out the new URL('./foo', import.meta.url) transform #2745

@sapphi-red

Description

@sapphi-red

What problem does this feature solve?

A plugin may inject new URL('./foo', import.meta.url) that is not intended to be process by rolldown and will be processed by the plugin itself in renderChunk or other build hooks.
In this case, the plugin wants a way to opt-out the new URL('./foo', import.meta.url) transform.

Currently, rolldown outputs Could not resolve, treating it as an external dependency warning but there's no way to suppress this warning for that use case. new URL is generated on transform hook so the URL cannot be added to external option.

Also this would be useful for cases like new URL('./non-existent-at-build', import.meta.url) in deps (e.g. webpack/webpack#16878).

What does the proposed API look like?

Vite supports /* @vite-ignore */ for new URL('./foo', import.meta.url) transform.

So maybe adding /* @rolldown-ignore */:

new URL(/* @rolldown-ignore */ './foo', import.meta.url)

I'm using new URL('./foo', '' + import.meta.url) as a workaround for now.

Metadata

Metadata

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions