We will build our first server in Deno
One of the considerations for any module written in Deno is whether it is best
to have one central dependency file, or if each file should only import the
respectively needed modules. There are pros and cons with both ways, and I use
either depending on the situation. Most libraries you come across will most
likely have one
deps.ts to keep versioning simple across the codebase.
Deno also supportsimport maps but these are more often used by applications, and you will most likely never see them being used in modules.
For the sake of this lesson, we will create a separate
deps.ts file so that
you can get comfortable with importing local files.
Create a new folder (you can name it after the title of this page) and add two
main.ts. In the last step, we added the imports to our
main.ts, but this time we will add the external imports into our
Add the following imports to
Notice that we are using
importto export the values to our other files.
Now it is time to create the server. Now that we have all our dependencies in
deps.ts, we can import them from there. We start by adding
to our imports in
main.ts file should now only have one line