56 Commits

Author SHA1 Message Date
Logan Smyth
5eb193c61f Ensure that Identifier source mappings explicitly start and stop on the generated range (#8380)
* Add sourcemap examples for identifiers in code generator.

* Generate sourcemaps with exact mappings for identifiers, even if leading/trailing tokens also use that location.
2018-07-27 16:27:33 -04:00
Brian Ng
e4b35f680d
Run prettier 2017-06-27 12:15:00 -05:00
jwbay
1a325ce5d5 codegen performance: use trim-right instead of lodash/trimEnd (#5255) 2017-02-09 13:04:42 -08:00
Brian Ng
8c35b320d3 Bump eslint-config-babel and fix lint (#5129) 2017-01-17 10:51:16 +01:00
Henry Zhu
672adba9a1 enable prefer const (#5113) 2017-01-14 09:48:52 -05:00
David Aurelio
2907d663dc add comments 2016-12-16 01:12:50 +00:00
David Aurelio
4cb7e5009a Add missing property descriptor values 2016-12-14 10:18:18 +00:00
David Aurelio
7ea283eb82 babel-generator: Expose raw mappings
Exposes raw mappings when source map generation is enabled. To avoid the cost of source map generation for consumers of the raw mappings only, `.map` is changed to a getter that generates the source map lazily on first access.
2016-12-09 09:55:42 +00:00
Sebastian McKenzie
4a19661346 Generate names field for identifiers to get correct names mappings (#3658) 2016-08-16 13:43:55 -04:00
Logan Smyth
9f49c99774 Drop .getLast(). 2016-07-18 19:12:21 -07:00
Logan Smyth
4dcec860bd Drop trailing whitespace after all newlines. 2016-07-17 21:51:01 -07:00
Logan Smyth
3cc38a0063 Merge pull request #3581 from loganfsmyth/generator-refactor-cleanup
babel-generator: Misc cleanup and stale code removal
2016-07-16 12:44:19 -07:00
Justin Ridgewell
a70755d0e6 Further optimize babel-generator Buffer
We can eek out a bit more speed from Babel generator by turning the
buffer into an array as well.
Re: #3565

```
Items: 2 , time: 4 length: 114
Items: 4 , time: 3 length: 218
Items: 8 , time: 3 length: 426
Items: 16 , time: 2 length: 861
Items: 32 , time: 5 length: 1741
Items: 64 , time: 2 length: 3501
Items: 128 , time: 4 length: 7106
Items: 256 , time: 8 length: 14530
Items: 512 , time: 12 length: 29378
Items: 1024 , time: 24 length: 59147
Items: 2048 , time: 38 length: 121611
Items: 4096 , time: 71 length: 246539
Items: 8192 , time: 131 length: 496395
Items: 16384 , time: 350 length: 1015260
Items: 32768 , time: 573 length: 2063836
Items: 65536 , time: 1263 length: 4160988
Items: 131072 , time: 2143 length: 8448509
Items: 262144 , time: 4859 length: 17230333
```

to

```
Items: 2 , time: 4 length: 114
Items: 4 , time: 3 length: 218
Items: 8 , time: 9 length: 426
Items: 16 , time: 1 length: 861
Items: 32 , time: 5 length: 1741
Items: 64 , time: 1 length: 3501
Items: 128 , time: 3 length: 7106
Items: 256 , time: 7 length: 14530
Items: 512 , time: 9 length: 29378
Items: 1024 , time: 17 length: 59147
Items: 2048 , time: 30 length: 121611
Items: 4096 , time: 61 length: 246539
Items: 8192 , time: 113 length: 496395
Items: 16384 , time: 307 length: 1015260
Items: 32768 , time: 443 length: 2063836
Items: 65536 , time: 1065 length: 4160988
Items: 131072 , time: 1799 length: 8448509
Items: 262144 , time: 4217 length: 17230333
```
2016-07-15 01:27:45 -04:00
Logan Smyth
475581dc66 Ditch the tiny Position class. 2016-07-14 21:55:08 -07:00
Logan Smyth
11d49db23b Use the first item in the queue since it is the most recent. 2016-07-06 23:30:45 -07:00
Logan Smyth
65a677decd Maintain a queue to allow deletion of whitespace/semicolons without accessing buf. 2016-07-05 21:03:29 -07:00
Logan Smyth
cb60808500 Make buffer a property for managing the token queue. 2016-07-05 21:02:46 -07:00
Logan Smyth
c5a6c5c291 Pass values directly to avoid object usage. 2016-07-05 21:01:33 -07:00
Logan Smyth
abb9618e8c Drop array support from endsWith. 2016-07-05 19:44:51 -07:00
Logan Smyth
f908f3fc88 Use 'push' for all cases. 2016-07-04 22:49:59 -07:00
Logan Smyth
caef91672d Remove unnecessary passthrough function. 2016-07-04 22:49:59 -07:00
Logan Smyth
578f48134b Remove removeLast usage. 2016-07-04 22:49:59 -07:00
Logan Smyth
80cd3ca331 Drop one usage of removeLast. 2016-07-04 22:49:59 -07:00
Logan Smyth
d6b1e36d49 Make the 'catchUp' call implicit to source location updates. 2016-07-04 22:49:58 -07:00
Logan Smyth
3680d10b6f Centralize position tracking into buffer. 2016-07-04 22:42:28 -07:00
Logan Smyth
177c092496 Remove sideeffectful position mutation. 2016-07-02 15:38:05 -07:00
Logan Smyth
1514d0a1ad Drop some space-insertion logic. 2016-06-16 22:00:23 -07:00
Logan Smyth
39896b4d91 Automatically prepend a space when writing a word immediately after a word. 2016-06-16 22:00:23 -07:00
Logan Smyth
4286cb4f2a Explicitly label standalone tokens and words. 2016-06-16 22:00:23 -07:00
Logan Smyth
e702e67233 Split all of the pushes into individual tokens. 2016-06-16 22:00:23 -07:00
Logan Smyth
22e2c88269 Drop the unneeded noIndent function param. 2016-06-16 22:00:23 -07:00
Logan Smyth
f566700657 Avoid processing indentation for every pushed string. 2016-06-16 21:59:51 -07:00
Logan Smyth
315c075419 Remove the unnecessary push/_push division. 2016-06-16 20:31:19 -07:00
Logan Smyth
680fcc16d7 Standardize on .endsWith 2016-06-16 20:31:19 -07:00
Logan Smyth
2f790889eb Make sure to roll back the generated position markers when trimming spaces. 2016-06-16 20:31:19 -07:00
Logan Smyth
9ddf9aabfc Don't track position when sourcemaps are off. 2016-06-16 20:31:19 -07:00
Logan Smyth
0be2f1cf48 Remove unnecessary ensureSemicolon. 2016-06-16 20:31:19 -07:00
Logan Smyth
c1ba5e6ac8 Remove unused force param. 2016-06-16 20:31:19 -07:00
dlwalsh
829d4497c9 remove micro modules in favour of lodash functions (#3500) 2016-05-15 22:00:50 -04:00
Logan Smyth
76bb1dffaa Track sourcemap location on a stack - fixes T7255 2016-04-11 01:54:40 -07:00
Amjad Masad
2fbe28cc88 Remove remaining @flow annotations 2016-03-03 15:10:59 -08:00
Amjad Masad
12ee11a0a4 Revert "Remove Flow annotations and pragmas"
This reverts commit 4252244d06b225ab26a02d52c04f9940a3e4d6a2.
2016-03-03 15:03:55 -08:00
Sam Goldman
4252244d06 Remove Flow annotations and pragmas 2016-02-28 13:18:57 -10:00
Henry Zhu
c2d7e95e1a add some more flow types 2016-02-04 11:07:03 -05:00
Amjad Masad
5699403835 Add comment clarifying the optimization 2016-01-22 14:24:45 -08:00
Jason
993c5a572b Improve performance for generator.buffer 2016-01-20 02:04:26 +08:00
Jason
76e3c5227b Improve generator performance by caching the last character in Buffer 2016-01-19 21:16:33 +08:00
Amjad Masad
cb03a98b65 Add minified format option
As a follow up from #3145 we agreed to add a new format that is a
superset of the compact format option. Do things that are considered
dangerous. e.g. not printing semicolons, or print literal values
as opposed to raw values.
2015-12-09 17:34:23 -08:00
Amjad Masad
44d5552840 Fix up semicolon omission in compact mode 2015-11-23 21:32:44 -08:00
Daniel Lo Nigro
0076204f80 Fix Flow.
Removed `@flow` annotation from files that don't actually pass Flow check at the moment. These will be added back file by file once the files are properly converted to use Flow.

Closes #3064
2015-11-15 21:30:22 -08:00