“`html
Deno 2.3: What’s New and Why It Matters (In Plain English!)
Hey everyone, John here! We’re diving into the latest update for Deno, which is now at version 2.3. Don’t worry if you’ve never heard of Deno before – we’ll break it all down. This update is all about making things easier for developers, especially when it comes to creating and sharing their programs.
Making Programs “Self-Contained” with Deno Compile Improvements
One of the coolest things about this update is the improvements to something called “deno compile.” Think of “deno compile” like a magic tool that packs up your program and all its necessary bits and bobs into a single, neat little package. This means you can share your program with anyone, and they can run it without needing to install Deno or any extra stuff!
This update makes that “packing” process even better. Now, “deno compile” can handle programs that use special tools called “Foreign Function Interface (FFI)” and “Node native add-ons.”
Lila: John, what on earth are “Foreign Function Interface” and “Node native add-ons”?
John: Great question, Lila! Imagine you have a Lego set (your Deno program), but you want to add some pieces from a different building set (another programming language, like C++). “Foreign Function Interface (FFI)” is like an adapter that lets those different pieces connect and work together. “Node native add-ons” are similar – they’re like special Lego pieces made specifically for another system (Node.js) that you can now use in your Deno creation.
The update also lets you exclude certain files from being included in the final package. It’s like being able to say, “I want everything in this suitcase except for my socks.” This gives developers more control over what gets included in their final program.
Knowing When Your Program is “Self-Contained”
Deno 2.3 introduces something called Deno.build.standalone
. This is basically a way for your program to know if it’s running as a self-contained package or not. Why is this useful?
Well, imagine you’re building a program that displays a special message. If it’s running as a self-contained package, you might want to show a different message than if it’s running in a development environment. Deno.build.standalone
lets you do just that!
Using Local NPM Packages: Testing Made Easier
Another great addition is the support for local NPM packages. Now, before I explain this, Lila has a question:
Lila: John, what’s an NPM package?
John: Good one, Lila! Think of NPM packages like pre-built modules or tools that programmers can easily add to their projects. It’s like buying a pre-made wheel for your car instead of having to build one from scratch. NPM (Node Package Manager) is a system for sharing and using these packages.
So, with this new Deno update, developers can now test and develop NPM packages directly on their computers before publishing them. This makes the testing process much easier and faster.
To use these local NPM packages, you’ll need a node_modules
folder. You can set this up automatically or manually. If you choose the manual option, you’ll need to run deno install
each time you update the local NPM package.
Other Cool Features in Deno 2.3
But wait, there’s more! Deno 2.3 comes with a bunch of other improvements, including:
- Better formatting: Deno can now format different types of code (like CSS, HTML, and SQL) embedded within your JavaScript or TypeScript code. This keeps your code looking nice and tidy.
- Easier package installation: You can now install packages from NPM and JSR (another package registry) more easily using special flags.
- Improved performance: Installing dependencies is now faster, especially when you’ve already downloaded them before.
- Security boost: The Deno program is now signed on Windows, which means Microsoft Defender will trust it more. This prevents those annoying security warnings.
- Better VS Code integration: If you use Visual Studio Code (a popular code editor) with Jupyter notebooks, this update improves the experience by ensuring that things like variables and type definitions are shared between different parts of your notebook.
- Upgraded Technologies: Deno 2.3 uses the latest versions of TypeScript (version 5.8) and V8 (version 13.5), which means you get access to new language features and better performance.
How to Get Deno 2.3
Want to try out Deno 2.3? You can find installation instructions on the Deno website. If you already have Deno installed, you can upgrade by running deno upgrade
in your terminal.
Final Thoughts
This Deno update seems really focused on making the lives of developers easier, especially when it comes to sharing and testing their code. The improved “deno compile” and local NPM package support are particularly useful. It’s great to see the Deno team constantly improving the developer experience.
Lila: As someone just starting to learn about this stuff, it’s helpful to see how these updates are trying to simplify things. It still sounds a bit complicated, but I can understand the basic ideas!
This article is based on the following original source, summarized from the author’s perspective:
Deno 2.3 adds compile improvements, support for local NPM
packages
“`