-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit converts the pdfjsdev-loader transform into a Babel plugin, to skip a AST->string->AST round-trip. Before this commit, the webpack build process was: 1. Babel parses the code 2. Babel transforms the AST 3. Babel generates the code 4. Acorn parses the code 5. pdfjsdev-loader transforms the AST 6. @javascript-obfuscator/escodegen generates the code 7. Webpack parses the file 8. Webpack concatenates the files After this commit, it is reduced to: 1. Babel parses the code 2. Babel transforms the AST 3. babel-plugin-pdfjs-preprocessor transforms the AST 4. Babel generates the code 5. Webpack parses the file 6. Webpack concatenates the files This change improves the build time by ~25% (tested on MacBook Air M2): - `gulp lib`: 3.4s to 2.6s - `gulp dist`: 36s to 29s - `gulp generic`: 5.5s to 4.0s - `gulp mozcentral`: 4.7s to 3.2s The new Babel plugin doesn't support the `saveComments` option of pdfjsdev-loader, and it just always discards comments. Even though pdfjsdev-loader supported multiple values for that option, it was effectively ignored due to `acorn` dropping comments by default.
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
function test() { | ||
"test"; | ||
"1"; | ||
"2"; | ||
"3"; | ||
if ("test") { | ||
"5"; | ||
} | ||
"4"; | ||
"test"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: 'test'.
|
||
"1"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: '1'.
|
||
"2"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: '2'.
|
||
"3"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: '3'.
|
||
if ("test") { | ||
"5"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} | ||
"4"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
function f1() { | ||
"1"; | ||
"2"; | ||
"1"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: '1'.
|
||
"2"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: '2'.
|
||
} | ||
function f2() { | ||
"1"; | ||
"2"; | ||
"1"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: '1'.
|
||
"2"; | ||
Check warning Code scanning / CodeQL Unknown directive Warning library
Unknown directive: '2'.
|
||
} | ||
function f3() { | ||
if ("1") { | ||
"1"; | ||
} | ||
"2"; | ||
if ("3") { | ||
"4"; | ||
} | ||
if ("1") { | ||
"1"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} | ||
"2"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
if ("3") { | ||
"4"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
function f1() { | ||
} | ||
function f1() {} | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused function f1.
|
||
function f2() { | ||
return 1; | ||
return 1; | ||
} | ||
function f3() { | ||
var i = 0; | ||
throw "test"; | ||
var i = 0; | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused variable i.
|
||
throw "test"; | ||
} | ||
function f4() { | ||
var i = 0; | ||
var i = 0; | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused variable i.
|
||
} | ||
var obj = { | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused variable obj.
|
||
method1() {}, | ||
method2() {} | ||
}; | ||
class C { | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused class C.
|
||
method1() {} | ||
method2() {} | ||
} | ||
|
||
var arrow1 = () => {}; | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused variable arrow1.
|
||
var arrow2 = () => {}; | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused variable arrow2.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{ 'test': 'test' } | ||
{ "test": "test" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
if ('test') { | ||
"1"; | ||
"1"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} | ||
{ | ||
"1"; | ||
"1"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} | ||
{ | ||
"1"; | ||
"1"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} | ||
; | ||
{ | ||
"2"; | ||
"2"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} | ||
; | ||
if ('1') { | ||
"1"; | ||
"1"; | ||
Check warning Code scanning / CodeQL Expression has no effect Warning library
This expression has no effect.
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import { Test } from 'import-name'; | ||
import { Test } from "import-name"; | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused import Test.
|
||
import { Test2 } from './non-alias'; | ||
export { | ||
Test3 | ||
} from 'import-name'; | ||
var Imp = require('import-name'); | ||
export { Test3 } from "import-name"; | ||
var Imp = require("import-name"); | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note library
Unused variable Imp.
|
||
var Imp2 = require('./non-alias'); |
This file was deleted.