@@ -195,7 +195,10 @@ export function makeBaseBundleConfig(options) {
195195}
196196
197197/**
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
199202 *
200203 * @param baseConfig The rollup config shared by the entire package
201204 * @returns An array of versions of that config
@@ -204,6 +207,8 @@ export function makeConfigVariants(baseConfig) {
204207 const configVariants = [ ] ;
205208
206209 const { plugins } = baseConfig ;
210+ const includeDebuggingPlugin = makeIsDebugBuildPlugin ( true ) ;
211+ const noDebuggingPlugin = makeIsDebugBuildPlugin ( false ) ;
207212
208213 // The license plugin has to be last, so it ends up after terser. Otherwise, terser will remove the license banner.
209214 assert (
@@ -217,13 +222,27 @@ export function makeConfigVariants(baseConfig) {
217222 output : {
218223 file : `${ baseConfig . output . file } .js` ,
219224 } ,
220- plugins,
225+ plugins : insertAt ( plugins , - 2 , includeDebuggingPlugin ) ,
221226 } ,
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+ // },
222235 {
223236 output : {
224237 file : `${ baseConfig . output . file } .min.js` ,
225238 } ,
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 ) ,
227246 } ,
228247 ] ;
229248
0 commit comments