@swc/core 1.2.206 → 1.2.209

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,171 @@
5
5
 
6
6
 
7
7
 
8
+ - **(es/codegen)** Emit numeric value for Binary and Octal literals (#5083) ([8df6e04](https://github.com/swc-project/swc/commit/8df6e047cc523088a26a3363fe33f1bc224738b0))
9
+
10
+
11
+ - **(es/compat)** Preserve spans in `object_rest_spread` (#5082) ([de66b64](https://github.com/swc-project/swc/commit/de66b64aed13166803ebdfb91d1c421eec064c25))
12
+
13
+
14
+ - **(es/compat)** Preserve class names (#5104) ([adbb0bf](https://github.com/swc-project/swc/commit/adbb0bf8d8391aa4f15d64c72be701c03de98617))
15
+
16
+
17
+ - **(es/lints)** Cover more `const-assign` cases (#5098) ([f7d857c](https://github.com/swc-project/swc/commit/f7d857c6b6c32ad228aa929d0301b22c9d34ff8b))
18
+
19
+
20
+ - **(es/modules)** Preserve orders of exports (#5081) ([2f2039c](https://github.com/swc-project/swc/commit/2f2039c693bd1e16b16dd1b1b32f3582fdadca4e))
21
+
22
+
23
+ - **(es/modules)** Create an indirect call for a lazy require (#5089) ([0a7ca2f](https://github.com/swc-project/swc/commit/0a7ca2f4bbfaa2573b4da6b25127064cbcfd755f))
24
+
25
+
26
+ - **(es/modules)** Support lazy for `export from` (#5103) ([c531e67](https://github.com/swc-project/swc/commit/c531e67a3058bd6d567922d74fe51dc6e393761b))
27
+
28
+
29
+ - **(es/react)** Don't panic on invalid react pragma (#5101) ([cc555ef](https://github.com/swc-project/swc/commit/cc555ef225e3299bc17b6e21d67b3a42619abd5a))
30
+
31
+
32
+ - **(es/resolver)** Fix handling of block scoped functions (#5092) ([9519e80](https://github.com/swc-project/swc/commit/9519e801ea3bd9a0d7cc4f145323d0a734c83669))
33
+
34
+
35
+ - **(html/minifier)** Small fix (#5079) ([5ac5ae2](https://github.com/swc-project/swc/commit/5ac5ae200c3c896f205e7c4567a5a6281d16015b))
36
+
37
+
38
+ - **(html/minifier)** Fix bugs of the smart mode (#5093) ([5932a0a](https://github.com/swc-project/swc/commit/5932a0a2ef42ae67f1d2eceebe752b01160ca6fe))
39
+
40
+
41
+ - **(node/types)** Add `simplify` (#5105) ([2a29b50](https://github.com/swc-project/swc/commit/2a29b50c5eb7e1441c2735fec9686771c6050053))
42
+
43
+ ### Features
44
+
45
+
46
+
47
+ - **(es/modules)** Support `allowTopLevelThis` (#5086) ([9addef6](https://github.com/swc-project/swc/commit/9addef6fc8672854b52a1b71668795474a6f3fec))
48
+
49
+
50
+ - **(es/modules)** Add pure annotations to interop functions (#5087) ([4d5783d](https://github.com/swc-project/swc/commit/4d5783d9cd1f91f5b7cdcc5efaa7d83f35ee4fef))
51
+
52
+
53
+ - **(es/modules)** Support AMD triple slash directives (#5091) ([ddb31d1](https://github.com/swc-project/swc/commit/ddb31d1fd79250b14cbb873424f02c750f9c6ef6))
54
+
55
+
56
+ - **(es/parser)** Support labelled function from annex B (#5078) ([b62fd3e](https://github.com/swc-project/swc/commit/b62fd3e6cc371ad4f8cb9055b3fed70f1954afa2))
57
+
58
+
59
+ - **(html/minifier)** Remove empty metadata elements (#5085) ([cb845c9](https://github.com/swc-project/swc/commit/cb845c9bf903136b074af269b96a685027599284))
60
+
61
+
62
+ - **(visit)** Add path-aware variants (#5073) ([204d742](https://github.com/swc-project/swc/commit/204d742ed6ed5f91612245604b4e9037470bc97a))
63
+
64
+ ### Testing
65
+
66
+
67
+
68
+ - **(es/modules)** Add test for string-names (#5088) ([52bfb18](https://github.com/swc-project/swc/commit/52bfb18113895d20bc952e84302e8591c1fdf407))
69
+
70
+ ## [1.2.208] - 2022-07-01
71
+
72
+ ### Bug Fixes
73
+
74
+
75
+
76
+ - **(es/compat)** Preserve this in function with block scoped vars (#5056) ([18ea2b5](https://github.com/swc-project/swc/commit/18ea2b577011d610fbb06bb6728a86be8366703a))
77
+
78
+
79
+ - **(es/modules)** Handle `this` in class methods (#5065) ([ef543b1](https://github.com/swc-project/swc/commit/ef543b1b22b9cf29add68984318fe19620240888))
80
+
81
+
82
+ - **(es/modules)** Improve compatibility with cjs lexer (#5080) ([9e162dc](https://github.com/swc-project/swc/commit/9e162dcbae91a3dd4cef47ab0d80de14ada6d70d))
83
+
84
+
85
+ - **(html/minifier)** Fix smart mode (#5058) ([e9bad20](https://github.com/swc-project/swc/commit/e9bad20898df92f7d0dd898ab1924229d5113251))
86
+
87
+
88
+ - **(html/minifier)** Minify `meta` element (#5075) ([214c60a](https://github.com/swc-project/swc/commit/214c60a313162218c9acb007b8747dbc8f39ac8a))
89
+
90
+ ### Documentation
91
+
92
+
93
+
94
+ - **(contributing)** Add `--features memory_cache` to test steps (#5074) ([9d8beb0](https://github.com/swc-project/swc/commit/9d8beb02b7161a6af604cf187f2a53d91cd336ea))
95
+
96
+ ### Features
97
+
98
+
99
+
100
+ - **(atoms)** Improve atoms (#5066) ([34f4f5a](https://github.com/swc-project/swc/commit/34f4f5a3bc7797e2b9b192671cf68b63ea0dd25c))
101
+
102
+
103
+ - **(es/modules)** Support node interop (#5069) ([1e33dba](https://github.com/swc-project/swc/commit/1e33dbab24a534477ed1046b57a0c9daeb84e3ca))
104
+
105
+
106
+ - **(es/parser)** Add `allow_return_outside_function` to options (#5046) ([37eb366](https://github.com/swc-project/swc/commit/37eb366a1f554668fd7011869ec8f58c67e9ce9f))
107
+
108
+
109
+ - **(html/minifier)** Allow minifying custom script contents (#5043) ([d7a5f71](https://github.com/swc-project/swc/commit/d7a5f710730063c51deb91c9aa937f7d5a33e582))
110
+
111
+
112
+ - **(html/minifier)** Sort unordered values in attributes (#5035) ([26cfeff](https://github.com/swc-project/swc/commit/26cfeff79cbae9c7b998690ed6b59d2336cf2430))
113
+
114
+
115
+ - **(html/minifier)** Improve `collapse_whitespaces` (#5070) ([144314d](https://github.com/swc-project/swc/commit/144314dcc2e98baba79502be6f82ea39aa71f560))
116
+
117
+
118
+ - **(plugin)** Add versioned wrapper struct (#5062) ([e34a864](https://github.com/swc-project/swc/commit/e34a864390dc6a8a0d78cc60af458be37031e30f))
119
+
120
+
121
+ - **(plugin)** Allow taking the inner data from versioned (#5071) ([e1aa937](https://github.com/swc-project/swc/commit/e1aa937183ca3c803be9665ec0a683b679bfc29f))
122
+
123
+ ### Miscellaneous Tasks
124
+
125
+
126
+
127
+ - **(deps)** Update `rkyv` (#5057) ([374366d](https://github.com/swc-project/swc/commit/374366d56ca431dc892b390efaf090ee4d116100))- **general**: Workaround cargo mono bug ([60424db](https://github.com/swc-project/swc/commit/60424db67b3c9bc0d36012249e16ebaa2100f299))
128
+
129
+ ### Performance
130
+
131
+
132
+
133
+ - **(atoms)** More groundwork for replacing `JsWord` with `Atom` (#5064) ([2e139f1](https://github.com/swc-project/swc/commit/2e139f144126636a5d44ae3866cf858426a1bb8e))
134
+
135
+ ## [1.2.207] - 2022-06-28
136
+
137
+ ### Bug Fixes
138
+
139
+
140
+
141
+ - **(es/compat)** Handle classes with accessors and a method with the same name (#5039) ([25bd520](https://github.com/swc-project/swc/commit/25bd5206205d76c1ff93e67b67b3aeca551113d6))
142
+
143
+
144
+ - **(es/modules)** Handle module references in binding idents (#5055) ([e13364f](https://github.com/swc-project/swc/commit/e13364f976e0c10f879fa0f9678c617a713d052d))
145
+
146
+
147
+ - **(node-swc/types)** Add `nodenext` config type (#5044) ([7d4e6be](https://github.com/swc-project/swc/commit/7d4e6bef96242d6506fb0f51c7002f7bbc84af94))
148
+
149
+ ### Features
150
+
151
+
152
+
153
+ - **(es/lints)** Report an error for reassignment to import binding (#5033) ([376c4e1](https://github.com/swc-project/swc/commit/376c4e11af5aa8c0e5bc5900f6168893644473b7))
154
+
155
+
156
+ - **(es/minifier)** Handle pure annotations on member expressions (#5050) ([a15bb48](https://github.com/swc-project/swc/commit/a15bb485241b2a5fb2ecbbd56558dcb5915b8ff4))
157
+
158
+
159
+ - **(es/modules)** Optimize a dynamic import with a literal path (#5049) ([2cc229e](https://github.com/swc-project/swc/commit/2cc229e6fb1d0b439e1fe7661be481494f57efa9))
160
+
161
+
162
+ - **(html/minifier)** Allow compressing additional attributes (#5036) ([55e0ea3](https://github.com/swc-project/swc/commit/55e0ea32940ff34de73e7eb4b8c999b58d798272))
163
+
164
+
165
+ - **(html/minifier)** Add `normalize_attributes` for disabling normalization (#5045) ([0836d29](https://github.com/swc-project/swc/commit/0836d29913e51846a3361837442c18e2011bec71))
166
+
167
+ ## [1.2.206] - 2022-06-27
168
+
169
+ ### Bug Fixes
170
+
171
+
172
+
8
173
  - **(es/compat)** Fix name conflict of `Array` (#5034) ([04fc1cb](https://github.com/swc-project/swc/commit/04fc1cb429b274e72bb2a939f4aaa102c158121a))
9
174
 
10
175
 
@@ -22,6 +187,12 @@
22
187
 
23
188
  - **(html/minifier)** Improve smart mode (#5004) ([9202ff9](https://github.com/swc-project/swc/commit/9202ff9700cbea5714a65746d7375fa41f8bb140))
24
189
 
190
+ ### Refactor
191
+
192
+
193
+
194
+ - **(es/module)** Implement new module transformer (#4758) ([fa68cbd](https://github.com/swc-project/swc/commit/fa68cbd74ad2b36c0f1aaec563320114d5603cae))
195
+
25
196
  ## [1.2.205] - 2022-06-24
26
197
 
27
198
  ### Bug Fixes
package/README.md CHANGED
@@ -34,6 +34,14 @@
34
34
 
35
35
  SWC (stands for `Speedy Web Compiler`) is a super-fast TypeScript / JavaScript compiler written in Rust. It's a library for Rust and JavaScript at the same time. If you are using SWC from Rust, see [rustdoc](https://rustdoc.swc.rs/swc/) and for most users, your entry point for using the library will be [parser](https://rustdoc.swc.rs/swc_ecma_parser/).
36
36
 
37
+ Also, SWC tries to ensure that
38
+
39
+ > If you select the latest version of each crates, it will work
40
+
41
+ for rust users. Without such guarantee, using SWC would be too hard as SWC is a large, modular project and typically you have to use many modules.
42
+
43
+ ---
44
+
37
45
  If you are using SWC from JavaScript, please refer to [docs on the website](https://swc.rs/docs/installation/).
38
46
 
39
47
  # Documentation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.206",
3
+ "version": "1.2.209",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
@@ -135,18 +135,18 @@
135
135
  "url": "https://opencollective.com/swc"
136
136
  },
137
137
  "optionalDependencies": {
138
- "@swc/core-win32-x64-msvc": "1.2.206",
139
- "@swc/core-darwin-x64": "1.2.206",
140
- "@swc/core-linux-x64-gnu": "1.2.206",
141
- "@swc/core-linux-x64-musl": "1.2.206",
142
- "@swc/core-freebsd-x64": "1.2.206",
143
- "@swc/core-win32-ia32-msvc": "1.2.206",
144
- "@swc/core-linux-arm64-gnu": "1.2.206",
145
- "@swc/core-linux-arm-gnueabihf": "1.2.206",
146
- "@swc/core-darwin-arm64": "1.2.206",
147
- "@swc/core-android-arm64": "1.2.206",
148
- "@swc/core-linux-arm64-musl": "1.2.206",
149
- "@swc/core-win32-arm64-msvc": "1.2.206",
150
- "@swc/core-android-arm-eabi": "1.2.206"
138
+ "@swc/core-win32-x64-msvc": "1.2.209",
139
+ "@swc/core-darwin-x64": "1.2.209",
140
+ "@swc/core-linux-x64-gnu": "1.2.209",
141
+ "@swc/core-linux-x64-musl": "1.2.209",
142
+ "@swc/core-freebsd-x64": "1.2.209",
143
+ "@swc/core-win32-ia32-msvc": "1.2.209",
144
+ "@swc/core-linux-arm64-gnu": "1.2.209",
145
+ "@swc/core-linux-arm-gnueabihf": "1.2.209",
146
+ "@swc/core-darwin-arm64": "1.2.209",
147
+ "@swc/core-android-arm64": "1.2.209",
148
+ "@swc/core-linux-arm64-musl": "1.2.209",
149
+ "@swc/core-win32-arm64-msvc": "1.2.209",
150
+ "@swc/core-android-arm-eabi": "1.2.209"
151
151
  }
152
152
  }
package/types.d.ts CHANGED
@@ -642,6 +642,7 @@ export interface ConstModulesConfig {
642
642
  };
643
643
  }
644
644
  export interface OptimizerConfig {
645
+ simplify?: boolean;
645
646
  globals?: GlobalPassOption;
646
647
  jsonify?: {
647
648
  minCost: number;
@@ -666,7 +667,7 @@ export interface GlobalPassOption {
666
667
  */
667
668
  envs?: string[];
668
669
  }
669
- export declare type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig;
670
+ export declare type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig;
670
671
  export interface BaseModuleConfig {
671
672
  /**
672
673
  * By default, when using exports with babel a non-enumerable `__esModule`
@@ -721,6 +722,8 @@ export interface BaseModuleConfig {
721
722
  */
722
723
  lazy?: boolean | string[];
723
724
  /**
725
+ * @deprecated Use the `importInterop` option instead.
726
+ *
724
727
  * By default, when using exports with swc a non-enumerable __esModule property is exported.
725
728
  * This property is then used to determine if the import is the default export or if
726
729
  * it contains the default export.
@@ -731,6 +734,93 @@ export interface BaseModuleConfig {
731
734
  * Defaults to `false`.
732
735
  */
733
736
  noInterop?: boolean;
737
+ /**
738
+ * Defaults to `swc`.
739
+ *
740
+ * CommonJS modules and ECMAScript modules are not fully compatible.
741
+ * However, compilers, bundlers and JavaScript runtimes developed different strategies
742
+ * to make them work together as well as possible.
743
+ *
744
+ * - `swc` (alias: `babel`)
745
+ *
746
+ * When using exports with `swc` a non-enumerable `__esModule` property is exported
747
+ * This property is then used to determine if the import is the default export
748
+ * or if it contains the default export.
749
+ *
750
+ * ```javascript
751
+ * import foo from "foo";
752
+ * import { bar } from "bar";
753
+ * foo;
754
+ * bar;
755
+ *
756
+ * // Is compiled to ...
757
+ *
758
+ * "use strict";
759
+ *
760
+ * function _interopRequireDefault(obj) {
761
+ * return obj && obj.__esModule ? obj : { default: obj };
762
+ * }
763
+ *
764
+ * var _foo = _interopRequireDefault(require("foo"));
765
+ * var _bar = require("bar");
766
+ *
767
+ * _foo.default;
768
+ * _bar.bar;
769
+ * ```
770
+ *
771
+ * When this import interop is used, if both the imported and the importer module are compiled
772
+ * with swc they behave as if none of them was compiled.
773
+ *
774
+ * This is the default behavior.
775
+ *
776
+ * - `node`
777
+ *
778
+ * When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
779
+ * Node.js always binds the `default` export to the value of `module.exports`.
780
+ *
781
+ * ```javascript
782
+ * import foo from "foo";
783
+ * import { bar } from "bar";
784
+ * foo;
785
+ * bar;
786
+ *
787
+ * // Is compiled to ...
788
+ *
789
+ * "use strict";
790
+ *
791
+ * var _foo = require("foo");
792
+ * var _bar = require("bar");
793
+ *
794
+ * _foo;
795
+ * _bar.bar;
796
+ * ```
797
+ * This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
798
+ * as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
799
+ * However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
800
+ *
801
+ * - `none`
802
+ *
803
+ * If you know that the imported file has been transformed with a compiler that stores the `default` export on
804
+ * `exports.default` (such as swc or Babel), you can safely omit the `_interopRequireDefault` helper.
805
+ *
806
+ * ```javascript
807
+ * import foo from "foo";
808
+ * import { bar } from "bar";
809
+ * foo;
810
+ * bar;
811
+ *
812
+ * // Is compiled to ...
813
+ *
814
+ * "use strict";
815
+ *
816
+ * var _foo = require("foo");
817
+ * var _bar = require("bar");
818
+ *
819
+ * _foo.default;
820
+ * _bar.bar;
821
+ * ```
822
+ */
823
+ importInterop?: "swc" | "babel" | "node" | "none";
734
824
  /**
735
825
  * If set to true, dynamic imports will be preserved.
736
826
  */
@@ -739,6 +829,9 @@ export interface BaseModuleConfig {
739
829
  export interface Es6Config extends BaseModuleConfig {
740
830
  type: "es6";
741
831
  }
832
+ export interface NodeNextConfig extends BaseModuleConfig {
833
+ type: "nodenext";
834
+ }
742
835
  export interface CommonJsConfig extends BaseModuleConfig {
743
836
  type: "commonjs";
744
837
  }