Skip to content

Commit

Permalink
fix(optimizer): # symbol in deps id stripped by browser (#12415)
Browse files Browse the repository at this point in the history
Co-authored-by: patak <matias.capeletto@gmail.com>
  • Loading branch information
sun0day and patak-dev committed Mar 15, 2023
1 parent 2b37cde commit e23f690
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/vite/src/node/utils.ts
Expand Up @@ -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, ' > ')
Expand Down
2 changes: 1 addition & 1 deletion playground/resolve/__tests__/resolve.spec.ts
Expand Up @@ -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',
)
})

Expand Down
4 changes: 3 additions & 1 deletion playground/resolve/index.html
Expand Up @@ -340,7 +340,9 @@ <h2>resolve package that contains # in path</h2>
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('#', '#')}`)
</script>

<style>
Expand Down

0 comments on commit e23f690

Please sign in to comment.