Improve documentation on how to import .server.ts and .client.ts files #1465
Unanswered
jjmoorhouse
asked this question in
Help & Questions
Replies: 1 comment
-
If you don't use If you use Also relevant: Let us know if And, yes, improved documentation is very much on the radar. |
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
-
Hi 👋
Raising an issue/discussion as couldn't find anything in the docs or solved issues.
We're currently evaluating Vike as an alternative to Nuxt 3. One of the biggest problems we're having with Nuxt 3 is how to separate clientside and server side code, which is one of the reasons we're evaluating Vike.
I've read the documentation on server.js + client.js files but it doesn't include information on how to import these files.
Expected behaviour:
This allows for custom behaviour, server logger will write logs to stdout and browser logger will send them directly to a log provider like datadog etc..
I've tried the following setup
gives
/logger/
-- index.ts
-- index.server.ts
/orders/
--+Page.vue
/logger/index.ts
const logger = console.log
export default isClient() ? logger : await import('./index.server')
// /orders/+Page.vue
import logger from '../logger'
[commonjs--resolver] [vike][Wrong Usage] Server-only module /logger/index.server.ts (https://vike.dev/file-env) imported on the client-side by /logger/index.ts.
Beta Was this translation helpful? Give feedback.
All reactions