esm.sh
esm.sh copied to clipboard
Parsing of `external` arg fails for scoped pkg names on `&extraQuery`
Specifying an external scoped package works fine with regular query parameters:
curl "https://esm.sh/@vue/[email protected]?external=@vue/shared"
/* esm.sh - @vue/[email protected] */
import "/@vue/[email protected]/X-ZUB2dWUvc2hhcmVk/es2022/runtime-core.mjs";
export * from "/@vue/[email protected]/X-ZUB2dWUvc2hhcmVk/es2022/runtime-dom.mjs";
However It fails when using the & query prefix to allow for importmap trailing slash:
curl "https://esm.sh/@vue/[email protected]&external=@vue/shared/"
module not found
Apparently It happens only when the external pkg is scoped (contains @?).
If not scoped, then seems to work fine:
curl "https://esm.sh/@vue/[email protected]&external=csstype/"
/* esm.sh - @vue/[email protected] */
import "/@vue/[email protected]/es2022/runtime-core.mjs";
import "/@vue/[email protected]/es2022/shared.mjs";
export * from "/@vue/[email protected]/X-ZWNzc3R5cGU/es2022/runtime-dom.mjs";
EDIT: probably the alias param has the same problem with @.
@ije when possible, would be great if you could take a quick look and confirm that the expectations of this test case are correct: https://github.com/esroyo/esm.sh/commit/85ae4f024f505035dde459d683e3d51363b5c2b4
Thanks so much!
I will look into it thanks 🙏
This seems like a related issue:
importMap.imports['@react-three/cannon'] =
'https://esm.sh/@react-three/[email protected]?external=react,three,@react-three/fiber';
importMap.imports['@react-three/cannon/'] =
'https://esm.sh/@react-three/[email protected]&external=react,three,@react-three/fiber/';
The cannon import map doesn't work with the trailing slash and the @react-three/fiber external dependency. However, it does work if you remove the @react-three/fiber. That means I can't specify react-three/fiber as an external dependency though.
I get this error:
Not sure what the workaround would be.
This import map snippet works:
"@mui/material": "https://esm.sh/@mui/[email protected]?external=@emotion/react,@emotion/styled,react,react-dom"
This one does not:
"@mui/material/": "https://esm.sh/@mui/[email protected]&external=@emotion/react,@emotion/styled,react,react-dom/"