@swc/core 1.2.146 → 1.2.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,134 @@
5
5
 
6
6
 
7
7
 
8
+ - **(es/compat)** Initialize class fields as a last step (#3767) ([11bf29f](https://github.com/swc-project/swc/commit/11bf29f44b4233b2e7f60b750ef56429dbe47ce9))
9
+
10
+
11
+ - **(es/minifier)** Disable some operations for asm.js codes (#3572) ([e7f7f69](https://github.com/swc-project/swc/commit/e7f7f69db4f327b35005e863d3669bad382626c6))
12
+
13
+
14
+ - **(es/minifier)** Fix inlining logic (#3776) ([cfc0363](https://github.com/swc-project/swc/commit/cfc036381a5c174798198f4ecf7e0a62abce5a75))
15
+
16
+
17
+ - **(es/minifier)** Preserve unresolved references (#3780) ([73cab63](https://github.com/swc-project/swc/commit/73cab638a11978da9f94c886a5fafc462b1556b7))
18
+
19
+
20
+ - **(es/minifier)** Fix optimizations of terminating expressions (#3794) ([8beaa20](https://github.com/swc-project/swc/commit/8beaa202e2a8c321a0f2266378d0f0a3ecb06c03))
21
+
22
+
23
+ - **(es/react)** Catch refresh directives widely (#3791) ([5ae907f](https://github.com/swc-project/swc/commit/5ae907f6f21d31da708ac7237536bd6f838856c3))
24
+
25
+
26
+ - **(es/react)** Fix logic for extracting refresh comments (#3796) ([b485b5a](https://github.com/swc-project/swc/commit/b485b5a1d5480548de9ce2c22060be37298e6346))
27
+
28
+
29
+ - **(es/typescript)** Transform `this` in TypeScript classes (#3764) ([5f3f9ef](https://github.com/swc-project/swc/commit/5f3f9ef033797a1b13d32bd854c3acf3cbaf4495))
30
+
31
+
32
+ - **(node-swc/cli)** Correctly expose `swcx` entrypoint (#3784) ([95ecc01](https://github.com/swc-project/swc/commit/95ecc013fe9b0ab0c2f52465bd961616315938c3))
33
+
34
+ ### Documentation
35
+
36
+
37
+
38
+ - **(adr)** Add `adr-00002` for event trace profiling (#3787) ([3c1c5d0](https://github.com/swc-project/swc/commit/3c1c5d0363b231a8ac3f5bdfd15f1b2ec9224849))
39
+
40
+ ### Features
41
+
42
+
43
+
44
+ - **(css/ast)** Union `Value` and `ComponentValue` (#3804) ([3ec45a6](https://github.com/swc-project/swc/commit/3ec45a6858a24c56ee1fe143410f3763b2b5e4b4))
45
+
46
+
47
+ - **(css/lints)** Add CSS linter (#3765) ([66c6cae](https://github.com/swc-project/swc/commit/66c6cae8dc7d614aac83a620b4dff022459f54d7))
48
+
49
+
50
+ - **(css/lints)** Add `selector-max-combinators` rule (#3789) ([e389bef](https://github.com/swc-project/swc/commit/e389bef3ad0f27382d2d6c5f2be62dd28e65e757))
51
+
52
+
53
+ - **(css/minifier)** Convert more length (#3769) ([500d62c](https://github.com/swc-project/swc/commit/500d62c0850a93321baafb44fa4ac4b8a9bff3f8))
54
+
55
+
56
+ - **(es/codegen)** Optimize output of new expressions without arguments (#3800) ([e1b13eb](https://github.com/swc-project/swc/commit/e1b13eb21a6eb1ec094a64ab30852042b89748a8))
57
+
58
+
59
+ - **(es/compat)** Optimize handling of literals in computed property names (#3756) ([8ed4d2f](https://github.com/swc-project/swc/commit/8ed4d2fcaccf27733e8fbfe19da810504653ce6b))
60
+
61
+
62
+ - **(es/compat)** Add tracing support for `es2022` transforms (#3785) ([4d70482](https://github.com/swc-project/swc/commit/4d7048291fae26c081754a496d9c77ddb2215575))
63
+
64
+
65
+ - **(es/compat)** Use sequence expressions instead of iife in `classes` pass (#3773) ([5b6beca](https://github.com/swc-project/swc/commit/5b6beca1afb7e4278629840c94c775a083288cd2))
66
+
67
+
68
+ - **(es/compat)** Add tracing support for es2020 transforms (#3798) ([8f41d7a](https://github.com/swc-project/swc/commit/8f41d7a10e99c21dc12176ee7724f0e13ca702dd))
69
+
70
+
71
+ - **(es/dep-graph)** Add support for `require.resolve` (#3783) ([19b84e7](https://github.com/swc-project/swc/commit/19b84e7723c381843c98df90f64e5123acdd5808))
72
+
73
+
74
+ - **(es/minifier)** Consider `arguments` while dropping unused assignments (#3775) ([714e05e](https://github.com/swc-project/swc/commit/714e05e5535dd4f8552ce700cc5b582d134d8a08))
75
+
76
+
77
+ - **(es/module)** Workaround stack overflow bug of JavaScriptCore related to too many exports (#3763) ([ad0a853](https://github.com/swc-project/swc/commit/ad0a8539e058fda49e40cc8fab167e2602576d48))
78
+
79
+
80
+ - **(es/modules)** Support system js (#3659) ([557a520](https://github.com/swc-project/swc/commit/557a520a6d6814f79625ca0227c47fa2d42a806e))
81
+
82
+
83
+ - **(es/parser)** Raise a syntax error on an invalid shorthand assignment (#3734) ([2aa3b21](https://github.com/swc-project/swc/commit/2aa3b2123fc73bc187099b5c4a0b1f796b0a51f4))
84
+
85
+
86
+ - **(es/quote)** Implement quasi quoter partially (#3155) ([fe0ddcc](https://github.com/swc-project/swc/commit/fe0ddcc54b0f8343a3a3d227bde8b38fa47ebd80))
87
+
88
+
89
+ - **(es/quote)** Support variables (#3774) ([e3c374b](https://github.com/swc-project/swc/commit/e3c374b53bdd3fe8baef5be7a63b10d2efcd47e4))
90
+
91
+
92
+ - **(plugin)** Expose `swc_ecma_quote` (#3790) ([bc60a6e](https://github.com/swc-project/swc/commit/bc60a6e90ccc1adcb8d9eda9ef47725e20fbfa23))
93
+
94
+
95
+ - **(plugin/runner)** Update `wasmer` to `v2.2` (#3788) ([99d536e](https://github.com/swc-project/swc/commit/99d536e4869df5a9cc642ed0a155683165ee93c9))
96
+
97
+ ### Miscellaneous Tasks
98
+ - **general**: Update `rustc` (#3768) ([3798436](https://github.com/swc-project/swc/commit/3798436201a0838e55beac974792f4d560b47657))
99
+
100
+ ### Performance
101
+
102
+
103
+
104
+ - **(css/lints)** Skip disabled rules (#3803) ([0336029](https://github.com/swc-project/swc/commit/0336029c22a8751d2acb9765f11ead79c77115dc))
105
+
106
+
107
+ - **(plugin/runner)** Optimize `write_into_memory_view` (#3797) ([7fd0eee](https://github.com/swc-project/swc/commit/7fd0eeecb844a182fef39872178e3991356e3ae0))
108
+
109
+ ### Refactor
110
+
111
+
112
+
113
+ - **(css/ast)** Simplify AST types (#3753) ([815a489](https://github.com/swc-project/swc/commit/815a489dcfb72df928fc03f216dbe4a21b0e0716))
114
+
115
+
116
+ - **(css/lints)** Simplify error reporting API (#3781) ([b8211da](https://github.com/swc-project/swc/commit/b8211da1c9a8277cf09a8a3a1d7ae537b5d6e783))
117
+
118
+ ### Testing
119
+
120
+
121
+
122
+ - **(css/parser)** Add tests for selectors (#3770) ([1651bcc](https://github.com/swc-project/swc/commit/1651bccf4578ff2d44a9c37eab3845c006b5164d))
123
+
124
+
125
+ - **(css/parser)** Add css files for material design (#3777) ([189707a](https://github.com/swc-project/swc/commit/189707a1fd5ef8547b3b80ac82f7f422f295086a))
126
+
127
+
128
+ - **(es/minifier)** Prepare porting more rules from `terser` (#3779) ([86072b5](https://github.com/swc-project/swc/commit/86072b57f9e0cf59b660f88cdb2c9cee15f33720))
129
+
130
+ ## [1.2.146] - 2022-02-27
131
+
132
+ ### Bug Fixes
133
+
134
+
135
+
8
136
  - **(css)** Fix processing of integers (#3752) ([f258ee4](https://github.com/swc-project/swc/commit/f258ee4729ccd007b43b1a08d77359d99f53ca87))
9
137
 
10
138
 
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.146",
3
+ "version": "1.2.147",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
7
+ "bin": {
8
+ "swcx": "run_swcx.js"
9
+ },
7
10
  "author": "강동윤 <kdy1997.dev@gmail.com>",
8
11
  "license": "Apache-2.0",
9
12
  "keywords": [
@@ -104,18 +107,18 @@
104
107
  "url": "https://opencollective.com/swc"
105
108
  },
106
109
  "optionalDependencies": {
107
- "@swc/core-win32-x64-msvc": "1.2.146",
108
- "@swc/core-darwin-x64": "1.2.146",
109
- "@swc/core-linux-x64-gnu": "1.2.146",
110
- "@swc/core-linux-x64-musl": "1.2.146",
111
- "@swc/core-freebsd-x64": "1.2.146",
112
- "@swc/core-win32-ia32-msvc": "1.2.146",
113
- "@swc/core-linux-arm64-gnu": "1.2.146",
114
- "@swc/core-linux-arm-gnueabihf": "1.2.146",
115
- "@swc/core-darwin-arm64": "1.2.146",
116
- "@swc/core-android-arm64": "1.2.146",
117
- "@swc/core-linux-arm64-musl": "1.2.146",
118
- "@swc/core-win32-arm64-msvc": "1.2.146",
119
- "@swc/core-android-arm-eabi": "1.2.146"
110
+ "@swc/core-win32-x64-msvc": "1.2.147",
111
+ "@swc/core-darwin-x64": "1.2.147",
112
+ "@swc/core-linux-x64-gnu": "1.2.147",
113
+ "@swc/core-linux-x64-musl": "1.2.147",
114
+ "@swc/core-freebsd-x64": "1.2.147",
115
+ "@swc/core-win32-ia32-msvc": "1.2.147",
116
+ "@swc/core-linux-arm64-gnu": "1.2.147",
117
+ "@swc/core-linux-arm-gnueabihf": "1.2.147",
118
+ "@swc/core-darwin-arm64": "1.2.147",
119
+ "@swc/core-android-arm64": "1.2.147",
120
+ "@swc/core-linux-arm64-musl": "1.2.147",
121
+ "@swc/core-win32-arm64-msvc": "1.2.147",
122
+ "@swc/core-android-arm-eabi": "1.2.147"
120
123
  }
121
124
  }
package/run_swcx.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/run_swcx.js ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ /**
17
+ * Lightweight entrypoint to native swc cli binary.
18
+ *
19
+ * This is to locate corresponding per-platform executables correctly, as well as
20
+ * let npm links binary to `node_modules/.bin` allows npm-related ecosystem (`npx swcx`, etcs)
21
+ * works correctly. However, it means spawning native binary still requires warmup from node.js
22
+ * process.
23
+ *
24
+ * NOTE: THIS IS NOT A PERMANENT APPROACH.
25
+ * Distribution of native cli binary is not fully concluded yet. This allows easier
26
+ * opt-in while implementation is in progress to collect feedback.
27
+ */
28
+ const child_process_1 = require("child_process");
29
+ const path_1 = __importDefault(require("path"));
30
+ const fs_1 = require("fs");
31
+ const { platform, arch } = process;
32
+ const isMusl = () => (() => {
33
+ function isMusl() {
34
+ if (!process.report || typeof process.report.getReport !== "function") {
35
+ try {
36
+ return (0, fs_1.readFileSync)("/usr/bin/ldd", "utf8").includes("musl");
37
+ }
38
+ catch (e) {
39
+ return true;
40
+ }
41
+ }
42
+ else {
43
+ const { glibcVersionRuntime } = process.report.getReport().header;
44
+ return !glibcVersionRuntime;
45
+ }
46
+ }
47
+ return isMusl();
48
+ })();
49
+ const platformPackagesMap = {
50
+ "android": {
51
+ "arm64": "@swc/core-android-arm64",
52
+ "arm": "@swc/core-android-arm-eabi",
53
+ },
54
+ "win32": {
55
+ "x64": "@swc/core-win32-x64-msvc",
56
+ "ia32": "@swc/core-win32-ia32-msvc",
57
+ "arm64": "@swc/core-win32-arm64-msvc"
58
+ },
59
+ "darwin": {
60
+ "x64": "@swc/core-darwin-x64",
61
+ "arm64": "@swc/core-darwin-arm64",
62
+ },
63
+ "freebsd": {
64
+ "x64": "@swc/core-freebsd-x64",
65
+ },
66
+ "linux": {
67
+ "x64": `@swc/core-linux-x64-${isMusl() ? 'musl' : 'gnu'}`,
68
+ "arm64": `@swc/core-linux-arm64-${isMusl() ? 'musl' : 'gnu'}`,
69
+ "arm": "@swc/core-linux-arm64-gnu"
70
+ },
71
+ };
72
+ const inferBinaryName = () => {
73
+ const packageName = platformPackagesMap[platform][arch];
74
+ if (!packageName) {
75
+ throw new Error(`Unsupported platform: binary for '${platform} ${arch}' is not available`);
76
+ }
77
+ return path_1.default.join(path_1.default.dirname(require.resolve(packageName)), platform === 'win32' ? 'swc.exe' : 'swc');
78
+ };
79
+ const executeBinary = () => __awaiter(void 0, void 0, void 0, function* () {
80
+ const binary = inferBinaryName();
81
+ const [, , ...args] = process.argv;
82
+ const options = { cwd: process.cwd(), stdio: "inherit" };
83
+ return (0, child_process_1.spawn)(binary, args, options);
84
+ });
85
+ executeBinary().catch((e) => console.error(e));
@@ -1 +0,0 @@
1
- ### This adr attempts to describe 10,000ft view for the swc project itself. To be filled gradually.
@@ -1,94 +0,0 @@
1
- # Support transform plugin in native rust binaries
2
-
3
- - Status: accepted <!-- optional -->
4
- - Deciders: @kdy1, @kwonoj <!-- optional -->
5
- - Date: 2021-01-01 <!-- optional -->
6
-
7
- Technical Story: [Issue](https://github.com/swc-project/swc/issues/2635) <!-- optional -->
8
-
9
- ## Context and Problem Statement
10
-
11
- SWC wants to support load, run plugins in the native binary for the custom transform behavior. SWC already have priliminary support to load plugins in its node.js JS bindings but it has known limitations.
12
-
13
- ## Decision Drivers <!-- optional -->
14
-
15
- - Allow to write a plugin binary can be loaded in the SWC's native binary without involving JS binding interop.
16
- - Provide good, satisfactory performance while loading, running plugin's custom transformation.
17
- - Keep abi stability as much, plugin binary should work across different versions of SWC host binary except intended breaking changes.
18
- - Allow to write a plugin without caring much around the native platform targets binaries.
19
-
20
- ## Considered Options
21
-
22
- - [option 1] JS-based plugins, including babel plugins
23
-
24
- - [option 2] Plugins based on `abi_stable` and native dynamic libraries
25
-
26
- - [option 3] Wasm plugins based on `wasmtime`
27
-
28
- - **[option 4]** Wasm plugins based on `wasmer`
29
-
30
- ## Decision Outcome
31
-
32
- Chosen option: **[option 4] Wasm plugins based on `wasmer`**
33
-
34
- This decision is taken because
35
-
36
- - It was relatively easy plugin author to generate single binary works across most of platforms SWC's host binary supports, without concern of cross-target compilations.
37
- - It was relatively easy to achieve abi-stable between SWC host to plugin binaries.
38
- - It doesn't require to have separate, specialized AST struct (named `plugin_ast`) to pass into ffi boundary of the plugin.
39
- - Its serialization / deserialization performance is near identical or faster than `abi_stable` based ffi
40
-
41
- ## Pros and Cons of the Options <!-- optional -->
42
-
43
- ### [option 1] JS-based plugins, including babel plugins
44
-
45
- SWC allow implementing plugins using javascript, and call it from worker threads as required.
46
- This includes babel plugins, to make migration from babel more convenient.
47
-
48
- - Good, because users can use rich ecosystem of babel.
49
- - Good, because users are used to javascript.
50
- - Good, because all platforms are supported.
51
- - Bad, because passing data to and from javascript is very costly. ([SWC issue: Speed up `parse`](https://github.com/swc-project/swc/issues/2175))
52
- - Bad, because js plugins require and block the main javascript thread.
53
- - Bad, because the main javascript is singled threaded and be bottleneck.
54
- - Bad, because `napi` (renamed to `node-api`) does not provide a way to get the return value of a function called from other thread than js thread. To workaround this, we should implement a complex request-response system based using lots of mutex.
55
- - Bad, because node js worker thread is not an event loop. This means worker we cannot `yield` from a worker thread when we need to call js plugin. As a result, the when main js thread is busy because of js plugins, worker threads are also blocked without doing any task.
56
-
57
- ### [option 2] Plugins based on `abi_stable` and native dynamic libraries
58
-
59
- Plugins are written in rust, and built as native libraries for each platforms. SWC pass data to plugin using special form of AST, which has stable memory representation regardless of the version of `rustc`.
60
-
61
- - Good, because it's fast, even on the first run.
62
- - Good, because it does not require very complex request-response system.
63
- - Good, because plugin authors can use all features of rust.
64
- - Bad, because configuring CI for publishing plugins is very hard.
65
- - Bad, because plugin developer cannot publish a plugin from a single machine.
66
- - Bad, because loading of plugins is complex. Path for dynamic libraries are platform-dependant.
67
- - Bad, because we have to handle quirks of each platforms.
68
- - Bad, because `@swc/wasm` has no way to support plugins.
69
-
70
- ### [option 3] Wasm plugins based on `wasmtime`
71
-
72
- SWC embeds `wasmtime`, loads plugin built as web assembly.
73
-
74
- - Good, because it's fast except the first run.
75
- - Good, because configuring CI is simple.
76
- - Good, because plugin authors can publish a plugin without CI, even with a single machine.
77
- - Bad, because `@swc/wasm` has no way to support plugins.
78
- - Bad, because first run is slow.
79
- - Bad, because we have to manage the cache of compiled wasm files.
80
- - Bad, because `wasmtime` does not support all platforms.
81
-
82
- ### [option 4] Wasm plugins based on `wasmer`
83
-
84
- SWC embeds web assembly runtime (https://wasmer.io/), loads plugin built as web assembly.
85
-
86
- - Good, because it's fast except the first run.
87
- - Good, because configuring CI is simple.
88
- - Good, because plugin authors can publish a plugin without CI, even with a single machine.
89
- - Good, because `@swc/wasm` can support plugins in future as `wasmer` officially supports using it within a wasm file.
90
- - Bad, because first run is slow.
91
- - Bad, because we have to manage the cache of compiled wasm files.
92
- - Bad, because `wasmer` does not support all platforms.
93
-
94
- ## Links
@@ -1,13 +0,0 @@
1
- # Architectural Decision Records
2
-
3
- This directory contains a series of [Architectural Decision Records](https://adr.github.io/)
4
- or "ADRs" for the `swc` project. We're going to try to use it as a kind of collective
5
- memory of the decisions we've made and the path we've taken to get the project to its current
6
- point.
7
-
8
- Note that these are *historical references* that do not supersede (but might enhance) the living
9
- documentation of the project itself, which you can find inline in the source code.
10
-
11
- Proposing a non-trivial change to the way `swc` works? You might like to start with an ADR
12
- by copying `template.md` into a new file, filling out a first version of the proposal, and
13
- posting it as a PR on the github repo for discussion.
@@ -1,72 +0,0 @@
1
- # [short title of solved problem and solution]
2
-
3
- * Status: [proposed | rejected | accepted | deprecated | … | superseded by [ADR-0005](0005-example.md)] <!-- optional -->
4
- * Deciders: [list everyone involved in the decision] <!-- optional -->
5
- * Date: [YYYY-MM-DD when the decision was last updated] <!-- optional -->
6
-
7
- Technical Story: [description | ticket/issue URL] <!-- optional -->
8
-
9
- ## Context and Problem Statement
10
-
11
- [Describe the context and problem statement, e.g., in free form using two to three sentences. You may want to articulate the problem in form of a question.]
12
-
13
- ## Decision Drivers <!-- optional -->
14
-
15
- * [driver 1, e.g., a force, facing concern, …]
16
- * [driver 2, e.g., a force, facing concern, …]
17
- * … <!-- numbers of drivers can vary -->
18
-
19
- ## Considered Options
20
-
21
- * [option 1]
22
- * [option 2]
23
- * [option 3]
24
- * … <!-- numbers of options can vary -->
25
-
26
- ## Decision Outcome
27
-
28
- Chosen option: "[option 1]", because [justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force force | … | comes out best (see below)].
29
-
30
- ### Positive Consequences <!-- optional -->
31
-
32
- * [e.g., improvement of quality attribute satisfaction, follow-up decisions required, …]
33
- * …
34
-
35
- ### Negative Consequences <!-- optional -->
36
-
37
- * [e.g., compromising quality attribute, follow-up decisions required, …]
38
- * …
39
-
40
- ## Pros and Cons of the Options <!-- optional -->
41
-
42
- ### [option 1]
43
-
44
- [example | description | pointer to more information | …] <!-- optional -->
45
-
46
- * Good, because [argument a]
47
- * Good, because [argument b]
48
- * Bad, because [argument c]
49
- * … <!-- numbers of pros and cons can vary -->
50
-
51
- ### [option 2]
52
-
53
- [example | description | pointer to more information | …] <!-- optional -->
54
-
55
- * Good, because [argument a]
56
- * Good, because [argument b]
57
- * Bad, because [argument c]
58
- * … <!-- numbers of pros and cons can vary -->
59
-
60
- ### [option 3]
61
-
62
- [example | description | pointer to more information | …] <!-- optional -->
63
-
64
- * Good, because [argument a]
65
- * Good, because [argument b]
66
- * Bad, because [argument c]
67
- * … <!-- numbers of pros and cons can vary -->
68
-
69
- ## Links <!-- optional -->
70
-
71
- * [Link type] [Link to ADR] <!-- example: Refined by [ADR-0005](0005-example.md) -->
72
- * … <!-- numbers of links can vary -->