Live data from Hacker News

Deno 1.6 supports compiling TypeScript to a single executable

github.com

51–60 of 284 posts

Re: Deno 1.6 supports compiling TypeScript to a single executable

#51
post #29

I've been using vercel/pkg with great success, in order to achieve a similar target and package a whole application into a standalone executable: https://github.com/vercel/pkg This can be useful for people wanting to do this with Node. It's nice to have a single file that can be started right away without any external dependency. And also, it prevents from having to distribute the full sources. Kudos to the Deno devs…

I'm not very familiar with Deno but I wonder how deno compile compares to pkg when it comes to native modules.

One of my gripes with PKG (and all other node.js packaging tools) has been that it's a pain in the ass to package when your dependency includes a native module, for example SQLite.

Since Deno has a different architecture and works in different ways, thought I would ask just in case there's a solution for this on Deno, that would be great.

Re: Deno 1.6 supports compiling TypeScript to a single executable

#52
post #36

Node is almost perfectly matched to the "Oops, well, too late now" design ethos of JavaScript itself. Nobody was stupid. We humans just can't really predict what will work out and what won't in the future, and this was one of those frustrating cases like carving in stone, where every mistake you make is permanent. But a combination of various factors made the web an enormously impactful medium. It's too important to…

> Node is almost perfectly matched to the "Oops, well, too late now" design ethos of JavaScript itself.

Anything even remotely successful has to commit to its previous choices, even when they were unfortunate (did anybody say C++?).

One of the reasons why Node had the impact it had was that it used plain JS and committed to supporting the standard language.

I myself prefer writing in statically-typed languages, but the JS direction is frankly commendable; ES6 looks nothing like OG JS, and the fact you can run basically the same code on the browser and on node is a massive bonus.

With that said, I hope Deno succeeds as well, having more choices is a good problem to have!

Re: Deno 1.6 supports compiling TypeScript to a single executable

#53

Hey, Bartek from deno.land here. I'll be more than happy to answer your questions about Deno and its development.

OK, so what is Deno? How is it different from Node? Why did you make Deno given that Node exists? Looks like Deno can run .ts files without first compiling to .js. What are the other benefits?

Deno is a JavaScript runtime much like Node. For the reasons on why creating Deno I recommend "10 Things I Regret About Node" by Deno's author [1]

Deno is different than Node in several aspects; most notably:

- Deno supports only ES modules, there's no built-in support for CommonJS modules

- Deno's APIs are all promised based

- Deno does not use NPM, instead it can pull code from any URL, much like browsers do

- Deno has built-in permission system that by default runs your code in full sandbox allowing to opt-in into breaking out of sandbox (eg. to read a file from disk)

- As you've mention Deno can run .ts files without explicit build step

- Deno comes with a full toolchain in a single binary (formatter, linter, test runner, bundler, doc generator)

[1] https://www.youtube.com/watch?v=M3BM9TB-8yA

Re: Deno 1.6 supports compiling TypeScript to a single executable

#54
post #5

Does this offer a speed increase vs running the the code directly using $ deno test.js ( not sure what the exact command is )

Not really, I think. Startup of a "hello world" seems to be 5ms faster on my Windows machine: https://gist.github.com/MarkTiedemann/c2f4013c3a60bb28df5005...

What's up with the page faults in the timing details?

Re: Deno 1.6 supports compiling TypeScript to a single executable

#55
post #29

I've been using vercel/pkg with great success, in order to achieve a similar target and package a whole application into a standalone executable: https://github.com/vercel/pkg This can be useful for people wanting to do this with Node. It's nice to have a single file that can be started right away without any external dependency. And also, it prevents from having to distribute the full sources. Kudos to the Deno devs…

I'm using vercel/pkg as well. I have a Node.js server which generates HTML and opens a browser on Windows which then asks the server for that html at 127.0.0.1. So browser will be my GUI and Node.js packaged with vercel/pkg my back-end. It is more flexible than say Electron because GUI can be anything I want it to be. My concern is only will users accept a local server running on their desktop. I've tried to configur…

Do you have any trouble with the users being prompted by the Windows firewall to allow the server to listen on localhost? I like this way of doing things but I've had propmts like that for my own dev tools and I think that would put off my users.

Re: Deno 1.6 supports compiling TypeScript to a single executable

#56
post #36

