Comments (11)
With <link>
you couldn't inline the map in the HTML. You could put it in a header but many servers have size limits on headers that the package map might exceed.
from import-maps.
I take that back, looks like the typical size limit is 8k, I doubt a packagemap would exceed that. I had thought the limit was smaller.
from import-maps.
@matthewp if the link header is mostly a href I don't think it likely to exceed the size limits. Per inlining into the document, I'm not sure if a precomputed workflow like this is as desirable to output back into inline HTML for most situations. If desirable to inline we could certainly support both ways to load things, similar to CSS.
I somewhat still question if inlining is going to be more desirable than linking since you will be doing many resource requests most likely as the README states. Inlining can help with initial load, but could cause fewer cache hits on the initial document load if the package name map changes over time. In particular, being unable to load updated package name maps after initial load means that any changes would require a refresh in order to be synced up. Hopefully, we can find a workflow where package name maps change rarely; I am unsure of that being realistic.
from import-maps.
Good point about cache hits. For a lot (but not all) sites, caching isn't used on documents as they tend to be dynamic. I'm concerned about using hrefs with http/1.1 servers though. The packagemap is a super-dependency of all modules, so it will block the preload scanner from doing its job.
from import-maps.
We considered both, but started with <script>
because of inlining, and not wanting to have two ways to do the same thing.
from import-maps.
@justinfagnani I'm curious about this:
Adding a second <script type="packagemap"> has no effect.
Should we be concerned that a large packagemap will block scripts from loading? One case where you might want multiple packagemaps would be if you wanted to put essential, above-the-fold scripts into its own tree and then defer the rest for later. For example:
<script type="packagemap">
[ESSENTIAL MAPPING HERE]
</script>
<script type="module" src="./main.js"></script>
<main> ... </main>
<script type="packagemap">
[NON-ESSENTIAL MAPPING HERE]
</script>
<script type="module" src="./less-important.js"></script>
The question being whether a packagemap is ever big enough where splitting would be desired. I understand that allowing multiple maps starts to raise conflict resolution problems...
from import-maps.
I hope that can be explored more, and my team has asked for it. I understand that there might be blockers, but maybe there's some way to figure it out.
from import-maps.
btw, this is a dupe of #1
from import-maps.
Hmm, I really tried to pre-empt this by pre-filing #1. Let's please continue discussion there? Some good points have been raised so far though!
from import-maps.
@domenic I'm not sure this fits in either #1 or #2 since the link:
header could apply to both.
from import-maps.
Well, I agree the issues slightly bleed over, but since #1 is where <script>
is the existing proposal, we'd need to establish that link is good enough or better for the window context before considering it for the worker context.
from import-maps.
Related Issues (20)
- Modulepreload error caching HOT 9
- Should HTMLScriptElement.supports("importmap") return true? HOT 1
- Fire a load event or an error event when the script element of the import map is from an external file? HOT 2
- preparation-time document check should be done first at #register-an-import-map HOT 2
- Throwing TypeError in resolve a module specifier? HOT 2
- calling onerror of the script element if the import map string cannot be parsed HOT 1
- What should 'parse an import map string' return when it throws an Error? HOT 8
- Speculatively parsing with import map if there's a dynmic import before, HOT 4
- Official file extension? HOT 2
- Support stars in imports besides trailing slashes HOT 1
- `importmap` cannot resolve dependencies entered relatively. HOT 3
- [feat] `script.integrity` and import map HOT 2
- Specification is not restricting address from containing query- or fragment parts not ending with "/" HOT 3
- global variables (f.e. map `"jquery"` specifier to `globalThis.jquery` variable) HOT 1
- Specify package.json path in <script>, and then generate the import map from package.json. HOT 7
- Unable to create folder alias to use in further alias. HOT 2
- ability to specify a default extension for extensionless URLs HOT 3
- Fallbacks for failed URLs? HOT 1
- import maps for `import()` statements HOT 1
- Support for "package.json browser" style file replacement/removal within modules? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from import-maps.