change vite dependency in all package.json files to 4.2.0
pnpm i
build all
run the backend
cd frontend/main-app
npm run dev
go to http://localhost:5173
login
when you are redirected to the main home page, you will see this error in the sveltekit log for the app (in the terminal):
08:24:50 [vite] Error when evaluating SSR module /src/lib/MainPanel.svelte: failed to import "@cozemble/model-assembled"
08:24:50 [vite] Error when evaluating SSR module /src/routes/tenants/[tenantId]/+page.svelte:
Internal server error: require() of ES Module /Users/mikehogan/repos/personal/cozemble/monorepo/model/string/ui/package/index.js from /Users/mikehogan/repos/personal/cozemble/monorepo/model/assembled/dist/cjs/index.js not supported.
Instead change the require of /Users/mikehogan/repos/personal/cozemble/monorepo/model/string/ui/package/index.js in /Users/mikehogan/repos/personal/cozemble/monorepo/model/assembled/dist/cjs/index.js to a dynamic import() which is available in all CommonJS modules.
at Object. (/Users/mikehogan/repos/personal/cozemble/monorepo/model/assembled/dist/cjs/index.js:4:27)
at async Promise.all (index 0)
at async nodeImport (file:///Users/mikehogan/repos/personal/cozemble/monorepo/node_modules/.pnpm/vite@4.2.0/node_modules/vite/dist/node/chunks/dep-c167897e.js:54024:21)
at async eval (/src/lib/MainPanel.svelte:10:31)
at async instantiateModule (file:///Users/mikehogan/repos/personal/cozemble/monorepo/node_modules/.pnpm/vite@4.2.0/node_modules/vite/dist/node/chunks/dep-c167897e.js:53981:9)
https://stackoverflow.com/questions/75843346/why-is-sveltekit-vite-loading-commonjs-code-when-es6-is-available-and-type-mo?noredirect=1#comment133781366_75843346
To reproduce:
change vite dependency in all package.json files to 4.2.0 pnpm i build all run the backend cd frontend/main-app npm run dev go to http://localhost:5173 login when you are redirected to the main home page, you will see this error in the sveltekit log for the app (in the terminal):
08:24:50 [vite] Error when evaluating SSR module /src/lib/MainPanel.svelte: failed to import "@cozemble/model-assembled"
08:24:50 [vite] Error when evaluating SSR module /src/routes/tenants/[tenantId]/+page.svelte:
Internal server error: require() of ES Module /Users/mikehogan/repos/personal/cozemble/monorepo/model/string/ui/package/index.js from /Users/mikehogan/repos/personal/cozemble/monorepo/model/assembled/dist/cjs/index.js not supported. Instead change the require of /Users/mikehogan/repos/personal/cozemble/monorepo/model/string/ui/package/index.js in /Users/mikehogan/repos/personal/cozemble/monorepo/model/assembled/dist/cjs/index.js to a dynamic import() which is available in all CommonJS modules. at Object. (/Users/mikehogan/repos/personal/cozemble/monorepo/model/assembled/dist/cjs/index.js:4:27)
at async Promise.all (index 0)
at async nodeImport (file:///Users/mikehogan/repos/personal/cozemble/monorepo/node_modules/.pnpm/vite@4.2.0/node_modules/vite/dist/node/chunks/dep-c167897e.js:54024:21)
at async eval (/src/lib/MainPanel.svelte:10:31)
at async instantiateModule (file:///Users/mikehogan/repos/personal/cozemble/monorepo/node_modules/.pnpm/vite@4.2.0/node_modules/vite/dist/node/chunks/dep-c167897e.js:53981:9)