-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't throw unreplaced macro
when running without Vite
#19
Comments
thanks, added a patch for 2.2.0 using your fix |
Originally, I hesitated to implement this feature since it felt like the error provided a base layer of safety. An alternative I thought of was to have Another option would be to have a So to summarize, I think you're right that a simple runtime check for Vite is the best approach. If you are using the Vite plugin, things continue to work the same way. If you aren't using the Vite plugin, there's no bundling going on so there's no module graph artifact to try to protect in the first place. |
I am using
serverOnly$
to ensure Vite doesn't bundle a function that's supposed to be executed on the server. But I actually also need to run that function in a simple Node.js script that doesn't use Vite. When I run my script, I get this error:So I propose that that error is only thrown when running via Vite.
Not sure if there's a better way to check, but possibly something like this:
The text was updated successfully, but these errors were encountered: