DEV Community

Discussion on: Deno: The next step in Node.js

Collapse
 
ryands17 profile image
Ryan Dsouza

My only concern is dependency management with URL imported packages. How would one go about changing the version of the package if it is been imported in 10 different places. Also solving resolution conflicts that package managers like yarn and npm perform when one package depends on several is quite handy. Having URL's is fine as long as there's a central way of managing the dependencies.

import lodash from 'lodash';
Enter fullscreen mode Exit fullscreen mode

vs

import lodash from 'some-long-url/lodash';
Enter fullscreen mode Exit fullscreen mode

I personally find the former easier to read and write. Also for autocomplete and intellisense, the dependencies need to be downloaded anyway.

Thread Thread
 
siddharthshyniben profile image
Siddharth

My only concern is dependency management with URL imported packages. How would one go about changing the version of the package if it is been imported in 10 different places.

As I said here, Deno has a convention of putting all imports in a deps.ts file. This makes it easier to change versions, as there is only a single import.

Also solving resolution conflicts that package managers like yarn and npm perform when one package depends on several is quite handy.

Deno has no "magical" module resolution. Instead, imported modules are specified as files (including extensions) or fully qualified URL imports. This makes it harder to mess up.

I personally find the former easier to read and write.

If you use the deps.ts convention, you could have this:

deps.ts

import * as _ from 'some-long-url/lodash';

// If you want it all
export {_};

// If you need only some
export {uniq: _.uniq, isEqual: _.isEqual}
Enter fullscreen mode Exit fullscreen mode

main.ts or wherever you use it

import {uniq, isEqual} from './deps.ts';

const foo = isEqual(...);
Enter fullscreen mode Exit fullscreen mode

Also for autocomplete and intellisense, the dependencies need to be downloaded anyway.

Deno caches modules once they are required once, so intellisense can work at that time.

Thread Thread
 
ryands17 profile image
Ryan Dsouza

Yup deps/ts is a much better way :)

Deno has no "magical" module resolution. Instead, imported modules are specified as files (including extensions) or fully qualified URL imports. This makes it harder to mess up.

Great to know! Will try this out with deps.ts. Thanks!