Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow resolveId to opt out of further resolving #3693

Closed
aapoalas opened this issue Jul 24, 2020 · 2 comments · Fixed by #4021
Closed

Allow resolveId to opt out of further resolving #3693

aapoalas opened this issue Jul 24, 2020 · 2 comments · Fixed by #4021

Comments

@aapoalas
Copy link

Feature Use Case

I have a ServiceWorker that intercepts all fetches to some URL path "/foo", eg "/foo/bar/baz". In Rollup config I can mark this path as external and Rollup will not attempt to include any file from said path (which at build time doesn't exist, and definitely not in the file system root). Unfortunately, Rollup will still helpfully resolve the path for me, resulting in something like "../../../../../../foo/bar/baz".

Most of the time this is exactly what one would want but in my case I'd want these URLs to remain as they are in the Rollup-built bundle so that eventually the ServiceWorker can intercept the request at runtime. Try as I might with the resolveId hook, returning an absolute path from said hook will always cause Rollup to helpfully make my absolute path into a relative one.

In the end I managed to get rid of the relative path by simply doing a search and replace in generateBundle step. This, however, feels like an ugly solution.

Feature Proposal

Allow resolveId return in it's object return format an extra boolean, eg. "resolve: false" or similar. This might only make sense in conjunction with "external: true". In short it would tell Rollup (and other plugins?) to not make alter the path any further.

@lukastaegert
Copy link
Member

To avoid the double flag, we could also allow string values such as external: "unresolved" or external: "resolved". In general I agree that having externals starting with a / is a useful thing, it just so happens that it currently conflicts with some other logic.

@lukastaegert
Copy link
Member

fix at #4021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants