Commit Graph

47 Commits

Author SHA1 Message Date
magic-akari
9c9a538f23
refactor(es/typescript): Reimplement TypeScript pass (#7202)
**Description:**

## Bugfixes
- Exported `let`/`var` declarations in TypeScript namespaces should be mutable.
- Fix missing declaration of complex exported patterns in TypeScript namespaces.
- Preserve concrete TS namespaces.

## New Features
- Introducing [Verbatim Module Syntax](https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax).
- Enum value will now be inlined whenever possible within a single module, optimizing runtime performance.
- Constant enums will be automatically eliminated when feasible, This can reduce bundle size.
- Added support for cross-referencing enum values.

## Deprecated
`TsEnumConfig` is deprecated
  - The `treat_const_enum_as_enum` transform option is deprecated.
  - The `ts_enum_is_readonly` assumption option is deprecated.

**BREAKING CHANGE:**

TypeScript Config is changed.


**Related issue:**

 - Closes #5197
 - Closes #5259 
 - Closes #7177
 - Closes #7453
 - Closes #7676 
 - Closes #7681
 - Closes #7791 
 - Closes #7961
2023-09-25 01:41:00 +00:00
Yunfei He
dba78a0031
fix(es/compat): Mark reserved function names private (#7298) 2023-05-17 13:10:27 +00:00
magic-akari
985f0cad06
fix(es/parser): Parse decorators after export (#7340) 2023-04-29 22:26:13 +09:00
magic-akari
38dfb91ebc
fix(es/helpers): Remove unnecessary parameters in helper_expr! macro (#7296)
**Description:**

We have moved to snake_case, so the last parameter of helper_expr is unnecessary.
2023-04-20 08:26:34 +00:00
magic-akari
3ca954b9f9
fix(es/helpers): Use snake_case for helpers (#7147)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/7144.
 - Closes https://github.com/swc-project/swc/issues/7118.
2023-03-31 15:15:21 +09:00
Donny/강동윤
0259a7465f
build(cargo): Update rustc to nightly-2023-03-20 (#7170)
**Description:**

This PR also updates `rkyv` to `=0.7.40`.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6807.
2023-03-30 08:06:02 +00:00
Donny/강동윤
12546c853a
build(cargo): Revert rustc upgrade (#7162)
**Description:**

The `rkyv` bug is not fixed.
2023-03-29 17:48:45 +09:00
Donny/강동윤
e445502072
build(cargo): Update rustc to nightly-2023-03-28 (#7154)
**Description:**

This PR also updates `rkyv` to `=0.7.40`.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6807.
2023-03-29 06:24:19 +00:00
Donny/강동윤
963c460613
refactor: Fix lints using clippy from nightly-2023-03-13 (#6920) 2023-03-14 04:56:21 +00:00
magic-akari
bb6dde7943
fix(es/compat): Handle useDefineForClassFields: false (#7055)
**BREAKING CHANGE:**

IMPORTANT NOTE: Users of decorators are recommended to configure `"useDefineForClassFields": false` to ensure that your code is properly transpiled.


**Related issue:**
 - Closes https://github.com/swc-project/swc/issues/6985.
2023-03-12 12:56:10 +09:00
magic-akari
703b340d39
fix(es/decorator): Preserve evaluation order (#6972)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6951.
2023-02-23 01:37:06 +00:00
Donny/강동윤
bbfa97a475
fix(es/decorator): Fix type detection for template literal types (#6786)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6682.
2023-01-11 07:42:09 +00:00
Donny/강동윤
81a4bb304a
fix(es/compat): Fix span hygiene of function naming pass (#6345)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6344.
2022-11-14 06:03:09 +00:00
Austaras
574502a816
feat(es/utils): Use more unique names for aliases (#6399) 2022-11-11 01:57:49 +00:00
Donny/강동윤
e6b1dd4731
feat(es/testing): Add an option to test sourcemap (#6079) 2022-10-07 05:52:22 +00:00
Austaras
31ffd5a01d
fix(es/renamer): Use a separate scope for the name of FnExpr (#6008) 2022-10-01 12:33:19 +09:00
Donny/강동윤
e410102633
fix(es/compat): Fix the order of initialization for decorators on computed keys (#5964) 2022-09-27 11:48:42 +00:00
magic-akari
2b2464271a
fix(es/codegen): Remove redundant ; after export default decl (#5851) 2022-09-14 06:07:15 +00:00
Donny/강동윤
b1f1a86a9d
feat(es/decorators): Support bigint (#5671) 2022-08-30 12:37:33 +00:00
Austaras
375774d31e
fix(es): Check the syntax context of arguments (#5174) 2022-07-13 10:29:03 +00:00
magic-akari
4d5783d9cd
feat(es/modules): Add pure annotations to interop functions (#5087) 2022-07-03 05:54:07 +00:00
magic-akari
9e162dcbae
fix(es/modules): Improve compatibility with cjs lexer (#5080) 2022-07-01 08:37:04 +00:00
magic-akari
fa68cbd74a
refactor(es/module): Implement new module transformer (#4758) 2022-06-27 12:32:06 +00:00
Donny/강동윤
36d960c7e9
perf(es/hygiene): Make hygiene faster (#4952) 2022-06-15 14:36:57 +00:00
Donny/강동윤
814f72f224
fix(es/decorators): Fix syntax context of decorated classes (#4905) 2022-06-08 05:00:22 +00:00
Donny/강동윤
a6d404a8c2
chore(repo): Configure prettier (#4523) 2022-05-04 14:25:28 +00:00
Donny/강동윤
f30ffdf200
fix(es/decorators): Make legacy decorator identical to tsc (#4496) 2022-05-03 07:48:09 +00:00
Donny/강동윤
8629e0c665
test(es/decorators): Migrate some tests to file-based fixture tests (#4510) 2022-05-03 15:29:18 +09:00
Donny/강동윤
53610fdafc
feat(es/resolver): Use different syntax context for unresolved refs (#4436)
- We don't need a list of bindings to check if an identifier is unresolved.
 - Checking if an identifier is unresolved is now one CPU instruction.
   - Previously it was one hashmap operation.
 - This PR also improves performance, by removing the hashmaps mentioned above.
2022-04-26 07:38:50 +00:00
那里好脏不可以
37a8c90750
chore(*): Typo + fomatting (#4304) 2022-04-11 18:45:58 +00:00
Alexander Akait
634d732803
feat(es/ast): Add raw to Str (#4071) 2022-03-22 07:54:08 +00:00
Donny/강동윤
55cfad152d
fix(es/helpers): Fix decorator helper script (#4072) 2022-03-18 01:44:13 +00:00
Austaras
0c76696ed2
fix(es/decorator): Insert initializer to constructor with body (#4028) 2022-03-15 12:21:17 +00:00
Donny/강동윤
40b8a4e596
feat(common): Implement a pretty error reporter (#3946) 2022-03-13 19:07:18 +00:00
Austaras
112f428734
feat(es/compat): Add pure comments for class fields keys (#3939) 2022-03-10 07:13:58 +00:00
Austaras
6f076e4927
feat(es/transform): Unify logic for handling class properties (#3766) 2022-03-05 06:46:09 +00:00
Austaras
5b6beca1af
feat(es/compat): Use sequence expressions instead of iife in classes pass (#3773) 2022-03-01 16:10:57 +09:00
Austaras
14155eb0e7
feat(es/compat): Implement loose mode for class_properties (#3722) 2022-02-27 00:09:02 +09:00
Austaras
0f7a99787f
feat(es/compat): Add loose mode for classes (#3474) 2022-02-15 04:02:08 +00:00
William Tetlow
4f5e87b66b
fix(es/compat): Fix legacy decorator pass (#3459) 2022-02-07 16:11:41 +00:00
Donny/강동윤
15b604b6d6
refactor(*): Fix some clippy warnings (#3257) 2022-01-14 07:20:45 +09:00
Donny/강동윤
f66c2cd375
fix(es/helpers): Fix decorators (#3105)
swc_ecma_transforms_base:
 - Fix `_applyDecoratedDescriptor`. (Closes #2127)
2021-12-23 19:03:53 +09:00
James Newell
938e544ac5
fix(es/compat): Fix handling of union of the legacy decorator pass (#3057)
swc_ecma_transforms_proposal:
 - Use `Object` for `null`/`undefined`.
 - Fix the type for union types. (Closes #2461)
2021-12-20 05:30:52 +00:00
Donny/강동윤
1ea965cecb
fix(es/parser): Drop outdated options (#2974)
swc_ecma_parser:
 - Drop flags in `EsConfig`.
 - Drop flags in `TsConfig`.
 - Drop unused variants from `SyntaxError`.
2021-12-05 17:33:34 +09:00
David Sherret
67280b6fb0
fix(es/typescript): Run resolver before typescript::strip (#2951)
swc_ecma_transforms_base:
 - `resolver`: Handle some typescript nodes.

swc_ecma_transforms_typescript:
 - `strip`: Use identifier span hygiene information for stripping types.
2021-12-04 02:35:16 +00:00
David Sherret
beb2c73c2c
fix(swc/hygiene): Prefer not renaming top level variables (#2940)
swc_ecma_transforms_base:
 - `hygiene`: Use concept of depth to prevent renaming top level nodes.
2021-12-04 01:55:27 +09:00
Donny/강동윤
2b2f6955f2
refactor: Flatten ecmascript (#2708) 2021-11-10 19:00:54 +09:00