Change src/core/{glyphlist, unicode}.js to use standard import/export statements

While the *built* `pdf.worker.js` file still works correctly with these changes, despite these two files being excluded by Babel[1], the development viewer does not because of issues with SystemJS[2] and/or its Babel-plugin (both of which are old).
Furthermore, note also that excluding these two files from Babel-processing isn't *generally* necessary since e.g. the `gulp mozcentral` command works anyway. The explanation is rather that it's actually the source-map generation which fails for these huge sequences when building the `pdf.worker.js` file.

However, not using standard `import`/`export` statements in all files means we also need to use SystemJS when e.e. running the unit-tests. This is very unfortunate, since SystemJS (or its old Babel-version) doesn't support modern ECMAScript features such as e.g. optional chaining and nullish coalescing.

Unfortunately it also seems that https://bugzilla.mozilla.org/show_bug.cgi?id=1247687, which tracks the implementation of worker-modules in Firefox, has stalled since there hasn't been any updates for six months now.

To hopefully address all of the above, this patch is the first in a series that attempts to further reduce our reliance on SystemJS.

---
[1] The only difference being how the dependencies are handled, in the Webpack-bundled file.

[2] Parsing takes way too long and consumes too much memory, thus rendering the development viewer essentially unusable.
This commit is contained in:
Jonas Jenwald 2020-10-25 12:27:07 +01:00
parent b2a4dacd31
commit 441d9c8cc0
2 changed files with 10 additions and 9 deletions

View File

@ -15,7 +15,7 @@
/* no-babel-preset */
/* eslint-disable no-var */
var getLookupTableFactory = require("./core_utils.js").getLookupTableFactory;
import { getLookupTableFactory } from "./core_utils.js";
var getGlyphsUnicode = getLookupTableFactory(function (t) {
t.A = 0x0041;
@ -4550,5 +4550,4 @@ var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
t[".notdef"] = 0x0000;
});
exports.getGlyphsUnicode = getGlyphsUnicode;
exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
export { getGlyphsUnicode, getDingbatsGlyphsUnicode };

View File

@ -15,7 +15,7 @@
/* no-babel-preset */
/* eslint-disable no-var */
var getLookupTableFactory = require("./core_utils.js").getLookupTableFactory;
import { getLookupTableFactory } from "./core_utils.js";
// Some characters, e.g. copyrightserif, are mapped to the private use area
// and might not be displayed using standard fonts. Mapping/hacking well-known
@ -1635,8 +1635,10 @@ function reverseIfRtl(chars) {
return s;
}
exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
exports.reverseIfRtl = reverseIfRtl;
exports.getUnicodeRangeFor = getUnicodeRangeFor;
exports.getNormalizedUnicodes = getNormalizedUnicodes;
exports.getUnicodeForGlyph = getUnicodeForGlyph;
export {
mapSpecialUnicodeValues,
reverseIfRtl,
getUnicodeRangeFor,
getNormalizedUnicodes,
getUnicodeForGlyph,
};