Deno: [Suggestions] Should not the module resolve GitHub As primary repository

Created on 6 Jun 2020  ·  4Comments  ·  Source: denoland/deno

This issue is to just look for suggestions. Most of the time, I (as a developer), will you git hub as a module. And getting a file from git hub, it looks very bad. Something like below:

import safeEval from "https://raw.githubusercontent.com/deepakshrma/deno-by-example/master/examples/safe_eval.ts";

Should be module try to resolve first from GitHub by default, and throw an exception if could not found. Just like GoLang.

import * as lib from 'username/repo_name/dir/file_name.ts'
to resolve as
import * as lib from 'https://raw.githubusercontent.com/username/repo_name/master/dir/file_name.ts'

And

import * as lib from 'username/repo_name'
to resolve as
import * as lib from 'https://raw.githubusercontent.com/username/repo_name/master/mod.ts'

I understand, there are online server resolver like deno.land/x and https://www.pika.dev/

But what if we use same library from Github and www.pika.dev or somewhere else. The cache will have multiple copies of the same library. Something as bellow:

deps

This will help in debug code and find the correct dependency.

Most helpful comment

@axetroy this feature was added recently: https://deno.land/x/gh:ry:v8worker2

All 4 comments

Relying on someone to host service is bad, even Github

You can’t predict what it will look like in 10 or even 20 years (eg, if Github exists or not)

You should not bind a service provider to the standard (Golang does not do this, but is based on HTML meta tag <meta name="go-import" content="gitea.mydomain.com/owner/repo git https://gitea.mydomain.com/owner/repo.git"> )

We should stick to distributed modules

If you need to import Github modules, then https://github.com/denoland/deno_website2 can do this or use https://denopkg.com

Experimental: Use npm:[package] orgh:[owner]:[repo] as module name to resolve any artibrary repository or npm package.

Of course, I prefer this way (not implement yet)

import lib from "https://deno.land/github.com/owner/repo/mod.ts"

@axetroy this feature was added recently: https://deno.land/x/gh:ry:v8worker2

@axetroy Anything, but not external cdns. Since all the cdn using github. Unnecessary to maintain so many confusing URLs. Frontend, Sill OK. But backend. I prefer basic support from denoland module resolver.

It will suck. Bypassing proxies and port etc. Hope, I will see new syntax soon!

Thanks! @ry. I would like to see some samples 👯‍♂️ Haha!

import * as lib from 'username/repo_name/dir/file_name.ts'
to resolve as
import * as lib from 'https://raw.githubusercontent.com/username/repo_name/master/dir/file_name.ts'

And

import * as lib from 'username/repo_name'
to resolve as
import * as lib from 'https://raw.githubusercontent.com/username/repo_name/master/mod.ts'

You can get this behavior by using Import maps.

Deno will not try to automatically resolve from any host.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

metakeule picture metakeule  ·  3Comments

kitsonk picture kitsonk  ·  3Comments

davidbarratt picture davidbarratt  ·  3Comments

CruxCv picture CruxCv  ·  3Comments

ry picture ry  ·  3Comments