From 41f381b4af985180cc13bf32cedd3b0678d8d2bc Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 14 Mar 2023 17:34:50 +0800 Subject: [PATCH 1/2] fix(optimizer): # symbol of deps id stripped in url --- packages/vite/src/node/utils.ts | 1 + playground/resolve/__tests__/resolve.spec.ts | 2 +- playground/resolve/index.html | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index b614da2696318c..75aa4a0b81d6a8 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -76,6 +76,7 @@ export function unwrapId(id: string): string { export const flattenId = (id: string): string => id + .replace(/\/#/g, '/[sharp]') .replace(/[/:]/g, '_') .replace(/\./g, '__') .replace(/(\s*>\s*)/g, '___') diff --git a/playground/resolve/__tests__/resolve.spec.ts b/playground/resolve/__tests__/resolve.spec.ts index f30fc3e9338140..38de04e9d47c30 100644 --- a/playground/resolve/__tests__/resolve.spec.ts +++ b/playground/resolve/__tests__/resolve.spec.ts @@ -155,7 +155,7 @@ test('resolve.conditions', async () => { test('resolve package that contains # in path', async () => { expect(await page.textContent('.path-contains-sharp-symbol')).toMatch( - '[success]', + '[success] true', ) }) diff --git a/playground/resolve/index.html b/playground/resolve/index.html index 0966f050bbd580..87a0ca749aa36a 100644 --- a/playground/resolve/index.html +++ b/playground/resolve/index.html @@ -334,7 +334,9 @@

resolve package that contains # in path

text('.inline-pkg', inlineMsg) import es5Ext from 'es5-ext' - text('.path-contains-sharp-symbol', '[success]') + import contains from 'es5-ext/string/#/contains' + + text('.path-contains-sharp-symbol', `[success] ${contains.call('#', '#')}`)