Bundle, Compile and Install Scripts

Discover Deno's built-in functions that allow us to easily group multiple files into a single bundle or executable script.

Deno offers a set of instructions to simplify common and repetitive operations. These built-in functionalities are useful during the development process and when we are ready to deploy to production.

Bundling

Bundling is an optimization technique typical of web development, used to reduce the number of server requests for JavaScript, CSS, or other assets. The bundling process attempts to merge multiple files into a single JavaScript file.
Deno features bundling capabilities through the following command:

deno bundle [OPTIONS] <source_file> [<output>]

Since version 1.5, tree-shaking capabilities have also been added. Tree shaking allows the user to detect and remove unused code from the output. The result is that the produced bundle is smaller and contains only what is used effectively by our application.
We can specify a module as input and an (optional) file name for the output that, if not provided, is sent to stout. The bundle command automatically downloads and groups the dependencies used by the input module.

Below is a terminal widget where Deno is already installed. Let’s enter the instruction: deno bundle --help in the widget to display all available options for the bundle command.

Get hands-on with 1400+ tech skills courses.