WICG / import-maps

How to control the behavior of JavaScript imports
https://html.spec.whatwg.org/multipage/webappapis.html#import-maps
Other
2.68k stars 69 forks source link

Should import map be applied to main module and workers main script? #157

Closed bartlomieju closed 2 years ago

bartlomieju commented 5 years ago

During implementation of import maps for Deno I believe I read that import maps shouldn't be applied to root script as well as workers root script, but now I can't find any mention about it now.

Example:

// importmap.json
{
    "imports": {
         "https://deno.land/std/http/file_server.ts": "./foo/bar.ts"
     }
}

Could you clarify that @domenic? Thanks in advance.

matthewp commented 5 years ago

There's this issue about workers: https://github.com/WICG/import-maps/issues/2 if that helps.

ljharb commented 5 years ago

I would expect import maps to be applied to everything, including the root script.

domenic commented 5 years ago

This is largely a decision for deno to make. Does it take as input URLs, or module specifiers? URLs (which on the web show up in places like <script src="url"> or <link rel="modulepreload" href="url">) don't get remapped by import maps; that's why we have future proposals for import: URLs and import.meta.resolve(). Module specifiers do get remapped.

I can tell you that on the web, new Worker() takes a URL, so it wouldn't get remapped.

Inside the Worker is a whole 'nother story; currently you cannot use import maps inside workers according to this spec, but that's a TODO as discussed in #2.