Skip to content

Commit

Permalink
test: add tests for ssr.optimizeDeps.include with dep1 > dep2 syn…
Browse files Browse the repository at this point in the history
…tax (#16408)
  • Loading branch information
hi-ogawa authored Nov 5, 2024
1 parent 61d0cfe commit ad9a987
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 2 deletions.
7 changes: 7 additions & 0 deletions playground/ssr-deps/__tests__/ssr-deps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions playground/ssr-deps/nested-exclude/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as nestedInclude } from '@vitejs/test-nested-include'

export default 'nested-exclude'
10 changes: 10 additions & 0 deletions playground/ssr-deps/nested-exclude/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 2 additions & 0 deletions playground/ssr-deps/nested-include/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// written in cjs, optimization should convert this to esm
module.exports = 'nested-include'
6 changes: 6 additions & 0 deletions playground/ssr-deps/nested-include/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@vitejs/test-nested-include",
"private": true,
"version": "1.0.0",
"main": "index.js"
}
1 change: 1 addition & 0 deletions playground/ssr-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 9 additions & 2 deletions playground/ssr-deps/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
3 changes: 3 additions & 0 deletions playground/ssr-deps/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!')
Expand Down Expand Up @@ -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'
}
23 changes: 23 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ad9a987

Please sign in to comment.