Commit Graph

235 Commits

Author SHA1 Message Date
SWC Bot
8fc1b651b1 chore: Publish crates 2023-01-26 02:11:53 +00:00
Donny/강동윤
99d48e305e
fix(plugin): Make span_to_source use dedicated function (#6853)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6852.
 - Closes https://github.com/swc-project/swc/issues/6404.
2023-01-26 02:09:36 +00:00
SWC Bot
a225efe363 chore: Publish crates 2023-01-08 04:59:27 +00:00
Justin Ridgewell
2b503c16d5
fix(es/codegen): Fix LineCol calculation of printed files (#6763)
**Description:**

There were several issues with the way we updated the current `LineCol` position during the printing of the generated file:

- We used `chars` and `char_indices` (UTF-32) instead of `encode_utf16` (UTF-16) chars.
- JS uses UCS-2 (basically UTF-16) for its strings, and source maps default to that implicitly.
- `\r` was incorrectly handled
  - it didn't add a `line_start`; only `\n` did
- `\r\n` was incorrectly handled
- It was trying to let the `\n` path handle the `line_start`, but it called
`chars.next()` which ate the `\n` char.

I also took the opportunity to avoid the `Vec` allocations and reduced some code duplication.

See the
[before](https://evanw.github.io/source-map-visualization/#ODEzAC8qKgogKiBmb28KICogQHBhcmFtIGRhdGEgZm9vCiAqIEByZXR1cm5zIGZvbwogKi8gZXhwb3J0IGNvbnN0IGZpeHVwUmlza0NvbmZpZ0RhdGEgPSAoZGF0YSk9PnsKICAgIGlmICh4KSB7CiAgICAgICAgcmV0dXJuIDEyMzsKICAgIH0gZWxzZSB7CiAgICAgICAgcmV0dXJuIDQ1NjsKICAgIH0KfTsKCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWRhdGE6YXBwbGljYXRpb24vanNvbjtiYXNlNjQsZXlKMlpYSnphVzl1SWpvekxDSnpiM1Z5WTJWeklqcGJJbWx1Y0hWMExuUnpJbDBzSW5OdmRYSmpaWE5EYjI1MFpXNTBJanBiSWk4cUtseHlYRzRnS2lCbWIyOWNjbHh1SUNvZ1FIQmhjbUZ0SUdSaGRHRWdabTl2WEhKY2JpQXFJRUJ5WlhSMWNtNXpJR1p2YjF4e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RkJUeXhKUVVGTlFTeHpRa0ZCYzBJc1UwRkJRME1zVFVGQmIwTTdTVUZEZEVVc1NVRkJTVU1zUjBGQlJ6dFJRVU5NTEU5QlFVODdTVUZEVkN4UFFVRlBPMUZCUTB3c1QwRkJUenRKUVVOVUxFTkJRVU03UVVGRFNDeEZRVUZGSW4wPTQ0NgB7InZlcnNpb24iOjMsInNvdXJjZXMiOlsiLi9hcHAuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqXHJcbiAqIGZvb1xyXG4gKiBAcGFyYW0gZGF0YSBmb29cclxuICogQHJldHVybnMgZm9vXHJcbiAqL1xyXG5leHBvcnQgY29uc3QgZml4dXBSaXNrQ29uZmlnRGF0YSA9IChkYXRhOiBhbnkpOiB0eXBlcy5SaXNrQ29uZmlnVHlwZSA9PiB7XHJcbiAgaWYgKHgpIHtcclxuICAgIHJldHVybiAxMjM7XHJcbiAgfSBlbHNlIHtcclxuICAgIHJldHVybiA0NTY7XHJcbiAgfVxyXG59OyJdLCJuYW1lcyI6WyJmaXh1cFJpc2tDb25maWdEYXRhIiwiZGF0YSIsIngiXSwibWFwcGluZ3MiOiJBQUFBOzs7O0NBSUMsR0FDRCxPQUFPLElBQU1BLHNCQUFzQixTQUFDQyxNQUFvQztJQUN0RSxJQUFJQyxHQUFHO1FBQ0wsT0FBTztJQUNULE9BQU87UUFDTCxPQUFPO0lBQ1QsQ0FBQztBQUNILEVBQUUifQ==)


**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6694.
2023-01-08 13:57:26 +09:00
SWC Bot
1161360d54 chore: Publish crates 2023-01-06 03:49:20 +00:00
Donny/강동윤
26a0c13589
fix(common): Mark \r as a line ending (#6752)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6694.
2023-01-06 03:47:16 +00:00
SWC Bot
61245739ea chore: Publish crates 2022-12-21 03:03:05 +00:00
SWC Bot
913230d02a chore: Publish crates 2022-12-20 06:11:34 +00:00
SWC Bot
30692bc26c chore: Publish crates 2022-12-13 15:48:32 +00:00
SWC Bot
292c3388b5 chore: Publish crates 2022-12-13 07:31:37 +00:00
SWC Bot
581d9ce769 chore: Publish crates 2022-12-13 03:38:21 +00:00
SWC Bot
4d4406d5b3 chore: Publish crates 2022-12-12 02:40:19 +00:00
SWC Bot
2379fc1fd9 chore: Publish crates 2022-12-04 05:55:52 +00:00
Justin Ridgewell
a203fdb1b6
fix(common): Fix BytePos -> CharPos calculations (#6574)
**Description:**

This fixes the BytePos -> CharPos calculation necessary for source maps.
There were a few issues in the old code:

1. UTF-8 maps 1-3 bytes into 1 UTF-16 char, but 4 bytes into 2 UTF-16 chars
2. The starting offset was not recorded when we reached the end of the `multibyte_chars` iteration
3. The `mappings` can be unordered, meaning we need to restart the UTF-16 offset calculation

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6552.
2022-12-04 14:52:00 +09:00
SWC Bot
cffa11122b chore: Publish crates 2022-12-03 00:26:38 +00:00
Justin Ridgewell
b3ea52f863
refactor(common): Cleanup source_map.rs (#6570) 2022-12-03 00:23:06 +00:00
SWC Bot
ab2e19b601 chore: Publish crates 2022-12-02 08:01:39 +00:00
Donny/강동윤
4af52c79ae
fix(common): Fix handling of input source maps (#6561)
**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/4578.
 - Closes https://github.com/swc-project/swc/issues/6244.
 - https://github.com/vercel/next.js/issues/39878.

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
2022-12-02 07:58:02 +00:00
SWC Bot
96a1f93e91 chore: Publish crates 2022-11-28 07:54:59 +00:00
Donny/강동윤
47908a49d3
perf(common): Fix perf bug of sourcemap for inputs with multi-byte chars (#6523)
**Description:**

This PR makes the source map generator cache the previous position instead of searching it from 0 every time.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6411.
2022-11-28 07:51:36 +00:00
SWC Bot
59954370cb chore: Publish crates 2022-11-20 00:30:30 +00:00
SWC Bot
2088dd4a84 chore: Publish crates 2022-11-11 22:50:50 +00:00
Andreas
b6c1cc49e1
fix(es/plugin): Print more details on pointer conversion failures (#6378) 2022-11-11 22:47:44 +00:00
SWC Bot
a4546a4d22 chore: Publish crates 2022-10-28 01:27:37 +00:00
Justin Ridgewell
47d7fcaaed
fix(common): Remove &mut from build_source_map_from (#6276) 2022-10-28 10:24:13 +09:00
SWC Bot
fd4b66ea8c chore: Publish crates 2022-10-27 01:25:04 +00:00
Matt Brubeck
2f61332177
chore(common): Switch to new_debug_unreachable (#6265) 2022-10-27 01:21:36 +00:00
SWC Bot
51132f0636 chore: Publish crates 2022-10-27 00:19:24 +00:00
SWC Bot
b48ec880fd chore: Publish crates 2022-10-19 04:00:51 +00:00
SWC Bot
a049ef058b chore: Publish crates 2022-10-18 14:51:39 +00:00
SWC Bot
1affcfe8e8 chore: Publish crates 2022-10-13 06:12:56 +00:00
SWC Bot
56da9981bb chore: Publish crates 2022-10-12 10:06:01 +00:00
SWC Bot
dcb3a4371d chore: Publish crates 2022-10-11 23:55:24 +00:00
SWC Bot
5f49ac012e chore: Publish crates 2022-10-06 11:38:55 +00:00
IWANABETHATGUY
047da86baa
chore(common): Make Mark::root const fn (#6072) 2022-10-06 11:36:08 +00:00
SWC Bot
d620ce60ff chore: Publish crates 2022-10-02 15:36:08 +00:00
IWANABETHATGUY
5ea2d81aa3
perf(common): Split the mutex for the hygiene system (#6019) 2022-10-03 00:32:22 +09:00
Donny/강동윤
10fb645552
chore(ci): Merge CI scripts (#5999)
**Description:**

This PR merges CI scripts, and make integration tests use patched crates.

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/5540.
2022-09-30 16:57:15 +09:00
OJ Kwon
af64217f19
build(cargo): Introduce workspace deps (#5997) 2022-09-30 13:43:32 +09:00
SWC Bot
c499e2054d chore: Publish crates 2022-09-28 22:57:51 +00:00
SWC Bot
d75addbdec chore: Publish crates 2022-09-28 10:37:40 +00:00
Donny/강동윤
19131e168e
perf(es): Don't share Globals (#5975)
**Description:**

We don't need to share an instance of `Globals`.
2022-09-28 10:34:30 +00:00
SWC Bot
e001226674 chore: Publish crates 2022-09-26 09:21:39 +00:00
Donny/강동윤
2ba88154fc
fix(es/codegen): Align sourcemap with terser (#5657) 2022-09-26 18:12:42 +09:00
SWC Bot
e5ba9636ac chore: Publish crates 2022-09-24 03:36:47 +00:00
Donny/강동윤
3c3529cb84
build(rustc): Update rustc (#5943)
**Description:**

This PR updates rustc, and fix some performance bugs of `swc_common`.
2022-09-24 03:33:47 +00:00
SWC Bot
8a5ed1e0ba chore: Publish crates 2022-09-23 07:50:26 +00:00
SWC Bot
4c3813dbcc chore: Publish crates 2022-09-22 03:16:22 +00:00
Donny/강동윤
f0ca487848 chore: Publish crates 2022-09-16 15:46:25 +09:00
SWC Bot
1d633e8ba7 chore: Publish crates 2022-09-15 06:08:07 +00:00