diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 4cb6931e7317de..c12e429c51529d 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -79,6 +79,7 @@ export const flattenId = (id: string): string => .replace(/[/:]/g, '_') .replace(/\./g, '__') .replace(/(\s*>\s*)/g, '___') + .replace(/#/g, '____') export const normalizeId = (id: string): string => id.replace(/(\s*>\s*)/g, ' > ') diff --git a/playground/resolve/__tests__/resolve.spec.ts b/playground/resolve/__tests__/resolve.spec.ts index 483c3767833935..65f973e4c85dd3 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 5de5ef46289c69..a562e96847548f 100644 --- a/playground/resolve/index.html +++ b/playground/resolve/index.html @@ -340,7 +340,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('#', '#')}`)