mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +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:
commit
d32b294a60
3 changed files with 33 additions and 1 deletions
|
@ -184,7 +184,7 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
|
||||||
path.replaceWith(t.importExpression(source));
|
path.replaceWith(t.importExpression(source));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
BlockStatement: {
|
"BlockStatement|StaticBlock": {
|
||||||
// Visit node in post-order so that recursive flattening
|
// Visit node in post-order so that recursive flattening
|
||||||
// of blocks works correctly.
|
// of blocks works correctly.
|
||||||
exit(path) {
|
exit(path) {
|
||||||
|
@ -215,6 +215,10 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
|
||||||
}
|
}
|
||||||
subExpressionIndex++;
|
subExpressionIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node.type === "StaticBlock" && node.body.length === 0) {
|
||||||
|
path.remove();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Function: {
|
Function: {
|
||||||
|
|
8
external/builder/fixtures_babel/staticblock-expected.js
vendored
Normal file
8
external/builder/fixtures_babel/staticblock-expected.js
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class A {
|
||||||
|
static {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
var a = 0;
|
||||||
|
}
|
||||||
|
}
|
20
external/builder/fixtures_babel/staticblock.js
vendored
Normal file
20
external/builder/fixtures_babel/staticblock.js
vendored
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue