Skip to content

Commit

Permalink
fix(node-swc): Sync types for jsc.optimizer.globals (#6603)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill authored Dec 9, 2022
1 parent fbf83db commit b97aa45
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions node-swc/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,18 +879,25 @@ export interface OptimizerConfig {
*/
export interface GlobalPassOption {
/**
* Global variables.
* Global variables that should be inlined with passed value.
*
* e.g. `{ __DEBUG__: true }`
*/
vars?: { [key: string]: string };
vars?: Record<string, string>;

/**
* Name of environment variables to inline.
* Names of environment variables that should be inlined with the value of corresponding env during build.
*
* Defaults to `["NODE_ENV", "SWC_ENV"]`
*/
envs?: string[];

/**
* Replaces typeof calls for passed variables with corresponding value
*
* e.g. `{ window: 'object' }`
*/
typeofs?: Record<string, string>;
}

export type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig | SystemjsConfig;
Expand Down

1 comment on commit b97aa45

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: b97aa45 Previous: 538d63e Ratio
es/full/bugs-1 311653 ns/iter (± 20688) 288109 ns/iter (± 4895) 1.08
es/full/minify/libraries/antd 1692283780 ns/iter (± 25213631) 1658905431 ns/iter (± 22417593) 1.02
es/full/minify/libraries/d3 351281331 ns/iter (± 4228840) 318610130 ns/iter (± 9834903) 1.10
es/full/minify/libraries/echarts 1435000507 ns/iter (± 18604912) 1287399654 ns/iter (± 14320181) 1.11
es/full/minify/libraries/jquery 94937556 ns/iter (± 743352) 98333338 ns/iter (± 668039) 0.97
es/full/minify/libraries/lodash 115923043 ns/iter (± 6113034) 109274037 ns/iter (± 1012557) 1.06
es/full/minify/libraries/moment 54947105 ns/iter (± 766906) 54381016 ns/iter (± 347877) 1.01
es/full/minify/libraries/react 20034345 ns/iter (± 167864) 20297218 ns/iter (± 205701) 0.99
es/full/minify/libraries/terser 278285717 ns/iter (± 7419550) 251371063 ns/iter (± 3680202) 1.11
es/full/minify/libraries/three 510521457 ns/iter (± 9551284) 445172704 ns/iter (± 12340627) 1.15
es/full/minify/libraries/typescript 3205587441 ns/iter (± 25319227) 2957533439 ns/iter (± 17379360) 1.08
es/full/minify/libraries/victory 720925728 ns/iter (± 15696619) 637074385 ns/iter (± 7165648) 1.13
es/full/minify/libraries/vue 142348209 ns/iter (± 6323362) 132348143 ns/iter (± 1133625) 1.08
es/full/codegen/es3 28005 ns/iter (± 43) 28047 ns/iter (± 42) 1.00
es/full/codegen/es5 28042 ns/iter (± 59) 27980 ns/iter (± 34) 1.00
es/full/codegen/es2015 27987 ns/iter (± 56) 28023 ns/iter (± 41) 1.00
es/full/codegen/es2016 28002 ns/iter (± 51) 28088 ns/iter (± 296) 1.00
es/full/codegen/es2017 27958 ns/iter (± 67) 27802 ns/iter (± 133) 1.01
es/full/codegen/es2018 28025 ns/iter (± 70) 28034 ns/iter (± 119) 1.00
es/full/codegen/es2019 27993 ns/iter (± 75) 28061 ns/iter (± 48) 1.00
es/full/codegen/es2020 28016 ns/iter (± 39) 28078 ns/iter (± 63) 1.00
es/full/all/es3 171240345 ns/iter (± 4447749) 168974847 ns/iter (± 3049018) 1.01
es/full/all/es5 164984607 ns/iter (± 2793096) 159224910 ns/iter (± 4445343) 1.04
es/full/all/es2015 124842615 ns/iter (± 2637280) 118923272 ns/iter (± 1614307) 1.05
es/full/all/es2016 123725518 ns/iter (± 3677416) 118274144 ns/iter (± 452629) 1.05
es/full/all/es2017 122420227 ns/iter (± 3180175) 117735153 ns/iter (± 1429708) 1.04
es/full/all/es2018 120473987 ns/iter (± 3149993) 116493988 ns/iter (± 2347512) 1.03
es/full/all/es2019 118526201 ns/iter (± 3627797) 116407678 ns/iter (± 1954693) 1.02
es/full/all/es2020 116989376 ns/iter (± 1804223) 109606417 ns/iter (± 2048834) 1.07
es/full/parser 519227 ns/iter (± 9051) 522436 ns/iter (± 7735) 0.99
es/full/base/fixer 22039 ns/iter (± 43) 22079 ns/iter (± 42) 1.00
es/full/base/resolver_and_hygiene 77883 ns/iter (± 493) 77693 ns/iter (± 72) 1.00
serialization of ast node 140 ns/iter (± 0) 140 ns/iter (± 0) 1
serialization of serde 123 ns/iter (± 0) 122 ns/iter (± 0) 1.01
css/minify/libraries/bootstrap 28455258 ns/iter (± 179122) 28090871 ns/iter (± 202600) 1.01
css/visitor/compare/clone 2372904 ns/iter (± 12763) 2349046 ns/iter (± 17505) 1.01
css/visitor/compare/visit_mut_span 2532263 ns/iter (± 14849) 2559065 ns/iter (± 29445) 0.99
css/visitor/compare/visit_mut_span_panic 2575805 ns/iter (± 9376) 2570510 ns/iter (± 11764) 1.00
css/visitor/compare/fold_span 3504573 ns/iter (± 7787) 3502784 ns/iter (± 12368) 1.00
css/visitor/compare/fold_span_panic 3646663 ns/iter (± 18418) 3663065 ns/iter (± 55758) 1.00
css/lexer/bootstrap_5_1_3 5363976 ns/iter (± 7775) 5344480 ns/iter (± 855) 1.00
css/lexer/foundation_6_7_4 4519710 ns/iter (± 1118) 4498239 ns/iter (± 1115) 1.00
css/lexer/tailwind_3_1_1 851439 ns/iter (± 130) 857326 ns/iter (± 278) 0.99
css/parser/bootstrap_5_1_3 21853712 ns/iter (± 213838) 21381131 ns/iter (± 111391) 1.02
css/parser/foundation_6_7_4 17258368 ns/iter (± 58976) 17068300 ns/iter (± 97840) 1.01
css/parser/tailwind_3_1_1 3246928 ns/iter (± 3420) 3235680 ns/iter (± 5498) 1.00
es/codegen/colors 332645 ns/iter (± 186223) 322507 ns/iter (± 180028) 1.03
es/codegen/large 1222415 ns/iter (± 635476) 1222879 ns/iter (± 641167) 1.00
es/codegen/with-parser/colors 45529 ns/iter (± 261) 45513 ns/iter (± 458) 1.00
es/codegen/with-parser/large 513255 ns/iter (± 1820) 511292 ns/iter (± 1323) 1.00
es/minify/libraries/antd 1498686886 ns/iter (± 10795433) 1380441326 ns/iter (± 28462492) 1.09
es/minify/libraries/d3 314289479 ns/iter (± 5057361) 293289030 ns/iter (± 6368591) 1.07
es/minify/libraries/echarts 1305749960 ns/iter (± 25476927) 1192567859 ns/iter (± 3595429) 1.09
es/minify/libraries/jquery 85466076 ns/iter (± 5003670) 91388606 ns/iter (± 1036557) 0.94
es/minify/libraries/lodash 103344074 ns/iter (± 2919142) 105456454 ns/iter (± 1145797) 0.98
es/minify/libraries/moment 48796473 ns/iter (± 931696) 50436507 ns/iter (± 449051) 0.97
es/minify/libraries/react 18125761 ns/iter (± 401803) 18719130 ns/iter (± 234495) 0.97
es/minify/libraries/terser 246473126 ns/iter (± 4622134) 240405587 ns/iter (± 3793754) 1.03
es/minify/libraries/three 433849874 ns/iter (± 5553057) 417417340 ns/iter (± 3627354) 1.04
es/minify/libraries/typescript 2769110528 ns/iter (± 20394334) 2688716784 ns/iter (± 9807572) 1.03
es/minify/libraries/victory 645780937 ns/iter (± 10737632) 629532001 ns/iter (± 6737812) 1.03
es/minify/libraries/vue 125648783 ns/iter (± 869423) 126997913 ns/iter (± 1385775) 0.99
es/visitor/compare/clone 2468686 ns/iter (± 10723) 2664098 ns/iter (± 14823) 0.93
es/visitor/compare/visit_mut_span 2860909 ns/iter (± 18427) 3053377 ns/iter (± 25974) 0.94
es/visitor/compare/visit_mut_span_panic 2904199 ns/iter (± 13822) 3126956 ns/iter (± 27641) 0.93
es/visitor/compare/fold_span 4066651 ns/iter (± 28120) 4233110 ns/iter (± 28701) 0.96
es/visitor/compare/fold_span_panic 4222855 ns/iter (± 16066) 4494836 ns/iter (± 45068) 0.94
es/lexer/colors 17372 ns/iter (± 2) 17425 ns/iter (± 5) 1.00
es/lexer/angular 8193338 ns/iter (± 2522) 8218622 ns/iter (± 2952) 1.00
es/lexer/backbone 1068395 ns/iter (± 1273) 1072072 ns/iter (± 200) 1.00
es/lexer/jquery 5947083 ns/iter (± 3609) 5956012 ns/iter (± 1670) 1.00
es/lexer/jquery mobile 9163571 ns/iter (± 21571) 9178182 ns/iter (± 2037) 1.00
es/lexer/mootools 4666690 ns/iter (± 2035) 4686438 ns/iter (± 1974) 1.00
es/lexer/underscore 890416 ns/iter (± 343) 894340 ns/iter (± 392) 1.00
es/lexer/three 27910829 ns/iter (± 12382) 27864260 ns/iter (± 19106) 1.00
es/lexer/yui 5038295 ns/iter (± 2830) 5046013 ns/iter (± 52261) 1.00
es/parser/colors 31343 ns/iter (± 152) 31005 ns/iter (± 182) 1.01
es/parser/angular 17105888 ns/iter (± 153750) 16696569 ns/iter (± 416873) 1.02
es/parser/backbone 2341324 ns/iter (± 12720) 2296871 ns/iter (± 13173) 1.02
es/parser/jquery 13159868 ns/iter (± 142909) 12349606 ns/iter (± 100460) 1.07
es/parser/jquery mobile 21717448 ns/iter (± 261220) 19328517 ns/iter (± 128731) 1.12
es/parser/mootools 9723180 ns/iter (± 50037) 9444402 ns/iter (± 29999) 1.03
es/parser/underscore 1970877 ns/iter (± 12018) 1943307 ns/iter (± 13648) 1.01
es/parser/three 60435202 ns/iter (± 254658) 57203964 ns/iter (± 891518) 1.06
es/parser/yui 9890199 ns/iter (± 109559) 9567365 ns/iter (± 55568) 1.03
es/preset-env/usage/builtin_type 143021 ns/iter (± 32341) 141257 ns/iter (± 32264) 1.01
es/preset-env/usage/property 21705 ns/iter (± 55) 21592 ns/iter (± 37) 1.01
es/resolver/typescript 113517064 ns/iter (± 2256653) 109847870 ns/iter (± 5445799) 1.03
es/fixer/typescript 86413093 ns/iter (± 395407) 85626579 ns/iter (± 755695) 1.01
es/hygiene/typescript 173259959 ns/iter (± 1104837) 167863914 ns/iter (± 1988619) 1.03
es/resolver_with_hygiene/typescript 305018275 ns/iter (± 1699102) 298084476 ns/iter (± 4993842) 1.02
es/visitor/base-perf/module_clone 74766 ns/iter (± 1331) 74800 ns/iter (± 1355) 1.00
es/visitor/base-perf/fold_empty 86512 ns/iter (± 1351) 87601 ns/iter (± 1719) 0.99
es/visitor/base-perf/fold_noop_impl_all 86594 ns/iter (± 1275) 87097 ns/iter (± 1210) 0.99
es/visitor/base-perf/fold_noop_impl_vec 86688 ns/iter (± 564) 86646 ns/iter (± 816) 1.00
es/visitor/base-perf/boxing_boxed_clone 54 ns/iter (± 0) 54 ns/iter (± 0) 1
es/visitor/base-perf/boxing_unboxed_clone 58 ns/iter (± 0) 58 ns/iter (± 0) 1
es/visitor/base-perf/boxing_boxed 101 ns/iter (± 0) 99 ns/iter (± 0) 1.02
es/visitor/base-perf/boxing_unboxed 101 ns/iter (± 0) 101 ns/iter (± 0) 1
es/visitor/base-perf/visit_contains_this 3591 ns/iter (± 56) 3596 ns/iter (± 70) 1.00
es/base/parallel/resolver/typescript 5447856809 ns/iter (± 322519267) 10064820431 ns/iter (± 191299337) 0.54
es/base/parallel/hygiene/typescript 2086672535 ns/iter (± 36699940) 1146833684 ns/iter (± 21325446) 1.82
misc/visitors/time-complexity/time 5 97 ns/iter (± 0) 94 ns/iter (± 0) 1.03
misc/visitors/time-complexity/time 10 342 ns/iter (± 2) 309 ns/iter (± 1) 1.11
misc/visitors/time-complexity/time 15 673 ns/iter (± 1) 667 ns/iter (± 7) 1.01
misc/visitors/time-complexity/time 20 1221 ns/iter (± 3) 1223 ns/iter (± 6) 1.00
misc/visitors/time-complexity/time 40 6219 ns/iter (± 1) 6162 ns/iter (± 83) 1.01
misc/visitors/time-complexity/time 60 15611 ns/iter (± 6) 15578 ns/iter (± 37) 1.00
es/full-target/es2016 187189 ns/iter (± 470) 185568 ns/iter (± 1885) 1.01
es/full-target/es2017 180318 ns/iter (± 523) 177114 ns/iter (± 1142) 1.02
es/full-target/es2018 169466 ns/iter (± 450) 164399 ns/iter (± 773) 1.03
es2020_nullish_coalescing 65362 ns/iter (± 109) 63691 ns/iter (± 512) 1.03
es2020_optional_chaining 94261 ns/iter (± 153) 91541 ns/iter (± 5922) 1.03
es2022_class_properties 92195 ns/iter (± 236) 89289 ns/iter (± 663) 1.03
es2018_object_rest_spread 70189 ns/iter (± 116) 68352 ns/iter (± 503) 1.03
es2019_optional_catch_binding 59494 ns/iter (± 132) 58238 ns/iter (± 548) 1.02
es2017_async_to_generator 60160 ns/iter (± 123) 59738 ns/iter (± 134) 1.01
es2016_exponentiation 63532 ns/iter (± 75) 61882 ns/iter (± 349) 1.03
es2015_arrow 68668 ns/iter (± 266) 66569 ns/iter (± 391) 1.03
es2015_block_scoped_fn 64685 ns/iter (± 157) 62498 ns/iter (± 454) 1.03
es2015_block_scoping 136627 ns/iter (± 7382) 152813 ns/iter (± 9498) 0.89
es2015_classes 115648 ns/iter (± 340) 111400 ns/iter (± 727) 1.04
es2015_computed_props 59407 ns/iter (± 111) 58023 ns/iter (± 455) 1.02
es2015_destructuring 114948 ns/iter (± 173) 111300 ns/iter (± 303) 1.03
es2015_duplicate_keys 62229 ns/iter (± 78) 61158 ns/iter (± 626) 1.02
es2015_parameters 77595 ns/iter (± 96) 75120 ns/iter (± 635) 1.03
es2015_fn_name 65312 ns/iter (± 572) 63025 ns/iter (± 734) 1.04
es2015_for_of 62330 ns/iter (± 130) 60551 ns/iter (± 316) 1.03
es2015_instanceof 61741 ns/iter (± 226) 59771 ns/iter (± 590) 1.03
es2015_shorthand_property 59849 ns/iter (± 99) 58657 ns/iter (± 604) 1.02
es2015_spread 59346 ns/iter (± 86) 58686 ns/iter (± 782) 1.01
es2015_sticky_regex 60527 ns/iter (± 119) 60288 ns/iter (± 254) 1.00
es2015_typeof_symbol 61066 ns/iter (± 97) 60416 ns/iter (± 246) 1.01
es/transform/baseline/base 50226 ns/iter (± 104) 50143 ns/iter (± 147) 1.00
es/transform/baseline/common_reserved_word 61280 ns/iter (± 102) 60064 ns/iter (± 257) 1.02
es/transform/baseline/common_typescript 140128 ns/iter (± 217) 139169 ns/iter (± 1371) 1.01
es/target/es3 166847 ns/iter (± 316) 164814 ns/iter (± 907) 1.01
es/target/es2015 630605 ns/iter (± 1210) 614038 ns/iter (± 3717) 1.03
es/target/es2016 63476 ns/iter (± 116) 62071 ns/iter (± 294) 1.02
es/target/es2017 60137 ns/iter (± 85) 58906 ns/iter (± 459) 1.02
es/target/es2018 80318 ns/iter (± 106) 78729 ns/iter (± 531) 1.02
es/target/es2020 130294 ns/iter (± 247) 128230 ns/iter (± 777) 1.02
babelify-only 665010 ns/iter (± 1826) 673521 ns/iter (± 1641) 0.99
parse_and_babelify_angular 44295403 ns/iter (± 1256111) 36318324 ns/iter (± 462570) 1.22
parse_and_babelify_backbone 5824676 ns/iter (± 184795) 5482930 ns/iter (± 53987) 1.06
parse_and_babelify_jquery 35290619 ns/iter (± 816871) 30050412 ns/iter (± 276999) 1.17
parse_and_babelify_jquery_mobile 59203508 ns/iter (± 1687493) 49779526 ns/iter (± 571360) 1.19
parse_and_babelify_mootools 37065907 ns/iter (± 706522) 32073968 ns/iter (± 536301) 1.16
parse_and_babelify_underscore 4644989 ns/iter (± 108789) 4443885 ns/iter (± 14174) 1.05
parse_and_babelify_yui 35569322 ns/iter (± 1225416) 30014828 ns/iter (± 530249) 1.19
html/minify/document/css_spec 45887376 ns/iter (± 479344) 41781682 ns/iter (± 365973) 1.10
html/minify/document/github 19034985 ns/iter (± 35511) 17938377 ns/iter (± 80765) 1.06
html/minify/document/stackoverflow 16927002 ns/iter (± 110991) 15918116 ns/iter (± 162740) 1.06
html/minify/document_fragment/css_spec 44448249 ns/iter (± 101077) 40262307 ns/iter (± 356042) 1.10
html/minify/document_fragment/github 18251155 ns/iter (± 23178) 17340529 ns/iter (± 76117) 1.05
html/minify/document_fragment/stackoverflow 16345630 ns/iter (± 110129) 15280068 ns/iter (± 103086) 1.07
html/document/visitor/compare/clone 342305 ns/iter (± 1768) 336447 ns/iter (± 2773) 1.02
html/document/visitor/compare/visit_mut_span 370409 ns/iter (± 1280) 364490 ns/iter (± 3098) 1.02
html/document/visitor/compare/visit_mut_span_panic 382224 ns/iter (± 1958) 371523 ns/iter (± 3507) 1.03
html/document/visitor/compare/fold_span 408604 ns/iter (± 2527) 402936 ns/iter (± 2914) 1.01
html/document/visitor/compare/fold_span_panic 468274 ns/iter (± 1420) 450981 ns/iter (± 2620) 1.04
html/document_fragment/visitor/compare/clone 344799 ns/iter (± 2090) 338431 ns/iter (± 2403) 1.02
html/document_fragment/visitor/compare/visit_mut_span 372619 ns/iter (± 2228) 364496 ns/iter (± 2296) 1.02
html/document_fragment/visitor/compare/visit_mut_span_panic 373019 ns/iter (± 2249) 368140 ns/iter (± 1917) 1.01
html/document_fragment/visitor/compare/fold_span 404962 ns/iter (± 2022) 403566 ns/iter (± 3122) 1.00
html/document_fragment/visitor/compare/fold_span_panic 462586 ns/iter (± 2453) 461691 ns/iter (± 3581) 1.00
html/lexer/css_2021_spec 16782949 ns/iter (± 9296) 15216102 ns/iter (± 73767) 1.10
html/lexer/github_com_17_05_2022 6335938 ns/iter (± 7122) 5910938 ns/iter (± 44757) 1.07
html/lexer/stackoverflow_com_17_05_2022 6053825 ns/iter (± 1619) 5543848 ns/iter (± 41953) 1.09
html/parser/parser_document/css_2021_spec 27286860 ns/iter (± 126202) 24818878 ns/iter (± 204225) 1.10
html/parser/parser_document/github_com_17_05_2022 8862078 ns/iter (± 13808) 8566891 ns/iter (± 45465) 1.03
html/parser/parser_document/stackoverflow_com_17_05_2022 7821223 ns/iter (± 11263) 7608899 ns/iter (± 56367) 1.03
html/parser/parser_document_fragment/css_2021_spec 29826279 ns/iter (± 145483) 25273256 ns/iter (± 143515) 1.18
html/parser/parser_document_fragment/github_com_17_05_2022 9306367 ns/iter (± 13117) 8600222 ns/iter (± 68371) 1.08
html/parser/parser_document_fragment/stackoverflow_com_17_05_2022 8536661 ns/iter (± 8824) 7686886 ns/iter (± 33559) 1.11

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.