Closed BenjaminLesne closed 9 months ago
@BenjaminLesne it looks like this is related to #41. The error is happening because the built library has an object called something like ie.process.env.MODE
, and that object is then partially replaced by the plugin as something like ie."development"
which is invalid. I still need to come up with a solution, but I have a better idea of the cause now.
I think this static replacement might be the cause. https://vitejs.dev/guide/env-and-mode.html#production-replacement
@davidmyersdev yeh I saw the Production Replacement thing from vite then I found this
It looks like this related to rollup (see this answer)
I have a react app with the lib mode activated in my vite config. I use
import.meta.env.mode
then build the app. When I use the library in an other app I get :Uncaught SyntaxError: Unexpected string
reproducible example repo
steps to reproduce: 1- install dependencies
2- build the library :
3- In main.jsx, uncomment line 4 and comment line 3
4- start the dev server
5- check the console in Chrome
Uncaught SyntaxError: Unexpected string
and the webpage shows nothingExpected behaviour : The web page displays "yay production" in prod and "not production" in dev mode.
I reproduced it with a Firefox and Chrome.