4 ms·
> import express from "npm:express@5"; > There will be no node_modules folder, no npm install; the packages will be automatically downloaded in the Deno cache.
by wokwokwok 4y ago
> import express from "npm:express@5";
> There will be no node_modules folder, no npm install; the packages will be automatically downloaded in the Deno cache.
My understanding of deno's package system (see https://deno.land/manual/linking_to_external_code#it-seems-unwieldy-to-import-urls-everywhere https://deno.land/manual/linking_to_external_code#it-seems-u...), is that basically, at compile time it will go and fetch external URLs and cache those files locally. So this change basically makes it so your import:
> import { assert } from "https://deno.land/std@0.152.0/testing/asserts.ts https://deno.land/std@0.152.0/testing/asserts.ts";
Is magically generated from npm when you do this instead:
> import { assert } from "npm:testing@2.0.1";
Ok cool. Whatever.
...surely this isn't the actual problem?
There seem to be certain pretty fundamental problems:
- not all npm packages are typescript
- a package is not just an 'assert.ts' file, it's often an amalgamation (eg. using rollup)
- a package often has many dependencies
- a package may use the node API, that deno doesn't have (it has a more-or-less compatibility mode, see 'differences that cannot be overcome' -> https://deno.land/manual/node https://deno.land/manual/node)
So bluntly, how on earth is this going to work?
I mean, I'm a fan, the folk working on Deno are smart and motivated, and if it works, I'm more 'wow' than 'I don't believe it'... but I'm very surprised to see:
> the vast majority of npm packages work in Deno within the next three months
That seems... ambitious.
I can't see how the approach is really sustainable, given that basically, it means 'anything node supports we have to support to'; doesn't that mean you're forever playing catchup and 'doesn't quite work'?
How is vendoring going to work without a package lock file? Doesn't this just mean you've reimplemented npm and you'll forever be playing catchup to the various npm features that are required to make packages work?
- frenchman99 4y ago> not all npm packages are typescript All Javascript is Typescript isn't it?
- georgyo 4y agoAll typescript is JavaScript, not all JavaScript is typescript.
- geysersam 4y agoNope. From the docs: > Typescript is a strict syntactical superset of JavaScript Typescript contains more than JS. But all JS is valid Typescript.
- lioeters 4y agoI think you mean the other way around. TypeScript is a superset of JavaScript. Most TS is not valid JS, but all JS is valid TS.
- deckard1 4y agoLooking at it in terms of sets is not really useful because the utility of TS is to exclude invalid behavior. JS allows many things which are not permissible in TS. Semantically, not syntactically. And TS can't infer a number of things such as higher-order functions. So you either have external definitions for those libraries, give up and type it "any" (and taint your entire code base), or have errors which means you can't use the JS library with your TS code base. Or to put it another way, JS is only a subset of TS in as far as you're willing to forgo the benefits of TS.
- jsmith45 4y agoYou overestimate many of these difficulties. The --compat mode can already run quite a bit of the node ecosystem, including programs like npm. Imports don't need to be written in typescript. They could have manually written type definitions (which is how people using typescript in the node ecosystem already handle this), and packages without type definitions will have the imports typed as `any`. Sure that makes them a bit annoying to handle especially in strict mode, but it entirely possible to use such packages. Deno is actually working on adding the native node API (https://github.com/denoland/deno/pull/13633 https://github.com/denoland/deno/pull/13633), so the website was a bit overoptimistic when saying "Deno will never support Node plugins". However it is possible for some plugins to be incompatible still, for example if they try to use node internals rather than just the API, or if they try to use utilize the libuv event loop, since deno is not libUV based.
- qbasic_forever 4y agoDeno runs both JS and TS. It still uses V8 internally, but with a rust wrapper around it that does TS conversion and more.