@@ -15,15 +15,16 @@ import {
1515 makeRemoveESLintCommentsPlugin ,
1616 makeSucrasePlugin ,
1717} from './plugins/index.js' ;
18+ import { mergePlugins } from './utils' ;
1819
1920const packageDotJSON = require ( path . resolve ( process . cwd ( ) , './package.json' ) ) ;
2021
2122export function makeBaseNPMConfig ( options = { } ) {
2223 const {
2324 entrypoints = [ 'src/index.ts' ] ,
2425 esModuleInterop = false ,
25- externals : packageSpecificExternals = [ ] ,
2626 hasBundles = false ,
27+ packageSpecificConfig = { } ,
2728 } = options ;
2829
2930 const nodeResolvePlugin = makeNodeResolvePlugin ( ) ;
@@ -33,7 +34,7 @@ export function makeBaseNPMConfig(options = {}) {
3334 const removeBlankLinesPlugin = makeRemoveBlankLinesPlugin ( ) ;
3435 const extractPolyfillsPlugin = makeExtractPolyfillsPlugin ( ) ;
3536
36- return {
37+ const defaultBaseConfig = {
3738 input : entrypoints ,
3839
3940 output : {
@@ -91,7 +92,6 @@ export function makeBaseNPMConfig(options = {}) {
9192 ...Object . keys ( packageDotJSON . dependencies || { } ) ,
9293 ...Object . keys ( packageDotJSON . devDependencies || { } ) ,
9394 ...Object . keys ( packageDotJSON . peerDependencies || { } ) ,
94- ...packageSpecificExternals ,
9595 ] ,
9696
9797 // TODO `'smallest'` will get rid of `isDebugBuild()` by evaluating it and inlining the result and then treeshaking
@@ -100,6 +100,11 @@ export function makeBaseNPMConfig(options = {}) {
100100 // treeshake: 'smallest',
101101 treeshake : false ,
102102 } ;
103+
104+ return deepMerge ( defaultBaseConfig , packageSpecificConfig , {
105+ // Plugins have to be in the correct order or everything breaks, so when merging we have to manually re-order them
106+ customMerge : key => ( key === 'plugins' ? mergePlugins : undefined ) ,
107+ } ) ;
103108}
104109
105110export function makeNPMConfigVariants ( baseConfig ) {
0 commit comments