@@ -21,6 +21,7 @@ test('packageReader falls back to main:index when package.json is missing', t =>
2121 moduleId : 'foo/index' ,
2222 alias : 'foo' ,
2323 packageName : 'foo' ,
24+ packageMainPath : 'index.js' ,
2425 sourceMap : undefined
2526 } ) ;
2627
@@ -64,6 +65,7 @@ test('packageReader can still read resource when main is missing', t => {
6465 contents : 'lorem' ,
6566 moduleId : 'foo/bar' ,
6667 packageName : 'foo' ,
68+ packageMainPath : 'index.js' ,
6769 sourceMap : undefined
6870 } ) ;
6971
@@ -91,6 +93,7 @@ test('packageReader uses default index.js as main path if main file is missing b
9193 contents : 'lorem' ,
9294 moduleId : 'foo/bar' ,
9395 packageName : 'foo' ,
96+ packageMainPath : 'index.js' ,
9497 sourceMap : undefined
9598 } ) ;
9699
@@ -118,6 +121,7 @@ test('packageReader reads main file', t => {
118121 contents : 'lorem' ,
119122 moduleId : 'foo/index' ,
120123 packageName : 'foo' ,
124+ packageMainPath : 'index.js' ,
121125 alias : 'foo' ,
122126 sourceMap : undefined
123127 } ) ;
@@ -161,6 +165,7 @@ test('packageReader use default main index.js', t => {
161165 contents : 'lorem' ,
162166 moduleId : 'foo/index' ,
163167 packageName : 'foo' ,
168+ packageMainPath : 'index.js' ,
164169 alias : 'foo' ,
165170 sourceMap : undefined
166171 } ) ;
@@ -189,6 +194,7 @@ test('packageReader reads module over main field', t => {
189194 contents : 'es' ,
190195 moduleId : 'foo/es' ,
191196 packageName : 'foo' ,
197+ packageMainPath : 'es.js' ,
192198 alias : 'foo' ,
193199 sourceMap : undefined
194200 } ) ;
@@ -218,6 +224,7 @@ test('packageReader reads browser over main/module field', t => {
218224 contents : 'br' ,
219225 moduleId : 'foo/br' ,
220226 packageName : 'foo' ,
227+ packageMainPath : 'br.js' ,
221228 alias : 'foo' ,
222229 sourceMap : undefined
223230 } ) ;
@@ -245,6 +252,7 @@ test('packageReader reads main file with explicit ext', t => {
245252 contents : 'lorem' ,
246253 moduleId : 'foo.js/main' ,
247254 packageName : 'foo.js' ,
255+ packageMainPath : 'main.js' ,
248256 alias : 'foo.js' ,
249257 sourceMap : undefined
250258 } ) ;
@@ -272,6 +280,7 @@ test('packageReader reads main file with non-js file', t => {
272280 contents : 'lorem' ,
273281 moduleId : 'foo/main.css' ,
274282 packageName : 'foo' ,
283+ packageMainPath : 'main.css' ,
275284 sourceMap : undefined
276285 } ) ;
277286
@@ -298,6 +307,7 @@ test('packageReader reads implicit main file', t => {
298307 contents : 'lorem' ,
299308 moduleId : 'foo/lib/index' ,
300309 packageName : 'foo' ,
310+ packageMainPath : 'lib/index.js' ,
301311 alias : 'foo' ,
302312 sourceMap : undefined
303313 } ) ;
@@ -344,6 +354,7 @@ test('packageReader reads resource', t => {
344354 contents : 'lorem2' ,
345355 moduleId : 'foo/lib/bar' ,
346356 packageName : 'foo' ,
357+ packageMainPath : 'lib/main.js' ,
347358 sourceMap : undefined
348359 } ) ;
349360
@@ -371,6 +382,7 @@ test('packageReader reads relative resource', t => {
371382 contents : 'lorem2' ,
372383 moduleId : 'foo/lib/bar' ,
373384 packageName : 'foo' ,
385+ packageMainPath : 'lib/main.js' ,
374386 alias : 'foo/bar' ,
375387 sourceMap : undefined
376388 } ) ;
@@ -399,6 +411,7 @@ test('packageReader reads deep relative resource', t => {
399411 contents : 'lorem2' ,
400412 moduleId : 'foo/dist/cjs/foo/bar' ,
401413 packageName : 'foo' ,
414+ packageMainPath : 'dist/cjs/main.js' ,
402415 alias : 'foo/foo/bar' ,
403416 sourceMap : undefined
404417 } ) ;
@@ -427,6 +440,7 @@ test('packageReader reads json resouce', t => {
427440 contents : '{"a":1}' ,
428441 moduleId : 'foo/dist/cjs/foo/bar.json' ,
429442 packageName : 'foo' ,
443+ packageMainPath : 'dist/cjs/main.js' ,
430444 alias : 'foo/foo/bar' ,
431445 sourceMap : undefined
432446 } ) ;
@@ -455,6 +469,7 @@ test('packageReader reads directory index.js', t => {
455469 contents : 'lorem2' ,
456470 moduleId : 'foo/lib/index' ,
457471 packageName : 'foo' ,
472+ packageMainPath : 'index.js' ,
458473 alias : 'foo/lib' ,
459474 sourceMap : undefined
460475 } ) ;
@@ -483,6 +498,7 @@ test('packageReader reads directory index.json', t => {
483498 contents : '{"a":1}' ,
484499 moduleId : 'foo/lib/index.json' ,
485500 packageName : 'foo' ,
501+ packageMainPath : 'index.js' ,
486502 alias : 'foo/lib' ,
487503 sourceMap : undefined
488504 } ) ;
@@ -513,6 +529,7 @@ test('packageReader reads directory package.json', t => {
513529 contents : 'es' ,
514530 moduleId : 'foo/lib/es/index' ,
515531 packageName : 'foo' ,
532+ packageMainPath : 'index.js' ,
516533 alias : 'foo/lib' ,
517534 sourceMap : undefined
518535 } ) ;
@@ -567,6 +584,7 @@ test('packageReader reads browser replacement in package.json', t => {
567584 contents : 'lorem' ,
568585 moduleId : 'foo/index' ,
569586 packageName : 'foo' ,
587+ packageMainPath : 'index.js' ,
570588 alias : 'foo' ,
571589 replacement : {
572590 'module-a' : '__ignore__' ,
@@ -611,6 +629,7 @@ test('packageReader uses browser replacement in package.json to normalize replac
611629 contents : "require('module-a');require('module-b.js');require('module-c');" ,
612630 moduleId : 'foo/shims/client-only' ,
613631 packageName : 'foo' ,
632+ packageMainPath : 'index.js' ,
614633 replacement : {
615634 'module-a' : '__ignore__' ,
616635 'module-b.js' : './module/b' ,
@@ -649,6 +668,7 @@ test('packageReader uses browser replacement in package.json to normalize main r
649668 contents : "browser" ,
650669 moduleId : 'foo/browser' ,
651670 packageName : 'foo' ,
671+ packageMainPath : 'browser.js' ,
652672 alias : 'foo' ,
653673 replacement : { './index' : './browser' } ,
654674 sourceMap : undefined
@@ -684,6 +704,7 @@ test('packageReader uses browser replacement in package.json to normalize main r
684704 contents : "require('module-a');require('module-b.js');require('module-c');require('./server/only.js');" ,
685705 moduleId : 'foo/index' ,
686706 packageName : 'foo' ,
707+ packageMainPath : 'index.js' ,
687708 alias : 'foo' ,
688709 replacement : {
689710 'module-a' : '__ignore__' ,
@@ -724,6 +745,7 @@ test('packageReader uses browser replacement in package.json to normalize replac
724745 contents : "require('module-a');require('module-b.js');require('module-c');require('./only.js');" ,
725746 moduleId : 'foo/server/bar' ,
726747 packageName : 'foo' ,
748+ packageMainPath : 'index.js' ,
727749 replacement : {
728750 'module-a' : '__ignore__' ,
729751 'module-b.js' : '../shims/module/b' ,
@@ -763,6 +785,7 @@ test('packageReader uses browser replacement in package.json to normalize replac
763785 contents : "require('module-a');require('module-b.js');require('module-c');require('../server/only.js');" ,
764786 moduleId : 'foo/lib/bar' ,
765787 packageName : 'foo' ,
788+ packageMainPath : 'index.js' ,
766789 replacement : {
767790 'module-a' : '__ignore__' ,
768791 'module-b.js' : '../shims/module/b' ,
@@ -794,6 +817,7 @@ test('packageReader reads main file for package alias', t => {
794817 contents : 'lorem' ,
795818 moduleId : 'bar/index' ,
796819 packageName : 'bar' ,
820+ packageMainPath : 'index.js' ,
797821 alias : 'bar' ,
798822 sourceMap : undefined
799823 } ) ;
@@ -823,6 +847,7 @@ test('packageReader reads resource file for package alias', t => {
823847 contents : 'lorem2' ,
824848 moduleId : 'bar/lo' ,
825849 packageName : 'bar' ,
850+ packageMainPath : 'index.js' ,
826851 sourceMap : undefined
827852 } ) ;
828853
0 commit comments