Add a New Deno Project
Supported Features
Because we are using an Nx plugin for Deno, all the features of Nx are available.
✅ Run Tasks ✅ Cache Task Results ✅ Share Your Cache ✅ Explore the Graph ✅ Distribute Task Execution ✅ Integrate with Editors ✅ Automate Updating Nx ✅ Enforce Module Boundaries ✅ Use Task Executors ✅ Use Code Generators ✅ Automate Updating Framework Dependencies
Install the Deno Plugin
Have Deno already installed?Make sure you have Deno installed on your machine. Consult the Deno docs for more details
❯
npm i --save-dev @nx/deno
Create an Application
Use the app
generator to create a new Deno app.
❯
nx g @nx/deno:app deno-app
Serve the API by running
❯
nx serve deno-app
This starts the application on localhost:4200 by default.
Create a Library
To create a new library, run:
❯
nx g @nx/deno:lib my-lib
Deno library paths are maintained in the root import_map.json
file. Because typescript doesn't understand how to parse this file, you may get errors in your code editor that are not problems during build
or serve
.
Once the library is created, update the following files.
1export function someFunction(): string {
2 return 'some function';
3}
4
1import { someFunction } from '@my-org/my-lib';
2
3// deno-lint-ignore require-await
4export async function handler(_request: Request): Promise<Response> {
5 const message = JSON.stringify({
6 message: 'Hello deno-app ' + someFunction(),
7 });
8 return new Response(message, {
9 status: 200,
10 headers: {
11 'content-type': 'application/json',
12 },
13 });
14}
15
Now when you serve your app, you'll see the content from the library being displayed.