Git Product home page Git Product logo

Comments (5)

FluorescentHallucinogen avatar FluorescentHallucinogen commented on July 23, 2024

I've quickly patched the https://github.com/modernweb-dev/web/blob/master/packages/dev-server-import-maps/src/importMapsPlugin.ts#L121-L123 file, and it works!

      if (getAttribute(importMapScript, 'src')) {
-       throw new Error('Import maps with a "src" attribute are not yet supported.');
+       const importMapPath = getAttribute(importMapScript, 'src');
+       const content = fs.readFileSync(importMapPath, 'utf8');
+       setTextContent(importMapScript, content);
+       removeAttribute(importMapScript, 'src');
      }

from web.

bashmish avatar bashmish commented on July 23, 2024

There might be a good reasons not to support src.

From MDN https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap

The src, async, nomodule, defer, crossorigin, integrity, and referrerpolicy attributes must not be specified.

Pay attention that src is specifically mention as not allowed.

At the same time, in the proposal I see the src being described in https://github.com/wicg/import-maps#import-map-processing

You can install an import map for your application using a <script> element, either inline or with a src="" attribute:

Is there actually a consensus about this feature?

In general we try not to add non-standard features, at least without a good confidence that they will become a standard and got enough support from browser vendors and other stakeholders. In this case I can imagine the src involves an extra HTTP call which must be a blocking request due to how essential this information is for the module resolution, so maybe that's why it's not implemented natively.

from web.

FluorescentHallucinogen avatar FluorescentHallucinogen commented on July 23, 2024

See WICG/import-maps#235. @domenic wrote that external import maps will be implemented in Chromium, but can't give an ETA.

Import maps can be very large and generated by third-party tools. Inline them manually into HTML is a poor DX.

from web.

bashmish avatar bashmish commented on July 23, 2024

Thanks for sharing this link, it does shed some light on this.
I quickly scrolled through and didn't find a confirmation about other browsers vendors, except Chrome. There is a link to a Mozilla/gecko repo where it's also raising an exception for external import maps.

I have a bad feeling about the future of this feature given it's taking already more than 3 years for Chrome and others to implement it, so I'd rather not run ahead of the locomotive.

from web.

bashmish avatar bashmish commented on July 23, 2024

Not sure if we had a practice before in Modern Web with experimental feature plugins, maybe that can be a sort of in the middle solution. Curious if @thepassle @Westbrook @koddsson have an idea?

You can also make your own plugin meanwhile and publish it yourself.

from web.

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.