jspm / generator

JSPM Import Map Generator
Apache License 2.0
165 stars 21 forks source link

feat: unified builtin hooking for standard libraries #183

Closed guybedford closed 1 year ago

guybedford commented 1 year ago

This adds a new resolveBuiltin provider method which is hooked both for generator.install('deno:x') as well as when resolving import 'deno:x'.

The hook is provided the conditional environment, allowing it to resolve to a final URL (deno:x itself being a valid return value), or it can optionally return an Install which corresponds to the standard library install to use for that module (either in JSPM core virtualization or directly against the Deno CDN like https://deno.land/std, just like normal installs).

In the process it was also necessary to separate the concept of subpaths of installs from subpath installs on the Install object, so that subpath installs are now a full first-class citizen for any install (generator.install({ alias: 'custom', target: { registry: 'deno', name: 'std' }, installSubpath: './node', subpath: './fs' }) would correspond to installing custom/fs where the custom/ package is effectively a subpackage install of https://deno.land/std@x.y.z/node/.

Still a bunch of use cases to work through thoroughly here, but this at least integrates the architeture to a point where all of these internal details are handled completely properly in the version management system.

fusionstrings commented 1 year ago

Just saw this... wow...almost a mind reader 💯