IssueRaiser

Support for Import Maps

I was hoping to start the conversation around getting [Import Map](https://github.com/WICG/import-maps) support into core. I figured starting here with a proposal was better than starting right off with a PR. ## What Are Import Maps > This proposal allows control over what URLs get fetched by JavaScript import statements and import() expressions. This allows "bare import specifiers", such as import moment from "moment", to work. The proposal was mainly targeted at browsers where URL imports have many downsides without bare specifier support. It enables a standardized map file format to be used when resolving import specifiers, giving developers more control of the behavior of import statements. Here is an example of the format: ```json { "imports": { "todayis": "node_modules/todayis/index.js" }, "scopes": { "node_modules/todayis": { "english-days": "node_modules/english-days/index.json" } } } ``` Proposal link: https://github.com/WICG/import-maps ## Why should they be supported in Node.js? Currently we use the structure of the filesystem and a resolution algorithm to map import specifiers to files. These files are typically installed by a package manager in a structure which the Node.js resolution algorithm knows how to resolve. This has some drawbacks: 1. It is slow 2. It can lead to unexpectedly resolving modules - if you have a `node_modules` at your filesystem root for example - if your package manager has hoisted a transitiv

Posted by wesleytodd on Jan 24, 2020, 4:20 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

support (Software)

Support for Import Maps

wesleytoddJan 24, 2020, 4:20 AM

I was hoping to start the conversation around getting [Import Map](https://github.com/WICG/import-maps) support into core. I figured starting here with a proposal was better than starting right off with a PR. ## What Are Import Maps > This proposal allows control over what URLs get fetched by JavaScript import statements and import() expressions. This allows "bare import specifiers", such as import moment from "moment", to work. The proposal was mainly targeted at browsers where URL imports have many downsides without bare specifier support. It enables a standardized map file format to be used when resolving import specifiers, giving developers more control of the behavior of import statements. Here is an example of the format: ```json { "imports": { "todayis": "node_modules/todayis/index.js" }, "scopes": { "node_modules/todayis": { "english-days": "node_modules/english-days/index.json" } } } ``` Proposal link: https://github.com/WICG/import-maps ## Why should they be supported in Node.js? Currently we use the structure of the filesystem and a resolution algorithm to map import specifiers to files. These files are typically installed by a package manager in a structure which the Node.js resolution algorithm knows how to resolve. This has some drawbacks: 1. It is slow 2. It can lead to unexpectedly resolving modules - if you have a `node_modules` at your filesystem root for example - if your package manager has hoisted a transitiv

Comments (0)

No comments yet. Start the discussion.

Comment on this issue