@swc/core 1.2.205 → 1.2.208

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/package.json +14 -14
  3. package/types.d.ts +93 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,132 @@
5
5
 
6
6
 
7
7
 
8
+ - **(es/compat)** Preserve this in function with block scoped vars (#5056) ([18ea2b5](https://github.com/swc-project/swc/commit/18ea2b577011d610fbb06bb6728a86be8366703a))
9
+
10
+
11
+ - **(es/modules)** Handle `this` in class methods (#5065) ([ef543b1](https://github.com/swc-project/swc/commit/ef543b1b22b9cf29add68984318fe19620240888))
12
+
13
+
14
+ - **(es/modules)** Improve compatibility with cjs lexer (#5080) ([9e162dc](https://github.com/swc-project/swc/commit/9e162dcbae91a3dd4cef47ab0d80de14ada6d70d))
15
+
16
+
17
+ - **(html/minifier)** Fix smart mode (#5058) ([e9bad20](https://github.com/swc-project/swc/commit/e9bad20898df92f7d0dd898ab1924229d5113251))
18
+
19
+
20
+ - **(html/minifier)** Minify `meta` element (#5075) ([214c60a](https://github.com/swc-project/swc/commit/214c60a313162218c9acb007b8747dbc8f39ac8a))
21
+
22
+ ### Documentation
23
+
24
+
25
+
26
+ - **(contributing)** Add `--features memory_cache` to test steps (#5074) ([9d8beb0](https://github.com/swc-project/swc/commit/9d8beb02b7161a6af604cf187f2a53d91cd336ea))
27
+
28
+ ### Features
29
+
30
+
31
+
32
+ - **(atoms)** Improve atoms (#5066) ([34f4f5a](https://github.com/swc-project/swc/commit/34f4f5a3bc7797e2b9b192671cf68b63ea0dd25c))
33
+
34
+
35
+ - **(es/modules)** Support node interop (#5069) ([1e33dba](https://github.com/swc-project/swc/commit/1e33dbab24a534477ed1046b57a0c9daeb84e3ca))
36
+
37
+
38
+ - **(es/parser)** Add `allow_return_outside_function` to options (#5046) ([37eb366](https://github.com/swc-project/swc/commit/37eb366a1f554668fd7011869ec8f58c67e9ce9f))
39
+
40
+
41
+ - **(html/minifier)** Allow minifying custom script contents (#5043) ([d7a5f71](https://github.com/swc-project/swc/commit/d7a5f710730063c51deb91c9aa937f7d5a33e582))
42
+
43
+
44
+ - **(html/minifier)** Sort unordered values in attributes (#5035) ([26cfeff](https://github.com/swc-project/swc/commit/26cfeff79cbae9c7b998690ed6b59d2336cf2430))
45
+
46
+
47
+ - **(html/minifier)** Improve `collapse_whitespaces` (#5070) ([144314d](https://github.com/swc-project/swc/commit/144314dcc2e98baba79502be6f82ea39aa71f560))
48
+
49
+
50
+ - **(plugin)** Add versioned wrapper struct (#5062) ([e34a864](https://github.com/swc-project/swc/commit/e34a864390dc6a8a0d78cc60af458be37031e30f))
51
+
52
+
53
+ - **(plugin)** Allow taking the inner data from versioned (#5071) ([e1aa937](https://github.com/swc-project/swc/commit/e1aa937183ca3c803be9665ec0a683b679bfc29f))
54
+
55
+ ### Miscellaneous Tasks
56
+
57
+
58
+
59
+ - **(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))
60
+
61
+ ### Performance
62
+
63
+
64
+
65
+ - **(atoms)** More groundwork for replacing `JsWord` with `Atom` (#5064) ([2e139f1](https://github.com/swc-project/swc/commit/2e139f144126636a5d44ae3866cf858426a1bb8e))
66
+
67
+ ## [1.2.207] - 2022-06-28
68
+
69
+ ### Bug Fixes
70
+
71
+
72
+
73
+ - **(es/compat)** Handle classes with accessors and a method with the same name (#5039) ([25bd520](https://github.com/swc-project/swc/commit/25bd5206205d76c1ff93e67b67b3aeca551113d6))
74
+
75
+
76
+ - **(es/modules)** Handle module references in binding idents (#5055) ([e13364f](https://github.com/swc-project/swc/commit/e13364f976e0c10f879fa0f9678c617a713d052d))
77
+
78
+
79
+ - **(node-swc/types)** Add `nodenext` config type (#5044) ([7d4e6be](https://github.com/swc-project/swc/commit/7d4e6bef96242d6506fb0f51c7002f7bbc84af94))
80
+
81
+ ### Features
82
+
83
+
84
+
85
+ - **(es/lints)** Report an error for reassignment to import binding (#5033) ([376c4e1](https://github.com/swc-project/swc/commit/376c4e11af5aa8c0e5bc5900f6168893644473b7))
86
+
87
+
88
+ - **(es/minifier)** Handle pure annotations on member expressions (#5050) ([a15bb48](https://github.com/swc-project/swc/commit/a15bb485241b2a5fb2ecbbd56558dcb5915b8ff4))
89
+
90
+
91
+ - **(es/modules)** Optimize a dynamic import with a literal path (#5049) ([2cc229e](https://github.com/swc-project/swc/commit/2cc229e6fb1d0b439e1fe7661be481494f57efa9))
92
+
93
+
94
+ - **(html/minifier)** Allow compressing additional attributes (#5036) ([55e0ea3](https://github.com/swc-project/swc/commit/55e0ea32940ff34de73e7eb4b8c999b58d798272))
95
+
96
+
97
+ - **(html/minifier)** Add `normalize_attributes` for disabling normalization (#5045) ([0836d29](https://github.com/swc-project/swc/commit/0836d29913e51846a3361837442c18e2011bec71))
98
+
99
+ ## [1.2.206] - 2022-06-27
100
+
101
+ ### Bug Fixes
102
+
103
+
104
+
105
+ - **(es/compat)** Fix name conflict of `Array` (#5034) ([04fc1cb](https://github.com/swc-project/swc/commit/04fc1cb429b274e72bb2a939f4aaa102c158121a))
106
+
107
+
108
+ - **(es/parser)** Allow initializer of the var of for-in loop in non-strict mode (#5038) ([f238093](https://github.com/swc-project/swc/commit/f238093c3b54e5a6e9d46239c28ab936de7d68e9))
109
+
110
+ ### Features
111
+
112
+
113
+
114
+ - **(html/codegen)** Improve API (#5031) ([8bf924a](https://github.com/swc-project/swc/commit/8bf924ae5f7305d1db65cf5a9b09f76cb7903e2b))
115
+
116
+
117
+ - **(html/minifier)** Add `remove_comments` option (#5037) ([e6c78d0](https://github.com/swc-project/swc/commit/e6c78d0b1d863c61882c941f62fccd04a501530b))
118
+
119
+
120
+ - **(html/minifier)** Improve smart mode (#5004) ([9202ff9](https://github.com/swc-project/swc/commit/9202ff9700cbea5714a65746d7375fa41f8bb140))
121
+
122
+ ### Refactor
123
+
124
+
125
+
126
+ - **(es/module)** Implement new module transformer (#4758) ([fa68cbd](https://github.com/swc-project/swc/commit/fa68cbd74ad2b36c0f1aaec563320114d5603cae))
127
+
128
+ ## [1.2.205] - 2022-06-24
129
+
130
+ ### Bug Fixes
131
+
132
+
133
+
8
134
  - **(css/parser)** Improve lexer errors (#5025) ([c345524](https://github.com/swc-project/swc/commit/c345524e368078a59cdf5376999a5b443f2918e7))
9
135
 
10
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.205",
3
+ "version": "1.2.208",
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.205",
139
- "@swc/core-darwin-x64": "1.2.205",
140
- "@swc/core-linux-x64-gnu": "1.2.205",
141
- "@swc/core-linux-x64-musl": "1.2.205",
142
- "@swc/core-freebsd-x64": "1.2.205",
143
- "@swc/core-win32-ia32-msvc": "1.2.205",
144
- "@swc/core-linux-arm64-gnu": "1.2.205",
145
- "@swc/core-linux-arm-gnueabihf": "1.2.205",
146
- "@swc/core-darwin-arm64": "1.2.205",
147
- "@swc/core-android-arm64": "1.2.205",
148
- "@swc/core-linux-arm64-musl": "1.2.205",
149
- "@swc/core-win32-arm64-msvc": "1.2.205",
150
- "@swc/core-android-arm-eabi": "1.2.205"
138
+ "@swc/core-win32-x64-msvc": "1.2.208",
139
+ "@swc/core-darwin-x64": "1.2.208",
140
+ "@swc/core-linux-x64-gnu": "1.2.208",
141
+ "@swc/core-linux-x64-musl": "1.2.208",
142
+ "@swc/core-freebsd-x64": "1.2.208",
143
+ "@swc/core-win32-ia32-msvc": "1.2.208",
144
+ "@swc/core-linux-arm64-gnu": "1.2.208",
145
+ "@swc/core-linux-arm-gnueabihf": "1.2.208",
146
+ "@swc/core-darwin-arm64": "1.2.208",
147
+ "@swc/core-android-arm64": "1.2.208",
148
+ "@swc/core-linux-arm64-musl": "1.2.208",
149
+ "@swc/core-win32-arm64-msvc": "1.2.208",
150
+ "@swc/core-android-arm-eabi": "1.2.208"
151
151
  }
152
152
  }
package/types.d.ts CHANGED
@@ -666,7 +666,7 @@ export interface GlobalPassOption {
666
666
  */
667
667
  envs?: string[];
668
668
  }
669
- export declare type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig;
669
+ export declare type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig;
670
670
  export interface BaseModuleConfig {
671
671
  /**
672
672
  * By default, when using exports with babel a non-enumerable `__esModule`
@@ -721,6 +721,8 @@ export interface BaseModuleConfig {
721
721
  */
722
722
  lazy?: boolean | string[];
723
723
  /**
724
+ * @deprecated Use the `importInterop` option instead.
725
+ *
724
726
  * By default, when using exports with swc a non-enumerable __esModule property is exported.
725
727
  * This property is then used to determine if the import is the default export or if
726
728
  * it contains the default export.
@@ -731,6 +733,93 @@ export interface BaseModuleConfig {
731
733
  * Defaults to `false`.
732
734
  */
733
735
  noInterop?: boolean;
736
+ /**
737
+ * Defaults to `swc`.
738
+ *
739
+ * CommonJS modules and ECMAScript modules are not fully compatible.
740
+ * However, compilers, bundlers and JavaScript runtimes developed different strategies
741
+ * to make them work together as well as possible.
742
+ *
743
+ * - `swc` (alias: `babel`)
744
+ *
745
+ * When using exports with `swc` a non-enumerable `__esModule` property is exported
746
+ * This property is then used to determine if the import is the default export
747
+ * or if it contains the default export.
748
+ *
749
+ * ```javascript
750
+ * import foo from "foo";
751
+ * import { bar } from "bar";
752
+ * foo;
753
+ * bar;
754
+ *
755
+ * // Is compiled to ...
756
+ *
757
+ * "use strict";
758
+ *
759
+ * function _interopRequireDefault(obj) {
760
+ * return obj && obj.__esModule ? obj : { default: obj };
761
+ * }
762
+ *
763
+ * var _foo = _interopRequireDefault(require("foo"));
764
+ * var _bar = require("bar");
765
+ *
766
+ * _foo.default;
767
+ * _bar.bar;
768
+ * ```
769
+ *
770
+ * When this import interop is used, if both the imported and the importer module are compiled
771
+ * with swc they behave as if none of them was compiled.
772
+ *
773
+ * This is the default behavior.
774
+ *
775
+ * - `node`
776
+ *
777
+ * When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
778
+ * Node.js always binds the `default` export to the value of `module.exports`.
779
+ *
780
+ * ```javascript
781
+ * import foo from "foo";
782
+ * import { bar } from "bar";
783
+ * foo;
784
+ * bar;
785
+ *
786
+ * // Is compiled to ...
787
+ *
788
+ * "use strict";
789
+ *
790
+ * var _foo = require("foo");
791
+ * var _bar = require("bar");
792
+ *
793
+ * _foo;
794
+ * _bar.bar;
795
+ * ```
796
+ * This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
797
+ * as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
798
+ * However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
799
+ *
800
+ * - `none`
801
+ *
802
+ * If you know that the imported file has been transformed with a compiler that stores the `default` export on
803
+ * `exports.default` (such as swc or Babel), you can safely omit the `_interopRequireDefault` helper.
804
+ *
805
+ * ```javascript
806
+ * import foo from "foo";
807
+ * import { bar } from "bar";
808
+ * foo;
809
+ * bar;
810
+ *
811
+ * // Is compiled to ...
812
+ *
813
+ * "use strict";
814
+ *
815
+ * var _foo = require("foo");
816
+ * var _bar = require("bar");
817
+ *
818
+ * _foo.default;
819
+ * _bar.bar;
820
+ * ```
821
+ */
822
+ importInterop?: "swc" | "babel" | "node" | "none";
734
823
  /**
735
824
  * If set to true, dynamic imports will be preserved.
736
825
  */
@@ -739,6 +828,9 @@ export interface BaseModuleConfig {
739
828
  export interface Es6Config extends BaseModuleConfig {
740
829
  type: "es6";
741
830
  }
831
+ export interface NodeNextConfig extends BaseModuleConfig {
832
+ type: "nodenext";
833
+ }
742
834
  export interface CommonJsConfig extends BaseModuleConfig {
743
835
  type: "commonjs";
744
836
  }