惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
腾讯CDC
P
Palo Alto Networks Blog
Spread Privacy
Spread Privacy
S
Schneier on Security
NISL@THU
NISL@THU
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
T
Threatpost
Scott Helme
Scott Helme
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
I
Intezer
C
Check Point Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cyber Attacks, Cyber Crime and Cyber Security
S
Securelist
Security Latest
Security Latest
大猫的无限游戏
大猫的无限游戏
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
云风的 BLOG
云风的 BLOG
量子位
T
Tor Project blog
博客园 - 叶小钗
The Cloudflare Blog
Simon Willison's Weblog
Simon Willison's Weblog
T
Tailwind CSS Blog
W
WeLiveSecurity
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Security Affairs
罗磊的独立博客
Know Your Adversary
Know Your Adversary
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
Help Net Security
Help Net Security
美团技术团队
P
Privacy International News Feed
The Hacker News
The Hacker News
Hugging Face - Blog
Hugging Face - Blog
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno Zero-config Debugging with Deno and OpenTelemetry | Deno Exploring Art with TypeScript, Jupyter, Polars, and Observable Plot | Deno Deno v Oracle Update 3: Fighting the JavaScript Trademark | Deno Build a custom RAG AI agent in TypeScript and Jupyter | Deno How to get deep traces in your Node.js backend with OTel and Deno | Deno toranoana.deno #20 登録受付中(2025年3月14日) | Deno Node just added TypeScript support. What does that mean for Deno? | Deno The Dino 🦕, the Llama 🦙, and the Whale 🐋 | Deno Publish a lint rule, get a prize | Deno Deno 2.2: OpenTelemetry, Lint Plugins, node:sqlite | Deno If you're not using npm specifiers, you're doing it wrong | Deno How Deno's documentation is evolving | Deno Oracle justified its JavaScript trademark with Node.js—now it wants that ignored | Deno Introducing the JSR open governance board | Deno Intro to Wasm in Deno | Deno Announcing OpenAI on JSR | Deno Deno in 2024 | Deno Goodbye WinterCG, welcome WinterTC | Deno Build a SolidJS app with Deno | Deno Run your Next.js SSR app on Deno Deploy | Deno Solve Advent of Code 2024 with Deno and Win Prizes! | Deno Deno v. Oracle: Canceling the JavaScript Trademark | Deno Deno 2.1: Wasm Imports and other enhancements | Deno Build a Typesafe API with tRPC and Deno | Deno Build a Database App with Drizzle ORM and Deno | Deno Introducing your new JavaScript package manager: Deno | Deno Announcing Growthbook on JSR | Deno Build an Astro site with Deno | Deno How to convert CommonJS to ESM | Deno Announcing Deno 2 | Deno The Final Touches: What’s New In v2.0.0-rc.10 | Deno Announcing Stable V8 Bindings for Rust | Deno Deno 2.0 Release Candidate | Deno Secure, efficient private npm registries with Cloudsmith and Deno | Deno Painting the Plane as We Fly It: Designing JSR | Deno Introducing Web Cache API support on Deno Deploy | Deno Deno 1.46: The Last 1.x Release | Deno Protect your cloud spend with new Deno Deploy spend limits | Deno What we got wrong about HTTP imports | Deno Benchmarking AWS Lambda Cold Starts Across JavaScript Runtimes | Deno Announcing Supabase on JSR | Deno Deno 1.45: Workspace and Monorepo Support | Deno Introducing KV Backup for Deno Subhosting | Deno A Gentle Intro to TypeScript | Deno Announcing Hono on JSR | Deno How We Made the Deno Language Server Ten Times Faster | Deno How the Guardian uses Deno to audit accessibility and performance across their 2.7 million articles | Deno Introducing More Flexible Domain Association for Deno Subhosting | Deno The stabilization process of the Standard Library has begun | Deno Deno 1.44: Private npm registries, improved Node.js compat, and performance boosts | Deno How we built a secure, performant, multi-tenant cloud platform to run untrusted code | Deno The Deno Standard Library is now available on JSR | Deno How to document your JavaScript package | Deno Your Low Code Solution Needs an Escape Hatch | Deno Deno 1.43: Improved Language Server performance | Deno How Slack used Deno to save months of engineering effort in launching their new platform | Deno JSR Is Not Another Package Manager | Deno Announcing the Hookdeck SDK on JSR | Deno Announcing the Neon Serverless Driver on JSR | Deno An intro to TSConfig for JavaScript Developers | Deno How we built JSR | Deno How Netlify used Deno Subhosting to build a successful edge functions product | Deno Introducing Simpler Project Creation in Deno Deploy | Deno Deno 1.42: Better dependency management with JSR | Deno Introducing deployctl, the command line interface for Deno Deploy | Deno Introducing JSR - the JavaScript Registry | Deno How to add Monaco to a Next.js app and securely run untrusted user code | Deno Survey Results and Roadmap | Deno Deno 1.41: smaller deno compile binaries | Deno Webhooks suck, but here are alternatives | Deno
Self-contained Executable Programs with Deno Compile | Deno
2024-11-14 · via Deno

Since Deno v1.6, the deno compile command has empowered developers to turn JavaScript and TypeScript programs into single, standalone binaries that run on all major platforms—no dependencies, no additional installs. This has big implications:

  • Cross-platform compatibility: Distribute a single binary that works without a Deno runtime or dependencies.
  • Bundled assets: Package everything your app needs inside the binary for easy portability.
  • Streamlined deployment: Ship one binary to production, reducing complexities.
  • Improved startup times: Faster launch times compared to typical server or runtime setups.

