Skip to content

Commit d6952ea

Browse files
authoredAug 25, 2023
feat(swc-info): Add a CLI to help issue reporting (#7871)
1 parent 7911973 commit d6952ea

File tree

10 files changed

+185
-10
lines changed

10 files changed

+185
-10
lines changed
 

‎.github/ISSUE_TEMPLATE/bug_report.yml

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ body:
3030
attributes:
3131
label: Playground link
3232
description: You can use [swc playground](https://play.swc.rs/) to create a reproduction link, then paste the link here.
33+
- type: input
34+
id: swc-info
35+
attributes:
36+
label: SWC Info output
37+
description: Please run `npx -y swc-info@latest` and paste the output here.
3338
- type: textarea
3439
id: expected-behavior
3540
attributes:

‎packages/swc-info/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
yarn.lock
2+
node_modules
3+
_/
4+
*.tgz
5+
lib/*.js
6+
tests/*.js
7+
*.d.ts
8+
*.map

‎packages/swc-info/.npmignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
examples/
2+
node_modules/
3+
package-lock.json
4+
*.log
5+
.swcrc
6+
.yarn
7+
*.tgz
8+
.dprint.json
9+
out/
10+
tests/

‎packages/swc-info/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# swc-info
2+
3+
## Usage
4+
5+
```sh
6+
npx -y swc-info@latest
7+
```
8+
9+
then copy the output to the issue;.

‎packages/swc-info/bin/swc-info.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require("../lib/index.js");

‎packages/swc-info/lib/index.ts

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import os from "node:os";
2+
import process from "node:process";
3+
import childProcess from "child_process";
4+
5+
function getUniqueCpuNames(): string {
6+
return os
7+
.cpus()
8+
.map((cpu) => cpu.model)
9+
.filter((model, index, models) => models.indexOf(model) === index)
10+
.join(", ");
11+
}
12+
13+
function getBinaryVersion(binaryName: string): string {
14+
try {
15+
return childProcess
16+
.execFileSync(binaryName, ["--version"])
17+
.toString()
18+
.trim();
19+
} catch {
20+
return "N/A";
21+
}
22+
}
23+
24+
function getPackageVersion(packageName: string) {
25+
try {
26+
return require(`${packageName}/package.json`).version;
27+
} catch {
28+
return null;
29+
}
30+
}
31+
32+
function interestingPackage(name: string): string | null {
33+
const version = getPackageVersion(name);
34+
if (version) {
35+
return `${name}: ${version}`;
36+
} else {
37+
return null;
38+
}
39+
}
40+
function interestingPackages(names: string[]): string {
41+
return names.map(interestingPackage).filter(Boolean).join("\n ");
42+
}
43+
44+
console.log(`
45+
Operating System:
46+
Platform: ${os.platform()}
47+
Arch: ${os.arch()}
48+
Machine Type: ${os.machine()}
49+
Version: ${os.version()}
50+
CPU: (${os.cpus().length} cores)
51+
Models: ${getUniqueCpuNames()}
52+
53+
Binaries:
54+
Node: ${process.versions.node}
55+
npm: ${getBinaryVersion("npm")}
56+
Yarn: ${getBinaryVersion("yarn")}
57+
pnpm: ${getBinaryVersion("pnpm")}
58+
59+
Relevant Packages:
60+
@swc/core: ${getPackageVersion("@swc/core") ?? "N/A"}
61+
@swc/helpers: ${getPackageVersion("@swc/helpers") ?? "N/A"}
62+
@swc/types: ${getPackageVersion("@swc/types") ?? "N/A"}
63+
${interestingPackages(["typescript", "next"])}
64+
65+
SWC Config:
66+
output: N/A
67+
.swcrc path: N/A
68+
69+
Next.js info:
70+
output: N/A
71+
`);

‎packages/swc-info/package.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "swc-info",
3+
"packageManager": "yarn@3.2.3",
4+
"version": "0.1.11",
5+
"description": "CLI tool to help issue reporting for swc",
6+
"sideEffects": false,
7+
"scripts": {
8+
"build": "tsc",
9+
"prepublishOnly": "yarn build",
10+
"prepack": "yarn build"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/swc-project/swc.git"
15+
},
16+
"publishConfig": {
17+
"registry": "https://registry.npmjs.org/",
18+
"access": "public"
19+
},
20+
"keywords": [
21+
"swc",
22+
"info",
23+
"cli"
24+
],
25+
"author": "강동윤 <kdy1997.dev@gmail.com>",
26+
"license": "Apache-2.0",
27+
"bugs": {
28+
"url": "https://github.com/swc-project/swc/issues"
29+
},
30+
"homepage": "https://swc.rs",
31+
"devDependencies": {
32+
"typescript": "^5.2.2"
33+
},
34+
"bin": {
35+
"swc-info": "bin/swc-info.js"
36+
}
37+
}

‎packages/swc-info/tsconfig.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2019",
4+
"useDefineForClassFields": true,
5+
"module": "commonjs",
6+
"baseUrl": "./",
7+
"paths": {},
8+
"resolveJsonModule": true,
9+
"declaration": true,
10+
"sourceMap": true,
11+
"downlevelIteration": true,
12+
"esModuleInterop": true,
13+
"forceConsistentCasingInFileNames": true,
14+
"strict": true,
15+
"skipLibCheck": true,
16+
"rootDir": "."
17+
},
18+
"include": [
19+
"lib",
20+
"tests"
21+
],
22+
"exclude": [
23+
"examples"
24+
]
25+
}

‎packages/types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"homepage": "https://swc.rs",
2929
"packageManager": "yarn@3.2.3",
3030
"devDependencies": {
31-
"typescript": "^5.1.6"
31+
"typescript": "^5.2.2"
3232
}
3333
}

‎packages/yarn.lock

+17-9
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ __metadata:
124124
version: 0.0.0-use.local
125125
resolution: "@swc/types@workspace:types"
126126
dependencies:
127-
typescript: ^5.1.6
127+
typescript: ^5.2.2
128128
languageName: unknown
129129
linkType: soft
130130

@@ -611,6 +611,14 @@ __metadata:
611611
languageName: node
612612
linkType: hard
613613

614+
"swc-info@workspace:swc-info":
615+
version: 0.0.0-use.local
616+
resolution: "swc-info@workspace:swc-info"
617+
dependencies:
618+
typescript: ^5.2.2
619+
languageName: unknown
620+
linkType: soft
621+
614622
"through@npm:2, through@npm:~2.3, through@npm:~2.3.1":
615623
version: 2.3.8
616624
resolution: "through@npm:2.3.8"
@@ -634,23 +642,23 @@ __metadata:
634642
languageName: node
635643
linkType: hard
636644

637-
"typescript@npm:^5.1.6":
638-
version: 5.1.6
639-
resolution: "typescript@npm:5.1.6"
645+
"typescript@npm:^5.2.2":
646+
version: 5.2.2
647+
resolution: "typescript@npm:5.2.2"
640648
bin:
641649
tsc: bin/tsc
642650
tsserver: bin/tsserver
643-
checksum: b2f2c35096035fe1f5facd1e38922ccb8558996331405eb00a5111cc948b2e733163cc22fab5db46992aba7dd520fff637f2c1df4996ff0e134e77d3249a7350
651+
checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c
644652
languageName: node
645653
linkType: hard
646654

647-
"typescript@patch:typescript@^5.1.6#~builtin<compat/typescript>":
648-
version: 5.1.6
649-
resolution: "typescript@patch:typescript@npm%3A5.1.6#~builtin<compat/typescript>::version=5.1.6&hash=a1c5e5"
655+
"typescript@patch:typescript@^5.2.2#~builtin<compat/typescript>":
656+
version: 5.2.2
657+
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=a1c5e5"
650658
bin:
651659
tsc: bin/tsc
652660
tsserver: bin/tsserver
653-
checksum: 21e88b0a0c0226f9cb9fd25b9626fb05b4c0f3fddac521844a13e1f30beb8f14e90bd409a9ac43c812c5946d714d6e0dee12d5d02dfc1c562c5aacfa1f49b606
661+
checksum: 07106822b4305de3f22835cbba949a2b35451cad50888759b6818421290ff95d522b38ef7919e70fb381c5fe9c1c643d7dea22c8b31652a717ddbd57b7f4d554
654662
languageName: node
655663
linkType: hard
656664

1 commit comments

Comments
 (1)

github-actions[bot] commented on Aug 26, 2023

@github-actions[bot]

Benchmark

Benchmark suite Current: d6952ea Previous: 11ebae1 Ratio
es/full/bugs-1 280619 ns/iter (± 5371) 294741 ns/iter (± 17799) 0.95
es/full/minify/libraries/antd 1298374692 ns/iter (± 14178530) 1353774624 ns/iter (± 19709215) 0.96
es/full/minify/libraries/d3 274144366 ns/iter (± 3711679) 282776418 ns/iter (± 7034123) 0.97
es/full/minify/libraries/echarts 1044609969 ns/iter (± 9518734) 1084848269 ns/iter (± 14523627) 0.96
es/full/minify/libraries/jquery 83595233 ns/iter (± 186091) 83769748 ns/iter (± 370697) 1.00
es/full/minify/libraries/lodash 96321253 ns/iter (± 638953) 97537042 ns/iter (± 895677) 0.99
es/full/minify/libraries/moment 49349460 ns/iter (± 100280) 49591857 ns/iter (± 509105) 1.00
es/full/minify/libraries/react 17872849 ns/iter (± 131613) 17862445 ns/iter (± 79443) 1.00
es/full/minify/libraries/terser 215683804 ns/iter (± 2435229) 219931785 ns/iter (± 2745553) 0.98
es/full/minify/libraries/three 381734046 ns/iter (± 2271046) 393541517 ns/iter (± 5484319) 0.97
es/full/minify/libraries/typescript 2598229586 ns/iter (± 7781357) 2667322670 ns/iter (± 21574738) 0.97
es/full/minify/libraries/victory 557996193 ns/iter (± 3490993) 592135605 ns/iter (± 16351602) 0.94
es/full/minify/libraries/vue 118201585 ns/iter (± 160980) 119677614 ns/iter (± 843292) 0.99
es/full/codegen/es3 35022 ns/iter (± 120) 35124 ns/iter (± 113) 1.00
es/full/codegen/es5 34980 ns/iter (± 103) 35154 ns/iter (± 99) 1.00
es/full/codegen/es2015 34883 ns/iter (± 187) 35248 ns/iter (± 108) 0.99
es/full/codegen/es2016 34934 ns/iter (± 115) 35032 ns/iter (± 96) 1.00
es/full/codegen/es2017 34980 ns/iter (± 176) 35104 ns/iter (± 149) 1.00
es/full/codegen/es2018 34829 ns/iter (± 132) 34967 ns/iter (± 170) 1.00
es/full/codegen/es2019 35039 ns/iter (± 152) 35065 ns/iter (± 401) 1.00
es/full/codegen/es2020 34915 ns/iter (± 204) 35149 ns/iter (± 123) 0.99
es/full/all/es3 167650525 ns/iter (± 1198731) 167713213 ns/iter (± 462897) 1.00
es/full/all/es5 160606367 ns/iter (± 811537) 161345203 ns/iter (± 754336) 1.00
es/full/all/es2015 120620423 ns/iter (± 766447) 120269261 ns/iter (± 506742) 1.00
es/full/all/es2016 119306522 ns/iter (± 737421) 119455138 ns/iter (± 367072) 1.00
es/full/all/es2017 118650721 ns/iter (± 1035784) 118849745 ns/iter (± 665869) 1.00
es/full/all/es2018 116101359 ns/iter (± 1046308) 116323980 ns/iter (± 890309) 1.00
es/full/all/es2019 115392605 ns/iter (± 766987) 115507936 ns/iter (± 1512163) 1.00
es/full/all/es2020 111576278 ns/iter (± 632941) 112397217 ns/iter (± 1295562) 0.99
es/full/parser 489291 ns/iter (± 5634) 499280 ns/iter (± 6986) 0.98
es/full/base/fixer 18789 ns/iter (± 514) 18316 ns/iter (± 44) 1.03
es/full/base/resolver_and_hygiene 80317 ns/iter (± 257) 80063 ns/iter (± 240) 1.00
serialization of serde 299 ns/iter (± 0) 295 ns/iter (± 2) 1.01
css/minify/libraries/bootstrap 28520582 ns/iter (± 126077) 28557242 ns/iter (± 54920) 1.00
css/visitor/compare/clone 1628869 ns/iter (± 2843) 1629298 ns/iter (± 2596) 1.00
css/visitor/compare/visit_mut_span 1775438 ns/iter (± 3812) 1757160 ns/iter (± 1857) 1.01
css/visitor/compare/visit_mut_span_panic 1828205 ns/iter (± 7917) 1838396 ns/iter (± 3476) 0.99
css/visitor/compare/fold_span 2564354 ns/iter (± 5668) 2551501 ns/iter (± 9886) 1.01
css/visitor/compare/fold_span_panic 2757153 ns/iter (± 17094) 2744024 ns/iter (± 9953) 1.00
css/lexer/bootstrap_5_1_3 4519492 ns/iter (± 16795) 4518565 ns/iter (± 3038) 1.00
css/lexer/foundation_6_7_4 3808347 ns/iter (± 8483) 3805691 ns/iter (± 2383) 1.00
css/lexer/tailwind_3_1_1 725380 ns/iter (± 785) 720948 ns/iter (± 506) 1.01
css/parser/bootstrap_5_1_3 20421693 ns/iter (± 41195) 19057353 ns/iter (± 33622) 1.07
css/parser/foundation_6_7_4 16378288 ns/iter (± 18615) 15466972 ns/iter (± 15570) 1.06
css/parser/tailwind_3_1_1 3088678 ns/iter (± 4968) 2983734 ns/iter (± 2861) 1.04
es/codegen/colors 737687 ns/iter (± 402963) 738781 ns/iter (± 402960) 1.00
es/codegen/large 3141051 ns/iter (± 1667538) 2891289 ns/iter (± 1524342) 1.09
es/codegen/with-parser/colors 45137 ns/iter (± 515) 45203 ns/iter (± 663) 1.00
es/codegen/with-parser/large 483459 ns/iter (± 626) 487504 ns/iter (± 826) 0.99
es/minify/libraries/antd 1115486653 ns/iter (± 8354504) 1152245650 ns/iter (± 11885588) 0.97
es/minify/libraries/d3 237542062 ns/iter (± 679763) 238716261 ns/iter (± 781809) 1.00
es/minify/libraries/echarts 877299356 ns/iter (± 7015934) 906320765 ns/iter (± 8264284) 0.97
es/minify/libraries/jquery 72861329 ns/iter (± 187144) 72544205 ns/iter (± 167978) 1.00
es/minify/libraries/lodash 86427551 ns/iter (± 189342) 86481074 ns/iter (± 216918) 1.00
es/minify/libraries/moment 43139017 ns/iter (± 71417) 43100624 ns/iter (± 60010) 1.00
es/minify/libraries/react 15918351 ns/iter (± 43120) 15950270 ns/iter (± 57231) 1.00
es/minify/libraries/terser 183825152 ns/iter (± 342827) 184596320 ns/iter (± 997584) 1.00
es/minify/libraries/three 317706317 ns/iter (± 1013083) 320538123 ns/iter (± 1950571) 0.99
es/minify/libraries/typescript 2209305961 ns/iter (± 7457249) 2235114049 ns/iter (± 9924833) 0.99
es/minify/libraries/victory 463207547 ns/iter (± 2627291) 480677564 ns/iter (± 9346096) 0.96
es/minify/libraries/vue 104965089 ns/iter (± 208612) 105556035 ns/iter (± 259560) 0.99
es/visitor/compare/clone 1965800 ns/iter (± 6956) 1957097 ns/iter (± 4260) 1.00
es/visitor/compare/visit_mut_span 2267856 ns/iter (± 5192) 2273498 ns/iter (± 9579) 1.00
es/visitor/compare/visit_mut_span_panic 2322029 ns/iter (± 3782) 2346508 ns/iter (± 5142) 0.99
es/visitor/compare/fold_span 3372421 ns/iter (± 5633) 3388515 ns/iter (± 7157) 1.00
es/visitor/compare/fold_span_panic 3481872 ns/iter (± 5448) 3491631 ns/iter (± 5873) 1.00
es/lexer/colors 12895 ns/iter (± 52) 12984 ns/iter (± 24) 0.99
es/lexer/angular 6015144 ns/iter (± 24692) 6012272 ns/iter (± 8122) 1.00
es/lexer/backbone 770729 ns/iter (± 1062) 772660 ns/iter (± 2110) 1.00
es/lexer/jquery 4397336 ns/iter (± 4885) 4425650 ns/iter (± 5106) 0.99
es/lexer/jquery mobile 6680276 ns/iter (± 3771) 6708183 ns/iter (± 10321) 1.00
es/lexer/mootools 3505647 ns/iter (± 5341) 3513608 ns/iter (± 4535) 1.00
es/lexer/underscore 649918 ns/iter (± 307) 648797 ns/iter (± 1508) 1.00
es/lexer/three 21015807 ns/iter (± 23806) 21011769 ns/iter (± 56317) 1.00
es/lexer/yui 3758545 ns/iter (± 3373) 3770270 ns/iter (± 4575) 1.00
es/parser/colors 27032 ns/iter (± 22) 27055 ns/iter (± 69) 1.00
es/parser/angular 13330624 ns/iter (± 74455) 13550817 ns/iter (± 100727) 0.98
es/parser/backbone 1956214 ns/iter (± 7306) 1985618 ns/iter (± 7238) 0.99
es/parser/jquery 10705150 ns/iter (± 53378) 10805712 ns/iter (± 46826) 0.99
es/parser/jquery mobile 16445822 ns/iter (± 45556) 16622316 ns/iter (± 61318) 0.99
es/parser/mootools 8235806 ns/iter (± 18171) 8303081 ns/iter (± 18014) 0.99
es/parser/underscore 1682280 ns/iter (± 7482) 1698416 ns/iter (± 9777) 0.99
es/parser/three 45879748 ns/iter (± 183188) 47348792 ns/iter (± 962846) 0.97
es/parser/yui 8135051 ns/iter (± 29773) 8232625 ns/iter (± 26337) 0.99
es/preset-env/usage/builtin_type 135365 ns/iter (± 31368) 138136 ns/iter (± 33304) 0.98
es/preset-env/usage/property 17032 ns/iter (± 50) 16983 ns/iter (± 49) 1.00
es/resolver/typescript 86910623 ns/iter (± 1097760) 88781610 ns/iter (± 926469) 0.98
es/fixer/typescript 63337937 ns/iter (± 389764) 64304909 ns/iter (± 634994) 0.98
es/hygiene/typescript 127698027 ns/iter (± 644994) 128949766 ns/iter (± 1185163) 0.99
es/resolver_with_hygiene/typescript 236671625 ns/iter (± 1298979) 240685626 ns/iter (± 1451966) 0.98
es/visitor/base-perf/module_clone 59410 ns/iter (± 321) 58869 ns/iter (± 248) 1.01
es/visitor/base-perf/fold_empty 63675 ns/iter (± 374) 62501 ns/iter (± 283) 1.02
es/visitor/base-perf/fold_noop_impl_all 63652 ns/iter (± 374) 63080 ns/iter (± 208) 1.01
es/visitor/base-perf/fold_noop_impl_vec 64085 ns/iter (± 186) 62905 ns/iter (± 263) 1.02
es/visitor/base-perf/boxing_boxed_clone 57 ns/iter (± 0) 58 ns/iter (± 0) 0.98
es/visitor/base-perf/boxing_unboxed_clone 41 ns/iter (± 0) 46 ns/iter (± 0) 0.89
es/visitor/base-perf/boxing_boxed 109 ns/iter (± 0) 110 ns/iter (± 0) 0.99
es/visitor/base-perf/boxing_unboxed 78 ns/iter (± 0) 80 ns/iter (± 0) 0.97
es/visitor/base-perf/visit_empty 0 ns/iter (± 0) 0 ns/iter (± 0) NaN
es/visitor/base-perf/visit_contains_this 2618 ns/iter (± 28) 2620 ns/iter (± 34) 1.00
es/base/parallel/resolver/typescript 4234443465 ns/iter (± 269562844) 3887086571 ns/iter (± 271399555) 1.09
es/base/parallel/hygiene/typescript 1447125972 ns/iter (± 12957803) 1442054423 ns/iter (± 13404763) 1.00
misc/visitors/time-complexity/time 5 133 ns/iter (± 3) 133 ns/iter (± 5) 1
misc/visitors/time-complexity/time 10 397 ns/iter (± 6) 305 ns/iter (± 0) 1.30
misc/visitors/time-complexity/time 15 687 ns/iter (± 13) 519 ns/iter (± 2) 1.32
misc/visitors/time-complexity/time 20 1045 ns/iter (± 14) 1049 ns/iter (± 3) 1.00
misc/visitors/time-complexity/time 40 4180 ns/iter (± 298) 3565 ns/iter (± 40) 1.17
misc/visitors/time-complexity/time 60 7246 ns/iter (± 43) 7302 ns/iter (± 26) 0.99
es/full-target/es2016 232871 ns/iter (± 659) 228013 ns/iter (± 358) 1.02
es/full-target/es2017 220794 ns/iter (± 697) 217853 ns/iter (± 986) 1.01
es/full-target/es2018 207680 ns/iter (± 1220) 205911 ns/iter (± 479) 1.01
es2020_nullish_coalescing 70211 ns/iter (± 555) 72388 ns/iter (± 283) 0.97
es2020_optional_chaining 80964 ns/iter (± 642) 82812 ns/iter (± 201) 0.98
es2022_class_properties 115468 ns/iter (± 794) 117005 ns/iter (± 357) 0.99
es2018_object_rest_spread 75276 ns/iter (± 839) 76552 ns/iter (± 225) 0.98
es2019_optional_catch_binding 64225 ns/iter (± 226) 65257 ns/iter (± 243) 0.98
es2017_async_to_generator 63710 ns/iter (± 480) 65240 ns/iter (± 283) 0.98
es2016_exponentiation 68132 ns/iter (± 727) 67370 ns/iter (± 203) 1.01
es2015_arrow 71643 ns/iter (± 259) 73067 ns/iter (± 325) 0.98
es2015_block_scoped_fn 68594 ns/iter (± 484) 70635 ns/iter (± 258) 0.97
es2015_block_scoping 125365 ns/iter (± 624) 122967 ns/iter (± 593) 1.02

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

Please sign in to comment.