From 249b199ff17902a42615ab0905252a720d90551d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 23 Jan 2019 20:18:23 +0100 Subject: [PATCH] Stop bundling the `ReadableStream` polyfill in MOZCENTRAL builds (PR 10470 follow-up) Based on the discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1521413, this patch simply removes the `ReadableStream` polyfill completely from MOZCENTRAL builds. With this patch, the size of the `gulp mozcentral` build target is thus further reduced (building on PR 10470): | | `build/mozcentral` |-------|------------------- |master | 3 339 666 |patch | 3 209 572 --- .../firefox/content/streams_polyfill.js | 19 ------------------- gulpfile.js | 12 ------------ src/pdf.worker.js | 6 +----- src/shared/streams_polyfill.js | 8 ++++---- web/viewer-snippet-firefox-extension.html | 7 ------- 5 files changed, 5 insertions(+), 47 deletions(-) delete mode 100644 extensions/firefox/content/streams_polyfill.js diff --git a/extensions/firefox/content/streams_polyfill.js b/extensions/firefox/content/streams_polyfill.js deleted file mode 100644 index 73ef7c75d..000000000 --- a/extensions/firefox/content/streams_polyfill.js +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2018 Mozilla Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -if (typeof ReadableStream === "undefined") { - require("../../../src/shared/global_scope").ReadableStream = - require("../../../external/streams/streams-lib").ReadableStream; -} diff --git a/gulpfile.js b/gulpfile.js index 6604ef23b..685a4d575 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -766,16 +766,6 @@ function preprocessDefaultPreferences(content) { content + '\n'); } -function createMozcentralStreamsPolyfillBundle(defines) { - var streamsPolyfillOutputName = 'streams_polyfill.js'; - - var streamsPolyfillFileConfig = createWebpackConfig(defines, { - filename: streamsPolyfillOutputName, - }); - return gulp.src('./extensions/firefox/content/streams_polyfill.js') - .pipe(webpack2Stream(streamsPolyfillFileConfig)); -} - gulp.task('mozcentral-pre', gulp.series('buildnumber', 'locale', function () { console.log(); console.log('### Building mozilla-central extension'); @@ -797,8 +787,6 @@ gulp.task('mozcentral-pre', gulp.series('buildnumber', 'locale', function () { return merge([ createBundle(defines).pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + 'build')), createWebBundle(defines).pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + 'web')), - createMozcentralStreamsPolyfillBundle(defines) - .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + 'build')), gulp.src(COMMON_WEB_FILES, { base: 'web/', }) .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + 'web')), gulp.src(['external/bcmaps/*.bcmap', 'external/bcmaps/LICENSE'], diff --git a/src/pdf.worker.js b/src/pdf.worker.js index afce1daeb..30f299c80 100644 --- a/src/pdf.worker.js +++ b/src/pdf.worker.js @@ -12,14 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* eslint-disable no-restricted-globals, no-unused-vars */ +/* eslint-disable no-unused-vars */ 'use strict'; -if (PDFJSDev.test('MOZCENTRAL') && typeof ReadableStream === 'undefined') { - importScripts('./streams_polyfill.js'); -} - const pdfjsVersion = PDFJSDev.eval('BUNDLE_VERSION'); const pdfjsBuild = PDFJSDev.eval('BUNDLE_BUILD'); diff --git a/src/shared/streams_polyfill.js b/src/shared/streams_polyfill.js index fbe70c092..0a694b358 100644 --- a/src/shared/streams_polyfill.js +++ b/src/shared/streams_polyfill.js @@ -15,10 +15,10 @@ /* eslint-disable no-restricted-globals */ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) { - // On the main-thread the `streams_polyfill.js` file is loaded using a - //