Node is almost perfectly matched to the "Oops, well, too late now" design ethos of JavaScript itself. Nobody was stupid. We humans just can't really predict what will work out and what won't in the future, and this was one of those frustrating cases like carving in stone, where every mistake you make is permanent. But a combination of various factors made the web an enormously impactful medium. It's too important to…

TBF, on the browser side, they have been slowly fixing some of the worst "oops" stuff. First they added "strict mode" and now they have type="module", both of which turn off a lot of bad behaviors. Deno is kind of like that for the backend.

Re: Deno 1.6 supports compiling TypeScript to a single executable

#57

Earlier quoted context omitted.

That really depends on concrete package; a lot of npm packages works perfectly fine in Deno, especially if they're available via CDNs like Skypack. For packages that use native Node APIs there's a Node compatibility layer being developed as part of the standard library: https://deno.land/std@0.80.0/node . It's still lacking a lot of modules and doesn't provide seamless experience, but with every release it's getting…

Thanks, that's useful info, we'll probably wait until there's >90% compatibility with the node APIs then. We're never going to put URLs into our imports because we want to be able to run things offline without depending on 3rd party servers to stay up & consistent over time, but if we can depend on local ./node_modules libs once compatibility is improved then that's great.

why not use artrifactory or similar proxy so you always have a local mirror?

Re: Deno 1.6 supports compiling TypeScript to a single executable

#58
post #29

I've been using vercel/pkg with great success, in order to achieve a similar target and package a whole application into a standalone executable: https://github.com/vercel/pkg This can be useful for people wanting to do this with Node. It's nice to have a single file that can be started right away without any external dependency. And also, it prevents from having to distribute the full sources. Kudos to the Deno devs…

I'm using vercel/pkg as well. I have a Node.js server which generates HTML and opens a browser on Windows which then asks the server for that html at 127.0.0.1. So browser will be my GUI and Node.js packaged with vercel/pkg my back-end. It is more flexible than say Electron because GUI can be anything I want it to be. My concern is only will users accept a local server running on their desktop. I've tried to configur…

> It is more flexible than say Electron because GUI can be anything I want it to be.

Feels like one of us is misunderstanding something. Electron lets you run any web technology - so when users open your app, they are greeted with whatever you can show on a webpage.

You can also have Electron run in the background as a server if that's something you're into ;)

Re: Deno 1.6 supports compiling TypeScript to a single executable

#59
post #29

I've been using vercel/pkg with great success, in order to achieve a similar target and package a whole application into a standalone executable: https://github.com/vercel/pkg This can be useful for people wanting to do this with Node. It's nice to have a single file that can be started right away without any external dependency. And also, it prevents from having to distribute the full sources. Kudos to the Deno devs…

I'm not very familiar with Deno but I wonder how deno compile compares to pkg when it comes to native modules. One of my gripes with PKG (and all other node.js packaging tools) has been that it's a pain in the ass to package when your dependency includes a native module, for example SQLite. Since Deno has a different architecture and works in different ways, thought I would ask just in case there's a solution for thi…

Yes, packaging a binary dependency can be problematic. I guess it depends on how easy the library puts it to import the binary in a compatible way (with the mechanisms that are expected by pkg)

Re: Deno 1.6 supports compiling TypeScript to a single executable

#60

Earlier quoted context omitted.

That really depends on concrete package; a lot of npm packages works perfectly fine in Deno, especially if they're available via CDNs like Skypack. For packages that use native Node APIs there's a Node compatibility layer being developed as part of the standard library: https://deno.land/std@0.80.0/node . It's still lacking a lot of modules and doesn't provide seamless experience, but with every release it's getting…

Thanks, that's useful info, we'll probably wait until there's >90% compatibility with the node APIs then. We're never going to put URLs into our imports because we want to be able to run things offline without depending on 3rd party servers to stay up & consistent over time, but if we can depend on local ./node_modules libs once compatibility is improved then that's great.

> We're never going to put URLs into our imports because we want to be able to run things offline without depending on 3rd party servers to stay up over time, but if we can depend on local ./node_modules libs once compatibility is improved then that's great.

You can achieve the same thing with Deno! By default Deno downloads all dependencies into a central cache directory, but by providing DENO_DIR env variable with a path you can tell Deno to change that cache dir. And these files are cached indefinitely; Deno will not try to fetch them again on next run (unless you opt into it with --reload flag).

Post reply on HN