diff --git a/external/builder/babel-plugin-pdfjs-preprocessor.mjs b/external/builder/babel-plugin-pdfjs-preprocessor.mjs index 8c5254e7374c86..8f8be7a724e750 100644 --- a/external/builder/babel-plugin-pdfjs-preprocessor.mjs +++ b/external/builder/babel-plugin-pdfjs-preprocessor.mjs @@ -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: { diff --git a/external/builder/fixtures_babel/staticblock-expected.js b/external/builder/fixtures_babel/staticblock-expected.js new file mode 100644 index 00000000000000..059f844aadeb4d --- /dev/null +++ b/external/builder/fixtures_babel/staticblock-expected.js @@ -0,0 +1,5 @@ +class A { + static { + foo(); + } +} diff --git a/external/builder/fixtures_babel/staticblock.js b/external/builder/fixtures_babel/staticblock.js new file mode 100644 index 00000000000000..0dc197df381a12 --- /dev/null +++ b/external/builder/fixtures_babel/staticblock.js @@ -0,0 +1,9 @@ +class A { + static {} + static { + { foo() } + } + static { + {;} + } +} \ No newline at end of file