Closed guybedford closed 1 year ago
A way to cheat in the above could be to make this a CLI-only feature that instead takes the following steps:
./
, ../
, /
or is a URL, AND the target does not end in a trailing /
? If so continue with the steps below, otherwise install it like a normal install target."imports"
overriding whatever is thereYeah, I started trying to tackle this at the generator level but it's a bit gnarlier than I expected (I mistook installSubpath
for "already resolved subpath"). So I think I'm going to take the cheat approach for now.
...but I think an approach that'll work in the generator is to expand the InstallTarget
type to be a union of the current { pkgTarget, installSubpath }
type and a URL, and then implementing the logic in the OP in the installer for URL targets.
I think it would be useful to consider installation of arbitrary URLs.
At the moment we install URLs as packages, with an optional subpath which is looked up in exports.
But when users do know the exact internal subpath, it can be useful to think in terms of installing a full module path.
Strictly speaking this isn't an install operation, it's more of an
add
operation. But I think treating it as an install makes sense from an end-user perspective to consider eg:The steps required would be:
URL install steps
/
treat that as the enforced package boundary to install and stop/
, determine the package boundary using the normal package boundary detection algorithm.I think it's a nice ease-of-use feature to have for those just wanting basic import map management, and now that decomposition is clever enough to handle these kinds of things I think it could even work quite intuitively.