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

Merge pull request #18562 from nicolo-ribaudo/babel-static-block

Update the Babel plugin to remove empty static blocks
This commit is contained in:
Jonas Jenwald 2024-08-05 16:19:25 +02:00 committed by GitHub
commit d32b294a60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 1 deletions

View file

@ -184,7 +184,7 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
path.replaceWith(t.importExpression(source));
}
},
BlockStatement: {
"BlockStatement|StaticBlock": {
// Visit node in post-order so that recursive flattening
// of blocks works correctly.
exit(path) {
@ -215,6 +215,10 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
}
subExpressionIndex++;
}
if (node.type === "StaticBlock" && node.body.length === 0) {
path.remove();
}
},
},
Function: {

View file

@ -0,0 +1,8 @@
class A {
static {
foo();
}
static {
var a = 0;
}
}

View file

@ -0,0 +1,20 @@
class A {
static {}
static {
{ foo() }
}
static {
{;}
}
static {
if (PDFJSDev.test('TRUE')) {
var a = 0;
}
}
static {
if (PDFJSDev.test('FALSE')) {
var a = 1;
}
}
}