You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as the * will be replaced with lib/utils/abs-ceil.js in "/node_modules/moment/src/*".
Resulting in an actual import of /node_modules/moment/src/lib/utils/abs-ceil.js.
Note: potentially in a first iteration we could only support * at the end of a / (e.g. functional foo/* would be the same as foo/)
Support limitations and extensionless imports
In node the star * can not only be at the end of the import but also before a file extension.
e.g. the following exports
"exports": {
"./*.js": "./src/*.js",
}
The import would change to extensionless but the actual file would remain the same
as the * will be replaced with lib/utils/abs-ceil in "/node_modules/moment/src/*.js".
Resulting in an actual import of /node_modules/moment/src/lib/utils/abs-ceil.js.
This solves our last remaining issue (Nr. 3) by limiting what can be imported to only .js files.
To quote nodes docs about the implementation
* maps expose nested subpaths as it is a string replacement syntax only.
Currently, import maps have a trailing slash functionality that allows importing anything within a folder
e.g. the above would allow imports like
to work. see moment src to verify
Issue
Suggestion
Besides the trailing slash functionality also support
*
as a "simple string replace" functionality.e.g. the above could then also be written as
this fixes
as it is more obvious that it supports
*
after "moment".as it can be 1:1 mapped to how node entry points work (which enables tools to very simply generate an import maps out of exports)
Note: trailing slash exports have been deprecated with node 16 and have been removed since node 17 (iirc)
The import would remain exactly the same
as the
*
will be replaced withlib/utils/abs-ceil.js
in"/node_modules/moment/src/*"
.Resulting in an actual import of
/node_modules/moment/src/lib/utils/abs-ceil.js
.Note: potentially in a first iteration we could only support
*
at the end of a/
(e.g. functionalfoo/*
would be the same asfoo/
)Support limitations and extensionless imports
In node the star
*
can not only be at the end of the import but also before a file extension.e.g. the following exports
The import would change to extensionless but the actual file would remain the same
as the
*
will be replaced withlib/utils/abs-ceil
in"/node_modules/moment/src/*.js"
.Resulting in an actual import of
/node_modules/moment/src/lib/utils/abs-ceil.js
.This solves our last remaining issue (Nr. 3) by limiting what can be imported to only
.js
files.To quote nodes docs about the implementation
https://nodejs.org/dist/latest-v18.x/docs/api/packages.html#packages_subpath_patterns
What do you think? should
*
be supported in an import-map?The text was updated successfully, but these errors were encountered: