netzo / fresh-netzo

Full-stack Deno Fresh meta-framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
https://netzo.io
MIT License
51 stars 3 forks source link

[deps] improve deno.json generation in templates #86

Closed deer closed 9 months ago

deer commented 9 months ago

What you have right now in your two deno.json files in the templates is not a scalable or correct solution. You have "netzo/": "../../../netzo/lib/", hardcoded, but this is undefined on the average user's computer.

Instead you need to do something similar to what fresh does. See https://github.com/denoland/fresh/blob/d19c22d5921bdf21de9a7d7bc043b8523ac81893/src/dev/imports.ts#L10 for details:

export function freshImports(imports: Record<string, string>) {
  imports["$fresh/"] = new URL("../../", import.meta.url).href;
  imports["preact"] = `https://esm.sh/preact@${RECOMMENDED_PREACT_VERSION}`;
  imports["preact/"] = `https://esm.sh/preact@${RECOMMENDED_PREACT_VERSION}/`;
  imports["@preact/signals"] =
    `https://esm.sh/*@preact/signals@${RECOMMENDED_PREACT_SIGNALS_VERSION}`;
  imports["@preact/signals-core"] =
    `https://esm.sh/*@preact/signals-core@${RECOMMENDED_PREACT_SIGNALS_CORE_VERSION}`;
}

That way, even if I run the cli remotely, it should still manage to install correctly. (I agree the entire templating story in fresh could be improved, since it's basically non-existent!)

miguelrk commented 9 months ago

My bad, I usually change it to "netzo/": "../../../netzo/lib/" during development and it apparently slipped through to production. It should point to a pinned absolute version e.g. "netzo/": "https://deno.land/x/netzo@0.4.12/". However, with regards to codegen, a dynamic approach like the one you point to from fresh might be beneficial, especially once netzo add lands, which should handle include proper dependencies management (although it is not strictly required in its initial implementation).

miguelrk commented 9 months ago

Just released a patch release 0.4.15 with a fix... keeping this open to track how to best handle dependencies going forward, https://jsr.io might be relevant here...