test: add tests for ssr.optimizeDeps.include with dep1 > dep2 syntax (#16408)

This commit is contained in:
Hiroshi Ogawa 2024-11-05 17:07:38 +09:00 committed by GitHub
parent 61d0cfe03a
commit ad9a987aa4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 64 additions and 2 deletions

View File

@ -119,6 +119,13 @@ test('import css library', async () => {
expect(await page.textContent('.module-condition')).toMatch('[success]')
})
test('optimize-deps-nested-include', async () => {
await page.goto(url)
expect(await page.textContent('.optimize-deps-nested-include')).toMatch(
'nested-include',
)
})
describe.runIf(isServe)('hmr', () => {
// TODO: the server file is not imported on the client at all
// so it's not present in the client moduleGraph anymore

View File

@ -0,0 +1,3 @@
export { default as nestedInclude } from '@vitejs/test-nested-include'
export default 'nested-exclude'

View File

@ -0,0 +1,10 @@
{
"name": "@vitejs/test-nested-exclude",
"private": true,
"version": "1.0.0",
"type": "module",
"main": "index.js",
"dependencies": {
"@vitejs/test-nested-include": "file:../nested-include"
}
}

View File

@ -0,0 +1,2 @@
// written in cjs, optimization should convert this to esm
module.exports = 'nested-include'

View File

@ -0,0 +1,6 @@
{
"name": "@vitejs/test-nested-include",
"private": true,
"version": "1.0.0",
"main": "index.js"
}

View File

@ -26,6 +26,7 @@
"@vitejs/test-non-optimized-with-nested-external": "workspace:*",
"@vitejs/test-optimized-with-nested-external": "file:./optimized-with-nested-external",
"@vitejs/test-optimized-cjs-with-nested-external": "file:./optimized-with-nested-external",
"@vitejs/test-nested-exclude": "file:./nested-exclude",
"@vitejs/test-external-using-external-entry": "file:./external-using-external-entry",
"@vitejs/test-external-entry": "file:./external-entry",
"@vitejs/test-linked-no-external": "link:./linked-no-external",

View File

@ -42,13 +42,20 @@ export async function createServer(root = process.cwd(), hmrPort) {
},
appType: 'custom',
ssr: {
noExternal,
noExternal: [
...noExternal,
'@vitejs/test-nested-exclude',
'@vitejs/test-nested-include',
],
external: [
'@vitejs/test-nested-external',
'@vitejs/test-external-entry/entry',
],
optimizeDeps: {
include: noExternal,
include: [
...noExternal,
'@vitejs/test-nested-exclude > @vitejs/test-nested-include',
],
},
},
plugins: [

View File

@ -23,6 +23,7 @@ import '@vitejs/test-non-optimized-with-nested-external'
import * as optimizedWithNestedExternal from '@vitejs/test-optimized-with-nested-external'
import * as optimizedCjsWithNestedExternal from '@vitejs/test-optimized-cjs-with-nested-external'
import * as optimizeDepsNestedInclude from '@vitejs/test-nested-exclude'
import { setMessage } from '@vitejs/test-external-entry/entry'
setMessage('Hello World!')
@ -94,5 +95,7 @@ export async function render(url, rootDir) {
html += `\n<p class="isomorphic-module-browser"></p>`
html += `\n<p class="optimize-deps-nested-include">message from optimize-deps-nested-include: ${optimizeDepsNestedInclude.nestedInclude}</p>`
return html + '\n'
}

View File

@ -1372,6 +1372,9 @@ importers:
'@vitejs/test-module-condition':
specifier: file:./module-condition
version: file:playground/ssr-deps/module-condition
'@vitejs/test-nested-exclude':
specifier: file:./nested-exclude
version: file:playground/ssr-deps/nested-exclude
'@vitejs/test-no-external-cjs':
specifier: file:./no-external-cjs
version: file:playground/ssr-deps/no-external-cjs
@ -1442,10 +1445,18 @@ importers:
playground/ssr-deps/module-condition: {}
playground/ssr-deps/nested-exclude:
dependencies:
'@vitejs/test-nested-include':
specifier: file:../nested-include
version: file:playground/ssr-deps/nested-include
playground/ssr-deps/nested-external: {}
playground/ssr-deps/nested-external-cjs: {}
playground/ssr-deps/nested-include: {}
playground/ssr-deps/no-external-cjs: {}
playground/ssr-deps/no-external-css: {}
@ -3357,12 +3368,18 @@ packages:
'@vitejs/test-nested-exclude@file:playground/optimize-deps/nested-exclude':
resolution: {directory: playground/optimize-deps/nested-exclude, type: directory}
'@vitejs/test-nested-exclude@file:playground/ssr-deps/nested-exclude':
resolution: {directory: playground/ssr-deps/nested-exclude, type: directory}
'@vitejs/test-nested-external@file:playground/ssr-deps/nested-external':
resolution: {directory: playground/ssr-deps/nested-external, type: directory}
'@vitejs/test-nested-include@file:playground/optimize-deps/nested-include':
resolution: {directory: playground/optimize-deps/nested-include, type: directory}
'@vitejs/test-nested-include@file:playground/ssr-deps/nested-include':
resolution: {directory: playground/ssr-deps/nested-include, type: directory}
'@vitejs/test-no-external-cjs@file:playground/ssr-deps/no-external-cjs':
resolution: {directory: playground/ssr-deps/no-external-cjs, type: directory}
@ -8803,10 +8820,16 @@ snapshots:
dependencies:
'@vitejs/test-nested-include': file:playground/optimize-deps/nested-include
'@vitejs/test-nested-exclude@file:playground/ssr-deps/nested-exclude':
dependencies:
'@vitejs/test-nested-include': file:playground/ssr-deps/nested-include
'@vitejs/test-nested-external@file:playground/ssr-deps/nested-external': {}
'@vitejs/test-nested-include@file:playground/optimize-deps/nested-include': {}
'@vitejs/test-nested-include@file:playground/ssr-deps/nested-include': {}
'@vitejs/test-no-external-cjs@file:playground/ssr-deps/no-external-cjs': {}
'@vitejs/test-no-external-css@file:playground/ssr-deps/no-external-css': {}