Closed luiz290788 closed 1 year ago
Start a new pull request in StackBlitz Codeflow.
Checkout https://stackblitz.com/edit/vitejs-vite-m8yvk7?file=vite.config.js
It seems langium
having some circular commonjs dependencies. You need to set build.commonjsOptions.strictRequires
to true
. More info at https://github.com/rollup/plugins/tree/master/packages/commonjs#strictrequires
vite.config.js
import { defineConfig } from 'vite'
export default defineConfig({
build: {
commonjsOptions: {
strictRequires: true
}
},
})
Great find @Tanimodori. I don't think there's much we can do either, we're using a default that works for most projects, and I think it's acceptable that some deps doesn't work with it (especially that Vite is pushing ESM instead). I'll close this for now then.
Thanks for all the help, that solves my problem!
Describe the bug
Everything works fine with with the development mode, but the preview is broken. It builds all right but I get this runtime error:
The only thing I made was to install a package called langium and import everything from the package and log.
I don't know if there is anything wrong with the package or vite.
Reproduction
https://stackblitz.com/edit/vitejs-vite-nfc7cf
Steps to reproduce
Run
npm install
then runnpx vite preview
.Go to the browser and check the error in the console.
System Info
Used Package Manager
npm
Logs
No response
Validations