Replace the bundled ReadableStream polyfill with the web-streams-polyfill npm package (issue 11157)

Compared to the recently replaced `URL` polyfill, the new `ReadableStream` polyfill isn't being exported globally for two reasons:
 - We're currently checking for the existence of a global `ReadableStream` implementation when determining if the Fetch API will be used; please see `isFetchSupported` in the src/display/display_utils.js file.
 - Given that it's much newer functionality (compared to `URL`) and that not all browsers may implement all parts of the specification yet, not exposing the `ReadableStream` globally seems safer for now.
This commit is contained in:
Jonas Jenwald 2019-09-23 21:55:55 +02:00
parent 9596d702a9
commit 0ee373f9cc
10 changed files with 15 additions and 4014 deletions

View file

@ -184,11 +184,12 @@ function createWebpackConfig(defines, output) {
rules: [
{
loader: 'babel-loader',
// `core-js` (see https://github.com/zloirock/core-js/issues/514) and
// `core-js` (see https://github.com/zloirock/core-js/issues/514),
// `web-streams-polyfill` (already using a transpiled file), and
// `src/core/{glyphlist,unicode}.js` (Babel is too slow for those)
// should be excluded from processing.
// eslint-disable-next-line max-len
exclude: /(node_modules[\\\/]core-js|src[\\\/]core[\\\/](glyphlist|unicode))/,
exclude: /(node_modules[\\\/]core-js|node_modules[\\\/]web-streams-polyfill|src[\\\/]core[\\\/](glyphlist|unicode))/,
options: {
presets: skipBabel ? undefined : ['@babel/preset-env'],
plugins: [
@ -541,7 +542,7 @@ gulp.task('default_preferences-pre', function() {
},
};
var preprocessor2 = require('./external/builder/preprocessor2.js');
var buildLib = merge([
return merge([
gulp.src([
'src/{display,shared}/*.js',
'!src/shared/{cffStandardStrings,fonts_utils}.js',
@ -553,11 +554,6 @@ gulp.task('default_preferences-pre', function() {
], { base: '.', }),
]).pipe(transform('utf8', preprocess))
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + 'lib/'));
return merge([
buildLib,
gulp.src('external/streams/*.js', { base: '.', })
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR)),
]);
});
gulp.task('default_preferences', gulp.series('default_preferences-pre',
@ -1034,7 +1030,7 @@ gulp.task('lib', gulp.series('buildnumber', 'default_preferences', function() {
var licenseHeaderLibre =
fs.readFileSync('./src/license_header_libre.js').toString();
var preprocessor2 = require('./external/builder/preprocessor2.js');
var buildLib = merge([
return merge([
gulp.src([
'src/{core,display,shared}/*.js',
'!src/shared/{cffStandardStrings,fonts_utils}.js',
@ -1048,11 +1044,6 @@ gulp.task('lib', gulp.series('buildnumber', 'default_preferences', function() {
gulp.src('test/unit/*.js', { base: '.', }),
]).pipe(transform('utf8', preprocess))
.pipe(gulp.dest('build/lib/'));
return merge([
buildLib,
gulp.src('external/streams/streams-lib.js', { base: '.', })
.pipe(gulp.dest('build/')),
]);
}));
gulp.task('publish', gulp.series('generic', function (done) {
@ -1369,8 +1360,6 @@ gulp.task('dist-pre', gulp.series('generic', 'components', 'image_decoders',
createStringSource('bower.json', JSON.stringify(bowerManifest, null, 2));
return merge([
gulp.src('external/streams/streams-lib.js', { base: '.', })
.pipe(gulp.dest('build/dist/')),
packageJsonSrc.pipe(gulp.dest(DIST_DIR)),
bowerJsonSrc.pipe(gulp.dest(DIST_DIR)),
vfs.src('external/dist/**/*',