@@ -15,15 +15,16 @@ import {
15
15
makeRemoveESLintCommentsPlugin ,
16
16
makeSucrasePlugin ,
17
17
} from './plugins/index.js' ;
18
+ import { mergePlugins } from './utils' ;
18
19
19
20
const packageDotJSON = require ( path . resolve ( process . cwd ( ) , './package.json' ) ) ;
20
21
21
22
export function makeBaseNPMConfig ( options = { } ) {
22
23
const {
23
24
entrypoints = [ 'src/index.ts' ] ,
24
25
esModuleInterop = false ,
25
- externals : packageSpecificExternals = [ ] ,
26
26
hasBundles = false ,
27
+ packageSpecificConfig = { } ,
27
28
} = options ;
28
29
29
30
const nodeResolvePlugin = makeNodeResolvePlugin ( ) ;
@@ -33,7 +34,7 @@ export function makeBaseNPMConfig(options = {}) {
33
34
const removeBlankLinesPlugin = makeRemoveBlankLinesPlugin ( ) ;
34
35
const extractPolyfillsPlugin = makeExtractPolyfillsPlugin ( ) ;
35
36
36
- return {
37
+ const defaultBaseConfig = {
37
38
input : entrypoints ,
38
39
39
40
output : {
@@ -91,7 +92,6 @@ export function makeBaseNPMConfig(options = {}) {
91
92
...Object . keys ( packageDotJSON . dependencies || { } ) ,
92
93
...Object . keys ( packageDotJSON . devDependencies || { } ) ,
93
94
...Object . keys ( packageDotJSON . peerDependencies || { } ) ,
94
- ...packageSpecificExternals ,
95
95
] ,
96
96
97
97
// 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 = {}) {
100
100
// treeshake: 'smallest',
101
101
treeshake : false ,
102
102
} ;
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
+ } ) ;
103
108
}
104
109
105
110
export function makeNPMConfigVariants ( baseConfig ) {
0 commit comments