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(optimizer): # symbol in deps id stripped by browser #12415

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '___')
sun0day marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion playground/resolve/__tests__/resolve.spec.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,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