Skip to content

Commit

Permalink
fix: add exports condition 'development|production' (to align Vite 5/6)
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Dec 3, 2024
1 parent ae614c0 commit 7eb9690
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/vike-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@
],
"repository": "github:vikejs/vike-node",
"license": "MIT"
}
}
18 changes: 16 additions & 2 deletions packages/vike-node/src/plugin/plugins/edgePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { promisify } from 'util'
import esbuild from 'esbuild'
import fs from 'fs/promises'
import { prerender } from 'vike/prerender'
import type { Plugin, ResolvedConfig } from 'vite'
import { defaultClientConditions, type Plugin, type ResolvedConfig } from 'vite'
import type { ConfigVikeNodeResolved, Runtime } from '../../types.js'
import { assert } from '../../utils/assert.js'
import { copyFileOrFolder } from '../utils/copyFileOrFolder.js'
Expand All @@ -16,7 +16,21 @@ import { unenvPlugin } from './esbuild/unenvPlugin.js'

const compress = promisify(gzip)

const DEFAULT_CONDITIONS = ['edge-light', 'workerd', 'worker', 'browser', 'module', 'import', 'require']
const DEFAULT_CONDITIONS = [
'edge-light',
'workerd',
'worker',
'browser',
'module',
'import',
'require',
// https://github.com/vitejs/vite/blob/ccee3d7c7d34fc66854029f27f6cc89de7dcf3c5/docs/config/shared-options.md?plain=1#L139
// Probably not supported by esbuild. (It's okay to add it for esbuild as well: it'll probably just be a no-op.)
'development|production'
]
// defaultClientConditions and not defaultServerConditions because target is 'webworker'
// https://github.com/vitejs/vite/blob/ccee3d7c7d34fc66854029f27f6cc89de7dcf3c5/docs/config/ssr-options.md?plain=1#L37
assert(defaultClientConditions.every((condition) => DEFAULT_CONDITIONS.includes(condition)))

type Entry = {
name: string
Expand Down

0 comments on commit 7eb9690

Please sign in to comment.