Skip to content

Commit

Permalink
fix(es/module): Revert #7901 (#7906)
Browse files Browse the repository at this point in the history
**Description:**

I'm reverting #7901 because it caused a regression in next.js CI.
vercel/next.js#54653


**Related issue:**

 - Reverts #7901.
  • Loading branch information
kdy1 authored Sep 1, 2023
1 parent fd1c0cf commit 85d6e9b
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
const _a = require("../packages/a/src/index.js");
const _a = require("../packages/a/src");
console.log(`${(0, _a.displayA)()}`);
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
(async function() {
const { displayA } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require("../packages/a/src/index.js")));
const { displayA } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require("../packages/a/src")));
console.log(displayA());
})();
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import test from "./utils/index.js";
import test from "./utils";
test();
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
require("./core/module/moduleFile");
require("./core/utils/index.js");
require("./core/utils");
require("./core/utilFile");
require("./utils/index.js");
require("./utils");
console.log("SUCCESS");
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import{config}from"../config/index.js";const main=()=>config();main();
import{config}from"../config";const main=()=>config();main();
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _ = /*#__PURE__*/ _interop_require_default._(require("./index.js"));
const _ = /*#__PURE__*/ _interop_require_default._(require("."));
function bar() {
console.log(_.default);
}
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/issues-7xxx/7829/1/output/1.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { fn } from "./libs/pkg/src/index.js";
import { fn } from "./libs/pkg/src";
console.log(fn);
6 changes: 5 additions & 1 deletion crates/swc_ecma_transforms_module/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ fn to_specifier(mut target_path: PathBuf, orig_filename: Option<&str>) -> JsWord
target_path.set_extension("js");
}
} else if is_resolved_as_ts && is_resolved_as_index {
target_path.set_extension("js");
if orig_filename == "index" {
target_path.set_extension("");
} else {
target_path.pop();
}
}
} else {
target_path.set_extension("");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { displayB } from "../packages/b/src/index.js";
import { displayB } from "../packages/b/src";
async function display() {
const displayA = await import("../packages/a/src/index.js").then((c)=>c.displayA);
const displayA = await import("../packages/a/src").then((c)=>c.displayA);
console.log(displayA());
console.log(displayB());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import o from "./index.js";
import o from ".";
export default function bar() {
console.log(o);
}
4 changes: 2 additions & 2 deletions node-swc/__tests__/transform/issue_4730_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ it("should work", async () => {
value: true
});
const _interop_require_wildcard = require(\\"@swc/helpers/_/_interop_require_wildcard\\");
const _b = require(\\"../packages/b/src/index.js\\");
const _b = require(\\"../packages/b/src\\");
async function display() {
const displayA = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require(\\"../packages/a/src/index.js\\"))).then((c)=>c.displayA);
const displayA = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require(\\"../packages/a/src\\"))).then((c)=>c.displayA);
console.log(displayA());
console.log((0, _b.displayB)());
}
Expand Down

1 comment on commit 85d6e9b

