pdf.js/external
Jonas Jenwald 927e50f5d4 [api-major] Output JavaScript modules in the builds (issue 10317)
At this point in time all browsers, and also Node.js, support standard `import`/`export` statements and we can now finally consider outputting modern JavaScript modules in the builds.[1]

In order for this to work we can *only* use proper `import`/`export` statements throughout the main code-base, and (as expected) our Node.js support made this much more complicated since both the official builds and the GitHub Actions-based tests must keep working.[2]
One remaining issue is that the `pdf.scripting.js` file cannot be built as a JavaScript module, since doing so breaks PDF scripting.

Note that my initial goal was to try and split these changes into a couple of commits, however that unfortunately didn't really work since it turned out to be difficult for smaller patches to work correctly and pass (all) tests that way.[3]
This is a classic case of every change requiring a couple of other changes, with each of those changes requiring further changes in turn and the size/scope quickly increasing as a result.

One possible "issue" with these changes is that we'll now only output JavaScript modules in the builds, which could perhaps be a problem with older tools. However it unfortunately seems far too complicated/time-consuming for us to attempt to support both the old and modern module formats, hence the alternative would be to do "nothing" here and just keep our "old" builds.[4]

---
[1] The final blocker was module support in workers in Firefox, which was implemented in Firefox 114; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility

[2] It's probably possible to further improve/simplify especially the Node.js-specific code, but it does appear to work as-is.

[3] Having partially "broken" patches, that fail tests, as part of the commit history is *really not* a good idea in general.

[4] Outputting JavaScript modules was first requested almost five years ago, see issue 10317, and nowadays there *should* be much better support for JavaScript modules in various tools.
2023-10-07 09:31:08 +02:00
..
bcmaps Removes external/cmaps; adds binary cmaps to the repo 2014-03-17 13:30:27 -05:00
builder [GeckoView] Exclude annotation_editor_layer_builder.css in the build (issue 16994) 2023-09-21 15:51:33 +02:00
cmapscompress [ESM] Convert the "cmaps"-task to use import() syntax 2023-07-08 18:52:58 +02:00
dist [api-major] Output JavaScript modules in the builds (issue 10317) 2023-10-07 09:31:08 +02:00
importL10n Enable the no-lonely-if ESLint rule 2023-07-21 20:10:44 +02:00
quickjs Update quickjs to revision 2788d71e823b522b178db3b3660ce93689534e6d 2022-05-01 15:53:50 +02:00
standard_fonts [api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039) 2023-05-10 14:10:23 +02:00
webL10n Run the PDF.js-viewer API unit-test in Node.js environments (PR 16592 follow-up) 2023-06-26 09:37:34 +02:00
webpack [ESM] Convert the external/builder/-folder to use standard modules 2023-07-11 11:38:59 +02:00
.eslintrc Enable unicorn/prefer-at unconditionally (PR 15014 follow-up) 2023-05-07 13:43:19 +02:00
.gitignore Removes external/cmaps; adds binary cmaps to the repo 2014-03-17 13:30:27 -05:00