1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 06:38:07 +02:00

Use JSON imports instead of PDFJSDev.json

JSON imports are now supported by all tools used in PDF.js' build
process. The `chromecom.js` file is bundled by webpack and
import attributes are thus removed, so browser compatibility for this
new syntax is not relevant.
This commit is contained in:
Nicolò Ribaudo 2024-11-18 15:04:14 +01:00
parent 658a0a16c1
commit a8592d86a9
No known key found for this signature in database
GPG key ID: AAFDA9101C58F338
7 changed files with 7 additions and 26 deletions

View file

@ -1,10 +1,7 @@
import { types as t, transformSync } from "@babel/core";
import fs from "fs";
import { join as joinPaths } from "path";
import vm from "vm";
const PDFJS_PREPROCESSOR_NAME = "PDFJSDev";
const ROOT_PREFIX = "$ROOT/";
function isPDFJSPreprocessor(obj) {
return obj.type === "Identifier" && obj.name === PDFJS_PREPROCESSOR_NAME;
@ -40,18 +37,6 @@ function handlePreprocessorAction(ctx, actionName, args, path) {
return result;
}
break;
case "json":
if (!t.isStringLiteral(arg)) {
throw new Error("Path to JSON is not provided");
}
let jsonPath = arg.value;
if (jsonPath.startsWith(ROOT_PREFIX)) {
jsonPath = joinPaths(
ctx.rootPath,
jsonPath.substring(ROOT_PREFIX.length)
);
}
return JSON.parse(fs.readFileSync(jsonPath, "utf8"));
}
throw new Error("Unsupported action");
} catch (e) {

View file

@ -10,9 +10,6 @@ var g = {
},
j: 2
};
var h = {
test: "test"
};
var i = '0';
var j = {
i: 1

View file

@ -5,7 +5,6 @@ var d = PDFJSDev.test('FALSE');
var e = PDFJSDev.eval('TRUE');
var f = PDFJSDev.eval('TEXT');
var g = PDFJSDev.eval('OBJ');
var h = PDFJSDev.json('$ROOT/external/builder/fixtures_babel/evals.json');
var i = typeof PDFJSDev === 'undefined' ? PDFJSDev.eval('FALSE') : '0';
var j = typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('OBJ.obj') : '0';
var k = !PDFJSDev.test('TRUE');

View file

@ -1 +0,0 @@
{ "test": "test" }