@@ -239,3 +239,78 @@ test('handles package side-effects', async (t) => {
239239
240240 delete global . sideEffects ;
241241} ) ;
242+
243+ test ( 'can resolve imports with hashes' , async ( t ) => {
244+ const bundle = await rollup ( {
245+ input : 'hash.js' ,
246+ onwarn : ( ) => t . fail ( 'No warnings were expected' ) ,
247+ plugins : [
248+ nodeResolve ( ) ,
249+ {
250+ load ( id ) {
251+ if ( id === resolve ( __dirname , 'fixtures' , 'node_modules' , 'test' , 'index.js#foo' ) ) {
252+ return 'export default "resolved with hash"' ;
253+ }
254+ return null ;
255+ }
256+ }
257+ ]
258+ } ) ;
259+ const { module } = await testBundle ( t , bundle ) ;
260+
261+ t . is ( module . exports , 'resolved with hash' ) ;
262+ } ) ;
263+
264+ test ( 'can resolve imports with search params' , async ( t ) => {
265+ const bundle = await rollup ( {
266+ input : 'search-params.js' ,
267+ onwarn : ( ) => t . fail ( 'No warnings were expected' ) ,
268+ plugins : [
269+ nodeResolve ( ) ,
270+ {
271+ load ( id ) {
272+ if (
273+ id ===
274+ resolve ( __dirname , 'fixtures' , 'node_modules' , 'test' , 'index.js?foo=bar&lorem=ipsum' )
275+ ) {
276+ return 'export default "resolved with search params"' ;
277+ }
278+ return null ;
279+ }
280+ }
281+ ]
282+ } ) ;
283+ const { module } = await testBundle ( t , bundle ) ;
284+
285+ t . is ( module . exports , 'resolved with search params' ) ;
286+ } ) ;
287+
288+ test ( 'can resolve imports with search params and hash' , async ( t ) => {
289+ const bundle = await rollup ( {
290+ input : 'search-params-and-hash.js' ,
291+ onwarn : ( ) => t . fail ( 'No warnings were expected' ) ,
292+ plugins : [
293+ nodeResolve ( ) ,
294+ {
295+ load ( id ) {
296+ if (
297+ id ===
298+ resolve (
299+ __dirname ,
300+ 'fixtures' ,
301+ 'node_modules' ,
302+ 'test' ,
303+ 'index.js?foo=bar&lorem=ipsum#foo'
304+ )
305+ ) {
306+ return 'export default "resolved with search params and hash"' ;
307+ }
308+ return null ;
309+ }
310+ }
311+ ]
312+ } ) ;
313+ const { module } = await testBundle ( t , bundle ) ;
314+
315+ t . is ( module . exports , 'resolved with search params and hash' ) ;
316+ } ) ;
0 commit comments