Commit graph

203 commits

Author SHA1 Message Date
Boshen
a63a45d5b2
refactor(transformer): remove the requirement of Semantic (#3140)
It seems like we need to rebuild the scopes and symbols while
traversing. We can't utilize the scopes and symbols built by semantic
because they are immutable.
2024-04-30 12:48:21 +08:00
Boshen
d76507699d
chore(transform_conformance): skip transform-destructuring (#3136) 2024-04-30 00:09:22 +08:00
Boshen
5a3f8a5811
feat(transform_conformance): handle parse error (#3135) 2024-04-30 00:07:53 +08:00
Dunqing
b5894964d1
fix(transformer/arrow-functions): should not transform this in class (#3129) 2024-04-29 13:44:10 +00:00
Dunqing
843318cdbe
refactor(transformer/typescript): reimplementation of Enum conversion based on Babel (#3102)
The remaining test cases will perform better with a scope
implementation, and while we can implement them without the scope, it
still requires us to do what the scope did.

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-04-29 16:26:22 +08:00
Dunqing
905ee3fef1
feat(transformer): add arrow-functions plugin (#3083)
close: #2983
2024-04-29 08:04:01 +00:00
Dunqing
c3d8a85eb5
feat(semantic): report that enum member must have initializer (#3113)
See
https://www.typescriptlang.org/play/?target=99#code/KYOwrgtgBAglDeAoKKoEMoF4oFk0BcALAOgGcBLEACgEYBKAGmVQCMmBfRRUSKAIQTMUGbACIaAJgDMopqihtEnRABtg+KADMwIAMZYoVOlgB8USVIDc3cNADCg+SK07dRuaw6IgA
2024-04-27 22:08:02 +08:00
Boshen
78875b79fe
feat(transformer): implement typescript namespace (#3025)
Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-04-25 10:26:11 +00:00
Dunqing
3831147b6d
feat(transformer/typescript): report error for export = <value> (#3021) 2024-04-18 18:56:29 +08:00
Dunqing
7416de217b
feat(transformer/typescript): reports error for import lib = require(...); (#3020) 2024-04-18 18:54:45 +08:00
Dunqing
e14ac17c72
feat(transformer/typescript): insert this assignment after the super call (#3018) 2024-04-18 18:53:01 +08:00
Boshen
722d4c2350
fix(transformer): TypeScriptOptions deserialize should fallback to default (#3012) 2024-04-17 16:27:50 +08:00
Dunqing
b72bdcaf96
feat(transformer/react): reports duplicate __self/__source prop error (#3009) 2024-04-17 13:34:31 +08:00
Boshen
df1996157f
chore(transform_conformance): ignore more unsupported plugins (#3008) 2024-04-16 18:59:21 +08:00
Dunqing
cdd3bc5a4e
feat(transformer_conformance): enable typescript when the typescript plugin is present (#3007) 2024-04-16 10:47:06 +00:00
Dunqing
99e038cfc0
fix(transformer/typescript): modifiers should not be removed (#3005)
`codegen` relies on the modifier to decide whether to print or not. For
example, if declare is present, nothing will be printed if typescript is
not enabled.

We may need to solve this problem in a way that doesn't rely on
modifers.
2024-04-16 10:33:13 +00:00
Boshen
ae9d681b4d
feat(transform_conformance): skip windows tests (#3003) 2024-04-16 17:50:43 +08:00
Boshen
85a3653994
feat(transformer): add "_jsxFileName" variable in jsx source plugin (#3000) 2024-04-16 17:40:24 +08:00
Boshen
67045467c7
fix(transformer): react development default value should be false (#3002) 2024-04-16 17:28:31 +08:00
Boshen
5f4c1e1d3e
chore(transform_conformance): skip custom presets (#3001) 2024-04-16 17:21:34 +08:00
Dunqing
afb1dd4b24
feat(transformer/typescript): support for transform TSImportEqualsDeclaration (#2998) 2024-04-16 06:45:41 +00:00
Dunqing
6732e8b9af
feat(transformer/typescript): support for transform enum (#2997)
The current implementation is copied from the previous implementation
2024-04-16 14:39:37 +08:00
Boshen
e43c245388
feat(transformer): add import helpers to manage module imports (#2996)
closes #2971
2024-04-16 14:33:44 +08:00
Dunqing
6a53fa367b
feat(transformer/typescript): correct elide imports/exports statements (#2995)
remove ts annotations one benefit: `IdentifierReference` only used on js
code

The `TypescriptReferenceCollector` implementation is inspired by
5f75019683/crates/swc_ecma_transforms_typescript/src/strip_import_export.rs (L9-L99)

This seems simpler to implement than using scope
2024-04-16 11:06:58 +08:00
Boshen
82e00bc951
refactor(transformer): remove boilerplate code around decorators to reduce noise (#2991) 2024-04-15 13:51:09 +08:00
Boshen
b4bfa2f34c
refactor(transform_conformance): correctly handle BABEL_8_BREAKING (#2990) 2024-04-15 13:41:45 +08:00
Boshen
5a286c3d9f
feat(transform_conformance): drop more unsupported plugins (#2984) 2024-04-14 23:04:04 +08:00
Boshen
9643cba4a4
feat(transform_conformance): drop all babel 7 specific tests (#2982)
@Dunqing Is this correct?
2024-04-14 23:02:38 +08:00
Boshen
c753c9fa74
feat(transform_conformance): handle deserialization errors (#2980) 2024-04-14 22:47:28 +08:00
Boshen
b6b63ac9bc
feat(transform_conformance): skip tests with plugin.js (#2978) 2024-04-14 21:55:32 +08:00
Boshen
7cf0927a38
feat(transform_conformance): skip tests with plugin.js (#2977) 2024-04-14 21:45:27 +08:00
Boshen
c211f1e57f
feat(transformer): add diagnostics to react transform (#2974) 2024-04-14 21:42:32 +08:00
Boshen
ef602af4cc
feat(transform_conformance): skip plugins we don't support yet (#2967) 2024-04-14 21:32:03 +08:00
Boshen
c7e70c80f0
fix(transformer): deserialize ReactJsxRuntime with camelCase (#2972) 2024-04-14 19:40:24 +08:00
Boshen
3a6eae1abd
feat(transformer): apply jsx self and source plugin inside jsx transform (#2966) 2024-04-14 19:10:59 +08:00
Boshen
10814d5331
fix(transformer): turn on react preset by default (#2968) 2024-04-14 19:04:59 +08:00
Boshen
35e3b0f1cb
fix(transformer): fix incorrect jsx whitespace text handling (#2969) 2024-04-14 18:40:40 +08:00
Boshen
bd9fc6d169
feat(transformer): react jsx transform (#2961) 2024-04-14 10:50:17 +08:00
Boshen
6561392202
feat(transform_conformance): add baseline for all TypeScript and jsx plugins 2024-04-13 19:05:39 +08:00
Miles Johnson
e67355045e
feat(transformer): start on TypeScript annotation removal (#2951) 2024-04-13 18:49:54 +08:00
Boshen
e651e50bda
feat(transformer): add the most basic plugin toggles (#2950) 2024-04-12 20:25:34 +08:00
Boshen
60ccbb105c
refactor(transformer): clean up some code (#2949) 2024-04-12 20:23:44 +08:00
Boshen
14754777a4
feat(transformer): implement react-jsx-source (#2948) 2024-04-12 20:21:54 +08:00
Boshen
f903a225a8
feat(transformer): implement react-jsx-self (#2946) 2024-04-12 18:08:36 +08:00
Boshen
0c04bf743f
feat(transformer): transform TypeScript namespace (#2942) 2024-04-12 10:19:13 +08:00
Boshen
f3a28c61b9
chore(transform_conformance): enable typescript plugin snapshot 2024-04-11 20:06:53 +08:00
Boshen
3419306ac0
feat(transformer): add filename (#2941) 2024-04-11 18:43:51 +08:00
Boshen
02adc76760
feat(transformer): implement plugin-transform-react-display-name top-down (#2937)
Missing case:


https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/nested/input.js

```js
var foo = qux(createReactClass({}));
var bar = qux(React.createClass({}));
```

This requires recursing down.

Top-down implementation in swc:


67ec5e09b9/crates/swc_ecma_transforms_react/src/display_name/mod.rs (L108-L132)

Or bottom-up in babel:


08b0472069/packages/babel-plugin-transform-react-display-name/src/index.ts (L87-L98)
2024-04-11 15:32:32 +08:00
Boshen
07bd85e25d
chore(transform_conformance): clear the conformance snapshot 2024-04-11 14:09:59 +08:00
Boshen
d65eab3b8b
feat(transformer): add react preset (#2921) 2024-04-09 12:39:33 +08:00