nksaraf / vinxi

The Full Stack JavaScript SDK
https://vinxi.vercel.app
MIT License
1.33k stars 57 forks source link

Error trying to use: __DEFINES__ is not defined #283

Open StringKe opened 2 months ago

StringKe commented 2 months ago

I'm wrapping up a tanstack-router based ssr framework (similar to nextjs)

Currently the javascript is not loading correctly in the browser (mine-type error or vite error)

repo: https://github.com/StringKe/qingmu

CleanShot 2024-04-12 at 02 00 01@2x

A guess about this error: the import in entry.client.tsx was not processed by vite and the content was returned uncompiled.

StringKe commented 2 months ago

Failed to resolve module specifier "pathe". Relative references must start with either "/", "./", or "../".

https://github.com/nksaraf/vinxi/blob/main/packages/vinxi/lib/path.js

Regarding this error I did not encounter it after I pulled vinxi locally and added my code to exmaples as a subproject.

CodeInKlingon commented 1 month ago

I'm running into this issue as well. Here is a repro for a vue ssr app. https://stackblitz.com/edit/vitejs-vite-flukcx?file=vite.config.ts Interestingly a nearly identical setup in just spa mode works just fine. https://stackblitz.com/edit/github-ewxdpx?file=app.config.js

CodeInKlingon commented 4 weeks ago

I've found a workaround but I'm not sure what the ramifications of it would be.

Add the vinxi config plugin import to your vinxi config file:

import { config } from 'vinxi/plugins/config';

in the client route under the vite plugins section add the config plugin like so:

plugins: () => [
    config('custom', {
        define: {
            __DEFINES__: '{}',
    },
    }),
    ...// the rest of your plugins
]