Replies: 4 comments 1 reply
-
/cc @antfu maybe will be better to move it to issues as enhancement? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I mean something like this: // main.ts
export const createApp = ViteSSG(
App,
{ routes },
(ctx) => {
// install all modules under `modules/`
const isClient = { cxt }
if (isClient)
Object.values(import.meta.globEager('./modules/*!(-server).ts').map(i => i.install?.(ctx))
else
Object.values(import.meta.globEager('./modules/*!(-client).ts').map(i => i.install?.(ctx))
},
) |
Beta Was this translation helpful? Give feedback.
0 replies
-
This should work in any case (if the glob patterns are ok, the negated ones): just update also the |
Beta Was this translation helpful? Give feedback.
0 replies
-
will not work |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To avoid
window is undefined
errors, it would be useful if we split modules into 3 ways to import them frommain.ts
module:modules/*.ts
: client and server side modulesmodules/client/*.ts
: only for modules running on client sidemodules/server/*.ts
: only for modules running on server sideMaybe we can do something similar to
nuxt
(and so, we don't need to add client and server directories), for example*-client.ts
for client modules,*-server.ts
for server side modules, and all not ending with-client.ts
or-server.ts
will run on client and server side.With this new approach, then the user just forget the
isClient
avoiding dynamic imports.Beta Was this translation helpful? Give feedback.
All reactions