Since Deno 2, we’ve introduced even more improvements to deno compile, like support for npm packages, web workers, cross-compilation, smaller binary sizes, and code signing with custom icons. These upgrades mean you can now compile not only scripts but also complete applications like desktop games directly to native binaries.

In this post, we’ll explore what makes deno compile unique, how it works, and examples of different use cases that highlight its advantages over alternatives in the ecosystem.

🚨️ Deno 2 is here. 🚨️

With backwards compatibility with Node/npm, built-in package management, all-in-one zero-config toolchain, and native TypeScript and web API support, writing JavaScript has never been simpler.

What is deno compile?

Deno offers a zero-config toolchain for JavaScript and TypeScript, so you don’t need to cobble together different tools before writing a single line of code. One subcommand is deno compile, which lets you build a single binary from your JavaScript or TypeScript code. And unlike Node’s 8-step compilation process, deno compile is just one command.

This subcommand lets you skip install requirements and run binaries on systems without Deno installed, across platforms like Windows, macOS, and Linux. Deno’s compiled binaries are also optimized for size. If you’re coming from Node, this simplicity reduces friction when moving code between environments, especially when cross-compiling for different OS targets.

How deno compile works

Though it’s called “compile,” deno compile doesn’t compile JavaScript in the traditional sense. Instead, it embeds your JavaScript and TypeScript into a special Deno runtime binary, called denort (short for “Deno runtime”).

Here’s a high-level overview of the process when you execute deno compile:

  1. A slimmed-down version of the runtime, denort, is downloaded. If you’re cross-compiling for a different operating system, the denort for that platform is downloaded.
  2. Your script, along with any dependencies, is bundled to an eszip file, a lossless format for serializing an ECMAScript module graph.
  3. The bundle is injected into the denort binary using Sui.

By embedding the bundle into a section of the executable, the outputted binary can still be codesigned.

Examples

Basic self-contained binary

To start, let’s look at how easy it is to create a single executable from a TypeScript script.


import open from "jsr:@rdsq/open";

await open("https://www.youtube.com/watch?v=dQw4w9WgXcQ");

Compiling it is as simple as:

deno compile -A -o runme main.ts

This outputs an executable binary (runme) that includes all required dependencies. Now you can share this single file on any platform, without requiring the end user to install Deno.

Note that you can pass opt-in permission flags, such as --allow-net, in the deno compile command. The permission flags will then be preserved in the compiled binary, giving you an added layer of security over how your binary can be used.

Cross-compiling for Windows

Say you want to share the app with a Windows user. Using the --target flag, you can cross-compile it for Windows:

deno compile --allow-all -o runme --target x86_64-pc-windows-msvc main.ts

Now you’ve got runme.exe, a Windows-compatible binary. You can even add a custom icon with the --icon flag for a more polished look:

deno compile --allow-all -o runme --target x86_64-pc-windows-msvc --icon icon.ico main.ts

Code signing

Code signing ensures that your binary is verified and trustworthy, which is critical for software distribution. Deno simplifies this, even on macOS, where you can use codesign as with any other app.

Let’s confirm our binary’s integrity:

codesign --verify -vv ./runme
./runme: valid on disk
./runme: satisfies its Designated Requirement

The binary we compiled is properly code signed and ready for publishing.

Compiling NPM packages

Of course it’s possible to use NPM packages with deno compile. This approach is ideal for performance-sensitive CI environments or when you need a single portable version of a tool.

As an example, let’s use deno compile on npm itself:

Running the compiled npm binary is simple, and it even shows performance boosts. In tests, Deno-compiled npm binaries ran ~1.9x faster than regular npm:

# hyperfine "./npm -v" "npm -v"
Benchmark 1: ./npm -v
  Time (mean ± σ):      40.1 ms ±  2.0 ms    [User: 37.7 ms, System: 5.3 ms]
  Range (min … max):    38.9 ms … 51.8 ms    71 runs

Benchmark 2: npm -v
  Time (mean ± σ):      75.2 ms ±  7.6 ms    [User: 59.1 ms, System: 9.0 ms]
  Range (min … max):    69.2 ms … 105.0 ms   40 runs

Summary
  ./npm -v ran
    1.87 ± 0.21 times faster than npm -v

This approach works with other popular npm tools too, like prettier and eslint, giving you faster, more portable versions.

Games and Desktop apps

deno compile also opens up the potential for bundling web-based games and apps as native desktop executables. For example, you could take an HTML/CSS/JavaScript game and turn it into a binary that’s easy to share and launch on any desktop.

Watch the video demo of bundling HTML games with deno compile.

Take a look at this Flappybird clone, which can be compiled into a desktop app using Deno:

deno compile --unstable-ffi --env -o flappybird -A main.js

Bundling assets

Though deno compile doesn’t currently support bundling assets directly (yet!), it’s possible to convert .png or other asset files into base64-encoded .js files and import them into your project, allowing them to be included in the final binary. This method, while a workaround, enables developers to package games and other assets in a single executable.

What’s next

We’re continually improving deno compile based on your feedback, with updates on the way to streamline asset bundling, support more frameworks like Svelte, reduce binary sizes, and improve startup times even further with caching.

🚨️ Want to learn more Deno? 🚨️

Check out our new Learn Deno tutorial series, where you’ll learn:

…and more, in short, bite-sized videos. New tutorials published every Tuesday and Thursday.