-
Notifications
You must be signed in to change notification settings - Fork 474
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
process is not defined #315
Comments
Checked Added the process as a global variable in Vite options. Add the lines to your
|
@lominming thanks for that. It's working very well when in dev mode. When try and build the project for production then im getting Any idea how to build it in this case? |
Since I don't need to support windows terminal, this is my work-around using patch-package:
|
FWIW, I added this to vue.config.js (as mentioned in https://stackoverflow.com/a/41359607) and it works:
However, I think that upgrading chalk dependency would be better. AFAICT, later major versions of chalk do not use |
For anyone still struggling with this. Changing the node resolutions options for {
"resolutions": {
"jsondiffpatch/chalk": "5.0.1"
}
} Note that it works in |
Then nothing else works like environment variables for example in sveltekit. |
If we don't use I forked and published jsondiffpatch-rc to npm which help fix this issue |
Sorry for the late response, but I also bumped into this issue and the fix ended up being to define everything as strings. I think Vite literally just inserts the string values, so you should do something like: export default defineConfig({
// ...
define: {
'process.platform': '"web"',
},
}) It doesn't need to be |
I have tested @trongitnlu 's solution and that package does work. import { diff, patch, unpatch } from 'jsondiffpatch/dist/jsondiffpatch.umd' For typescript, use js with dts to wrap it.
export { diff, patch, unpatch } from 'jsondiffpatch/dist/jsondiffpatch.umd'
import type { Delta } from 'jsondiffpatch'
export const diff: (left: any, right: any) => Delta | undefined
export const patch: (left: any, delta: Delta) => any
export const unpatch: (right: any, delta: Delta) => any
export type Delta = Delta |
When trying to import any of the exported functions (e.g.
import { create } from 'jsondiffpatch'
) the app crashes with the message:App is built using Vite and svelte.
The text was updated successfully, but these errors were encountered: