Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SystemJS usage from the development viewer and the unit-tests #12527

Merged
merged 7 commits into from
Oct 26, 2020
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",
Snuffleupagus marked this conversation as resolved.
Show resolved Hide resolved
"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