Deno: local modules?

Created on 26 Feb 2020  路  7Comments  路  Source: denoland/deno

What's the best way to consume local modules in Deno, with no network access?

Most helpful comment

an obvious file-system only way to consume files

deno run --no-remote?

All 7 comments

I think it is great to have spec'd ES Modules, and be able to access modules just like in a browser, because it makes some things very easy without any tooling.

But I think for on-device non-browser code there should definitely be an obvious file-system only way to consume files or "packages".

It would be great to have the best of both worlds!

After stumbling around, I realize this is a continuation of https://github.com/denoland/deno/issues/4137.

Maybe Deno simply needs a simple way to install anything from https://deno.land/x to a local deps folder, along with a way to configure imports like import {foo} from 'deps/foo/index.ts', similar to the deptool idea in https://github.com/denoland/deno/issues/195#issuecomment-395524973 by @jbreckmckye.

This would be a way to install anything registered on https://deno.land/x locally. There would also be some command line option to install things from any other domain locally.

Deno itself doesn't need to make this command line tool, so as to let the community compete at this aspect. All deno needs is some way to configure the deps/foo.ts types of "absolute" imports.

an obvious file-system only way to consume files

deno run --no-remote?

It certainly would help if you do a bit of searching before opening issues and keep the issue tracker to issue.

General use questions should be done in other channels, like Gitter.

other channels, like Gitter.

Thanks for pointing that out! I'll post ideas/questions there first from now on.

deno run --no-remote

That wasn't obvious. The Manual has no search results for no-remote, and other searches for things like "package" lead to

Deno does not use package.json in its module resolution algorithm.

@trusktr Well, it has nothing to do with packages. It just disables modules specified via remote URLs.

I think you want a workflow that works strictly with local modules via a traditional package manager? The --no-remote flag is all there is to be done on Deno's end. The rest as you said is third party tooling. In fact, you could even use existing tools like npm to distribute modules consumable by Deno and use
--import-maps to make the module specifiers look the way you want them to. If I've understood this right then you can close this.

Aha! I just found the Import maps section too.

Deno has everything we need then! Someone can build a CLI tool on top of this to generate import maps to achieve NodeJS-like import statements.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

motss picture motss  路  3Comments

ry picture ry  路  3Comments

ry picture ry  路  3Comments

metakeule picture metakeule  路  3Comments

watilde picture watilde  路  3Comments