-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/module): Handle directives (#8048)
**Related issue:** - Closes: #8047
- Loading branch information
1 parent
0c8d8a3
commit 4d8e101
Showing
11 changed files
with
134 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
crates/swc_ecma_transforms_module/tests/fixture/common/issue-8047/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use client"; | ||
|
||
"foo"; | ||
|
||
"use bar"; | ||
|
||
"use strict"; | ||
// All above are directives | ||
|
||
function foo() { } | ||
|
||
"use hello"; // This is not directive |
11 changes: 11 additions & 0 deletions
11
crates/swc_ecma_transforms_module/tests/fixture/common/issue-8047/output.amd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
define([ | ||
"require" | ||
], function(require) { | ||
"use client"; | ||
"foo"; | ||
"use bar"; | ||
"use strict"; | ||
// All above are directives | ||
function foo() {} | ||
"use hello"; // This is not directive | ||
}); |
7 changes: 7 additions & 0 deletions
7
crates/swc_ecma_transforms_module/tests/fixture/common/issue-8047/output.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use client"; | ||
"foo"; | ||
"use bar"; | ||
"use strict"; | ||
// All above are directives | ||
function foo() {} | ||
"use hello"; // This is not directive |
13 changes: 13 additions & 0 deletions
13
crates/swc_ecma_transforms_module/tests/fixture/common/issue-8047/output.umd.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(function(global, factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") factory(); | ||
else if (typeof define === "function" && define.amd) define([], factory); | ||
else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(); | ||
})(this, function() { | ||
"use client"; | ||
"foo"; | ||
"use bar"; | ||
"use strict"; | ||
// All above are directives | ||
function foo() {} | ||
"use hello"; // This is not directive | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4d8e101
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/bugs-1
275528
ns/iter (± 1852
)277700
ns/iter (± 26995
)0.99
es/full/minify/libraries/antd
1313388202
ns/iter (± 13063122
)1296931646
ns/iter (± 8457837
)1.01
es/full/minify/libraries/d3
278470778
ns/iter (± 5361479
)275029976
ns/iter (± 7061922
)1.01
es/full/minify/libraries/echarts
1048540142
ns/iter (± 10779862
)1052617424
ns/iter (± 11323377
)1.00
es/full/minify/libraries/jquery
83973165
ns/iter (± 168650
)83813640
ns/iter (± 132058
)1.00
es/full/minify/libraries/lodash
97160484
ns/iter (± 359447
)96871030
ns/iter (± 273483
)1.00
es/full/minify/libraries/moment
49767035
ns/iter (± 112519
)49734858
ns/iter (± 179312
)1.00
es/full/minify/libraries/react
18078089
ns/iter (± 107091
)17918412
ns/iter (± 68088
)1.01
es/full/minify/libraries/terser
216864726
ns/iter (± 893834
)215583178
ns/iter (± 1707353
)1.01
es/full/minify/libraries/three
384437340
ns/iter (± 1525872
)384143758
ns/iter (± 5259211
)1.00
es/full/minify/libraries/typescript
2632573209
ns/iter (± 22876423
)2631939666
ns/iter (± 14979883
)1.00
es/full/minify/libraries/victory
563959199
ns/iter (± 3775218
)559882757
ns/iter (± 3650006
)1.01
es/full/minify/libraries/vue
119010406
ns/iter (± 325846
)119013314
ns/iter (± 150541
)1.00
es/full/codegen/es3
34700
ns/iter (± 52
)34181
ns/iter (± 53
)1.02
es/full/codegen/es5
34612
ns/iter (± 89
)34176
ns/iter (± 82
)1.01
es/full/codegen/es2015
34547
ns/iter (± 111
)34180
ns/iter (± 109
)1.01
es/full/codegen/es2016
34622
ns/iter (± 95
)34106
ns/iter (± 84
)1.02
es/full/codegen/es2017
34607
ns/iter (± 133
)34080
ns/iter (± 87
)1.02
es/full/codegen/es2018
34616
ns/iter (± 135
)34040
ns/iter (± 83
)1.02
es/full/codegen/es2019
34609
ns/iter (± 76
)34174
ns/iter (± 89
)1.01
es/full/codegen/es2020
34658
ns/iter (± 87
)34159
ns/iter (± 81
)1.01
es/full/all/es3
164374660
ns/iter (± 912152
)165479614
ns/iter (± 755581
)0.99
es/full/all/es5
157601005
ns/iter (± 1594985
)157931122
ns/iter (± 1037684
)1.00
es/full/all/es2015
116261825
ns/iter (± 768070
)117551894
ns/iter (± 3157855
)0.99
es/full/all/es2016
116286729
ns/iter (± 785445
)116296416
ns/iter (± 698565
)1.00
es/full/all/es2017
114617768
ns/iter (± 1081265
)116068245
ns/iter (± 514407
)0.99
es/full/all/es2018
113623986
ns/iter (± 875593
)114383554
ns/iter (± 1711770
)0.99
es/full/all/es2019
112463834
ns/iter (± 1185707
)113537218
ns/iter (± 824325
)0.99
es/full/all/es2020
107996064
ns/iter (± 963528
)109234215
ns/iter (± 705824
)0.99
es/full/parser
485766
ns/iter (± 6118
)499748
ns/iter (± 4928
)0.97
es/full/base/fixer
17943
ns/iter (± 111
)21043
ns/iter (± 314
)0.85
es/full/base/resolver_and_hygiene
80666
ns/iter (± 278
)81865
ns/iter (± 136
)0.99
This comment was automatically generated by workflow using github-action-benchmark.