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
Import maps are static (see WICG/import-maps#92 for context), so when previewing a site, we can’t add a library to the import map after the page has loaded. This results in a broken experience:
TypeError: Failed to fetch dynamically imported module: npm:whatever
A workaround would be to detect in the diff when a library needs to be added to the import map. In this case we would reload the entire page rather than doing an incremental update. (A full reload isn’t ideal, but at least the page will continue working.)
A more involved workaround would be to avoid import maps entirely during live preview, and instead transpile the JavaScript directly to use URLs. This would avoid needing to reload the page. The only wrinkle is that we’d also need to transpile local ES modules, but I expect we’ll probably have to do that anyway if we e.g. want to support FileAttachment in ES modules, too. It’s also kind of a shame because I was excited to use import maps.
The text was updated successfully, but these errors were encountered:
Import maps are static (see WICG/import-maps#92 for context), so when previewing a site, we can’t add a library to the import map after the page has loaded. This results in a broken experience:
A workaround would be to detect in the diff when a library needs to be added to the import map. In this case we would reload the entire page rather than doing an incremental update. (A full reload isn’t ideal, but at least the page will continue working.)
A more involved workaround would be to avoid import maps entirely during live preview, and instead transpile the JavaScript directly to use URLs. This would avoid needing to reload the page. The only wrinkle is that we’d also need to transpile local ES modules, but I expect we’ll probably have to do that anyway if we e.g. want to support FileAttachment in ES modules, too. It’s also kind of a shame because I was excited to use import maps.
The text was updated successfully, but these errors were encountered: