-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fix Vite support #92
Fix Vite support #92
Conversation
@jaclas Can you check if this branch fixes your issue? |
Codecov Report
@@ Coverage Diff @@
## main #92 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 146 146
=========================================
Hits 146 146
Continue to review full report at Codecov.
|
I checked, everything works, thank you very much! |
Thank you, @jaclas. Just curious, but how did you test that this branch fixed your issue? |
@jorgebucaran Damn... I installed colorette with npm, did a quick test, saw the color changes in the console (bash) and wrote that it was ok. Sorry for the rush, didn't want to block the issue and hence too superficial check. |
Okay, so are we positive that this fixes the Vite issue? Just want to make sure. |
@jaclas Can you try solution from facebook/create-react-app#12212 and report back if it helps? Namely adding
into the beginning of the file |
@jorgebucaran I don't think it's possible to have version that works both with Node and with browser, and also is an ESM module (because that one executes in strict mode and does not allow referencing undefined variables). How would you like to proceed? |
Would Can anybody help me understand how browser support should work? How do you use this package in a browser? And what is the expected behavior (other than not seeing an uncaught error)? |
No, because it is failing in non-node environments where node package is not going to be present either. |
Hmm, this good? 🤔 const proc = typeof process === "undefined" ? {} : process |
@jorgebucaran I think any reference to non-defined variable will break it. you can try running locally and replace process with xyz |
I am using colorette in a backend project in node. There I made my own wrapper for a logger that also uses colorette. Now I started working in SvelteKit and just wanted to move my logger wrapper to that environment, unfortunately I ran into a problem and had to abandon colorette. SvelteKit works on both sides, the backend and the frontend, in the backend everything colors nicely (I like it a lot), and already in the browser it would be enough if it didn't crash, I don't know if the colors are even available in the browser console. |
Thanks for the info, @jaclas. 👍 @kibertoad #92 (comment) seems to work for me. |
@jaclas Could you please try latest version of this branch? It should fix the issue for real now, would be great to confirm :D |
@kibertoad Okay, just give me a hint how should I install this version? Should I clone your repo or is it possible via npm? |
@jaclas You can use npm: https://stackoverflow.com/questions/39732397/install-specific-branch-from-github-using-npm But actually easiest way to try would be just copy-paste whole index.js from the branch into your local node_modules version :D |
@jaclas Thank you for checking this! |
@jaclas Actually you can use define: export default defineConfig({
define: {
'process.env': {}
}
}) |
fix #89