I’m currently trying to upgrade from 4.16.7 to 5.0.3 but afterwards I get a few of those (all md5-related) which causes the engine failing to load:
md5.js?v=03d92c56:2 Uncaught ReferenceError: require is not defined
at md5.js?v=03d92c56:2:15
at md5.js?v=03d92c56:160:3
(anonymous) @ md5.js?v=03d92c56:2
(anonymous) @ md5.js?v=03d92c56:160
With a bit of AI support I found it works again when adding this to my vite.config.js:
optimizeDeps: {
include: ['md5'],
exclude: []
}
I do not have this error in a toy project where I tried to reproduce it, only in my full production setup.
The ReferenceError: require is not defined usually points to a module resolution issue in a browser environment, especially when upgrading. Since adding md5 to optimizeDeps.include in vite.config.js fixed it for your production setup, it suggests Vite isn’t pre-bundling md5 correctly by default in that specific project. Your toy project might have a slightly different dependency tree or configuration that allows Vite to resolve it without the explicit optimizeDeps entry.
To confirm this, can you share the package.json from your production setup? It would help see if there are any unusual dependencies or configurations that might interfere with Vite’s default optimization.