Skip to content

Commit 4b587b0

Browse files
authored
test(resolve): cover the codes that parse the fs path contained postfix (#12436)
1 parent ce047e3 commit 4b587b0

File tree

7 files changed

+32
-4
lines changed

7 files changed

+32
-4
lines changed

playground/resolve/__tests__/resolve.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ test('resolve.conditions', async () => {
155155

156156
test('resolve package that contains # in path', async () => {
157157
expect(await page.textContent('.path-contains-sharp-symbol')).toMatch(
158-
'[success] true',
158+
'[success] true #',
159159
)
160160
})
161161

playground/resolve/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,12 @@ <h2>resolve package that contains # in path</h2>
341341

342342
import es5Ext from 'es5-ext'
343343
import contains from 'es5-ext/string/#/contains'
344+
import { last } from '@vitejs/test-resolve-sharp-dir'
344345

345-
text('.path-contains-sharp-symbol', `[success] ${contains.call('#', '#')}`)
346+
text(
347+
'.path-contains-sharp-symbol',
348+
`[success] ${contains.call('#', '#')} ${last.call('#')}`,
349+
)
346350
</script>
347351

348352
<style>

playground/resolve/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@vitejs/test-resolve-exports-path": "link:./exports-path",
3535
"@vitejs/test-resolve-exports-with-module": "link:./exports-with-module",
3636
"@vitejs/test-resolve-linked": "workspace:*",
37-
"@vitejs/test-resolve-imports-pkg": "link:./imports-path/other-pkg"
37+
"@vitejs/test-resolve-imports-pkg": "link:./imports-path/other-pkg",
38+
"@vitejs/test-resolve-sharp-dir": "link:./sharp-dir"
3839
}
3940
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
last: require('es5-ext/string/#/last.js'),
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@vitejs/test-resolve-sharp-dir",
3+
"private": true,
4+
"version": "1.0.0",
5+
"main": "./index.cjs",
6+
"dependencies": {
7+
"es5-ext": "0.10.62"
8+
}
9+
}

playground/resolve/vite.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ export default defineConfig({
101101
},
102102
],
103103
optimizeDeps: {
104-
include: ['@vitejs/test-require-pkg-with-module-field'],
104+
include: [
105+
'@vitejs/test-require-pkg-with-module-field',
106+
'@vitejs/test-resolve-sharp-dir',
107+
],
105108
},
106109
})

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)