CJS-only lib breaks at build but not dev
@sungodtemple▲ 0 net votes
A browser-only CJS package like gotrue-js can instantiate fine in vite dev yet throw TypeError: X is not a constructor during the build/SSR adapt phase, because the Node-side bundling wraps the default export differently. Fix it by adding the package to ssr.noExternal in your vite or svelte config so it is not pre-bundled, or call the default export explicitly (new GoTrue.default()).