test: resolve using absolute dep path (#5495)

Co-authored-by: patak <matias.capeletto@gmail.com>
This commit is contained in:
yangxingyuan 2023-04-09 18:06:06 +08:00 committed by GitHub
parent 72a379f46b
commit 66ec31caa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 8 deletions

View File

@ -10,7 +10,8 @@ test('handle nested package', async () => {
expect(await page.textContent('.side-c')).toBe(c)
expect(await page.textContent('.d')).toBe('D@1.0.0')
expect(await page.textContent('.nested-d')).toBe('D-nested@1.0.0')
// TODO: Review if the test is correct
// expect(await page.textContent('.nested-e')).toBe('1')
expect(await page.textContent('.absolute-f')).toBe('F@2.0.0')
})

View File

@ -22,6 +22,8 @@
<h2>exclude dependency of pre-bundled dependency</h2>
<div>nested module instance count: <span class="nested-e"></span></div>
<h2>absolute dependency path: <span class="absolute-f"></span></h2>
<script type="module">
import A from '@vitejs/test-package-a'
import B, { A as nestedA } from '@vitejs/test-package-b'
@ -29,6 +31,7 @@
import { C as sideC } from '@vitejs/test-package-c/side'
import D, { nestedD } from '@vitejs/test-package-d'
// import { testExcluded } from '@vitejs/test-package-e'
import F from '__F_ABSOLUTE_PACKAGE_PATH__'
text('.a', A)
text('.b', B)
@ -42,6 +45,8 @@
// text('.nested-e', testExcluded())
text('.absolute-f', F)
function text(sel, text) {
document.querySelector(sel).textContent = text
}

View File

@ -13,6 +13,7 @@
"@vitejs/test-package-b": "link:./test-package-b",
"@vitejs/test-package-c": "link:./test-package-c",
"@vitejs/test-package-d": "link:./test-package-d",
"@vitejs/test-package-e": "link:./test-package-e"
"@vitejs/test-package-e": "link:./test-package-e",
"@vitejs/test-package-f": "link:./test-package-f"
}
}

View File

@ -0,0 +1 @@
export default 'F@2.0.0'

View File

@ -0,0 +1,7 @@
{
"name": "@vitejs/test-package-f",
"private": true,
"version": "2.0.0",
"type": "module",
"main": "index.js"
}

View File

@ -1,6 +1,14 @@
import path from 'node:path'
import { defineConfig } from 'vite'
const packageFPath = path.resolve(__dirname, 'test-package-f')
export default defineConfig({
resolve: {
alias: {
__F_ABSOLUTE_PACKAGE_PATH__: packageFPath,
},
},
optimizeDeps: {
include: [
'@vitejs/test-package-a',
@ -9,6 +17,7 @@ export default defineConfig({
'@vitejs/test-package-c/side',
'@vitejs/test-package-d > @vitejs/test-package-d-nested',
'@vitejs/test-package-e > @vitejs/test-package-e-included',
'@vitejs/test-package-f',
],
exclude: ['@vitejs/test-package-d', '@vitejs/test-package-e-excluded'],
},

View File

@ -6,15 +6,15 @@ overrides:
packageExtensionsChecksum: 2a87e01b470616d3b7def19cc0830231
patchedDependencies:
chokidar@3.5.3:
hash: dzxbf3kgof5pdmbsyih2x43sq4
path: patches/chokidar@3.5.3.patch
dotenv-expand@9.0.0:
hash: dccccn23nvejzy75sgiosdt2au
path: patches/dotenv-expand@9.0.0.patch
sirv@2.0.2:
hash: hmoqtj4vy3i7wnpchga2a2mu3y
path: patches/sirv@2.0.2.patch
dotenv-expand@9.0.0:
hash: dccccn23nvejzy75sgiosdt2au
path: patches/dotenv-expand@9.0.0.patch
chokidar@3.5.3:
hash: dzxbf3kgof5pdmbsyih2x43sq4
path: patches/chokidar@3.5.3.patch
importers:
@ -579,12 +579,14 @@ importers:
'@vitejs/test-package-c': link:./test-package-c
'@vitejs/test-package-d': link:./test-package-d
'@vitejs/test-package-e': link:./test-package-e
'@vitejs/test-package-f': link:./test-package-f
dependencies:
'@vitejs/test-package-a': link:test-package-a
'@vitejs/test-package-b': link:test-package-b
'@vitejs/test-package-c': link:test-package-c
'@vitejs/test-package-d': link:test-package-d
'@vitejs/test-package-e': link:test-package-e
'@vitejs/test-package-f': link:test-package-f
playground/nested-deps/test-package-a:
specifiers: {}
@ -621,6 +623,9 @@ importers:
dependencies:
test-package-e-excluded: link:../test-package-e-excluded
playground/nested-deps/test-package-f:
specifiers: {}
playground/object-hooks:
specifiers:
vue: ^3.2.47