@swc/core 1.2.127 → 1.2.128

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,74 @@
5
5
 
6
6
 
7
7
 
8
+ - **(es/helpers)** Don't transpile `_typeof` helper (#3208) ([54353a6](https://github.com/swc-project/swc/commit/54353a6fb5ab53ed4762161ecdda1a3ec0d77c62))
9
+
10
+
11
+ - **(es/hygiene)** Visit computed properties in usage analyzer (#3217) ([cdb46cf](https://github.com/swc-project/swc/commit/cdb46cfb9180e67915c88eabdfd48317870e330d))
12
+
13
+
14
+ - **(es/minifier)** Disable inlining of expressions from `collapse_vars` (#3200) ([69b5f79](https://github.com/swc-project/swc/commit/69b5f799f3d40947ce3b5bc851ee44d3caad5328))
15
+
16
+
17
+ - **(es/minifier)** Drop unreachable statements eagerly (#3204) ([0105939](https://github.com/swc-project/swc/commit/01059394268791d85d48d9c1cbfa11564b1eb85e))
18
+
19
+
20
+ - **(es/modules)** Fix lazy import handling (#3211) ([9565149](https://github.com/swc-project/swc/commit/956514953940556847e7a5b42d7f1f21cffe9dd8))
21
+
22
+ ### Features
23
+
24
+
25
+
26
+ - **(es/ast)** Use `ModuleExportName` for `ExportNamespaceSpecifier` (#3195) ([432f877](https://github.com/swc-project/swc/commit/432f87779003e50f17bcaedc35edb8583644c548))
27
+
28
+
29
+ - **(es/ast)** Update `is-macro` (#3226) ([1edbf1a](https://github.com/swc-project/swc/commit/1edbf1a37a37c5e3a9bf695b4793d0c35c2d6592))
30
+
31
+
32
+ - **(es/compat)** Implement object super (#3127) ([b649d23](https://github.com/swc-project/swc/commit/b649d23bac1faf5ae0ba9463ba9069d09055b63c))
33
+
34
+
35
+ - **(es/parser)** Accept strings for import/exports (#3190) ([3fb76f6](https://github.com/swc-project/swc/commit/3fb76f64c4e5ee49b0415757b3ead5fc753a93b6))
36
+
37
+
38
+ - **(es/transforms)** Add `Assumptions` (#3215) ([42f7268](https://github.com/swc-project/swc/commit/42f726873e6c9e813a750acbf6d818bd4e914e31))
39
+
40
+
41
+ - **(plugin)** Pass serialized ast to a wasm file (#3199) ([92de2c7](https://github.com/swc-project/swc/commit/92de2c78841ee1dc8b372268690637a19c3f4307))
42
+
43
+
44
+ - **(plugin)** Allow multi-value for the plugin signature (#3216) ([c9ded9b](https://github.com/swc-project/swc/commit/c9ded9b72080b013466f450d9b3917055e40fa23))
45
+
46
+
47
+ - **(plugin)** Perform actual transforms in plugins (#3220) ([7e7421e](https://github.com/swc-project/swc/commit/7e7421ea527f499c6488de19fb8171f2b65787b4))
48
+
49
+ ### Miscellaneous Tasks
50
+
51
+
52
+
53
+ - **(es/minifier)** Add scripts to extract tests automatically (#3212) ([057fca4](https://github.com/swc-project/swc/commit/057fca4196263dcfc05e6161cb727ec4888d7e10))
54
+
55
+ ### Refactor
56
+
57
+
58
+
59
+ - **(es/ast)** Change types of member-like expressions (#3178) ([f58b50b](https://github.com/swc-project/swc/commit/f58b50bea7507def95b94b498ba9c5faf55df802))
60
+
61
+
62
+ - **(es/compat)** Preserve length of functions in `async_generator` (#3202) ([5bee4e4](https://github.com/swc-project/swc/commit/5bee4e490229a3a045d4008b156034c4233ec89e))
63
+
64
+ ### Security
65
+
66
+
67
+
68
+ - **(repo)** Fix crev integration (#3210) ([70c2f3b](https://github.com/swc-project/swc/commit/70c2f3b3a57ec9afc1f28ec1c6377dbbf4e920b6))
69
+
70
+ ## [1.2.127] - 2022-01-06
71
+
72
+ ### Bug Fixes
73
+
74
+
75
+
8
76
  - **(es/lints)** Fix incorrect duplicate binding error (#3194) ([913c82a](https://github.com/swc-project/swc/commit/913c82a2ab94e14eb350e1573af736aa87c7f2bb))
9
77
 
10
78
 
@@ -31,6 +99,39 @@
31
99
 
32
100
  - **(ci)** Split cargo docs (#3187) ([46949d3](https://github.com/swc-project/swc/commit/46949d39ebdcb14347156eb00490e53d37d06707))
33
101
 
102
+
103
+ - **(ci)** Fix publish scripts ([3458e9f](https://github.com/swc-project/swc/commit/3458e9f1d3eac7c47ba00a5768d3f8f41c8037ef))
104
+
105
+
106
+ - **(ci)** Fix publish scripts again ([b292126](https://github.com/swc-project/swc/commit/b292126b387c4efff0576517c7d706b16c08bca3))
107
+
108
+
109
+ - **(ci)** Fix `--cargo-flags` ([a20f5d9](https://github.com/swc-project/swc/commit/a20f5d9a7cd007d3c5fb671710d1344cd1577119))
110
+
111
+
112
+ - **(ci)** Use `--cargo-flags` in correct place ([ef4ea2f](https://github.com/swc-project/swc/commit/ef4ea2fc7b10ec50d317118680f58c70cf64c89b))
113
+
114
+
115
+ - **(ci)** Use `RUSTFLAGS` for linux ([4cbe8d1](https://github.com/swc-project/swc/commit/4cbe8d18bb10dfa8a333931767ebf958dab3bbae))
116
+
117
+
118
+ - **(ci)** Use more `RUSTFLAGS` ([bf0acd1](https://github.com/swc-project/swc/commit/bf0acd13da50a500414edbaf686a0632736f66fd))
119
+
120
+
121
+ - **(ci)** Fix musl ([fef8449](https://github.com/swc-project/swc/commit/fef844954b6aecd610c87ccb5ec30a2b08bd328a))
122
+
123
+
124
+ - **(ci)** Fix `aarch64-pc-windows-msvc` ([1ebbe62](https://github.com/swc-project/swc/commit/1ebbe622909a974abd0ea96929adee1c33f8f256))
125
+
126
+
127
+ - **(ci)** Change version of `rustc` ([d901b62](https://github.com/swc-project/swc/commit/d901b6222f8a77beed64968fcb4764bbacf8c755))
128
+
129
+
130
+ - **(ci)** Fix publish script (#3197) ([c34f1a9](https://github.com/swc-project/swc/commit/c34f1a977fac44813ebda5beb77b6444469e36e4))
131
+
132
+
133
+ - **(ci)** Remove redudant plugin test ([e19fe7d](https://github.com/swc-project/swc/commit/e19fe7d33b2a18c1b068c2f808f3ea72f1ccff15))
134
+
34
135
  ### Refactor
35
136
 
36
137
 
@@ -46,6 +147,12 @@
46
147
 
47
148
  - **(plugin/runner)** Avoid redundant filesystem reads (#3186) ([b61c49f](https://github.com/swc-project/swc/commit/b61c49fe39acf28e09888e7b2163c7be5cceff4b))
48
149
 
150
+
151
+ - **(plugin/runner)** Replace wasm runtime (#3196) ([c3895ca](https://github.com/swc-project/swc/commit/c3895ca9aaf4c8b76f1eb1bf2c8655d8acb20b94))
152
+
153
+
154
+ - **(plugin/runner)** Reuse wasmer ([28ff059](https://github.com/swc-project/swc/commit/28ff0592a4005e89561500f915929ffa25da9160))
155
+
49
156
  ## [1.2.126] - 2022-01-03
50
157
 
51
158
  ### Bug Fixes
package/Visitor.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Accessibility, ArrayExpression, ArrayPattern, ArrowFunctionExpression, Argument, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BinaryExpression, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassProperty, ComputedPropName, ConditionalExpression, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, Identifier, IfStatement, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXAttrValue, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, MemberExpression, MetaProperty, MethodProperty, Module, ModuleDeclaration, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptionalChainingExpression, ParenthesisExpression, Pattern, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, SpreadElement, Statement, StringLiteral, Super, SwitchCase, SwitchStatement, TaggedTemplateExpression, TemplateLiteral, ThisExpression, ThrowStatement, TryStatement, TsAsExpression, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnParameter, TsImportEqualsDeclaration, TsIndexSignature, TsInterfaceBody, TsInterfaceDeclaration, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsParameterProperty, TsParameterPropertyParameter, TsQualifiedName, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression, Param, ExprOrSpread, TsConstAssertion } from "./types";
1
+ import { Accessibility, ArrayExpression, ArrayPattern, ArrowFunctionExpression, Argument, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BinaryExpression, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassProperty, ComputedPropName, ConditionalExpression, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, Identifier, IfStatement, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXAttrValue, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, MemberExpression, MetaProperty, MethodProperty, Module, ModuleDeclaration, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptionalChainingExpression, ParenthesisExpression, Pattern, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, SpreadElement, Statement, StringLiteral, Super, SwitchCase, SwitchStatement, TaggedTemplateExpression, TemplateLiteral, ThisExpression, ThrowStatement, TryStatement, TsAsExpression, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnParameter, TsImportEqualsDeclaration, TsIndexSignature, TsInterfaceBody, TsInterfaceDeclaration, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsParameterProperty, TsParameterPropertyParameter, TsQualifiedName, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression, Param, ExprOrSpread, TsConstAssertion, Import, SuperPropExpression } from "./types";
2
2
  export declare class Visitor {
3
3
  visitProgram(n: Program): Program;
4
4
  visitModule(m: Module): Module;
@@ -140,7 +140,8 @@ export declare class Visitor {
140
140
  visitArgument(n: Argument): Argument;
141
141
  visitMetaProperty(n: MetaProperty): Expression;
142
142
  visitMemberExpression(n: MemberExpression): Expression;
143
- visitExpressionOrSuper(n: Expression | Super): Expression | Super;
143
+ visitSuperPropExpression(n: SuperPropExpression): Expression;
144
+ visitCallee(n: Expression | Super | Import): Expression | Super | Import;
144
145
  visitJSXText(n: JSXText): JSXText;
145
146
  visitJSXNamespacedName(n: JSXNamespacedName): JSXNamespacedName;
146
147
  visitJSXMemberExpression(n: JSXMemberExpression): JSXMemberExpression;
package/Visitor.js CHANGED
@@ -730,6 +730,8 @@ class Visitor {
730
730
  return this.visitJSXText(n);
731
731
  case "MemberExpression":
732
732
  return this.visitMemberExpression(n);
733
+ case "SuperPropExpression":
734
+ return this.visitSuperPropExpression(n);
733
735
  case "MetaProperty":
734
736
  return this.visitMetaProperty(n);
735
737
  case "NewExpression":
@@ -955,17 +957,39 @@ class Visitor {
955
957
  return n;
956
958
  }
957
959
  visitMetaProperty(n) {
958
- n.meta = this.visitIdentifierReference(n.meta);
959
- n.property = this.visitIdentifier(n.property);
960
960
  return n;
961
961
  }
962
962
  visitMemberExpression(n) {
963
- n.object = this.visitExpressionOrSuper(n.object);
964
- n.property = this.visitExpression(n.property);
965
- return n;
963
+ n.object = this.visitExpression(n.object);
964
+ switch (n.property.type) {
965
+ case 'Computed': {
966
+ n.property = this.visitComputedPropertyKey(n.property);
967
+ return n;
968
+ }
969
+ case 'Identifier': {
970
+ n.property = this.visitIdentifier(n.property);
971
+ return n;
972
+ }
973
+ case 'PrivateName': {
974
+ n.property = this.visitPrivateName(n.property);
975
+ return n;
976
+ }
977
+ }
978
+ }
979
+ visitSuperPropExpression(n) {
980
+ switch (n.property.type) {
981
+ case 'Computed': {
982
+ n.property = this.visitComputedPropertyKey(n.property);
983
+ return n;
984
+ }
985
+ case 'Identifier': {
986
+ n.property = this.visitIdentifier(n.property);
987
+ return n;
988
+ }
989
+ }
966
990
  }
967
- visitExpressionOrSuper(n) {
968
- if (n.type === "Super") {
991
+ visitCallee(n) {
992
+ if (n.type === "Super" || n.type === "Import") {
969
993
  return n;
970
994
  }
971
995
  return this.visitExpression(n);
@@ -1116,7 +1140,7 @@ class Visitor {
1116
1140
  return n;
1117
1141
  }
1118
1142
  visitCallExpression(n) {
1119
- n.callee = this.visitExpressionOrSuper(n.callee);
1143
+ n.callee = this.visitCallee(n.callee);
1120
1144
  n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
1121
1145
  if (n.arguments) {
1122
1146
  n.arguments = this.visitArguments(n.arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.127",
3
+ "version": "1.2.128",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
@@ -51,19 +51,19 @@
51
51
  "@node-rs/helper": "^1.0.0"
52
52
  },
53
53
  "optionalDependencies": {
54
- "@swc/core-win32-x64-msvc": "1.2.127",
55
- "@swc/core-darwin-x64": "1.2.127",
56
- "@swc/core-linux-x64-gnu": "1.2.127",
57
- "@swc/core-linux-x64-musl": "1.2.127",
58
- "@swc/core-freebsd-x64": "1.2.127",
59
- "@swc/core-win32-ia32-msvc": "1.2.127",
60
- "@swc/core-linux-arm64-gnu": "1.2.127",
61
- "@swc/core-linux-arm-gnueabihf": "1.2.127",
62
- "@swc/core-darwin-arm64": "1.2.127",
63
- "@swc/core-android-arm64": "1.2.127",
64
- "@swc/core-linux-arm64-musl": "1.2.127",
65
- "@swc/core-win32-arm64-msvc": "1.2.127",
66
- "@swc/core-android-arm-eabi": "1.2.127"
54
+ "@swc/core-win32-x64-msvc": "1.2.128",
55
+ "@swc/core-darwin-x64": "1.2.128",
56
+ "@swc/core-linux-x64-gnu": "1.2.128",
57
+ "@swc/core-linux-x64-musl": "1.2.128",
58
+ "@swc/core-freebsd-x64": "1.2.128",
59
+ "@swc/core-win32-ia32-msvc": "1.2.128",
60
+ "@swc/core-linux-arm64-gnu": "1.2.128",
61
+ "@swc/core-linux-arm-gnueabihf": "1.2.128",
62
+ "@swc/core-darwin-arm64": "1.2.128",
63
+ "@swc/core-android-arm64": "1.2.128",
64
+ "@swc/core-linux-arm64-musl": "1.2.128",
65
+ "@swc/core-win32-arm64-msvc": "1.2.128",
66
+ "@swc/core-android-arm-eabi": "1.2.128"
67
67
  },
68
68
  "types": "./index.d.ts",
69
69
  "scripts": {
package/types.d.ts CHANGED
@@ -719,7 +719,7 @@ export interface VariableDeclarator extends Node, HasSpan {
719
719
  init?: Expression;
720
720
  definite: boolean;
721
721
  }
722
- export declare type Expression = ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | MemberExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | Identifier | Literal | TemplateLiteral | TaggedTemplateExpression | ArrowFunctionExpression | ClassExpression | YieldExpression | MetaProperty | AwaitExpression | ParenthesisExpression | JSXMemberExpression | JSXNamespacedName | JSXEmptyExpression | JSXElement | JSXFragment | TsTypeAssertion | TsConstAssertion | TsNonNullExpression | TsAsExpression | PrivateName | OptionalChainingExpression | Invalid;
722
+ export declare type Expression = ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | MemberExpression | SuperPropExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | Identifier | Literal | TemplateLiteral | TaggedTemplateExpression | ArrowFunctionExpression | ClassExpression | YieldExpression | MetaProperty | AwaitExpression | ParenthesisExpression | JSXMemberExpression | JSXNamespacedName | JSXEmptyExpression | JSXElement | JSXFragment | TsTypeAssertion | TsConstAssertion | TsNonNullExpression | TsAsExpression | PrivateName | OptionalChainingExpression | Invalid;
723
723
  interface ExpressionBase extends Node, HasSpan {
724
724
  }
725
725
  export interface OptionalChainingExpression extends ExpressionBase {
@@ -787,9 +787,13 @@ export interface AssignmentExpression extends ExpressionBase {
787
787
  }
788
788
  export interface MemberExpression extends ExpressionBase {
789
789
  type: "MemberExpression";
790
- object: Expression | Super;
791
- property: Expression;
792
- computed: boolean;
790
+ object: Expression;
791
+ property: Identifier | PrivateName | ComputedPropName;
792
+ }
793
+ export interface SuperPropExpression extends ExpressionBase {
794
+ type: "SuperPropExpression";
795
+ object: Super;
796
+ property: Identifier | ComputedPropName;
793
797
  }
794
798
  export interface ConditionalExpression extends ExpressionBase {
795
799
  type: "ConditionalExpression";
@@ -800,9 +804,12 @@ export interface ConditionalExpression extends ExpressionBase {
800
804
  export interface Super extends Node, HasSpan {
801
805
  type: "Super";
802
806
  }
807
+ export interface Import extends Node, HasSpan {
808
+ type: "Import";
809
+ }
803
810
  export interface CallExpression extends ExpressionBase {
804
811
  type: "CallExpression";
805
- callee: Expression | Super;
812
+ callee: Expression | Super | Import;
806
813
  arguments: Argument[];
807
814
  typeArguments?: TsTypeParameterInstantiation;
808
815
  }
@@ -832,8 +839,7 @@ export interface YieldExpression extends ExpressionBase {
832
839
  }
833
840
  export interface MetaProperty extends Node {
834
841
  type: "MetaProperty";
835
- meta: Identifier;
836
- property: Identifier;
842
+ kind: 'ImportMeta' | 'NewTarget';
837
843
  }
838
844
  export interface AwaitExpression extends ExpressionBase {
839
845
  type: "AwaitExpression";