@@ -12,7 +12,7 @@ import { makeNodeResolvePlugin, makeSucrasePlugin } from './plugins/index.js';
1212const packageDotJSON = require ( path . resolve ( process . cwd ( ) , './package.json' ) ) ;
1313
1414export function makeBaseNPMConfig ( options = { } ) {
15- const { entrypoints = [ 'src/index.ts' ] } = options ;
15+ const { entrypoints = [ 'src/index.ts' ] , hasBundles = false } = options ;
1616
1717 const nodeResolvePlugin = makeNodeResolvePlugin ( ) ;
1818 const sucrasePlugin = makeSucrasePlugin ( ) ;
@@ -21,6 +21,9 @@ export function makeBaseNPMConfig(options = {}) {
2121 input : entrypoints ,
2222
2323 output : {
24+ // an appropriately-named directory will be added to this base value when we specify either a cjs or esm build
25+ dir : hasBundles ? 'build/npm' : 'build' ,
26+
2427 sourcemap : true ,
2528
2629 // output individual files rather than one big bundle
@@ -62,8 +65,8 @@ export function makeBaseNPMConfig(options = {}) {
6265
6366export function makeNPMConfigVariants ( baseConfig ) {
6467 const variantSpecificConfigs = [
65- { output : { format : 'cjs' , dir : 'build/ cjs' } } ,
66- { output : { format : 'esm' , dir : 'build/ esm' } } ,
68+ { output : { format : 'cjs' , dir : path . join ( baseConfig . output . dir , ' cjs') } } ,
69+ { output : { format : 'esm' , dir : path . join ( baseConfig . output . dir , ' esm') } } ,
6770 ] ;
6871
6972 return variantSpecificConfigs . map ( variant => deepMerge ( baseConfig , variant ) ) ;
0 commit comments