@@ -405,6 +405,82 @@ describe('generateExports', () => {
405405 ` )
406406 } )
407407
408+ test ( 'export all includes non-entry chunks' , async ( { expect } ) => {
409+ const results = generateExports (
410+ {
411+ es : [ genChunk ( 'index.js' ) , genChunk ( 'utils.js' , false ) ] ,
412+ } ,
413+ {
414+ exports : { all : true } ,
415+ } ,
416+ )
417+ await expect ( results ) . resolves . toMatchInlineSnapshot ( `
418+ {
419+ "exports": {
420+ ".": "./index.js",
421+ "./*": "./*",
422+ "./utils": "./utils.js",
423+ },
424+ "main": undefined,
425+ "module": undefined,
426+ "publishExports": undefined,
427+ "types": undefined,
428+ }
429+ ` )
430+ } )
431+
432+ test ( 'export all excludes virtual modules' , async ( { expect } ) => {
433+ const results = generateExports (
434+ {
435+ es : [
436+ genChunk ( 'index.js' ) ,
437+ genChunk ( 'virtual.js' , false , '\0virtual-module' ) ,
438+ ] ,
439+ } ,
440+ {
441+ exports : { all : true } ,
442+ } ,
443+ )
444+ await expect ( results ) . resolves . toMatchInlineSnapshot ( `
445+ {
446+ "exports": {
447+ ".": "./index.js",
448+ "./*": "./*",
449+ },
450+ "main": undefined,
451+ "module": undefined,
452+ "publishExports": undefined,
453+ "types": undefined,
454+ }
455+ ` )
456+ } )
457+
458+ test ( 'export all excludes node_modules chunks' , async ( { expect } ) => {
459+ const results = generateExports (
460+ {
461+ es : [
462+ genChunk ( 'index.js' ) ,
463+ genChunk ( 'lodash.js' , false , '/project/node_modules/lodash/index.js' ) ,
464+ ] ,
465+ } ,
466+ {
467+ exports : { all : true } ,
468+ } ,
469+ )
470+ await expect ( results ) . resolves . toMatchInlineSnapshot ( `
471+ {
472+ "exports": {
473+ ".": "./index.js",
474+ "./*": "./*",
475+ },
476+ "main": undefined,
477+ "module": undefined,
478+ "publishExports": undefined,
479+ "types": undefined,
480+ }
481+ ` )
482+ } )
483+
408484 test ( 'windows-like paths for subpackages' , async ( { expect } ) => {
409485 const results = generateExports ( {
410486 es : [
@@ -604,13 +680,13 @@ describe('generateExports', () => {
604680 } )
605681} )
606682
607- function genChunk ( fileName : string , isEntry = true ) {
683+ function genChunk ( fileName : string , isEntry = true , facadeModuleId ?: string ) {
608684 // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
609685 return {
610686 type : 'chunk' ,
611687 fileName,
612688 isEntry,
613- facadeModuleId : path . resolve ( `./SRC/${ fileName } ` ) ,
689+ facadeModuleId : facadeModuleId ?? path . resolve ( `./SRC/${ fileName } ` ) ,
614690 outDir : cwd ,
615691 } as RolldownChunk
616692}
0 commit comments