@@ -195,7 +195,10 @@ export function makeBaseBundleConfig(options) {
195
195
}
196
196
197
197
/**
198
- * Takes the CDN rollup config for a given package and produces configs for both minified and unminified bundles.
198
+ * Takes the CDN rollup config for a given package and produces three versions of it:
199
+ * - non-minified, including debug logging,
200
+ * - minified, including debug logging,
201
+ * - minified, with debug logging stripped
199
202
*
200
203
* @param baseConfig The rollup config shared by the entire package
201
204
* @returns An array of versions of that config
@@ -204,6 +207,8 @@ export function makeConfigVariants(baseConfig) {
204
207
const configVariants = [ ] ;
205
208
206
209
const { plugins } = baseConfig ;
210
+ const includeDebuggingPlugin = makeIsDebugBuildPlugin ( true ) ;
211
+ const noDebuggingPlugin = makeIsDebugBuildPlugin ( false ) ;
207
212
208
213
// The license plugin has to be last, so it ends up after terser. Otherwise, terser will remove the license banner.
209
214
assert (
@@ -217,13 +222,27 @@ export function makeConfigVariants(baseConfig) {
217
222
output : {
218
223
file : `${ baseConfig . output . file } .js` ,
219
224
} ,
220
- plugins,
225
+ plugins : insertAt ( plugins , - 2 , includeDebuggingPlugin ) ,
221
226
} ,
227
+ // This variant isn't particularly helpful for an SDK user, as it strips logging while making no other minification
228
+ // changes, so by default we don't create it. It is however very useful when debugging rollup's treeshaking, so it's
229
+ // left here for that purpose.
230
+ // {
231
+ // output: { file: `${baseConfig.output.file}.no-debug.js`,
232
+ // },
233
+ // plugins: insertAt(plugins, -2, noDebuggingPlugin),
234
+ // },
222
235
{
223
236
output : {
224
237
file : `${ baseConfig . output . file } .min.js` ,
225
238
} ,
226
- plugins : insertAt ( plugins , - 2 , terserPlugin ) ,
239
+ plugins : insertAt ( plugins , - 2 , noDebuggingPlugin , terserPlugin ) ,
240
+ } ,
241
+ {
242
+ output : {
243
+ file : `${ baseConfig . output . file } .debug.min.js` ,
244
+ } ,
245
+ plugins : insertAt ( plugins , - 2 , includeDebuggingPlugin , terserPlugin ) ,
227
246
} ,
228
247
] ;
229
248
0 commit comments