1
- import { join , sep } from 'node:path'
1
+ import path , { join } from 'node:path'
2
2
import { fileURLToPath } from 'node:url'
3
3
4
4
import test from 'ava'
@@ -217,7 +217,7 @@ for (const [title, context, request, expected] of [
217
217
'handle fragment escaping' ,
218
218
enhancedResolveRoot ,
219
219
'./no\0#fragment/\0#/\0##fragment' ,
220
- join ( enhancedResolveRoot , 'no#fragment' , '#' , '#.js#fragment' ) ,
220
+ join ( enhancedResolveRoot , 'no#fragment' , '#' , '#.js#fragment' ) ,
221
221
] ,
222
222
] ) {
223
223
test ( title , ( t ) => {
@@ -229,3 +229,31 @@ for (const [title, context, request, expected] of [
229
229
t . is ( resolver . sync ( context , request ) . path , expected )
230
230
} )
231
231
}
232
+
233
+ test ( 'resolve pnpm package' , ( t ) => {
234
+ const pnpmProjectPath = join ( currentDir , '..' , '..' , 'fixtures' , 'pnpm8' )
235
+ const resolver = new ResolverFactory ( {
236
+ aliasFields : [ 'browser' ] ,
237
+ } )
238
+ t . deepEqual ( resolver . sync ( pnpmProjectPath , 'styled-components' ) , {
239
+ path : join (
240
+ pnpmProjectPath ,
241
+ 'node_modules/.pnpm/styled-components@6.1.1_react-dom@18.2.0_react@18.2.0/node_modules/styled-components/dist/styled-components.browser.cjs.js'
242
+ ) ,
243
+ } )
244
+ t . deepEqual (
245
+ resolver . sync (
246
+ join (
247
+ pnpmProjectPath ,
248
+ 'node_modules/.pnpm/styled-components@6.1.1_react-dom@18.2.0_react@18.2.0/node_modules/styled-components'
249
+ ) ,
250
+ 'react'
251
+ ) ,
252
+ {
253
+ path : join (
254
+ pnpmProjectPath ,
255
+ 'node_modules/.pnpm/react@18.2.0/node_modules/react/index.js'
256
+ ) ,
257
+ }
258
+ )
259
+ } )
0 commit comments