Giter VIP home page Giter VIP logo

Comments (3)

robmosca avatar robmosca commented on May 30, 2024

The problem seems to be functional. When the import-map-overrides code loads for the first time, it reads the remote import map and stores the content in localStorage as-is (relative paths). If you then reload the page, the code takes the overrides from the localStorage and creates a new local import map with them, which it inserts dynamically in the page (

referenceNode = insertOverrideMap(
).

The problem is that this dynamic import map is local and the relative paths are resolved from the current host (localhost) instead of the host from which of the original import map was downloaded.
Why does the code need to store the import map in the localStorage and then insert it dynamically? :thinking_face: (just trying to understand how it works)

I guess that is needed for the library to work. If that is the case, some possible solutions would be:
resolve and expand the URL of the override before storing it in the localStorage. In this way, when reloading it it would point to the correct remote URL
store in the local storage more structured data containing information about the original import map URL, so that we can resolve the URL when reloading the page and injecting the import map.

What is not clear to me is why, despite the fact that I have no overrides setup, the first time I load the page the library still saves in localStorage the content of the external override map that I load in the index.html page… 🤔

from import-map-overrides.

robmosca avatar robmosca commented on May 30, 2024

OK, I think I understood the problem. It's a very edge case. The overrides from the import map downloaded remotely in my example are all dev libs. They are added to the localStorage because the import-map-overrides changes all devLibs to their development version, by default (here).
This is what accidentally introduces the problem, due to the fact that, by modifying them and adding them back in as dynamic overrides, since they are relative URLs they become relative to the host, instead of being relative to the position of the original import map (as specified in the import map specs, here).

from import-map-overrides.

robmosca avatar robmosca commented on May 30, 2024

This has been resolved. Closing it.

from import-map-overrides.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.