From 21495c1dd17641aad6d1bac5f764b0fde47911a4 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 3 May 2020 11:14:14 +0200 Subject: [PATCH 1/2] Remove the `gulp bundle` task since it's unused and doesn't really make sense Not only is there no code depending on it now, the actual task itself doesn't even make sense as-is. Note that it uses the default `DEFINES` configuration *unaltered*, which is neither useful nor correct since the resulting build thus won't make sense without an actual built target set. --- gulpfile.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index eb6ac14b6..bb1f0bb16 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -677,13 +677,6 @@ gulp.task("cmaps", function (done) { done(); }); -gulp.task( - "bundle", - gulp.series("buildnumber", function () { - return createBundle(DEFINES).pipe(gulp.dest(BUILD_DIR)); - }) -); - function preprocessCSS(source, mode, defines, cleanup) { var outName = getTempFile("~preprocess", ".css"); builder.preprocessCSS(mode, source, outName); From a9e7798ac6c7f37d82c10f9f79599fa6390ea61f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 3 May 2020 11:27:22 +0200 Subject: [PATCH 2/2] Split the `createBundle` helper function, in gulpfile.js, into separate ones for the main/worker-thread files All of the other *similar* helper functions only target one file per function, and there's no particular reason for this one to be different. This patch will simplify future changes, e.g. experimenting with using `gulp watch` instead of SystemJS for the development viewer. --- gulpfile.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index bb1f0bb16..8fc5b44c8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -296,10 +296,7 @@ function replaceJSRootName(amdName, jsName) { ); } -function createBundle(defines) { - console.log(); - console.log("### Bundling files into pdf.js"); - +function createMainBundle(defines) { var mainAMDName = "pdfjs-dist/build/pdf"; var mainOutputName = "pdf.js"; @@ -309,12 +306,14 @@ function createBundle(defines) { libraryTarget: "umd", umdNamedDefine: true, }); - var mainOutput = gulp + return gulp .src("./src/pdf.js") .pipe(webpack2Stream(mainFileConfig)) .pipe(replaceWebpackRequire()) .pipe(replaceJSRootName(mainAMDName, "pdfjsLib")); +} +function createWorkerBundle(defines) { var workerAMDName = "pdfjs-dist/build/pdf.worker"; var workerOutputName = "pdf.worker.js"; @@ -324,13 +323,11 @@ function createBundle(defines) { libraryTarget: "umd", umdNamedDefine: true, }); - - var workerOutput = gulp + return gulp .src("./src/pdf.worker.js") .pipe(webpack2Stream(workerFileConfig)) .pipe(replaceWebpackRequire()) .pipe(replaceJSRootName(workerAMDName, "pdfjsWorker")); - return merge([mainOutput, workerOutput]); } function createWebBundle(defines) { @@ -706,7 +703,8 @@ function buildGeneric(defines, dir) { rimraf.sync(dir); return merge([ - createBundle(defines).pipe(gulp.dest(dir + "build")), + createMainBundle(defines).pipe(gulp.dest(dir + "build")), + createWorkerBundle(defines).pipe(gulp.dest(dir + "build")), createWebBundle(defines).pipe(gulp.dest(dir + "web")), gulp.src(COMMON_WEB_FILES, { base: "web/" }).pipe(gulp.dest(dir + "web")), gulp.src("LICENSE").pipe(gulp.dest(dir)), @@ -840,7 +838,8 @@ gulp.task( rimraf.sync(MINIFIED_DIR); return merge([ - createBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "build")), + createMainBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "build")), + createWorkerBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "build")), createWebBundle(defines).pipe(gulp.dest(MINIFIED_DIR + "web")), createImageDecodersBundle( builder.merge(defines, { IMAGE_DECODERS: true }) @@ -1000,7 +999,12 @@ gulp.task( ]; return merge([ - createBundle(defines).pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")), + createMainBundle(defines).pipe( + gulp.dest(MOZCENTRAL_CONTENT_DIR + "build") + ), + createWorkerBundle(defines).pipe( + gulp.dest(MOZCENTRAL_CONTENT_DIR + "build") + ), createWebBundle(defines).pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")), gulp .src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" }) @@ -1055,7 +1059,12 @@ gulp.task( var version = getVersionJSON().version; return merge([ - createBundle(defines).pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + "build")), + createMainBundle(defines).pipe( + gulp.dest(CHROME_BUILD_CONTENT_DIR + "build") + ), + createWorkerBundle(defines).pipe( + gulp.dest(CHROME_BUILD_CONTENT_DIR + "build") + ), createWebBundle(defines).pipe( gulp.dest(CHROME_BUILD_CONTENT_DIR + "web") ),