forked from vitejs/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrongly resolve to optimized doppelganger (vitejs#11290)
- Loading branch information
Showing
12 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
playground/resolve-optimized-dup-deps/__tests__/resolve-optimized-dup-deps.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test } from 'vitest' | ||
import { page } from '~utils' | ||
|
||
test('resolve-optimized-dup-deps', async () => { | ||
expect(await page.textContent('.a')).toBe('test-package-a:test-package-b-v2') | ||
expect(await page.textContent('.b')).toBe('test-package-b-v1') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h2>direct dependency A</h2> | ||
<pre class="a"></pre> | ||
|
||
<h2>direct dependency B</h2> | ||
<pre class="b"></pre> | ||
|
||
<script type="module"> | ||
import A from '@vitejs/test-resolve-optimized-dup-deps-package-a' | ||
import B from '@vitejs/test-resolve-optimized-dup-deps-package-b' | ||
|
||
text('.a', A) | ||
text('.b', B) | ||
|
||
function text(sel, text) { | ||
document.querySelector(sel).textContent = text | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import b from '@vitejs/test-resolve-optimized-dup-deps-package-b' | ||
|
||
// should get test-package-a:test-package-b-v2 | ||
const result = 'test-package-a:' + b | ||
|
||
export default result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@vitejs/test-resolve-optimized-dup-deps-package-a", | ||
"private": true, | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"dependencies": { | ||
"@vitejs/test-resolve-optimized-dup-deps-package-b": "file:../package-b-v2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// test-package-b-v1 is install and imported by user | ||
// it is written in cjs and should be optimized | ||
module.exports = 'test-package-b-v1' |
6 changes: 6 additions & 0 deletions
6
playground/resolve-optimized-dup-deps/package-b-v1/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@vitejs/test-resolve-optimized-dup-deps-package-b", | ||
"private": true, | ||
"version": "1.0.0", | ||
"main": "index.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// test-package-b-v2 is install and imported by test-package-a | ||
// it is written in esm. it is not optimized | ||
export default 'test-package-b-v2' |
6 changes: 6 additions & 0 deletions
6
playground/resolve-optimized-dup-deps/package-b-v2/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@vitejs/test-resolve-optimized-dup-deps-package-b", | ||
"private": true, | ||
"version": "2.0.0", | ||
"main": "index.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@vitejs/test-resolve-optimized-dup-deps", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"debug": "node --inspect-brk ../../packages/vite/bin/vite", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@vitejs/test-resolve-optimized-dup-deps-package-a": "file:./package-a", | ||
"@vitejs/test-resolve-optimized-dup-deps-package-b": "file:./package-b-v1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* @type {import('vite').UserConfig} | ||
*/ | ||
module.exports = { | ||
optimizeDeps: { | ||
exclude: ['@vitejs/test-resolve-optimized-dup-deps-package-a'], | ||
}, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.