Commit Graph

979 Commits

Author SHA1 Message Date
Donny/강동윤
fac6f47863
perf(es/transforms): Improve performance (#2329)
swc_ecma_ast:
 - Implement `Take` for `Function`.
 - Implement `Take` for `FnExpr`.
 - Implement `Take` for `ClassExpr`.

swc_ecma_transforms_compat:
 - Migrate `es2015::duplicate_keys` to `VisitMut`.
 - Migrate `es2015::template_literals` to `VisitMut`.
 - Migrate `es2015::function_name` to `VisitMut`.
 - Add more fast-path to `reserved_words` pass.

swc_ecma_transforms_react:
 - Reduce allocations of `pure_annotations`.
 - Migrate `pure_annotations` to `VisitMut`.
 - Migrate `jsx::display_name` to `VisitMut`.

swc_ecma_transforms_optimization:
 - Migrate `inline_globals` to `VisitMut`.
 - `inline_globals`: Use `Lrc<FxHashMap<K, V>>`.

swc:
 - Cache `current_dir()`.
 - `ModuleConfig::build`: cacnonicalize only if `paths` is used.
2021-10-05 13:31:35 +00:00
Donny/강동윤
87b20a8896
fix(es/minifier): Fix inlining into shorthand properties (#2348)
swc_ecma_minifer:
 - Fix inlining of bindings into shorthand properties.
2021-10-05 09:53:00 +00:00
Pig Fang
ef4c80be7d
feat(babel/compat): Support type-only import/export specifiers (#2342) 2021-10-05 18:27:45 +09:00
Donny/강동윤
b64afb5b6f
fix(es/utils): Fix macros (#2349)
swc_ecma_utils:
 - Allow using macros from crates using `swc_ecmascript`.
2021-10-05 09:14:25 +00:00
Donny/강동윤
8403057268
fix(es/minifier): Don't optimize new String. (#2341)
swc_ecma_transforms_optimization:
 - Don't optimize calls like `new String`.
2021-10-04 06:44:37 +00:00
Donny/강동윤
bbefa0e57e
chore: Improve documentation for rust users (#2340) 2021-10-04 06:10:30 +00:00
Donny/강동윤
a7357ab517
chore: Update rustc (#2332) 2021-10-01 12:11:17 +00:00
Donny/강동윤
dad73926e6
fix(es/minifier): Fix minifier (#2323)
swc_ecma_minifier:
 - Don't inline literals if a property is mutated.
2021-09-30 07:50:34 +00:00
Donny/강동윤
6a41e9a0be
fix(es): Fix performance bugs (#2313)
swc_common:
 - Optimize `SourceMap.span_until_char`.

swc_ecma_codegen:
 - Make `Emitter` generic.

swc_ecma_parser:
 - `Lexer`: Reuse allocation of `String`.
 - `Lexer`: Avoid copying useless data.
2021-09-29 12:10:38 +00:00
Donny/강동윤
bd92d89306
fix(es/codegen): Fix codegen of numbers (#2317)
swc_ecma_codegen:
 - Fix codegen of numbers when minification is enabled. (#2294)
2021-09-29 11:08:59 +00:00
Pig Fang
2b292e6d17
feat(es): Support type-only import/export specifiers (#2309) 2021-09-28 22:05:20 +09:00
Donny/강동윤
e8a1710a21
fix(es/minifier): Fix bugs (#2283)
swc_ecma_transforms_optimization:
 - `expr_simplifier`: Don't inject `0` needlessly. (#2257)
2021-09-27 12:05:31 +00:00
Donny/강동윤
650e1494d4
fix: Migrate dependencies (#2307)
*:
 - Migrate from `log` to `tracing`. (#2284)
 - Migrate from `fxhash` to `rustc-hash`.

swc_common:
 - Add a cargo feature named `debug`.
2021-09-27 09:19:15 +00:00
Donny/강동윤
e46a842e99
feat(es/parser, es/transform): Implement ergonomic brand checking (#2079)
swc_ecma_parser:
 - Implement parsing of private properties in object literals.

swc_ecma_transforms_base:
 - `fixer`: Handle `const [a = (b, c)]`.

swc_ecma_transforms_compat:
 - `class_properties`: Support ergonomic brand checks. (#2064)

swc_ecma_transforms_proposal:
 - Implement ergonomic brand checks for private fields. (#2064)
2021-09-27 08:03:48 +00:00
Pig Fang
552fc2374d
fix(es/parser): Improve error message (#2304)
swc_ecma_parser:
 - Improve error message for unexpected tokens.
2021-09-26 01:19:08 +09:00
Pig Fang
83153a0f85
fix(es/parser): Report errors for multiple import/export specifiers without comma (#2302) 2021-09-25 23:53:57 +09:00
Donny/강동윤
5e1003ec4c
fix(es/transforms/base): Fix hygiene (#2299)
swc_ecma_transforms_base:
 - `hygiene`: Support usage-def conflict where def comes first. (#2297)
2021-09-24 10:26:01 +00:00
Donny/강동윤
ca0d6ddf2e
fix(es/parser): Fix bugs (#2255)
swc_ecma_parser:
 - Treat `{` after an arrow as a brace stmt. (#2237)
 - Handle comments correctly while backtracking. (#2264)
2021-09-23 11:32:40 +00:00
Donny/강동윤
2156364121
fix(es/transforms/base): Fix hygiene (#2282)
swc_ecma_transforms_base:
 - `hygiene`: Handle decl-ref conflict. (#2211)
2021-09-22 06:56:04 +00:00
Donny/강동윤
e5f46a6800
fix(wasm): Fix bugs (#2279)
swc:
 - Ensure that #2281 is fixed. (#2281)

wasm:
 - Fix `baseUrl` and `paths` support.
 - Apply `hygiene` pass.
2021-09-21 15:24:03 +00:00
Pig Fang
4d500baaaa
fix(es/transforms/compat): Move the optional catch binding pass to ES2019 (#2247)
swc_ecma_transforms_compat:
 - Move optional chaining pass to `es2019`.

Co-authored-by: Donny <kdy1997.dev@gmail.com>
2021-09-21 21:54:51 +09:00
Donny/강동윤
180dc31550
fix(es/transforms/base): Fix hygiene pass (#2266)
swc_ecma_transforms_base:
 - `hygiene`: Consider nested scopes correctly. (#2211)
 - `hygiene`: Fix handling of constructors.
2021-09-21 12:21:49 +00:00
Fábio Santos
3f306f0b79
fix(es/minifier): Don't drop used variables (#2272)
swc_ecma_minifier:
 - Don't drop used variables. (#2262)

Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
2021-09-21 16:45:28 +09:00
Fábio Santos
406fa3fc78
feat(es/minifier): Add CLI for debugging (#2273)
swc_ecma_minifier:
 - Add a binary to help development.
2021-09-20 15:25:51 +09:00
David Sherret
8e0a5450b1
fix(es/codegen): Emit static before readonly (#2271) 2021-09-19 16:28:33 +09:00
강동윤
ce01b8a9b7
fix(es): Fix bugs (#2256)
swc_ecma_codegen:
 - Fix source map of string literals. (#2253)

swc_ecma_transforms_typescript:
 - Allow using same name for a module with function. (#2243)
2021-09-18 07:52:08 +00:00
강동윤
f087d1515b
fix(es/transforms/testing): Fix comparing logic (#2263)
swc_ecma_transform_testing:
 - Fix comparing logic.
2021-09-16 20:21:09 +09:00
강동윤
e2d8465565
fix(es/codegen): Fix codegen of ` in synthesized template literals (#2260)
swc_ecma_codegen:
 - Fix codegen of ` in synthesized template string literals.
2021-09-16 09:26:02 +00:00
강동윤
20ce326909
feat(es/minifer): Improve minifier (#2229)
swc_ecma_minifier:
 - `if_return`: Allow side-effect-free statements to come after `if_return`.
 - `collapse_vars`: Move variables without init to first.
 - `analyzer`: Remove useless fields.
 - Don't drop `return` tokens if there's a finally block.
 - `drop_return_value`: Drop side-effect-free return arguments.
 - `make_sequences`: Don't inject `void 0` to return args.
 - `if_terminate`: Move to the pure optimizer.
 - Fix a bug related to `RegExp`.
2021-09-16 04:23:33 +00:00
강동윤
6f33c327cb
fix(es/transforms): Fix bugs (#2249)
swc_ecma_transforms_compat:
 - Fix `this` in class properties. (#2228)

swc_ecma_transforms_typescript:
 - Handle `import =` correctly. (#2234)
 - Ensure that #1653 is not the case anymore. (#1653)

swc:
 - Ensure that #2232 is not the case. (#2232)
2021-09-15 07:46:03 +00:00
Iron Lu
6e12ef0306
fix(es/transforms/compat): Add new.target to es5 (#2231) 2021-09-13 15:51:17 +09:00
강동윤
9eafd0c6c4
fix(es/loader): Fix support for jsc.paths. (#2227)
swc_ecma_loader:
 - `TsConfigResolver`: Use `baseUrl`. (#2050)

swc:
 - Change type of `JscConfig.base_url` to `PathBuf`.

testing:
 - Improve `NormalizedOutput::compare_to_file`.
2021-09-10 12:29:26 +00:00
강동윤
2c477780f0
fix(es): Fix bugs (#2222)
swc_ecma_parser:
 - Don't panic on `typeof import(T)`. (#2198)
 - Fix parsing of ternary. (#2196)

swc_ecma_transforms_base:
 - `fixer`: Handle unary in lhs of an exponentation expression. (#2191)

swc_ecma_transforms_compat:
 - Use variable for `this` in arrow expressions. (#2212)

swc_ecma_visit:
 - Add a trait `InjectVars`.

node_swc:
 - Increease recursion limit while deserializing. (#2223)
2021-09-09 20:45:20 +09:00
강동윤
b4796d9d54
fix: Fix simple bugs (#2220)
swc_ecma_utils:
 - Don't panic on jsx.

swc_ecma_transforms_typescript:
 - Drop type-only reexports. (#2219)
2021-09-09 05:06:03 +00:00
강동윤
c8b46bf6db
feat(es/minifier): Implement more rules (#2183)
swc_ecma_codegen:
 - Don't panic on `Pat::Invalid`.
 - Fix codegen of unary minus. (#2213)

swc_ecma_minifier:
 - Remove identifier of function expressions if a variable with same name exists.
 - `sequences`: Merge into the argument of a throw statement.
 - Use `ignore_return_value` for `void` expressions.
 - Improve inlining.
 - Drop last `return` if the return value is not used.
 - `sequences`: Merge `c++; use(c)` as `use(++c)`.
 - `sequences`: Merge assignments with an operator.
 - `comparisons`: Optimize the comparison operator if type is equivalent.
 - Fix `negate_cost`.
 - `unused`: Fix order or variable initalizer when variables are dropped.
 - Fix `top_retain` option.
 - `if_return`: Don't merge nested if it's wrong to do so. (#2214)
 - Fix negation of `if_return`.
2021-09-08 09:45:39 +00:00
Sosuke Suzuki
cbc8230310
fix(es/parser): Fix parsing of static blocks (#2200)
swc_ecma_parser:
 - Fix parsing of static blocks with line breaks. (#2195)
2021-09-03 14:57:23 +09:00
Kitson Kelly
87f30b21a3
feat(common): Add variants to FileName (#2202) 2021-09-03 13:55:31 +09:00
강동윤
77be9f63b9
fix(swc): Improve rust apis (#2197)
swc_ecma_transforms_testing:
 - Make `expected` not affect source map of input.

swc:
 - Accept `before` pass.
2021-09-01 23:34:37 +00:00
강동윤
cb2b0c671f
fix(es/transforms/base): Optimize hygiene (#2193)
swc_ecma_transforms_base:
 - `hygiene`: Don't rename if not required. (#1600)

swc_ecma_minifier:
 - Remove `hygiene_optimizer`.
2021-09-01 13:11:55 +00:00
강동윤
a8cb554be5
feat: Expose .take() (#2190)
swc_common:
 - Add `Take`. (#2189)

swc_ecma_ast:
 - Implement `Take` for ast nodes. 

swc_ecma_transforms_base:
 - Remove `MapWithMut`.
2021-08-31 14:45:48 +00:00
David Sherret
99c35ff980
refactor(es): Use BlockStmt instead Vec<Stmt> for static blocks. (#2188)
swc_ecma_ast:
 - Use `BlockStmt` instead of `Vec<Stmt>` for static blocks.

swc_ecma_parser:
 - Fix span of static blocks.
2021-08-31 16:12:18 +09:00
David Sherret
2f2e35af69
fix(es/parser): Remove static_blocks from TsConfig (#2186) 2021-08-31 14:52:51 +09:00
muji
361bc70065
fix(es/loader): Improve handling of base_dir (#2182) 2021-08-30 21:21:52 +09:00
강동윤
11fe35dbd1
feat(es/minifier): Implement static evaluator (#2176)
swc_ecma_minifier:
 - Add an api to evaluate constants statically.
2021-08-30 05:21:38 +00:00
강동윤
ee16139a19
fix(es/transforms): Fix bugs (#2181)
swc_ecma_transforms_compat:
 - `regenerator`: Fix variable hoisting for for-in/of loops. (#2164)
 - Ensure #2071 is fixed. (#2071)
2021-08-30 04:08:24 +00:00
Sosuke Suzuki
b2c99719fd
feat(es/parser): Add tests for static blocks (#2180)
swc_ecma_parser:
 - Add tests for multiple static blocks in a class.
2021-08-30 12:45:41 +09:00
강동윤
c0b0337d1d
fix(es): Fix easy bugs (#2178)
swc_ecma_parser:
 - Fix parsing of complex arrow expressions in a conditional expression. (#2174)
 - Report an error for wrong jsx, instead of `panic!`. (#2173)

swc_ecma_transforms_react:
 - `jsx`: Handle fragment with single child correctly. (#2177)

swc:
 - Ensure that #2170 is an invalid issue. (#2170)
2021-08-29 20:40:52 +00:00
Sosuke Suzuki
a10118c90f
feat(es/parser, es/codegen, es/visit): Support static blocks in classes (#2130)
swc_ecma_ast:
 - Add support for static blocks in classes.
2021-08-30 00:03:14 +09:00
muji
5d702835e8
fix(es/loader): Fix node resolver (#2172)
swc_ecma_module_loader:
 - Use correct base directory.
2021-08-29 17:47:15 +09:00
강동윤
97514a7549
fix(es): Fix some easy bugs (#2166)
swc_ecma_parser:
 - Fix parsing of typescript generics in jsx context. (#2161)

swc_ecma_transforms_base:
 - `fixer`: Handle assignment with patterns in arrow body. (#2163)

swc_ecma_utils:
 - `as_bool`: Handle assignment with operator correctly. (#2165)
2021-08-27 06:03:06 +00:00