Revert "Try to *temporarily* hack around the __non_webpack_require__ bug (issue 10177)"

This reverts commit 6f67e39a0a, since the regressing bug was fixed upstream.
This commit is contained in:
Jonas Jenwald 2019-02-28 14:26:14 +01:00
parent 21d70b19c2
commit 0f24bb73a6

View File

@ -150,21 +150,6 @@ function createWebpackConfig(defines, output) {
var skipBabel = bundleDefines.SKIP_BABEL ||
process.env['SKIP_BABEL'] === 'true';
// TODO: Remove this hack once the Webpack regression has been fixed; see
// https://github.com/mozilla/pdf.js/issues/10177
function babelPluginReplaceNonWebPackRequire(babel) {
return {
visitor: {
Identifier(path, state) {
if (path.node.name === '__non_webpack_require__') {
path.replaceWith(
babel.types.identifier('TEMPORARY_NON_WEBPACK_REQUIRE_HACK'));
}
},
},
};
}
// Required to expose e.g., the `window` object.
output.globalObject = 'this';
@ -199,7 +184,6 @@ function createWebpackConfig(defines, output) {
'helpers': false,
'regenerator': true,
}],
babelPluginReplaceNonWebPackRequire, // Temporary hack.
],
},
},
@ -264,12 +248,6 @@ function replaceWebpackRequire() {
return replace('__webpack_require__', '__w_pdfjs_require__');
}
function replaceTemporaryNonWebpackRequireHack() {
// TODO: Remove this hack once the Webpack regression has been fixed; see
// https://github.com/mozilla/pdf.js/issues/10177
return replace('TEMPORARY_NON_WEBPACK_REQUIRE_HACK', 'require');
}
function replaceJSRootName(amdName, jsName) {
// Saving old-style JS module name.
return replace('root["' + amdName + '"] = factory()',
@ -292,7 +270,6 @@ function createBundle(defines) {
var mainOutput = gulp.src('./src/pdf.js')
.pipe(webpack2Stream(mainFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceTemporaryNonWebpackRequireHack()) // Temporary hack.
.pipe(replaceJSRootName(mainAMDName, 'pdfjsLib'));
var workerAMDName = 'pdfjs-dist/build/pdf.worker';
@ -308,7 +285,6 @@ function createBundle(defines) {
var workerOutput = gulp.src('./src/pdf.worker.js')
.pipe(webpack2Stream(workerFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceTemporaryNonWebpackRequireHack()) // Temporary hack.
.pipe(replaceJSRootName(workerAMDName, 'pdfjsWorker'));
return merge([mainOutput, workerOutput]);
}
@ -320,8 +296,7 @@ function createWebBundle(defines) {
filename: viewerOutputName,
});
return gulp.src('./web/viewer.js')
.pipe(webpack2Stream(viewerFileConfig))
.pipe(replaceTemporaryNonWebpackRequireHack()); // Temporary hack.
.pipe(webpack2Stream(viewerFileConfig));
}
function createComponentsBundle(defines) {
@ -337,7 +312,6 @@ function createComponentsBundle(defines) {
return gulp.src('./web/pdf_viewer.component.js')
.pipe(webpack2Stream(componentsFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceTemporaryNonWebpackRequireHack()) // Temporary hack.
.pipe(replaceJSRootName(componentsAMDName, 'pdfjsViewer'));
}
@ -354,7 +328,6 @@ function createImageDecodersBundle(defines) {
return gulp.src('./src/pdf.image_decoders.js')
.pipe(webpack2Stream(componentsFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceTemporaryNonWebpackRequireHack()) // Temporary hack.
.pipe(replaceJSRootName(imageDecodersAMDName, 'pdfjsImageDecoders'));
}