Open egoist opened 5 years ago
their difference in appearance?
How about those rely on Node's core API?
@motss via polyfills, path
url
and some other core modules can be shimmed easily. Deno may not have all the APIs that we have in Node.js, we can try to support as many as possible.
Sounds interesting. Considering that Deno has a different security model would the compiler or whatever is generating the code be aware of this? Or are you thinking of making the generated code "less secure" by being permissive (--allow-all
)? Just curious if you have thought about it.
@scanf The generated code should work the same as normal Deno code, Deno will only ask for permissions when needed.
How about working with the package author to support Deno?
@motss that's like working with the package author to support TypeScript 😂which won't work since not everyone has the time / interest in doing so.
denoify ./index.js -o ./dist/index.js deno dist/index.js # it works
Which is more or less same as:
npx webrunify ./index.js > ./dist/index.js
deno dist/index.js
Where webrunify
is bundler made on top of browserify that produces ES module bundles in rollup like fashion: https://github.com/brechtcs/webrunify
However, bundling stuff together is an easy part. Next wall you'll gonna hit is unfortunate fact that your compiler can't produce bundles that are guaranteed to pass typescript's type checking. That is important because deno
forces type checking of js files (aka your resulting bundle): https://github.com/denoland/deno/blob/9dfebbc/js/compiler.ts#L162 (docs)
So you essentially need to prepend your bundle with // @ts-nocheck
pragma :weary:
There is also webpack powered PoC: https://github.com/reggi/node-to-deno
Also let me point you to two related deno
issues/discussions:
Discussion: Use of NPM modules within deno https://github.com/denoland/deno/issues/1397
No typing check for js files https://github.com/denoland/deno/issues/1432
But I'm just a reader who did few local tests, @reggi knows all nasty details and what is needed here is his expertise :neckbeard:
Problem
There are many great Node.js libraries that are also useful in Deno ecosystem, it would be a waste of time to reinvent the wheels from scratch for Deno.
Solution
Creating a compiler, probably on top of webpack, to generate Deno-compatible code from Node.js code.
👍 If you like this idea