Closed nestarz closed 4 years ago
I think this is mentioned in one of the README examples (https://github.com/WICG/import-maps#general-url-like-specifier-remapping). Afaik URL-like keys will be normalized to full URLs. The following should be equivalent (assuming inline source maps on a page with the base URL https://x.example/app/
):
{
"imports": {
"./src/foo.mjs": "./dist/foo.mjs",
}
}
{
"imports": {
"https://x.example/app/src/foo.mjs": "./dist/foo.mjs",
}
}
{
"imports": {
"/app/src/foo.mjs": "./dist/foo.mjs",
}
}
{
"imports": {
"https://x.example/app/src/foo.mjs": "https://x.example/app/dist/foo.mjs",
}
}
And as broader question, can specifiers be any string ?
In JavaScript, I don't think there's a restriction on the specifier string (it can be any JavaScript string). In both the basic HTML spec for imports and in this proposal, there's a separation between "URL-like" specifiers (absolute URLs, relative URLs starting with .
//
/./
) and "bare" specifiers. The bare specifiers can be any string that's not URL-like. In other words, there's currently nothing stopping a remapping of 🍕:
{
"imports": {
"🍕": "./pizza.mjs",
}
}
I would like to map some calls to files that have the relative scheme
./src/...
to./dist/...
Can I do this using import-maps ? Can it be something like this:And as broader question, can specifiers be any string ?
Thanks