We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
swc-project
Learn more about funding links in repositories.
Report abuse
jsc.paths
.ts
1 parent 9de2a12 commit 9c9c3ebCopy full SHA for 9c9c3eb
crates/swc_ecma_transforms_module/src/path.rs
@@ -113,12 +113,24 @@ where
113
{
114
fn resolve_import(&self, base: &FileName, module_specifier: &str) -> Result<JsWord, Error> {
115
fn to_specifier(target_path: &str, orig_ext: Option<&str>) -> JsWord {
116
- let p = PathBuf::from(target_path);
+ let mut p = PathBuf::from(target_path);
117
118
if cfg!(debug_assertions) {
119
trace!("to_specifier: orig_ext={:?}", orig_ext);
120
}
121
122
+ if let Some(orig_ext) = orig_ext {
123
+ let use_orig = if let Some(ext) = p.extension() {
124
+ (ext == "ts" || ext == "tsx") && p.is_file()
125
+ } else {
126
+ false
127
+ };
128
+
129
+ if use_orig {
130
+ p.set_extension(orig_ext);
131
+ }
132
133
134
p.display().to_string().into()
135
136
es/full/bugs-1
349986
± 23901
415024
± 11128
0.84
es/full/minify/libraries/antd
1934789356
± 23070368
2059852743
± 21382128
0.94
es/full/minify/libraries/d3
441425492
± 13334204
400056910
± 12122381
1.10
es/full/minify/libraries/echarts
1631399893
± 23971596
1747708510
± 51799219
0.93
es/full/minify/libraries/jquery
105250008
± 4197173
114822889
± 2099146
0.92
es/full/minify/libraries/lodash
121952960
± 5997550
136021333
± 2885108
0.90
es/full/minify/libraries/moment
64139381
± 2439516
68753123
± 1921550
es/full/minify/libraries/react
19524393
± 889560
23768869
± 371905
0.82
es/full/minify/libraries/terser
323287095
± 12244757
319858540
± 7732483
1.01
es/full/minify/libraries/three
566247022
± 12461867
587466327
± 16970628
0.96
es/full/minify/libraries/typescript
3404412242
± 59099208
3928839245
± 96394563
0.87
es/full/minify/libraries/victory
828383184
± 16656445
858729512
± 44506772
es/full/minify/libraries/vue
156822302
± 9688709
176970113
± 4334526
0.89
es/full/codegen/es3
33282
± 411
39903
± 393
0.83
es/full/codegen/es5
33198
± 868
39878
± 1156
es/full/codegen/es2015
33350
± 1023
39900
± 2029
es/full/codegen/es2016
33305
± 1891
39958
± 1408
es/full/codegen/es2017
33172
± 999
39856
± 6764
es/full/codegen/es2018
32509
± 1026
39962
± 1280
0.81
es/full/codegen/es2019
32420
± 946
39774
± 398
es/full/codegen/es2020
33245
± 1702
39770
± 2499
es/full/all/es3
187398591
± 7271044
231297844
± 12075968
es/full/all/es5
178482800
± 7573081
221334095
± 6321418
es/full/all/es2015
142353419
± 6180392
177746904
± 5251374
0.80
es/full/all/es2016
141010441
± 5199930
176211727
± 6218441
es/full/all/es2017
141411608
± 5769307
176323630
± 5322826
es/full/all/es2018
138981524
± 4475812
173754346
± 5824901
es/full/all/es2019
138017983
± 7235148
172430481
± 8524138
es/full/all/es2020
133637106
± 5799622
166146618
± 11099605
es/full/parser
721147
± 30622
860817
± 29437
es/full/base/fixer
26438
± 886
32970
± 2391
es/full/base/resolver_and_hygiene
90459
± 4581
114336
± 7573
0.79
serialization of ast node
224
± 6
260
± 3
0.86
serialization of serde
231
± 7
264
± 5
0.88
This comment was automatically generated by workflow using github-action-benchmark.
1 commit comments
github-actions[bot] commentedon Nov 14, 2022
Benchmark
es/full/bugs-1
349986
ns/iter (± 23901
)415024
ns/iter (± 11128
)0.84
es/full/minify/libraries/antd
1934789356
ns/iter (± 23070368
)2059852743
ns/iter (± 21382128
)0.94
es/full/minify/libraries/d3
441425492
ns/iter (± 13334204
)400056910
ns/iter (± 12122381
)1.10
es/full/minify/libraries/echarts
1631399893
ns/iter (± 23971596
)1747708510
ns/iter (± 51799219
)0.93
es/full/minify/libraries/jquery
105250008
ns/iter (± 4197173
)114822889
ns/iter (± 2099146
)0.92
es/full/minify/libraries/lodash
121952960
ns/iter (± 5997550
)136021333
ns/iter (± 2885108
)0.90
es/full/minify/libraries/moment
64139381
ns/iter (± 2439516
)68753123
ns/iter (± 1921550
)0.93
es/full/minify/libraries/react
19524393
ns/iter (± 889560
)23768869
ns/iter (± 371905
)0.82
es/full/minify/libraries/terser
323287095
ns/iter (± 12244757
)319858540
ns/iter (± 7732483
)1.01
es/full/minify/libraries/three
566247022
ns/iter (± 12461867
)587466327
ns/iter (± 16970628
)0.96
es/full/minify/libraries/typescript
3404412242
ns/iter (± 59099208
)3928839245
ns/iter (± 96394563
)0.87
es/full/minify/libraries/victory
828383184
ns/iter (± 16656445
)858729512
ns/iter (± 44506772
)0.96
es/full/minify/libraries/vue
156822302
ns/iter (± 9688709
)176970113
ns/iter (± 4334526
)0.89
es/full/codegen/es3
33282
ns/iter (± 411
)39903
ns/iter (± 393
)0.83
es/full/codegen/es5
33198
ns/iter (± 868
)39878
ns/iter (± 1156
)0.83
es/full/codegen/es2015
33350
ns/iter (± 1023
)39900
ns/iter (± 2029
)0.84
es/full/codegen/es2016
33305
ns/iter (± 1891
)39958
ns/iter (± 1408
)0.83
es/full/codegen/es2017
33172
ns/iter (± 999
)39856
ns/iter (± 6764
)0.83
es/full/codegen/es2018
32509
ns/iter (± 1026
)39962
ns/iter (± 1280
)0.81
es/full/codegen/es2019
32420
ns/iter (± 946
)39774
ns/iter (± 398
)0.82
es/full/codegen/es2020
33245
ns/iter (± 1702
)39770
ns/iter (± 2499
)0.84
es/full/all/es3
187398591
ns/iter (± 7271044
)231297844
ns/iter (± 12075968
)0.81
es/full/all/es5
178482800
ns/iter (± 7573081
)221334095
ns/iter (± 6321418
)0.81
es/full/all/es2015
142353419
ns/iter (± 6180392
)177746904
ns/iter (± 5251374
)0.80
es/full/all/es2016
141010441
ns/iter (± 5199930
)176211727
ns/iter (± 6218441
)0.80
es/full/all/es2017
141411608
ns/iter (± 5769307
)176323630
ns/iter (± 5322826
)0.80
es/full/all/es2018
138981524
ns/iter (± 4475812
)173754346
ns/iter (± 5824901
)0.80
es/full/all/es2019
138017983
ns/iter (± 7235148
)172430481
ns/iter (± 8524138
)0.80
es/full/all/es2020
133637106
ns/iter (± 5799622
)166146618
ns/iter (± 11099605
)0.80
es/full/parser
721147
ns/iter (± 30622
)860817
ns/iter (± 29437
)0.84
es/full/base/fixer
26438
ns/iter (± 886
)32970
ns/iter (± 2391
)0.80
es/full/base/resolver_and_hygiene
90459
ns/iter (± 4581
)114336
ns/iter (± 7573
)0.79
serialization of ast node
224
ns/iter (± 6
)260
ns/iter (± 3
)0.86
serialization of serde
231
ns/iter (± 7
)264
ns/iter (± 5
)0.88
This comment was automatically generated by workflow using github-action-benchmark.