@swc/core 1.2.148 → 1.2.149

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,95 @@
5
5
 
6
6
 
7
7
 
8
+ - **(css/lints)** Allow empty `@layer` at-rule before `@import` at-rule (#3842) ([90fdbab](https://github.com/swc-project/swc/commit/90fdbab0d67f1fca8b52fb6df9b927cc35219445))
9
+
10
+
11
+ - **(es/lints)** Ignore identifiers used as types while checking for duplicate bindings (#3869) ([d10e662](https://github.com/swc-project/swc/commit/d10e66285bab3ae6aadd1d4e6ef3ae0d5c977ec4))
12
+
13
+
14
+ - **(es/minifier)** Don't remove comments if `compress` is not configured (#3866) ([e70c9d8](https://github.com/swc-project/swc/commit/e70c9d8f22ad91f7a1246ac60b0ace8a3b3e7d79))
15
+
16
+
17
+ - **(es/module)** Fix `jest.spyOn` (#3845) ([9546eef](https://github.com/swc-project/swc/commit/9546eefe72178bbc7059d0fc6c5e7e9bbca089e0))
18
+
19
+
20
+ - **(es/module)** Visit the value of class properties (#3877) ([6a005fc](https://github.com/swc-project/swc/commit/6a005fc15a16c0d056a559fe3695a61b2e63944b))
21
+
22
+
23
+ - **(es/parser)** Use unicode id instead of xid (#3867) ([4426250](https://github.com/swc-project/swc/commit/44262508c6e122e7f9dd8e0ad961a4d6ad4a8a0c))
24
+
25
+
26
+ - **(es/parser)** Allow `await` in non-strict mode (#3871) ([f757163](https://github.com/swc-project/swc/commit/f7571630caf249b4a10101a2f1c86b2bbc12d4d6))
27
+
28
+ ### Features
29
+
30
+
31
+
32
+ - **(cli)** Setup subcommands for the features (#3858) ([367a57d](https://github.com/swc-project/swc/commit/367a57df6d66bc11dd750c6b7c30bf3a114e00fa))
33
+
34
+
35
+ - **(css)** Improve error recovery (#3853) ([c84bf13](https://github.com/swc-project/swc/commit/c84bf133a6ffce311548170cb9c4b0edb9804478))
36
+
37
+
38
+ - **(css/lints)** Allow using regex in ignore list (#3855) ([dc0de58](https://github.com/swc-project/swc/commit/dc0de58a46c495bb520a99c4d8e8fcf380713f54))
39
+
40
+
41
+ - **(css/minifier)** Compress `@import` at-rule (#3850) ([ccfb4bf](https://github.com/swc-project/swc/commit/ccfb4bfc0b10375d96620f2748b0a3d022c4e359))
42
+
43
+
44
+ - **(es/compat)** Implement loose mode for `async_to_generator` (#3870) ([c7f2bdb](https://github.com/swc-project/swc/commit/c7f2bdb8138f4fbe59b6a03f9d6aa74966389d04))
45
+
46
+
47
+ - **(es/minifier)** Implement `pure_getters` partially (#3872) ([a264360](https://github.com/swc-project/swc/commit/a2643608a7aeda910da0ed03a705cff3ddecd543))
48
+
49
+
50
+ - **(es/module/cjs)** Support regex-based patterns for lazy config (#3704) ([1f70fa6](https://github.com/swc-project/swc/commit/1f70fa6e08e9b400c2e34ee9f0d6749cf21b9e3f))
51
+
52
+
53
+ - **(es/transform)** Unify logic for handling class properties (#3766) ([6f076e4](https://github.com/swc-project/swc/commit/6f076e4927fca646882709832826dc0eb7106e35))
54
+
55
+ ### Performance
56
+
57
+
58
+
59
+ - **(es)** Filter logs for `cranelift` out (#3801) ([225f9a7](https://github.com/swc-project/swc/commit/225f9a7f2a3dad917aaf2a231463ec05699b4064))
60
+
61
+
62
+ - **(es/ast)** Implement `Clone` without inline for some enums (#3878) ([3b04789](https://github.com/swc-project/swc/commit/3b04789a5750532ab9ccb78a833226b39b47a714))
63
+
64
+
65
+ - **(es/compat)** Add tracing support to transforms for from es2017 to es2019 (#3844) ([a933db5](https://github.com/swc-project/swc/commit/a933db5a1a54804efefd1b1d901b85a44ba059a5))
66
+
67
+
68
+ - **(es/compat)** Add tracing support for es2015 transforms (#3857) ([cd8bb0f](https://github.com/swc-project/swc/commit/cd8bb0fb2c70c30ea421842fc6c5b6837e3ff182))
69
+
70
+
71
+ - **(es/transform)** Use `SingleThreadedComments` for transform (#3847) ([73ec0b3](https://github.com/swc-project/swc/commit/73ec0b3dd734dfd1ee79addfe078c709620ade17))
72
+
73
+ ### Testing
74
+
75
+
76
+
77
+ - **(es)** Add a test for a fixed issue (#3873) ([0ab3263](https://github.com/swc-project/swc/commit/0ab32639a1ce04eba221a0bc958d150ba65fa656))
78
+
79
+
80
+ - **(es)** Add tests for fixed issues (#3874) ([2605e13](https://github.com/swc-project/swc/commit/2605e132e683ad0b649621a321be31347e0ac5e6))
81
+
82
+
83
+ - **(es)** Add tests for fixed issues (#3875) ([8d3c9d3](https://github.com/swc-project/swc/commit/8d3c9d39f036a1e876ca98bd801515edfe1cee5b))
84
+
85
+
86
+ - **(es/transform/jest)** Ensure that sourcemap is working (#3864) ([fc87f43](https://github.com/swc-project/swc/commit/fc87f43507ed398eb0941cffb426321e1b781980))
87
+
88
+
89
+ - **(swc)** Use external helpers for reference testing (#3865) ([8400708](https://github.com/swc-project/swc/commit/84007087688292fe7fcb1becea56538944dabc66))
90
+
91
+ ## [1.2.148] - 2022-03-04
92
+
93
+ ### Bug Fixes
94
+
95
+
96
+
8
97
  - **(css/codegen)** Fix codegen of preserved tokens (#3819) ([7ba5861](https://github.com/swc-project/swc/commit/7ba5861a334657cb443b2f143222f632fcbcf752))
9
98
 
10
99
 
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  <p align="center">
12
12
  <a href="https://www.npmjs.com/package/@swc/core">
13
- <img alt="npm Downloads" src="https://img.shields.io/npm/dw/@swc/core">
13
+ <img alt="npm Downloads" src="https://img.shields.io/npm/dm/@swc/core">
14
14
  </a>
15
15
  <a href="https://crates.io/crates/swc_ecma_parser">
16
16
  <img alt="undefined" src="https://img.shields.io/crates/d/swc_ecma_parser.svg?label=crates.io%20downloads">
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, Import, SuperPropExpression } from "./types";
1
+ import { Accessibility, ArrayExpression, ArrayPattern, ArrowFunctionExpression, Argument, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BigIntLiteral, 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;
@@ -91,7 +91,6 @@ export declare class Visitor {
91
91
  visitAccessibility(n: Accessibility | undefined): Accessibility | undefined;
92
92
  visitClassProperty(n: ClassProperty): ClassMember;
93
93
  visitClassMethod(n: ClassMethod): ClassMember;
94
- visitPropertName(n: PropertyName): PropertyName;
95
94
  visitComputedPropertyKey(n: ComputedPropName): ComputedPropName;
96
95
  visitClass<T extends Class>(n: T): T;
97
96
  visitFunction<T extends Fn>(n: T): T;
@@ -186,6 +185,7 @@ export declare class Visitor {
186
185
  visitIdentifier(n: Identifier): Identifier;
187
186
  visitStringLiteral(n: StringLiteral): StringLiteral;
188
187
  visitNumericLiteral(n: NumericLiteral): NumericLiteral;
188
+ visitBigIntLiteral(n: BigIntLiteral): BigIntLiteral;
189
189
  visitPattern(n: Pattern): Pattern;
190
190
  visitRestElement(n: RestElement): RestElement;
191
191
  visitAssignmentPattern(n: AssignmentPattern): Pattern;
package/Visitor.js CHANGED
@@ -586,6 +586,8 @@ class Visitor {
586
586
  return this.visitStringLiteral(key);
587
587
  case "NumericLiteral":
588
588
  return this.visitNumericLiteral(key);
589
+ case "BigIntLiteral":
590
+ return this.visitBigIntLiteral(key);
589
591
  default:
590
592
  return this.visitComputedPropertyKey(key);
591
593
  }
@@ -596,7 +598,7 @@ class Visitor {
596
598
  visitClassProperty(n) {
597
599
  n.accessibility = this.visitAccessibility(n.accessibility);
598
600
  n.decorators = this.visitDecorators(n.decorators);
599
- n.key = this.visitExpression(n.key);
601
+ n.key = this.visitPropertyName(n.key);
600
602
  n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
601
603
  n.value = this.visitOptionalExpression(n.value);
602
604
  return n;
@@ -607,18 +609,6 @@ class Visitor {
607
609
  n.key = this.visitPropertyName(n.key);
608
610
  return n;
609
611
  }
610
- visitPropertName(n) {
611
- switch (n.type) {
612
- case "Identifier":
613
- return this.visitIdentifier(n);
614
- case "NumericLiteral":
615
- return this.visitNumericLiteral(n);
616
- case "StringLiteral":
617
- return this.visitStringLiteral(n);
618
- case "Computed":
619
- return this.visitComputedPropertyKey(n);
620
- }
621
- }
622
612
  visitComputedPropertyKey(n) {
623
613
  n.expression = this.visitExpression(n.expression);
624
614
  return n;
@@ -1241,6 +1231,9 @@ class Visitor {
1241
1231
  visitNumericLiteral(n) {
1242
1232
  return n;
1243
1233
  }
1234
+ visitBigIntLiteral(n) {
1235
+ return n;
1236
+ }
1244
1237
  visitPattern(n) {
1245
1238
  switch (n.type) {
1246
1239
  case "Identifier":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/core",
3
- "version": "1.2.148",
3
+ "version": "1.2.149",
4
4
  "description": "Super-fast alternative for babel",
5
5
  "homepage": "https://swc.rs",
6
6
  "main": "./index.js",
@@ -107,18 +107,18 @@
107
107
  "url": "https://opencollective.com/swc"
108
108
  },
109
109
  "optionalDependencies": {
110
- "@swc/core-win32-x64-msvc": "1.2.148",
111
- "@swc/core-darwin-x64": "1.2.148",
112
- "@swc/core-linux-x64-gnu": "1.2.148",
113
- "@swc/core-linux-x64-musl": "1.2.148",
114
- "@swc/core-freebsd-x64": "1.2.148",
115
- "@swc/core-win32-ia32-msvc": "1.2.148",
116
- "@swc/core-linux-arm64-gnu": "1.2.148",
117
- "@swc/core-linux-arm-gnueabihf": "1.2.148",
118
- "@swc/core-darwin-arm64": "1.2.148",
119
- "@swc/core-android-arm64": "1.2.148",
120
- "@swc/core-linux-arm64-musl": "1.2.148",
121
- "@swc/core-win32-arm64-msvc": "1.2.148",
122
- "@swc/core-android-arm-eabi": "1.2.148"
110
+ "@swc/core-win32-x64-msvc": "1.2.149",
111
+ "@swc/core-darwin-x64": "1.2.149",
112
+ "@swc/core-linux-x64-gnu": "1.2.149",
113
+ "@swc/core-linux-x64-musl": "1.2.149",
114
+ "@swc/core-freebsd-x64": "1.2.149",
115
+ "@swc/core-win32-ia32-msvc": "1.2.149",
116
+ "@swc/core-linux-arm64-gnu": "1.2.149",
117
+ "@swc/core-linux-arm-gnueabihf": "1.2.149",
118
+ "@swc/core-darwin-arm64": "1.2.149",
119
+ "@swc/core-android-arm64": "1.2.149",
120
+ "@swc/core-linux-arm64-musl": "1.2.149",
121
+ "@swc/core-win32-arm64-msvc": "1.2.149",
122
+ "@swc/core-android-arm-eabi": "1.2.149"
123
123
  }
124
124
  }
package/types.d.ts CHANGED
@@ -455,6 +455,7 @@ export interface TransformConfig {
455
455
  */
456
456
  decoratorMetadata?: boolean;
457
457
  treatConstEnumAsEnum?: boolean;
458
+ useDefineForClassFields?: boolean;
458
459
  }
459
460
  export interface ReactConfig {
460
461
  /**
@@ -662,20 +663,19 @@ export interface ClassPropertyBase extends Node, HasSpan, HasDecorator {
662
663
  value?: Expression;
663
664
  typeAnnotation?: TsTypeAnnotation;
664
665
  is_static: boolean;
665
- computed: boolean;
666
666
  accessibility?: Accessibility;
667
- is_abstract: boolean;
668
667
  is_optional: boolean;
669
668
  readonly: boolean;
670
- definite: boolean;
671
669
  }
672
670
  export interface ClassProperty extends ClassPropertyBase {
673
671
  type: "ClassProperty";
674
- key: Expression;
672
+ key: PropertyName;
675
673
  }
676
674
  export interface PrivateProperty extends ClassPropertyBase {
677
675
  type: "PrivateProperty";
678
676
  key: PrivateName;
677
+ is_abstract: boolean;
678
+ definite: boolean;
679
679
  }
680
680
  export interface Param extends Node, HasSpan, HasDecorator {
681
681
  type: "Parameter";
@@ -993,6 +993,10 @@ export interface NumericLiteral extends Node, HasSpan {
993
993
  type: "NumericLiteral";
994
994
  value: number;
995
995
  }
996
+ export interface BigIntLiteral extends Node, HasSpan {
997
+ type: "BigIntLiteral";
998
+ value: bigint;
999
+ }
996
1000
  export declare type ModuleDeclaration = ImportDeclaration | ExportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportDefaultExpression | ExportAllDeclaration | TsImportEqualsDeclaration | TsExportAssignment | TsNamespaceExportDeclaration;
997
1001
  export interface ExportDefaultExpression extends Node, HasSpan {
998
1002
  type: "ExportDefaultExpression";
@@ -1159,7 +1163,7 @@ export interface SetterProperty extends PropBase, HasSpan {
1159
1163
  export interface MethodProperty extends PropBase, Fn {
1160
1164
  type: "MethodProperty";
1161
1165
  }
1162
- export declare type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropName;
1166
+ export declare type PropertyName = Identifier | StringLiteral | NumericLiteral | BigIntLiteral | ComputedPropName;
1163
1167
  export interface ComputedPropName extends Node, HasSpan {
1164
1168
  type: "Computed";
1165
1169
  expression: Expression;