You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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.
The text was updated successfully, but these errors were encountered: