-
Notifications
You must be signed in to change notification settings - Fork 44
import-maps a proposal for bare imports in browsers #51
Comments
TypeScript already has support for a similar config, as did/does requireJS, webpack, and the babel module resolver plugin, though it's not particularly easy to use compared to the convention-based default So while it works (and has been in use to map node-style paths to browser-capable ones for somewhere between a half-decade and a decade), and would definitely improve things in the browser, I'm not sure it'd get browsers all the way to where people are really satisfied? It's definitely better than needing to edit the imports in every file, anyway; though I think it may need more work on how I imagine it's definitely worth supporting, for the sake of mirroring what the browser of capable of, but it's not really the kind of experience a node dev has come to expect as the default. |
not sure why we can't just wait for whatwg to finish the proper hookable loader /cc @domenic |
I wonder if maybe there was a way to use this map to specify a way to handle all bare imports without having to specify each one? |
I think it's an open question whether the format will support that. At the limit it could bloat the package name map with an entry for every file, or involve a lot more complexity in constructing paths from various settings. Currently, I rather like the idea that resolution is just mapping the package name to a path, and supporting a main file, but everything after the package name is a path within the package. |
to expand on @justinfagnani's point... I think that the package-name-maps supports the majority of the module specifier loader algorithm in node, except for two primary cases
|
I think we should invite @domenic to the team if possible or at least to the next meeting to discuss. |
I was going to offer to present the proposal at the next meeting. |
@MylesBorins @domenic ... where would you prefer feedback on this design to be directed? Here or in the package-name-maps repo? |
@jasnell in the package-name-maps repo |
@bmeck has brought up concerns about this proposal over in nodejs/node#21729 Putting this back on the agenda so we can discuss. We can also do so in the issue |
@bmeck |
@demurgos you can do creative things like (note that we are working with preliminary spec and things might change):
{
"path_prefix": "/node_modules",
"packages": {
"pkg": {"main": "lib/index.js"},
"pkg/lib": {"main": "index.js"},
"pkg/lib/index": {"path":"pkg/lib", "main": "index.js"}
}
} |
Removing from agenda for now, can be re-added |
Closing this as there has been no movement in a while, please feel free to re-open or ask me to do so if you are unable to. |
Domenic opened a new repo with a proposal for Package Name maps, a mechanism for allowing for bare imports in the browser. This potentially allows for a consistent resolution algorithm between platforms.
Thoughts?
https://github.com/domenic/package-name-maps
The text was updated successfully, but these errors were encountered: