@@ -38,94 +38,6 @@ const UTILS = {
38
38
} ,
39
39
} ;
40
40
41
- function getBaseConfigs ( pkg ) {
42
- const packageName = pkg . name . replace ( NPM_ORG , '' ) ;
43
- const isUtils = UTILS [ packageName ] !== undefined ;
44
- const baseConfigs = [ ] ;
45
-
46
- if ( ! isUtils ) {
47
- const isAlgoliasearchClient = packageName === 'algoliasearch' ;
48
- const commonConfig = {
49
- package : packageName ,
50
- name : pkg . name ,
51
- output : packageName ,
52
- dependencies : pkg . dependencies ? Object . keys ( pkg . dependencies ) : [ ] ,
53
- external : [ ] ,
54
- plugins : [ ] ,
55
- } ;
56
-
57
- // This non-generated client is an aggregation of client, hence does not follow
58
- // the same build process.
59
- if ( isAlgoliasearchClient ) {
60
- const litePackageName = `${ packageName } /lite` ;
61
- baseConfigs . push (
62
- {
63
- ...commonConfig ,
64
- package : litePackageName ,
65
- name : litePackageName ,
66
- output : 'lite' ,
67
- input : 'lite/builds/browser.ts' ,
68
- formats : BROWSER_FORMATS ,
69
- external : [ 'dom' ] ,
70
- dependencies : [
71
- `${ NPM_ORG } client-common` ,
72
- `${ NPM_ORG } requester-browser-xhr` ,
73
- ] ,
74
- globals : {
75
- [ litePackageName ] : litePackageName ,
76
- } ,
77
- } ,
78
- // Node build
79
- {
80
- ...commonConfig ,
81
- package : litePackageName ,
82
- name : litePackageName ,
83
- output : 'lite' ,
84
- input : 'lite/builds/node.ts' ,
85
- formats : NODE_FORMATS ,
86
- dependencies : [
87
- `${ NPM_ORG } client-common` ,
88
- `${ NPM_ORG } requester-node-http` ,
89
- ] ,
90
- }
91
- ) ;
92
- }
93
-
94
- baseConfigs . push (
95
- // Browser build
96
- {
97
- ...commonConfig ,
98
- input : 'builds/browser.ts' ,
99
- formats : BROWSER_FORMATS ,
100
- external : [ 'dom' ] ,
101
- globals : {
102
- [ packageName ] : packageName ,
103
- } ,
104
- } ,
105
- // Node build
106
- {
107
- ...commonConfig ,
108
- input : 'builds/node.ts' ,
109
- formats : NODE_FORMATS ,
110
- }
111
- ) ;
112
-
113
- return baseConfigs ;
114
- }
115
-
116
- return [
117
- {
118
- ...UTILS [ packageName ] ,
119
- formats : NODE_FORMATS ,
120
- input : 'index.ts' ,
121
- dependencies : pkg . dependencies ? Object . keys ( pkg . dependencies ) : [ ] ,
122
- package : packageName ,
123
- name : pkg . name ,
124
- output : packageName ,
125
- } ,
126
- ] ;
127
- }
128
-
129
41
/**
130
42
* Returns the license at the top of the UMD bundled file.
131
43
*/
@@ -168,6 +80,92 @@ function createBundlers({ output, isLiteClient }) {
168
80
} ;
169
81
}
170
82
83
+ /**
84
+ * Build configs to iterate on based on the package.json information.
85
+ */
86
+ function getBaseConfigs ( pkg ) {
87
+ const packageName = pkg . name . replace ( NPM_ORG , '' ) ;
88
+ const isUtils = UTILS [ packageName ] !== undefined ;
89
+
90
+ if ( isUtils ) {
91
+ return [
92
+ {
93
+ ...UTILS [ packageName ] ,
94
+ formats : NODE_FORMATS ,
95
+ input : 'index.ts' ,
96
+ dependencies : pkg . dependencies ? Object . keys ( pkg . dependencies ) : [ ] ,
97
+ package : packageName ,
98
+ name : pkg . name ,
99
+ output : packageName ,
100
+ } ,
101
+ ] ;
102
+ }
103
+
104
+ const baseConfigs = [ ] ;
105
+ const isAlgoliasearchClient = packageName === 'algoliasearch' ;
106
+ const commonConfig = {
107
+ package : packageName ,
108
+ name : pkg . name ,
109
+ output : packageName ,
110
+ dependencies : pkg . dependencies ? Object . keys ( pkg . dependencies ) : [ ] ,
111
+ external : [ ] ,
112
+ plugins : [ ] ,
113
+ } ;
114
+ const configPerEnv = {
115
+ browser : {
116
+ ...commonConfig ,
117
+ input : 'builds/browser.ts' ,
118
+ formats : BROWSER_FORMATS ,
119
+ external : [ 'dom' ] ,
120
+ globals : {
121
+ [ packageName ] : packageName ,
122
+ } ,
123
+ } ,
124
+ node : {
125
+ ...commonConfig ,
126
+ input : 'builds/node.ts' ,
127
+ formats : NODE_FORMATS ,
128
+ } ,
129
+ } ;
130
+
131
+ // This non-generated client is an aggregation of client, hence does not follow
132
+ // the same build process.
133
+ if ( isAlgoliasearchClient ) {
134
+ const litePackageName = `${ packageName } /lite` ;
135
+ baseConfigs . push (
136
+ {
137
+ ...commonConfig ,
138
+ ...configPerEnv . browser ,
139
+ package : litePackageName ,
140
+ name : litePackageName ,
141
+ output : 'lite' ,
142
+ input : 'lite/builds/browser.ts' ,
143
+ dependencies : [
144
+ `${ NPM_ORG } client-common` ,
145
+ `${ NPM_ORG } requester-browser-xhr` ,
146
+ ] ,
147
+ globals : {
148
+ [ litePackageName ] : litePackageName ,
149
+ } ,
150
+ } ,
151
+ // Node build
152
+ {
153
+ ...commonConfig ,
154
+ package : litePackageName ,
155
+ name : litePackageName ,
156
+ output : 'lite' ,
157
+ input : 'lite/builds/node.ts' ,
158
+ dependencies : [
159
+ `${ NPM_ORG } client-common` ,
160
+ `${ NPM_ORG } requester-node-http` ,
161
+ ] ,
162
+ }
163
+ ) ;
164
+ }
165
+
166
+ return [ ...baseConfigs , configPerEnv . browser , configPerEnv . node ] ;
167
+ }
168
+
171
169
export function buildConfigs ( pkg ) {
172
170
const baseConfigs = getBaseConfigs ( pkg ) ;
173
171
const rollupConfig = [ ] ;
0 commit comments