@@ -12,7 +12,7 @@ import { makeNodeResolvePlugin, makeSucrasePlugin } from './plugins/index.js';
12
12
const packageDotJSON = require ( path . resolve ( process . cwd ( ) , './package.json' ) ) ;
13
13
14
14
export function makeBaseNPMConfig ( options = { } ) {
15
- const { entrypoints = [ 'src/index.ts' ] } = options ;
15
+ const { entrypoints = [ 'src/index.ts' ] , hasBundles = false } = options ;
16
16
17
17
const nodeResolvePlugin = makeNodeResolvePlugin ( ) ;
18
18
const sucrasePlugin = makeSucrasePlugin ( ) ;
@@ -21,6 +21,9 @@ export function makeBaseNPMConfig(options = {}) {
21
21
input : entrypoints ,
22
22
23
23
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
+
24
27
sourcemap : true ,
25
28
26
29
// output individual files rather than one big bundle
@@ -62,8 +65,8 @@ export function makeBaseNPMConfig(options = {}) {
62
65
63
66
export function makeNPMConfigVariants ( baseConfig ) {
64
67
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') } } ,
67
70
] ;
68
71
69
72
return variantSpecificConfigs . map ( variant => deepMerge ( baseConfig , variant ) ) ;
0 commit comments