Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prebundle dep with colon #7006

Merged
merged 1 commit into from Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -87,3 +87,7 @@ test('import from hidden dir', async () => {
test('import optimize-excluded package that imports optimized-included package', async () => {
expect(await page.textContent('.nested-include')).toBe('nested-include')
})

test('import aliased package with colon', async () => {
expect(await page.textContent('.url')).toBe('vitejs.dev')
})
6 changes: 6 additions & 0 deletions packages/playground/optimize-deps/index.html
Expand Up @@ -53,6 +53,9 @@ <h2>Dep from hidden dir</h2>
<h2>Nested include</h2>
<div>Module path: <span class="nested-include"></span></div>

<h2>Alias with colon</h2>
<div>URL: <span class="url"></span></div>

<script type="module">
// test dep detection in globbed files
const globbed = import.meta.globEager('./glob/*.js')
Expand Down Expand Up @@ -85,6 +88,9 @@ <h2>Nested include</h2>
import { nestedInclude } from 'nested-exclude'
text('.nested-include', nestedInclude)

import { parse } from 'node:url'
text('.url', parse('https://vitejs.dev').hostname)

function text(el, text) {
document.querySelector(el).textContent = text
}
Expand Down
1 change: 1 addition & 0 deletions packages/playground/optimize-deps/package.json
Expand Up @@ -23,6 +23,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"resolve-linked": "workspace:0.0.0",
"url": "^0.11.0",
"vue": "^3.2.25",
"vuex": "^4.0.0"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/playground/optimize-deps/vite.config.js
Expand Up @@ -5,7 +5,10 @@ const vue = require('@vitejs/plugin-vue')
*/
module.exports = {
resolve: {
dedupe: ['react']
dedupe: ['react'],
alias: {
'node:url': 'url'
}
},

optimizeDeps: {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/utils.ts
Expand Up @@ -33,7 +33,7 @@ export function unwrapId(id: string): string {
}

export const flattenId = (id: string): string =>
id.replace(/(\s*>\s*)/g, '__').replace(/[\/\.]/g, '_')
id.replace(/(\s*>\s*)/g, '__').replace(/[\/\.:]/g, '_')

export const normalizeId = (id: string): string =>
id.replace(/(\s*>\s*)/g, ' > ')
Expand Down
19 changes: 19 additions & 0 deletions pnpm-lock.yaml

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