Skip to content

Commit

Permalink
Merge pull request #12527 from Snuffleupagus/worker-rm-require
Browse files Browse the repository at this point in the history
Remove SystemJS usage from the development viewer and the unit-tests
  • Loading branch information
timvandermeij authored Oct 26, 2020
2 parents b2a4dac + 666535b commit b27e4fa
Show file tree
Hide file tree
Showing 10 changed files with 6,047 additions and 5,990 deletions.
19 changes: 14 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ function createWebpackConfig(defines, output) {
!bundleDefines.TESTING;
var skipBabel = bundleDefines.SKIP_BABEL;

// `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 when
// source-maps are enabled) should be excluded from processing.
const babelExcludes = [
"node_modules[\\\\\\/]core-js",
"node_modules[\\\\\\/]web-streams-polyfill",
];
if (enableSourceMaps) {
babelExcludes.push("src[\\\\\\/]core[\\\\\\/](glyphlist|unicode)");
}
const babelExcludeRegExp = new RegExp(`(${babelExcludes.join("|")})`);

// Required to expose e.g., the `window` object.
output.globalObject = "this";

Expand All @@ -209,11 +222,7 @@ function createWebpackConfig(defines, output) {
rules: [
{
loader: "babel-loader",
// `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.
exclude: /(node_modules[\\\/]core-js|node_modules[\\\/]web-streams-polyfill|src[\\\/]core[\\\/](glyphlist|unicode))/,
exclude: babelExcludeRegExp,
options: {
presets: skipBabel ? undefined : ["@babel/preset-env"],
plugins: [
Expand Down
17 changes: 17 additions & 0 deletions src/core/core_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ function getLookupTableFactory(initializer) {
};
}

function getArrayLookupTableFactory(initializer) {
let lookup;
return function () {
if (initializer) {
let arr = initializer();
initializer = null;
lookup = Object.create(null);
for (let i = 0, ii = arr.length; i < ii; i += 2) {
lookup[arr[i]] = arr[i + 1];
}
arr = null;
}
return lookup;
};
}

class MissingDataException extends BaseException {
constructor(begin, end) {
super(`Missing data [${begin}, ${end})`);
Expand Down Expand Up @@ -212,6 +228,7 @@ function escapePDFName(str) {
export {
escapePDFName,
getLookupTableFactory,
getArrayLookupTableFactory,
MissingDataException,
XRefEntryException,
XRefParseException,
Expand Down
Loading

0 comments on commit b27e4fa

Please sign in to comment.