mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Output JavaScript modules for the LIB
build-target (PR 17055 follow-up)
This *finally* allows us to mark the entire PDF.js library as a "module", which should thus conclude the (multi-year) effort to re-factor and improve how we import files/resources in the code-base. This also means that the `gulp ci-test` target, which is what's run in GitHub Actions, now uses JavaScript modules since that's supported in modern Node.js versions.
This commit is contained in:
parent
96258449e3
commit
38245500fd
9 changed files with 58 additions and 102 deletions
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
import { createRequire } from "module";
|
||||
import fs from "fs";
|
||||
|
||||
const fs = require("fs");
|
||||
const require = createRequire(import.meta.url);
|
||||
const ttest = require("ttest");
|
||||
|
||||
const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"];
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals __non_webpack_require__ */
|
||||
/* globals __non_webpack_import__ */
|
||||
|
||||
import { AbortException, isNodeJS } from "../../src/shared/util.js";
|
||||
import { PDFNodeStream } from "../../src/display/node_stream.js";
|
||||
|
@ -24,10 +24,10 @@ if (!isNodeJS) {
|
|||
);
|
||||
}
|
||||
|
||||
const path = __non_webpack_require__("path");
|
||||
const url = __non_webpack_require__("url");
|
||||
const http = __non_webpack_require__("http");
|
||||
const fs = __non_webpack_require__("fs");
|
||||
const path = await __non_webpack_import__("path");
|
||||
const url = await __non_webpack_import__("url");
|
||||
const http = await __non_webpack_import__("http");
|
||||
const fs = await __non_webpack_import__("fs");
|
||||
|
||||
describe("node_stream", function () {
|
||||
let server = null;
|
||||
|
|
|
@ -12,12 +12,19 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals __non_webpack_import__ */
|
||||
|
||||
import { NullStream, StringStream } from "../../src/core/stream.js";
|
||||
import { Page, PDFDocument } from "../../src/core/document.js";
|
||||
import { isNodeJS } from "../../src/shared/util.js";
|
||||
import { Ref } from "../../src/core/primitives.js";
|
||||
|
||||
let fs;
|
||||
if (isNodeJS) {
|
||||
// Native packages.
|
||||
fs = await __non_webpack_import__("fs");
|
||||
}
|
||||
|
||||
const TEST_PDFS_PATH = isNodeJS ? "./test/pdfs/" : "../pdfs/";
|
||||
|
||||
const CMAP_URL = isNodeJS ? "./external/bcmaps/" : "../../external/bcmaps/";
|
||||
|
@ -38,8 +45,6 @@ class DOMFileReaderFactory {
|
|||
|
||||
class NodeFileReaderFactory {
|
||||
static async fetch(params) {
|
||||
const fs = require("fs");
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(params.path, (error, data) => {
|
||||
if (error || !data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue