@@ -97,27 +97,18 @@ export function makeBaseNPMConfig(options = {}) {
9797
9898export function makeNPMConfigVariants ( baseConfig , options = { } ) {
9999 const { emitEsm = true , emitCjs = true , splitDevProd = false } = options ;
100- const baseOutput = baseConfig . output ;
101- if ( ! baseOutput || Array . isArray ( baseOutput ) ) {
102- throw new Error ( 'Base config must have a single output object' ) ;
103- }
104-
105- const baseOutputDir = baseOutput . dir ;
106- if ( typeof baseOutputDir !== 'string' ) {
107- throw new Error ( 'Base config must have a string for dir' ) ;
108- }
109100
110101 const variantSpecificConfigs = [ ] ;
111102
112103 if ( emitCjs ) {
113104 if ( splitDevProd ) {
114- variantSpecificConfigs . push ( { output : { format : 'cjs' , dir : path . join ( baseOutputDir , 'cjs/dev' ) } } ) ;
105+ variantSpecificConfigs . push ( { output : { format : 'cjs' , dir : path . join ( baseConfig . output . dir , 'cjs/dev' ) } } ) ;
115106 variantSpecificConfigs . push ( {
116- output : { format : 'cjs' , dir : path . join ( baseOutputDir , 'cjs/prod' ) } ,
107+ output : { format : 'cjs' , dir : path . join ( baseConfig . output . dir , 'cjs/prod' ) } ,
117108 plugins : [ makeProductionReplacePlugin ( ) ] ,
118109 } ) ;
119110 } else {
120- variantSpecificConfigs . push ( { output : { format : 'cjs' , dir : path . join ( baseOutputDir , 'cjs' ) } } ) ;
111+ variantSpecificConfigs . push ( { output : { format : 'cjs' , dir : path . join ( baseConfig . output . dir , 'cjs' ) } } ) ;
121112 }
122113 }
123114
@@ -126,22 +117,22 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
126117 variantSpecificConfigs . push ( {
127118 output : {
128119 format : 'esm' ,
129- dir : path . join ( baseOutputDir , 'esm/dev' ) ,
120+ dir : path . join ( baseConfig . output . dir , 'esm/dev' ) ,
130121 plugins : [ makePackageNodeEsm ( ) ] ,
131122 } ,
132123 } ) ;
133124 variantSpecificConfigs . push ( {
134125 output : {
135126 format : 'esm' ,
136- dir : path . join ( baseOutputDir , 'esm/prod' ) ,
127+ dir : path . join ( baseConfig . output . dir , 'esm/prod' ) ,
137128 plugins : [ makeProductionReplacePlugin ( ) , makePackageNodeEsm ( ) ] ,
138129 } ,
139130 } ) ;
140131 } else {
141132 variantSpecificConfigs . push ( {
142133 output : {
143134 format : 'esm' ,
144- dir : path . join ( baseOutputDir , 'esm' ) ,
135+ dir : path . join ( baseConfig . output . dir , 'esm' ) ,
145136 plugins : [ makePackageNodeEsm ( ) ] ,
146137 } ,
147138 } ) ;
0 commit comments