Commit Graph

264 Commits

Author SHA1 Message Date
강동윤
da97acca20 Bump 2020-03-10 00:35:53 +09:00
강동윤
e448a8910c
Fix bugs (#710)
- The parser now supports parsing optional patterns in .d.ts files (Closes #709)
 - The source map is handled properly (Closes #705, Closes #707)
2020-03-09 21:18:41 +09:00
강동윤
e5a818aabd
Fix resolver and block_scoping (#700) 2020-03-04 16:07:17 +09:00
강동윤
6e028696a5
Faster sourcemap generation for large files (#697)
We buffer operations related to source map and make it fast using an assumption that the byte positions always increment while emitting a file.
2020-03-02 20:49:08 +09:00
강동윤
8f280c535c
Performance (#696)
- Parser performance is improved by ~15%
 - Codegen performance is improved by ~90% (when comment and source map is enabled)
2020-03-01 20:05:03 +09:00
강동윤
99b5018ba6
Fix ts enum with initializer (#694) 2020-02-29 14:54:10 +09:00
David Sherret
0e8c5a6c93
Fix assignment pattern start when there is a type annotation (#693)
- Update dashmap to 3.5.1

Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
2020-02-29 10:29:34 +09:00
강동윤
363b8353cf
resolver: handle hoisting correctly (#689) 2020-02-25 21:29:52 +09:00
강동윤
1cf86b059d
Fix bugs (#687)
- stript type-only export default
- allow `continue` in a for loop
2020-02-22 14:49:04 +09:00
강동윤
cb43a69e02
implement { Hash, Eq } for ast nodes (#684)
As NaN is`IIdent` not `Number`, we can use implement Hash and Eq for ast nodes.
2020-02-21 12:47:06 +09:00
강동윤
e3ca8e5d13
Fix bugs (#683)
- Fix block_scoping (Fix #682)
 - Handle new.target in susbscript position (Fix #675)
2020-02-20 13:06:28 +09:00
강동윤
f79223e98c
resolver: Handle method property correctly (#679) 2020-02-19 19:49:58 +09:00
강동윤
53d09d448e
Handle await-for loop just like babel (#676) 2020-02-18 12:27:13 +09:00
강동윤
e709da9d55
Fix SourceMap (#672)
Previously, `SourceMap` (taken from rustc) has a bug which reuses start position when new_source_file is invoked concurrently.
2020-02-17 15:56:41 +09:00
강동윤
1fc09caa2f
type-only import, exports (#662) 2020-02-13 22:56:13 +09:00
강동윤
f344caa4fa
Reduce binary size (#663)
This pr add two helper macros to prevent folding type unnecessarily.
This reduces the binary size by 3MB on linux.
2020-02-13 21:55:54 +09:00
강동윤
f26ef0cfb7
Fix optimizer (#661) 2020-02-13 15:03:38 +09:00
강동윤
348052b017
Improve optimizer (#660)
Although it's quite naive at the moment, I added two optimization passes.

 - dead code elimination (Closes #607)
 - inlining
2020-02-13 11:45:14 +09:00
kdy1
82e73b1121 Fix bugs (#659)
- Strip out const assertions (Closes #656)
 - Fix exclude of the file matcher (Closes #658) 
 - Automatic typescript detection (Closes #655)
2020-02-12 15:07:45 +00:00
Hyeon Kim
226336b38b
Fix version of regenerator-runtime (#644)
7.7.7 is version of @babel/runtime, not regenerator-runtime. Looks like
the intended version was "0.11.0" as you can see in the yarn.lock:

    regenerator-runtime@^0.11.0:
      version "0.11.1"
      resolved "https://registry.yarnpkg.com/regenerator-runtime/-/re...
      integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT9...

Reference:
  https://github.com/swc-project/swc/commit/05be89c19
2020-02-10 03:23:10 +09:00
kdy1
f8c358c9ac Strip type-only imports (#641)
Fixes #640
2020-02-09 11:35:33 +00:00
강동윤
26eb4e3206
Collect all comments (#633)
- Comments are now appended
 - pin dashmap's version
2020-02-07 14:32:43 +09:00
강동윤
05be89c198
Smaller runtime (#631)
Replace babel-runtime with regenerator-runtime
2020-02-07 11:19:23 +09:00
alubbe
45604fa6e7 Remove dependency renaming to enable WASM (#625)
This PR supercedes https://github.com/swc-project/swc/pull/621 and tries to remove dependency renaming to enable WASM, as discussed in https://github.com/swc-project/swc/issues/106
2020-02-05 11:20:25 +00:00
강동윤
8afa3413ea
Remove dependency on lazy_static and chashmap (#617)
- `lazy_static` is replaced by `once_cell`
 - `chashmap` is replaced by `dashmap`
2020-01-30 23:29:12 +09:00
kdy1
01659585e4 Fix parsing of jsx attribute values (#616)
Closes #614.
Closes #615.
2020-01-29 06:24:35 +00:00
kdy1
480015d407 block_scoping: handle variable infection (#610)
Handle variable infection in the block scoping pass. 

i.e. In the code below, v is 'infected' by i.
```js
var functions = [];
for (let i = 0; i < 10; i++) {
   let v = i;
   functions.push(function() {
       return v;
   });
}
functions[0]() // should print 0
```

Closes #609.
2020-01-24 12:29:57 +00:00
kdy1
0ebda3c33e hygiene / block scoping improvement (#608)
`hygiene` pass had a bug related to globally defined variables like `Object` or `undefined`. This pr make hygiene to utilize use-bind conflict to resolve global objects correctly.
Closes #605.

block_scoping pass had a bug with closure in for statement with let or const. This pr fixes it by extracting a loop body as a variable.
Closes #604.
2020-01-24 05:54:52 +00:00
kdy1
9be9ea2c43 hygiene: fix handling of special identifiers (#603)
The identifiers are `arguments`, `undefined`, `NaN`.

Closes #602.
2020-01-23 14:23:24 +00:00
kdy1
20e37eae5d regenerator: allow nested finally block (#601)
Previously, 

```js
function *foo() {
    try {
    } finally {
        try {
        } finally {
             throw new Error('foo');
        }
    }
}

```

make swc panic

Closes #600.
2020-01-23 01:04:08 +00:00
강동윤
8ecbe14207
hygiene: handle use-use conflict (#599)
Note that as we don't care about emitting a clean code, the renamed output may not match it of bind-bind conflict or bind-use conflict.
2020-01-22 10:43:59 +09:00
erikdesjardins
08ce8d0293 fix as_bool treating bitor like bitand (#596) 2020-01-20 08:22:52 +09:00
강동윤
8e476d8a83
Make parser work identically in release mode (#577)
swc_ecma_parser:
 - parser behaves identically on debug mode and release mode

swc:
 - run all tests on travis ci
 - use nvm on travis ci

swc_ecma_transforms:
 - make async_to_generator understand hoisting
2020-01-17 18:44:51 +09:00
kdy1
96e1dbe213 Improve hygiene and use JSXAttrValue (#592)
swc_ecmacript:
 - use JSXAttrValue (Fixes #584)

swc_ecma_transforms:
 - make hygiene pass check for exported vars (Fixes #591)
2020-01-17 05:45:33 +00:00
David Sherret
0d67d5d855 Fix JSX opening, closing, spread child, and expression container spans (#582)
swc_ecma_parser:
 - fix opening and closing jsx spans.
 - fix JSX expression.
 - fix JSX spread child.
2020-01-14 12:37:29 +09:00
강동윤
b7f8282eb1
resolver: handle methods correctly (#579)
swc_ecma_transform:
 - handle a class method in child scope (#578)
2020-01-11 13:29:31 +09:00
강동윤
5503cde085
Extract utils from swc_ecma_transforms (#575)
swc_ecma_transforms:
 - extract utils
2020-01-08 10:55:22 +09:00
erikdesjardins
3e0f4a5bd7 dce: preserve nested if statement (#565)
swc_ecma_transforms:
  - preserve nested if statements

Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
2020-01-05 09:51:40 +09:00
David Sherret
c43bc471dd Fix span for patterns with a type annotation (#558)
swc_ecma_parser:
* fix span for patterns with a type annotation.

Co-authored-by: 강동윤 <kdy1997.dev@gmail.com>
2020-01-03 14:37:48 +09:00
David Sherret
5acf557e35 GetterProp - Add type_ann (#557)
swc_ecma_ast:
 - add type_ann to GetterProp

swc_ecmascript_parser:
 - parse type annotation after a getter property
2020-01-03 13:08:27 +09:00
강동윤
806a6d97da
Regenerator (#554)
swc_ecma_transforms:
 - implement regenerator pass
 - add regenerator pass to es2015 preset

swc_ecma_preset_env:
 - add regenerator
2020-01-02 20:53:06 +09:00
David Sherret
288008091a Typo (#550) 2020-01-02 10:13:47 +09:00
강동윤
916858ae81
Bugfixes (#549)
swc_ecma_ast:
 - fix TsExprWithTypeArgs (closes #548)

swc_ecma_codegen:
 - allow using default import with namespace import (closes #546)

swc_ecma_parser:
 - parse import.meta (closes #545)
2020-01-01 06:57:34 +09:00
강동윤
aa2a394f7d
Fix #542 (#543)
swc_ecma_transforms:
 - preserve space after a jsx element
2019-12-30 00:05:43 +09:00
강동윤
702800e0d9
Attach comments to correct node (#541) 2019-12-28 22:02:58 +09:00
강동윤
3cf1caa4b1 Bump version 2019-12-28 14:05:12 +09:00
강동윤
6fa85b646f
preset-env (#537)
swc_ecma_preset_env:
 - can inject polyfills automatically
 - can apply transforms automatically

swc:
 - added env config to .swcrc
2019-12-28 11:25:54 +09:00
강동윤
31a5bed497
Legacy decorator for class and class members (#531) 2019-12-25 19:30:16 +09:00
강동윤
ac3f69acd0
Split tests to reduce compile time (#530) 2019-12-24 22:53:48 +09:00
강동윤
e2764e997b Transform for nullish coalescing operator.
Fixes #526.
2019-12-24 18:01:27 +09:00