[api-major] Remove the SINGLE_FILE build target

Please note that this build target, and the resulting `build/pdf.combined.js` file, is equivalent to setting the `PDFJS.disableWorker` option to `true` which is a performance footgun.
This commit is contained in:
Jonas Jenwald 2018-01-17 18:20:00 +01:00
parent 55e3f97aa9
commit c56f3f04dd
4 changed files with 7 additions and 40 deletions

View File

@ -48,7 +48,6 @@ var BASELINE_DIR = BUILD_DIR + 'baseline/';
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline/';
var GENERIC_DIR = BUILD_DIR + 'generic/';
var COMPONENTS_DIR = BUILD_DIR + 'components/';
var SINGLE_FILE_DIR = BUILD_DIR + 'singlefile/';
var MINIFIED_DIR = BUILD_DIR + 'minified/';
var FIREFOX_BUILD_DIR = BUILD_DIR + 'firefox/';
var CHROME_BUILD_DIR = BUILD_DIR + 'chromium/';
@ -79,7 +78,6 @@ var DEFINES = {
MOZCENTRAL: false,
CHROME: false,
MINIFIED: false,
SINGLE_FILE: false,
COMPONENTS: false,
LIB: false,
SKIP_BABEL: false,
@ -235,10 +233,6 @@ function createBundle(defines) {
var mainAMDName = 'pdfjs-dist/build/pdf';
var mainOutputName = 'pdf.js';
if (defines.SINGLE_FILE) {
mainAMDName = 'pdfjs-dist/build/pdf.combined';
mainOutputName = 'pdf.combined.js';
}
var mainFileConfig = createWebpackConfig(defines, {
filename: mainOutputName,
@ -250,9 +244,6 @@ function createBundle(defines) {
.pipe(webpack2Stream(mainFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceJSRootName(mainAMDName));
if (defines.SINGLE_FILE) {
return mainOutput; // don't need a worker file.
}
var workerAMDName = 'pdfjs-dist/build/pdf.worker';
var workerOutputName = 'pdf.worker.js';
@ -634,18 +625,6 @@ gulp.task('components', ['buildnumber'], function () {
]);
});
gulp.task('singlefile', ['buildnumber'], function () {
console.log();
console.log('### Creating singlefile build');
var defines = builder.merge(DEFINES, { SINGLE_FILE: true, });
var SINGLE_FILE_BUILD_DIR = SINGLE_FILE_DIR + 'build/';
rimraf.sync(SINGLE_FILE_DIR);
return createBundle(defines).pipe(gulp.dest(SINGLE_FILE_BUILD_DIR));
});
gulp.task('minified-pre', ['buildnumber', 'locale'], function () {
console.log();
console.log('### Creating minified viewer');
@ -1275,9 +1254,7 @@ gulp.task('gh-pages-git', ['gh-pages-prepare', 'wintersmith'], function () {
gulp.task('web', ['gh-pages-prepare', 'wintersmith', 'gh-pages-git']);
gulp.task('dist-pre',
['generic', 'singlefile', 'components', 'lib', 'minified'],
function () {
gulp.task('dist-pre', ['generic', 'components', 'lib', 'minified'], function() {
var VERSION = getVersionJSON().version;
console.log();
@ -1359,8 +1336,6 @@ gulp.task('dist-pre',
GENERIC_DIR + 'build/pdf.js.map',
GENERIC_DIR + 'build/pdf.worker.js',
GENERIC_DIR + 'build/pdf.worker.js.map',
SINGLE_FILE_DIR + 'build/pdf.combined.js',
SINGLE_FILE_DIR + 'build/pdf.combined.js.map',
SRC_DIR + 'pdf.worker.entry.js',
]).pipe(gulp.dest(DIST_DIR + 'build/')),
gulp.src(MINIFIED_DIR + 'build/pdf.js')

View File

@ -46,8 +46,7 @@ var pdfjsFilePath =
var fakeWorkerFilesLoader = null;
var useRequireEnsure = false;
if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('GENERIC && !SINGLE_FILE')) {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
// For GENERIC build we need add support of different fake file loaders
// for different frameworks.
if (typeof window === 'undefined') {
@ -1243,10 +1242,6 @@ var PDFWorker = (function PDFWorkerClosure() {
throw new Error(
'SystemJS or CommonJS must be used to load fake worker.');
}
} else if (PDFJSDev.test('SINGLE_FILE')) {
var pdfjsCoreWorker = require('../core/worker.js');
WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
} else {
var loader = fakeWorkerFilesLoader || function (callback) {
Util.loadScript(getWorkerSrc(), function () {
@ -1320,9 +1315,8 @@ var PDFWorker = (function PDFWorkerClosure() {
// all requirements to run parts of pdf.js in a web worker.
// Right now, the requirement is, that an Uint8Array is still an
// Uint8Array as it arrives on the worker. (Chrome added this with v.15.)
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('SINGLE_FILE')) &&
!isWorkerDisabled && !getDefaultSetting('disableWorker') &&
typeof Worker !== 'undefined') {
if (typeof Worker !== 'undefined' && !isWorkerDisabled &&
!getDefaultSetting('disableWorker')) {
var workerSrc = getWorkerSrc();
try {

View File

@ -25,8 +25,7 @@ var SVGGraphics = function() {
throw new Error('Not implemented: SVGGraphics');
};
if (typeof PDFJSDev === 'undefined' ||
PDFJSDev.test('GENERIC || SINGLE_FILE')) {
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
var SVG_DEFAULTS = {
fontStyle: 'normal',

View File

@ -29,8 +29,7 @@ var pdfjsDisplayAnnotationLayer = require('./display/annotation_layer.js');
var pdfjsDisplayDOMUtils = require('./display/dom_utils.js');
var pdfjsDisplaySVG = require('./display/svg.js');
if (typeof PDFJSDev === 'undefined' ||
!PDFJSDev.test('FIREFOX || MOZCENTRAL || CHROME')) {
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
const isNodeJS = require('./shared/is_node.js');
if (isNodeJS()) {
let PDFNodeStream = require('./display/node_stream.js').PDFNodeStream;
@ -43,7 +42,7 @@ if (typeof PDFJSDev === 'undefined' ||
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
return new PDFFetchStream(params);
});
} else {
} else {
let PDFNetworkStream = require('./display/network.js').PDFNetworkStream;
pdfjsDisplayAPI.setPDFNetworkStreamFactory((params) => {
return new PDFNetworkStream(params);