Open JayaKrishnaNamburu opened 1 month ago
Looks like the bug might be from here https://github.com/jspm/generator/blob/main/src/install/installer.ts#L137
if (opts.defaultRegistry) this.defaultRegistry = opts.defaultRegistry;
Before assigning the his.defaultRegistry
. We need to do something like
if (opts.defaultRegistry) {
this.defaultRegistry =
registryProviders[`${opts.defaultProvider}:`] ?? opts.defaultRegistry;
}
So, when a provider
of denoland is selected, it automatically assigns to denoland
registry. The only issue i see for the approach is, the standard libs of deno are moved to jsr
which in turn need to add support for jsr #366
We have two separate providers for Deno:
denoland
the (now deprecated it seems) Denoland URLs which host packages for Denodeno
the Deno core librariesThat is, you would want to set defaultProvider: 'denoland'
here.
Thanks for the clarification @guybedford. I am not aware of that, but looking like even when we set the defaultProvider
to denoland. The import map seems to load from the ga.jspm.io
const generator = new Generator({
defaultProvider: "denoland",
});
await generator.install("zod");
await generator.install("lodash");
console.log(
`Installing by passing defaultProvider as deno land\n`,
JSON.stringify(generator.getMap(), null, 2),
);
is generating
{
"imports": {
"lodash": "https://ga.jspm.io/npm:lodash@4.17.21/lodash.js",
"zod": "https://ga.jspm.io/npm:zod@3.23.8/lib/index.mjs"
}
}
When passing
defaultProvider
asdeno
toGenerator
. The dependencies should be loaded fromdenoland
. But instead the dependencies are being loaded fromnpm
but they are loading fromdenoland
if users passdenoland
protocol for the package name.Here are some examples
Will result in an importmap of
The dependencies are loaded from
ga.jspm.io
withnpm:
as prefix for protocol.When we pass the protocol for the package name. Then it loaded from deno registry.
Will result in an importmap of
Here the package
zod
comes fromdenoland
since theprotocol
isdenoland
. But we can see the packageloadash
is coming fromnpm
here as expected.Let's try the same with
skypack
This will result in an import of
Here the package loads from
skypack
respecting thedefaultProtocol
that is passed to the generator. Sandbox for the same to test.