vitest.config.build.ts
This file
Path
vitest.config.build.ts
59 lines · 1.5 KiB · TypeScript
Last changed by
fix: Fix broken array patching and ensure all values in draft Maps/Sets are finalized (#1201)Mark Eriksonbefore adoptionb208d58
History of this fileTake it
chore: Migrate test setup to Vitest (#1162)Mark Eriksonbefore adoption4b8bcc5
lines 1–3why, one step back1import {defineConfig} from "vitest/config"2import path from "path"3fix: Fix broken array patching and ensure all values in draft Maps/Sets are finalized (#1201)Mark Eriksonbefore adoptionb208d58
lines 4–5why, one step back4const prodCJSPath = path.resolve(__dirname, "dist/cjs/immer.cjs.production.js")5chore: Migrate test setup to Vitest (#1162)Mark Eriksonbefore adoption4b8bcc5
lines 6–7why, one step back6export default defineConfig({7 resolve: {fix: Fix broken array patching and ensure all values in draft Maps/Sets are finalized (#1201)Mark Eriksonbefore adoptionb208d58
lines 8–24why, one step back8 // // Make all `immer` imports use the production build9 alias: [10 {11 find: /^src\/(.*)/,12 replacement: prodCJSPath13 },14 {15 find: "../src/immer",16 replacement: prodCJSPath17 },18 {19 find: "immer",20 replacement: prodCJSPath21 }22 ],23 // Ensure only one copy of immer is used throughout the dependency tree24 dedupe: ["immer"]chore: Migrate test setup to Vitest (#1162)Mark Eriksonbefore adoption4b8bcc5
line 25why, one step back25 },fix: Fix broken array patching and ensure all values in draft Maps/Sets are finalized (#1201)Mark Eriksonbefore adoptionb208d58
lines 26–36why, one step back26 // Force Vite to process immer so our alias applies to dependencies too27 optimizeDeps: {28 include: ["immer"],29 // Force re-bundling to pick up our alias30 force: true31 },32 // SSR settings are needed because Vitest runs in Node environment33 ssr: {34 // Don't externalize immer - this makes our alias apply to it35 noExternal: ["immer"]36 },chore: Migrate test setup to Vitest (#1162)Mark Eriksonbefore adoption4b8bcc5
lines 37–47why, one step back37 define: {38 "global.USES_BUILD": true,39 "process.env.NODE_ENV": '"production"'40 },41 test: {42 environment: "node",43 include: ["**/__tests__/**/*.[jt]s?(x)"],44 globals: true,45 resolveSnapshotPath: (testPath: string, snapExtension: string) =>46 testPath.replace("__tests__", "__tests__/__prod_snapshots__") +47 snapExtension,fix: Fix broken array patching and ensure all values in draft Maps/Sets are finalized (#1201)Mark Eriksonbefore adoptionb208d58
lines 48–57why, one step back48 reporters: ["default", "./vitest-custom-reporter.ts"],49 // Ensure deps are processed through Vite's transform pipeline50 deps: {51 optimizer: {52 // For SSR (Node) environment, include immer so it's transformed53 ssr: {54 include: ["immer"]55 }56 }57 }chore: Migrate test setup to Vitest (#1162)Mark Eriksonbefore adoption4b8bcc5
lines 58–59why, one step back58 }59})