Compare commits

...

4 Commits

Author SHA1 Message Date
Jonas Jenwald
0bde69c7bf
Merge pull request #19767 from Snuffleupagus/issue-19761
Attempt to get bundlers to leave Emscripten Compiler generated `URL`s alone (issue 19761)
2025-04-04 12:30:15 +02:00
Jonas Jenwald
20e06c4bb5 Attempt to get bundlers to leave Emscripten Compiler generated URLs alone (issue 19761)
Note that we load all wasm-files manually, however the Emscripten Compiler (emcc) unfortunately generates `URL`s for fallback wasm-file loading.
In the PDF.js build-scripts we work-around that by using suitable Webpack-options, however that apparently doesn't work when third-party users re-bundle our code and we thus try to work-around this by adding "ignore comments" to these `URL`s (similar to how we handle `import`-statements).
2025-04-04 11:45:54 +02:00
Jonas Jenwald
bd06061e85
Merge pull request #19766 from Snuffleupagus/version-5.2
Bump library version to `5.2`
2025-04-04 08:58:16 +02:00
Jonas Jenwald
bd418de6b0 Bump library version to 5.2 2025-04-04 08:54:06 +02:00
4 changed files with 37 additions and 2 deletions

View File

@ -173,6 +173,36 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
path.replaceWith(t.importExpression(source));
}
},
NewExpression(path) {
const { node } = path;
if (
t.isIdentifier(node.callee, { name: "URL" }) &&
node.arguments.length === 2
) {
const [arg1, arg2] = node.arguments;
if (
arg1.type === "StringLiteral" &&
arg1.value.endsWith(".wasm") &&
arg2.type === "MemberExpression"
) {
// This statement is generated by the Emscripten Compiler (emcc),
// however we're manually loading wasm-files and we want to ensure
// that bundlers will leave it alone; this *must* include Webpack.
arg1.leadingComments = [
{
type: "CommentBlock",
value: "webpackIgnore: true",
},
{
type: "CommentBlock",
value: "@vite-ignore",
},
];
}
}
},
"BlockStatement|StaticBlock": {
// Visit node in post-order so that recursive flattening
// of blocks works correctly.

View File

@ -0,0 +1,4 @@
const wasmUrl = new URL(
/*webpackIgnore: true*/
/*@vite-ignore*/
"qwerty.wasm", import.meta.url);

View File

@ -0,0 +1 @@
const wasmUrl = new URL("qwerty.wasm" , import.meta.url);

View File

@ -1,5 +1,5 @@
{
"stableVersion": "5.1.91",
"baseVersion": "d86045eacbd6f8cc9cbe8fd616800ca3edcbd0dc",
"versionPrefix": "5.1."
"baseVersion": "e5fbf52405fbb092351ef1cda8f44fbae3a84473",
"versionPrefix": "5.2."
}