Closed sudokzt closed 4 years ago
Hi @sudokzt 👋
You are correct - the current Deno precedent is to use a file called deps.ts
as a place to write all of your imports of third-party modules so they can be managed from a central location. This can have benefits such as being a single place to upgrade dependencies (instead of all over your code), and is also support by tools such as the nest.land eggs CLI.
However, you don't have to be limited to this style of doing imports - it is simply something the community has adopted, likely because they are used to having a single place from Node.
As an alternative, some people are instead making use of Deno's import maps which is probably even more like using a package.json
!
In the case of these examples, given they were relatively simple I did not worry with creating a deps.ts
, instead just inlining the imports into the files that they are needed. If you prefer the deps.ts
way of doing things then by all means use that in your code 😄 In fact, we use a deps.ts
in the main Opine code!
If you're interested in a different perspective, there is also a good article by @wongjiahau which raises valid concerns on how a single mod.ts
and deps.ts
could actually be bad for your project. Specifically, it can really hurt start-up performance because although a file may only want to import a single module, Deno will end up compiling all modules referenced in the file!
For now I don't intend to spend the time updating the examples to use a deps.ts
, but am very open to pull requests if you feel strongly that the examples should be using one 😄
Going to close for now - happy to re-open if have further questions / feel strongly etc. 😄
Issue
This issue is question.
Why don't you use
deps.ts
for React and so on?Details
I looked at Craig's nice entry. Then I looked at this source in the repo. https://github.com/asos-craigmorten/opine/blob/main/examples/react/server.tsx
If the
deps.ts
seems to have the role ofpackage.json
, you can write following intodeps.ts
.import { renderFileToString } from "https://deno.land/x/dejs@0.7.0/mod.ts";
import React from "https://dev.jspm.io/react@16.13.1";
Am I wrong?