Skip to content

Commit

Permalink
Small improvements on bundle generation: fewer useless comments / "us…
Browse files Browse the repository at this point in the history
…e strict" directives; restore module list comment
  • Loading branch information
dgirardi committed Jun 1, 2022
1 parent a3364b5 commit e7bfbb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 4 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const execa = require('execa');

var prebid = require('./package.json');
var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10);
var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + '*/\n';
var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + '\nModules: <%= modules %> */\n';
var port = 9999;
const INTEG_SERVER_HOST = argv.host ? argv.host : 'localhost';
const INTEG_SERVER_PORT = 4444;
Expand Down Expand Up @@ -154,7 +154,7 @@ function addBanner() {

return gulp.src(['build/dist/prebid-core.js'])
.pipe(gulpif(sm, sourcemaps.init({loadMaps: true})))
.pipe(header(banner, {prebid}))
.pipe(header(banner, {prebid, modules: getModulesListToAddInBanner(helpers.getArgModules())}))
.pipe(gulpif(sm, sourcemaps.write('.')))
.pipe(gulp.dest('build/dist'))
}
Expand Down Expand Up @@ -210,11 +210,7 @@ function bundle(dev, moduleArr) {
gutil.log('Appending ' + prebid.globalVarName + '.processQueue();');
gutil.log('Generating bundle:', outputFileName);

return gulp.src(
entries
)
// Need to uodate the "Modules: ..." section in comment with the current modules list
.pipe(replace(/(Modules: )(.*?)(\*\/)/, ('$1' + getModulesListToAddInBanner(helpers.getArgModules()) + ' $3')))
return gulp.src(entries)
.pipe(gulpif(sm, sourcemaps.init({ loadMaps: true })))
.pipe(concat(outputFileName))
.pipe(gulpif(!argv.manualEnable, footer('\n<%= global %>.processQueue();', {
Expand Down Expand Up @@ -405,6 +401,7 @@ gulp.task('build-postbid', gulp.series(escapePostbidConfig, buildPostbid));

gulp.task('serve', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, test)));
gulp.task('serve-fast', gulp.series(clean, gulp.parallel('build-bundle-dev', watchFast)));
gulp.task('serve-prod', gulp.series(clean, gulp.parallel('build-bundle-prod', startLocalServer)));
gulp.task('serve-and-test', gulp.series(clean, gulp.parallel('build-bundle-dev', watchFast, testTaskMaker({watch: true}))));
gulp.task('serve-e2e', gulp.series(clean, 'build-bundle-prod', gulp.parallel(() => startIntegServer(), startLocalServer)))
gulp.task('serve-e2e-dev', gulp.series(clean, 'build-bundle-dev', gulp.parallel(() => startIntegServer(true), startLocalServer)))
Expand Down
9 changes: 9 additions & 0 deletions webpack.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const TerserPlugin = require('terser-webpack-plugin');
var prebid = require('./package.json');
var path = require('path');
var webpack = require('webpack');
Expand Down Expand Up @@ -71,6 +72,14 @@ module.exports = {
optimization: {
usedExports: true,
sideEffects: true,
minimizer: [
new TerserPlugin({
extractComments: false, // do not generate unhelpful LICENSE comment
terserOptions: {
module: true, // do not prepend every module with 'use strict'; allow mangling of top-level locals
}
})
]
},
plugins
};

0 comments on commit e7bfbb0

Please sign in to comment.