Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

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

Closed
bartlomieju opened this issue Jul 12, 2019 · 3 comments
Closed
Milestone

Comments

@bartlomieju
Copy link
Contributor

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"
     }
}
  • main script:
$ deno --importmap importmap.json run https://deno.land/std/http/file_server.ts
// should script be loaded from original URL or should it use remapped './foo/bar.ts'?
  • worker example:
// some_entry_point.ts
const worker = new Worker("https://deno.land/std/http/file_server.ts");
// should script be loaded from original URL or should it use remapped './foo/bar.ts'?

Could you clarify that @domenic? Thanks in advance.

@matthewp
Copy link

There's this issue about workers: #2 if that helps.

@ljharb
Copy link

ljharb commented Jul 12, 2019

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

@domenic
Copy link
Collaborator

domenic commented Jul 12, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants