@@ -109,15 +109,23 @@ export function makeBaseNPMConfig(options = {}) {
109109 external : [ ...builtinModules . filter ( m => ! bundledBuiltins . includes ( m ) ) , ...externalWithSubpaths ] ,
110110 } ) ;
111111
112- return deepMerge ( defaultBaseConfig , packageSpecificConfig , {
112+ const baseConfig = deepMerge ( defaultBaseConfig , packageSpecificConfig , {
113113 // Plugins have to be in the correct order or everything breaks, so when merging we have to manually re-order them
114114 customMerge : key => ( key === 'plugins' ? mergePlugins : undefined ) ,
115115 } ) ;
116+
117+ if ( hasBundles ) {
118+ // @ts -expect-error - this is a private property that we use to determine if the package has bundles
119+ baseConfig . __sentry_internal_hasBundles = true ;
120+ }
121+
122+ return baseConfig ;
116123}
117124
118125export function makeNPMConfigVariants ( baseConfig , options = { } ) {
119126 const { emitEsm = true , emitCjs = true , splitDevProd = false } = options ;
120127
128+ const hasBundles = baseConfig . __sentry_internal_hasBundles ;
121129 const variantSpecificConfigs = [ ] ;
122130
123131 if ( emitCjs ) {
@@ -139,6 +147,9 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
139147 tsgo : true ,
140148 } ) ;
141149
150+ const moveDtsDir = hasBundles ? 'build/npm/esm' : 'build/esm' ;
151+ const moveDtsOutputDir = hasBundles ? 'build/npm/types' : 'build/types' ;
152+
142153 if ( splitDevProd ) {
143154 variantSpecificConfigs . push ( {
144155 output : {
@@ -153,7 +164,11 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
153164 output : {
154165 format : 'esm' ,
155166 dir : path . join ( baseConfig . output . dir , 'esm/prod' ) ,
156- plugins : [ makeProductionReplacePlugin ( ) , makePackageNodeEsm ( ) , makeMoveDtsPlugin ( ) ] ,
167+ plugins : [
168+ makeProductionReplacePlugin ( ) ,
169+ makePackageNodeEsm ( ) ,
170+ makeMoveDtsPlugin ( `${ moveDtsDir } /prod` , moveDtsOutputDir ) ,
171+ ] ,
157172 } ,
158173 } ) ;
159174 } else {
@@ -162,12 +177,13 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
162177 output : {
163178 format : 'esm' ,
164179 dir : path . join ( baseConfig . output . dir , 'esm' ) ,
165- plugins : [ makePackageNodeEsm ( ) , makeMoveDtsPlugin ( ) ] ,
180+ plugins : [ makePackageNodeEsm ( ) , makeMoveDtsPlugin ( moveDtsDir , moveDtsOutputDir ) ] ,
166181 } ,
167182 } ) ;
168183 }
169184 }
170185
186+ // @ts -expect-error -TODO: Not properly typed at the moment
171187 return variantSpecificConfigs . map ( variant => deepMerge ( baseConfig , variant ) ) ;
172188}
173189
0 commit comments