-
Notifications
You must be signed in to change notification settings - Fork 3
[core] improve dynamic import in lib/mod.ts #85
Comments
Interesting, I thought the type errors during development where caused by the limited support of Deno LSP for monorepos, because types do work when outside of the monorepo setup... I'll see how to fix this, since this still requires that users set a That being said, and in spirit of our recent discussions @deer, it might be best to return to the default fresh project structure with a 1) split import { auth } from "netzo/core/auth/mod.ts"
import { api } from "netzo/core/api/mod.ts"
export default defineConfig({
plugins: [
auth({...}),
api({...}),
]
}); 2) split but import from barrel file for DX convenience import * as netzo from "netzo/core/mod.ts"
export default defineConfig({
plugins: [
netzo.auth({...}),
netzo.api({...}),
]
}); 3) unified import * as netzo from "netzo/core/mod.ts"
export default defineConfig({
plugins: [
netzo({
auth: {...},
api: {...},
})
]
}); Anyways, thinking about it, simplifying the project structure should ideally be done at fresh-land. I know the Update: created https://github.com/netzo/netzo/issues/92 to track this |
On the monorepo front, I guess the issues to watch are:
But I think this is a slightly different issue. The solution here might be to convert away from a statically-analyzable dynamic import, and instead bury it behind a variable: const importLocation = "@/fresh.gen.ts";
return start((await import(importLocation)).default, config); The issue here is not that this file should be governed by a different The above change will at least keep the type checker happy, since it no longer tries to look for the import at the nonexistent |
Reopening since I was forced to revert (70f9aa3, patch release return start((await import("@/fresh.gen.ts")).default, config); since this fix was throwing deploytime issue
For reference, the following attempts did resolve the type error, but threw the same deploytime error: const importLocation = "@/fresh.gen.ts";
return start((await import(importLocation)).default, config);
const url = new URL("./fresh.gen.ts", Deno.mainModule);
return start((await import(url.href)).default, config);
const manifestURL = import.meta.resolve("@/fresh.gen.ts");
return start((await import(manifestURL)).default, config); This type issue should be solved in a way that does not break deployments. This makes me wonder if going back to a plugin-first approach by mounting |
Hi @miguelrk, sorry about that. Can you provide more details on what deployment is? It works just fine on my laptop, so it'd be great to learn more about this environment in order to properly fix this. |
Sure! This happens when running The unfortunate thing for this issue is that it's more cumbersome to test, since it requires to make changes, create a new release (that's why I created several path releases earlier today 😆), and redeploying. |
In https://github.com/netzo/netzo/pull/84 I commented out the import, since it's breaking type checking. I think you need to come up with a new way to do this. I guess the intent is to use this in client projects, where
@/
is defined in the import map, but what you currently have throws errors for developers developing netzo.The text was updated successfully, but these errors were encountered: