Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

Import Maps review #13

Closed
littledan opened this issue Dec 4, 2018 · 7 comments
Closed

Import Maps review #13

littledan opened this issue Dec 4, 2018 · 7 comments

Comments

@littledan
Copy link
Contributor

@domenic's import maps proposal defines a JSON format to map from "bare" module specifiers to the URL where the module lives. This mapping can also be used to polyfill/virtualize built-in modules.

Although the proposal was originally designed with the web in mind, it may be useful within Node.js as well: a map to point to the particular path of an import could reduce the number of stat calls needed to locate it, which could improve startup time on platforms where that operation is expensive.

@joyeecheung told me this optimization a frequently requested feature in Node's module system, which is typically rejected due to the existing complexity of module loading. Maybe a standard solution could be more sustainable than yet another edge case.

What do you think of the import maps proposal? Would it make sense within Node? If it makes sense, how should it be integrated into require or ESM support?

@ljharb
Copy link
Member

ljharb commented Dec 4, 2018

The @nodejs/modules group has discussed it many times; it's definitely going to be useful for node's integration of ESM.

@joyeecheung
Copy link
Member

Couldn't find specific references on the proposal but from what I can find looks like @bmeck is setting up a meeting to discuss specifically about this: nodejs/modules#231

@littledan
Copy link
Contributor Author

littledan commented Dec 4, 2018

@ljharb Do you know where we can find notes from these discussions?

Has any feedback from the modules team made it back to the import-maps proposal?

@ljharb
Copy link
Member

ljharb commented Dec 4, 2018

Notes are here: https://github.com/nodejs/modules/tree/master/doc/meetings, discussed under "package name maps", "import maps", and "module maps", as the name has changed over time. I'm pretty confident there's been lots of communication between @domenic and the modules group - @MylesBorins and @bmeck can probably best speak to that.

@littledan
Copy link
Contributor Author

Thanks, @ljharb ! Glad this has been receiving detailed review already.

@littledan
Copy link
Contributor Author

Has there been discussion in the modules team about the optimization I noted in the beginning of this thread? I'm having trouble finding any references to that in the notes.

@jkrems
Copy link

jkrems commented Dec 4, 2018

I have been working on a proposal of a "stat-less public interface" for bare specifiers: https://github.com/jkrems/proposal-pkg-exports/blob/master/README.md#packagejson-interface. Important to note that this is still being discussed. But the idea is that it would allow generating a complete import map offline from a package-lock.json, removing all file system hits from import resolution in the absence of CommonJS.*

(*) There still might be some for finding "package boundaries" that are used to load additional meta data. But that can happen after the URL is resolved.

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

5 participants