BT

Facilitating the spread of knowledge and innovation in professional software development

Contribute

Topics

Choose your language

InfoQ Homepage News Deno Now Compiles to Self-Contained, Standalone Binaries

Deno Now Compiles to Self-Contained, Standalone Binaries

This item in japanese

Bookmarks

Deno 1.6 introduced the compilation of Deno projects into standalone executables, whose size Deno 1.7 further reduced (up to 60%). Deno now has a dedicated language server that seeks to improve the experience of Deno developers in code editors. Deno also added support for data URLs, enabling the execution of computer-generated code.

Deno 1.6’s release note explained the new compilation toolchain as follows:

deno compile does for Deno what nexe or pkg do for Node: create a standalone, self-contained binary from your JavaScript or TypeScript source code. This has been the single most upvoted issue on the Deno issue tracker.

Compiling Deno applications to self-contained binaries addresses the same use cases as Node or the Nectarjs JavaScript native compiler. Some developers for instance may want to make a closed-source commercial/demo/trial version of their application; deploy their application as a single file on a series of platforms; or incorporate assets inside the executable for portability purposes.

The release note provides an example of usage of the new compilation feature:

The Deno compiler can compile to any supported architecture (Windows x64, MacOS x64, and Linux x64) independently of the architecture used by the compiling computer. This means a Linux machine can create executables for Windows or MacOS. The --lite option (available in Deno 1.7) generates binaries that are 40-60% smaller. deno compile also creates binaries that have built-in CA certificates, custom V8 flags, locked-down Deno permissions, and pre-populated command line arguments. A few limitations apply, however. Deno compilation supports neither web workers nor dynamic imports.

Deno 1.6 introduced a new lsp subcommand that starts a language server implementing Language Server Protocol (LSP). LSP defines the protocol used between a code editor or integrated development environment and a language server to provide convenient features like code completion, go-to-definition, or linting. Currently, deno lsp implements code completion, hints on hover, go-to-definition, and go-to-references actions. The Deno VSCode extension does not yet support deno lsp.

Deno 1.7 adds support for data URLs. The following data URLs

data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=

encode in base64 the following TypeScript source code:

export  const a =  "a";

export  enum  A  {
  A,
  B,
  C,
}

The code encoded in the data URL can then be imported with the regular import syntax (import * as a from "data:application/typescript;base64,..."). The feature is particularly useful for executing dynamically-generated content. A similar feature is used to implement the interactive playground for the Svelte front-end framework. Source code entered in text areas by the user of the playground is preprocessed, bundled, imported through a URL object, executed, and displayed in the preview pane. Data URLs can also be used in web workers.

The release notes for Deno 1.6 and 1.7 detail additional minor features that are part of the release. Deno is open-source software available under the MIT license. Contributions are encouraged via the Deno Project and should follow the Deno contribution guideline.

We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.