@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: 85d6e9b Previous: aa64955 Ratio
es/full/bugs-1 283033 ns/iter (± 5467) 280628 ns/iter (± 5331) 1.01
es/full/minify/libraries/antd 1335264000 ns/iter (± 13559921) 1304215294 ns/iter (± 8869837) 1.02
es/full/minify/libraries/d3 280355522 ns/iter (± 6638995) 273847872 ns/iter (± 3444517) 1.02
es/full/minify/libraries/echarts 1063321369 ns/iter (± 11193471) 1042977928 ns/iter (± 3513275) 1.02
es/full/minify/libraries/jquery 84018119 ns/iter (± 581700) 83156038 ns/iter (± 181838) 1.01
es/full/minify/libraries/lodash 97009616 ns/iter (± 410638) 96792320 ns/iter (± 178328) 1.00
es/full/minify/libraries/moment 49622622 ns/iter (± 144554) 49279230 ns/iter (± 123532) 1.01
es/full/minify/libraries/react 17884288 ns/iter (± 42623) 17838421 ns/iter (± 131766) 1.00
es/full/minify/libraries/terser 217277824 ns/iter (± 3073211) 215340552 ns/iter (± 913117) 1.01
es/full/minify/libraries/three 389508115 ns/iter (± 6870755) 381908258 ns/iter (± 2231572) 1.02
es/full/minify/libraries/typescript 2646593410 ns/iter (± 27835604) 2609878206 ns/iter (± 9740386) 1.01
es/full/minify/libraries/victory 576163193 ns/iter (± 7881833) 555183081 ns/iter (± 2989671) 1.04
es/full/minify/libraries/vue 119710247 ns/iter (± 309679) 118084901 ns/iter (± 299658) 1.01
es/full/codegen/es3 34912 ns/iter (± 125) 34608 ns/iter (± 59) 1.01
es/full/codegen/es5 34575 ns/iter (± 68) 34501 ns/iter (± 61) 1.00
es/full/codegen/es2015 34528 ns/iter (± 138) 34850 ns/iter (± 1019) 0.99
es/full/codegen/es2016 34544 ns/iter (± 96) 34631 ns/iter (± 77) 1.00
es/full/codegen/es2017 34461 ns/iter (± 129) 34615 ns/iter (± 173) 1.00
es/full/codegen/es2018 34477 ns/iter (± 70) 34561 ns/iter (± 39) 1.00
es/full/codegen/es2019 34537 ns/iter (± 76) 34595 ns/iter (± 75) 1.00
es/full/codegen/es2020 34486 ns/iter (± 130) 34625 ns/iter (± 85) 1.00
es/full/all/es3 169109701 ns/iter (± 591640) 168254806 ns/iter (± 1301071) 1.01
es/full/all/es5 161068730 ns/iter (± 813033) 159439700 ns/iter (± 1087981) 1.01
es/full/all/es2015 119781030 ns/iter (± 580442) 119757720 ns/iter (± 668073) 1.00
es/full/all/es2016 119368458 ns/iter (± 365486) 118609520 ns/iter (± 584228) 1.01
es/full/all/es2017 118208061 ns/iter (± 433504) 117321568 ns/iter (± 723892) 1.01
es/full/all/es2018 116638240 ns/iter (± 952899) 116235109 ns/iter (± 459972) 1.00
es/full/all/es2019 115833091 ns/iter (± 419147) 115619869 ns/iter (± 624074) 1.00
es/full/all/es2020 111314100 ns/iter (± 792140) 110738411 ns/iter (± 484225) 1.01
es/full/parser 489813 ns/iter (± 6081) 483137 ns/iter (± 5017) 1.01
es/full/base/fixer 18903 ns/iter (± 67) 19566 ns/iter (± 132) 0.97
es/full/base/resolver_and_hygiene 81167 ns/iter (± 610) 80521 ns/iter (± 179) 1.01
serialization of serde 286 ns/iter (± 0) 292 ns/iter (± 0) 0.98
css/minify/libraries/bootstrap 28739286 ns/iter (± 146047) 28632362 ns/iter (± 35847) 1.00
css/visitor/compare/clone 1669958 ns/iter (± 6747) 1623491 ns/iter (± 2246) 1.03
css/visitor/compare/visit_mut_span 1804396 ns/iter (± 3517) 1753361 ns/iter (± 5560) 1.03
css/visitor/compare/visit_mut_span_panic 1881029 ns/iter (± 6232) 1811776 ns/iter (± 7586) 1.04
css/visitor/compare/fold_span 2603664 ns/iter (± 6917) 2544639 ns/iter (± 6827) 1.02
css/visitor/compare/fold_span_panic 2769640 ns/iter (± 10480) 2756553 ns/iter (± 7741) 1.00
css/lexer/bootstrap_5_1_3 4490446 ns/iter (± 4899) 4517821 ns/iter (± 10224) 0.99
css/lexer/foundation_6_7_4 3778104 ns/iter (± 3302) 3787629 ns/iter (± 9823) 1.00
css/lexer/tailwind_3_1_1 722682 ns/iter (± 819) 720181 ns/iter (± 1835) 1.00
css/parser/bootstrap_5_1_3 19358599 ns/iter (± 27991) 19370990 ns/iter (± 43308) 1.00
css/parser/foundation_6_7_4 15508469 ns/iter (± 34162) 15367679 ns/iter (± 16171) 1.01
css/parser/tailwind_3_1_1 2976185 ns/iter (± 9144) 2964892 ns/iter (± 4517) 1.00
es/codegen/colors 736534 ns/iter (± 402412) 732624 ns/iter (± 401990) 1.01
es/codegen/large 3150942 ns/iter (± 1684907) 3150171 ns/iter (± 1688483) 1.00
es/codegen/with-parser/colors 45292 ns/iter (± 176) 44447 ns/iter (± 553) 1.02
es/codegen/with-parser/large 491211 ns/iter (± 961) 480275 ns/iter (± 2208) 1.02
es/minify/libraries/antd 1169272945 ns/iter (± 10497030) 1159615366 ns/iter (± 12149059) 1.01
es/minify/libraries/d3 240961402 ns/iter (± 1620762) 237999454 ns/iter (± 1254132) 1.01
es/minify/libraries/echarts 931222919 ns/iter (± 27171260) 894669912 ns/iter (± 13732259) 1.04
es/minify/libraries/jquery 74474045 ns/iter (± 500497) 72863573 ns/iter (± 237897) 1.02
es/minify/libraries/lodash 87327854 ns/iter (± 350956) 86755698 ns/iter (± 147892) 1.01
es/minify/libraries/moment 43514093 ns/iter (± 88552) 43270626 ns/iter (± 90890) 1.01
es/minify/libraries/react 16036078 ns/iter (± 70671) 15907124 ns/iter (± 48865) 1.01
es/minify/libraries/terser 187303388 ns/iter (± 664260) 184357685 ns/iter (± 478766) 1.02
es/minify/libraries/three 328474161 ns/iter (± 2068585) 319156278 ns/iter (± 825059) 1.03
es/minify/libraries/typescript 2278061495 ns/iter (± 10308705) 2214282612 ns/iter (± 9205167) 1.03
es/minify/libraries/victory 486686793 ns/iter (± 3565389) 463942297 ns/iter (± 1520798) 1.05
es/minify/libraries/vue 107037696 ns/iter (± 2137403) 105365415 ns/iter (± 168985) 1.02
es/visitor/compare/clone 1958855 ns/iter (± 5827) 1930916 ns/iter (± 6083) 1.01
es/visitor/compare/visit_mut_span 2311988 ns/iter (± 4238) 2273367 ns/iter (± 8639) 1.02
es/visitor/compare/visit_mut_span_panic 2349307 ns/iter (± 4473) 2310412 ns/iter (± 7754) 1.02
es/visitor/compare/fold_span 3365138 ns/iter (± 12138) 3298212 ns/iter (± 7375) 1.02
es/visitor/compare/fold_span_panic 3476294 ns/iter (± 5570) 3451946 ns/iter (± 5678) 1.01
es/lexer/colors 13412 ns/iter (± 17) 13105 ns/iter (± 42) 1.02
es/lexer/angular 6250011 ns/iter (± 1894) 6058310 ns/iter (± 6634) 1.03
es/lexer/backbone 803351 ns/iter (± 616) 785587 ns/iter (± 1502) 1.02
es/lexer/jquery 4583990 ns/iter (± 7330) 4491766 ns/iter (± 6937) 1.02
es/lexer/jquery mobile 7002492 ns/iter (± 6090) 6845951 ns/iter (± 19240) 1.02
es/lexer/mootools 3663840 ns/iter (± 14320) 3533913 ns/iter (± 12819) 1.04
es/lexer/underscore 678477 ns/iter (± 1244) 664242 ns/iter (± 1563) 1.02
es/lexer/three 21877803 ns/iter (± 10734) 21454814 ns/iter (± 37875) 1.02
es/lexer/yui 3910496 ns/iter (± 7077) 3807684 ns/iter (± 4623) 1.03
es/parser/colors 28050 ns/iter (± 33) 27235 ns/iter (± 180) 1.03
es/parser/angular 13440270 ns/iter (± 57452) 13405636 ns/iter (± 51758) 1.00
es/parser/backbone 1991726 ns/iter (± 9276) 1971400 ns/iter (± 7868) 1.01
es/parser/jquery 10887996 ns/iter (± 43392) 10812270 ns/iter (± 40807) 1.01
es/parser/jquery mobile 16705314 ns/iter (± 50964) 16449758 ns/iter (± 34066) 1.02
es/parser/mootools 8358743 ns/iter (± 18217) 8332841 ns/iter (± 18133) 1.00
es/parser/underscore 1713117 ns/iter (± 10530) 1707761 ns/iter (± 7232) 1.00
es/parser/three 47304373 ns/iter (± 331385) 46488151 ns/iter (± 104538) 1.02
es/parser/yui 8242898 ns/iter (± 38725) 8247970 ns/iter (± 25640) 1.00
es/preset-env/usage/builtin_type 137933 ns/iter (± 33329) 139218 ns/iter (± 32783) 0.99
es/preset-env/usage/property 16657 ns/iter (± 54) 16886 ns/iter (± 49) 0.99
es/resolver/typescript 91123619 ns/iter (± 1416943) 90157207 ns/iter (± 1314261) 1.01
es/fixer/typescript 62938032 ns/iter (± 241414) 63178593 ns/iter (± 716556) 1.00
es/hygiene/typescript 130539910 ns/iter (± 864132) 129450887 ns/iter (± 514825) 1.01
es/resolver_with_hygiene/typescript 244683720 ns/iter (± 2570144) 241473030 ns/iter (± 819258) 1.01
es/visitor/base-perf/module_clone 60434 ns/iter (± 227) 60741 ns/iter (± 296) 0.99
es/visitor/base-perf/fold_empty 64097 ns/iter (± 364) 64127 ns/iter (± 268) 1.00
es/visitor/base-perf/fold_noop_impl_all 63959 ns/iter (± 337) 65109 ns/iter (± 242) 0.98
es/visitor/base-perf/fold_noop_impl_vec 63754 ns/iter (± 712) 65034 ns/iter (± 397) 0.98
es/visitor/base-perf/boxing_boxed_clone 56 ns/iter (± 0) 57 ns/iter (± 0) 0.98
es/visitor/base-perf/boxing_unboxed_clone 40 ns/iter (± 0) 39 ns/iter (± 0) 1.03
es/visitor/base-perf/boxing_boxed 109 ns/iter (± 0) 106 ns/iter (± 0) 1.03
es/visitor/base-perf/boxing_unboxed 77 ns/iter (± 0) 75 ns/iter (± 0) 1.03
es/visitor/base-perf/visit_empty 0 ns/iter (± 0) 0 ns/iter (± 0) NaN
es/visitor/base-perf/visit_contains_this 2541 ns/iter (± 26) 2540 ns/iter (± 11) 1.00
es/base/parallel/resolver/typescript 4221688644 ns/iter (± 175862327) 4219568887 ns/iter (± 282081759) 1.00
es/base/parallel/hygiene/typescript 1442947567 ns/iter (± 15048725) 1435281187 ns/iter (± 14686868) 1.01
misc/visitors/time-complexity/time 5 134 ns/iter (± 0) 138 ns/iter (± 0) 0.97
misc/visitors/time-complexity/time 10 259 ns/iter (± 0) 372 ns/iter (± 14) 0.70
misc/visitors/time-complexity/time 15 677 ns/iter (± 6) 669 ns/iter (± 2) 1.01
misc/visitors/time-complexity/time 20 1063 ns/iter (± 20) 907 ns/iter (± 4) 1.17
misc/visitors/time-complexity/time 40 3890 ns/iter (± 4) 3558 ns/iter (± 11) 1.09
misc/visitors/time-complexity/time 60 7446 ns/iter (± 20) 7224 ns/iter (± 25) 1.03
es/full-target/es2016 226349 ns/iter (± 1554) 234726 ns/iter (± 1548) 0.96
es/full-target/es2017 215126 ns/iter (± 422) 226324 ns/iter (± 460) 0.95
es/full-target/es2018 204197 ns/iter (± 662) 212973 ns/iter (± 635) 0.96
es2020_nullish_coalescing 69230 ns/iter (± 286) 70239 ns/iter (± 350) 0.99
es2020_optional_chaining 78591 ns/iter (± 383) 81812 ns/iter (± 274) 0.96
es2022_class_properties 113956 ns/iter (± 386) 116187 ns/iter (± 327) 0.98
es2018_object_rest_spread 73576 ns/iter (± 161) 75045 ns/iter (± 219) 0.98
es2019_optional_catch_binding 63309 ns/iter (± 331) 64598 ns/iter (± 139) 0.98
es2017_async_to_generator 63467 ns/iter (± 288) 63421 ns/iter (± 274) 1.00
es2016_exponentiation 67910 ns/iter (± 287) 69274 ns/iter (± 193) 0.98
es2015_arrow 70766 ns/iter (± 367) 72027 ns/iter (± 196) 0.98
es2015_block_scoped_fn 68038 ns/iter (± 285) 68394 ns/iter (± 231) 0.99
es2015_block_scoping 122181 ns/iter (± 652) 119572 ns/iter (± 773) 1.02

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

Please sign in to comment.