Skip to content

Commit d7e5a3a

Browse files
committed
Bugfix: Force isomorphic-git ESM entry + ship sourcemaps
`isomorphic-git`'s `exports."."` only declares a CJS entry, which `require`s Node's `crypto`. Vite 7 (Rollup) was loose enough to pick the `module` field; Vite 8 (Rolldown) follows `exports` strictly and bundled the CJS path, crashing the worker with `o.createHash is not a function`. Alias the package to its `index.js` (pure-JS SHA-1, no Node `crypto`). Also turn on production sourcemaps for the app and the worker. The maps are external `.map` files — browsers only fetch them when DevTools is open, so there's no cost for regular visitors and prod stack traces become readable.
1 parent e14caf3 commit d7e5a3a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

vite.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
import { fileURLToPath } from 'node:url'
12
import devtoolsJson from 'vite-plugin-devtools-json'
23
import { sveltekit } from '@sveltejs/kit/vite'
34
import tailwindcss from '@tailwindcss/vite'
45
import { defineConfig } from 'vitest/config'
56

67
export default defineConfig({
78
plugins: [tailwindcss(), sveltekit(), devtoolsJson()],
9+
build: { sourcemap: true },
10+
worker: { format: 'es', rollupOptions: { output: { sourcemap: true } } },
811
// Vite 8 (Rolldown) no longer rewrites bare `global` to `globalThis` in worker bundles, breaking UMD polyfills like `fast-text-encoding` (pulled in by `lightning-fs`) that probe `typeof global`.
912
define: { global: 'globalThis' },
13+
// `isomorphic-git`'s `exports."."` only declares a CJS entry that imports Node's `crypto`. Force the ESM entry, which uses a pure-JS SHA-1 instead.
14+
resolve: {
15+
alias: [
16+
{
17+
find: /^isomorphic-git$/,
18+
replacement: fileURLToPath(new URL('./node_modules/isomorphic-git/index.js', import.meta.url)),
19+
},
20+
],
21+
},
1022
server: {
1123
port: Number(process.env.CONDUCTOR_PORT) || 5233,
1224
strictPort: true,

0 commit comments

Comments
 (0)