Question Regarding Restriction on "#/" in Imports Field Key
Hello,
I came across the following code snippet in the project and had a question about its implementation:
if (key.charCodeAt(1) === slashCode) {
throw new Error(
`Imports field key should not start with "#/" (key: ${JSON.stringify(
key
)})`
);
}
https://github.com/webpack/enhanced-resolve/blame/a1976054344a85da8e0e1b2e1611694630e8f97b/lib/util/entrypoints.js#L594-L600
Could you please explain why there is a restriction that the imports field key should not start with "#/"? I reviewed the Node.js documentation on Subpath Imports, but I didn't find any specific mention of such a limitation.
Thank you!
Do you mean to have import "#/dep/#foo"?, because it is not valid URL
Given Node.js actually requires subpath imports begin with a #, it would be nice if this package handled such scenarios. Even if not technically a valid URLs, they're import paths it may encounter, no?
Sorry we want to align with Node.js behaviour.
index.js
import * as foo from "#/dep/#foo";
output:
TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module "#/dep/#foo" is not a valid internal imports specifier name imported from