Open andrea-benato-deltatre opened 1 month ago
I get that the error is related to the fact that the library exposes exports using react-server
Yup, that's the problem. These functions do, in fact, not exist in the node
or browser
environments, which vite
seems to assume here.
My first idea would be to tell vite in some way that @apollo+experimental-nextjs-app-support
is external and should not be packaged. That might already keep it from looking at it and complaining about it.
If that's not working, you might have to compile the file in question with a react-server
condition. If you have code that relies on node
or browser
features, that means that you'll have to split it up and compile it twice.
I believe the way of doing that would be a vite config like this:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
resolve: {
conditions: ["react-server"],
},
});
HI! I'm creating a library to wrap some precofigured hooks/funcs for my application. Building it using vite I have this error while trying to import registerApolloClient:
Do you have any idea how to solve it? (I get that the error is related to the fact that the library exposes exports using
reasct-server
)