AI: address review on PR #490
このコミットが含まれているのは:
+2
-2
@@ -6,8 +6,8 @@
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && npm run build:client && npm run build:server",
|
||||
"build:client": "NODE_ENV=production vite build --outDir dist/client",
|
||||
"build:server": "NODE_ENV=production vite build --ssr src/entry-server.tsx --outDir dist/server",
|
||||
"build:client": "vite build --outDir dist/client",
|
||||
"build:server": "vite build --ssr src/entry-server.tsx --outDir dist/server",
|
||||
"start": "node server.mjs",
|
||||
"lint": "eslint .",
|
||||
"test": "vitest",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { createServer } from 'node:http'
|
||||
import { spawn } from 'node:child_process'
|
||||
import { after, before, test } from 'node:test'
|
||||
@@ -332,6 +333,12 @@ after (async () => {
|
||||
if (errors.length) throw new AggregateError (errors, 'SSR teardown failed')
|
||||
})
|
||||
|
||||
test ('SSR bundle uses JSX compatible with production React', async () => {
|
||||
const bundle = await readFile (
|
||||
new URL ('./dist/server/entry-server.js', import.meta.url), 'utf8')
|
||||
assert.doesNotMatch (bundle, /react\/jsx-dev-runtime|\bjsxDEV\b/)
|
||||
})
|
||||
|
||||
test ('counts SSR renders the shell without result requests or embedded results', async () => {
|
||||
for (const locale of ['ja', 'ain-Kana']) {
|
||||
for (const [resource, mode] of ['posts', 'tags'].flatMap (resource =>
|
||||
|
||||
@@ -10,7 +10,8 @@ type Transform = (source: string, id: string) => Promise<{ code: string } | null
|
||||
|
||||
|
||||
export const transformMdx = async (source: string, suffix = '.mdx') => {
|
||||
const plugins = viteConfig.plugins?.flat () as { name: string; transform: Transform }[]
|
||||
const config = viteConfig ({ command: 'serve', mode: 'test' })
|
||||
const plugins = config.plugins?.flat () as { name: string; transform: Transform }[]
|
||||
const plugin = plugins.find (entry => entry.name === '@mdx-js/rollup')
|
||||
if (plugin == null)
|
||||
throw new Error ('The application MDX compiler is not registered')
|
||||
|
||||
@@ -21,7 +21,8 @@ if (typeof originalTransform === 'function')
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig ({
|
||||
export default defineConfig (({ command }) => ({
|
||||
esbuild: { jsxDev: command === 'build' ? false : undefined },
|
||||
plugins: [{ name: 'request-render-context', enforce: 'pre',
|
||||
resolveId (id, _importer, options) {
|
||||
const contextPath = path.resolve (__dirname, './src/lib/renderContext')
|
||||
@@ -40,4 +41,4 @@ export default defineConfig ({
|
||||
rewrite: requestPath => requestPath.replace (/^\/api/, ''),
|
||||
secure: false } },
|
||||
watch: { usePolling: true,
|
||||
interval: 100 } } })
|
||||
interval: 100 } } }))
|
||||
|
||||
@@ -3,11 +3,11 @@ import { defineConfig, mergeConfig } from 'vitest/config'
|
||||
import viteConfig from './vite.config'
|
||||
|
||||
|
||||
export default mergeConfig (
|
||||
viteConfig,
|
||||
export default defineConfig (environment => mergeConfig (
|
||||
viteConfig (environment),
|
||||
defineConfig ({
|
||||
test: { environment: 'jsdom',
|
||||
testTimeout: 30_000,
|
||||
exclude: ['**/node_modules/**', '**/dist/**', 'server.ssr.test.mjs'],
|
||||
setupFiles: './src/test/setup.ts',
|
||||
globals: false } }))
|
||||
globals: false } })))
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする