import-map-overrides icon indicating copy to clipboard operation
import-map-overrides copied to clipboard

Infer same filename with port number

Open petermikitsh opened this issue 4 years ago • 1 comments

Screen Shot 2021-02-17 at 12 14 34 PM

Expected behavior: inferred filename is main.js

Actual behavior: inferred file name is platform-ui-analytics.js

Note: URL pattern from original (non-overriden URL) is //mydomain.com/@platform-ui/analytics/{x.y.z}-canary-{hash}/main.js

petermikitsh avatar Feb 17 '21 20:02 petermikitsh

You can implement this behavior yourself by overriding the getUrlFromPort hook: https://github.com/joeldenning/import-map-overrides/blob/master/docs/api.md#geturlfromport

However, I agree that this would be a sensible default. Do you have interest in implementing it? Here's the code to change:

https://github.com/joeldenning/import-map-overrides/blob/8869268bb3b393af2b1a2e4e49b7a2fe84e13ba4/src/api/js-api.js#L157-L160

joeldenning avatar Feb 18 '21 05:02 joeldenning

I ended up pivoting my solution a bit here. Instead of overriding from localhost, I added a build step to pull request builds to publish artifacts to our CDN and use those for overrides. This approach also solves SSL problems you can run into (loading http resources from an https website). I no longer have a need for this functionality.

petermikitsh avatar Dec 09 '22 18:12 petermikitsh