Commit graph

14 commits

Author SHA1 Message Date
underfin
114f68ea7c
refactor(codegen): make codegen sourcemap builder clearer (#2894)
Avoid `enable_sourcemap` appear multiply times.
2024-04-03 15:07:19 +08:00
underfin
6177c2f7ef
fix(codegen): sourcemap token name should be original name (#2843)
close https://github.com/oxc-project/oxc/issues/2753.
2024-03-28 20:14:10 +08:00
underfin
b199cb89a2
feat: add oxc sourcemap crate (#2825)
The sourcemap implement port from
[rust-sourcemap](https://github.com/getsentry/rust-sourcemap), but has
some different with it.

- Encode sourcemap at parallel, including quote `sourceContent` and
encode token to `vlq` mappings.
- Avoid `Sourcemap` some methods overhead, like `SourceMap::tokens()`
caused extra overhead at common cases. Here using `SourceViewToken` to
instead of it.
2024-03-28 19:36:38 +08:00
underfin
dc3f6e7570
chore: update sourcemap 8.0.0 (#2788) 2024-03-22 21:52:21 +08:00
underfin
d7004da253
perf(sourcemap): remove unnecessary binary search (#2728)
Becuase `position` argument is ordering, using binary search is
unnecessary.
2024-03-15 18:50:53 +08:00
underfin
2be5f9d6c9
perf(codegen): avoid unnecessary copy (#2727) 2024-03-15 16:09:24 +08:00
Boshen
c72675e89e
chore: Rust v1.76.0 (#2643) 2024-03-08 20:54:36 +08:00
Boshen
ef932a3c27
refactor(codegen): clean up API around building sourcemaps (#2602)
closes #2564
2024-03-04 16:03:33 +08:00
overlookmotel
b7f5c63833
perf(codegen): speed up generating sourcemap mappings (#2597)
This PR optimizes the `update_generated_line_and_column` function used in generating source maps.

The main change is that `generated_column` only depends on the last line, so just spin through bytes to find the last line break, and then only convert last line UTF-8 to UTF-16. There's also a fast path for when last line is ASCII, to avoid iterating over the last line twice in that common case.
2024-03-04 12:46:32 +08:00
overlookmotel
42fa8ebbc2
perf(codegen): speed up building sourcemap line tables (#2591)
Speed up building the line tables for source maps, using same kind of techniques as have been using in the lexer:

* Iterate byte-by-byte not char-by-char (`chars` iterator is slow).
* Fast path for ASCII (common case).
2024-03-04 12:40:39 +08:00
overlookmotel
ea30fd5b12
fix(codegen): fix adding mapping to sourcemaps (#2590)
Fix creating a sourcemap mapping when last byte of output in `\r`. Currently this panics because it assumes there's another byte after it when checking for `\n`, and reads out of bounds.
2024-03-04 12:33:28 +08:00
overlookmotel
fe29fa4797
fix(codegen): correct sourcemaps when Windows line breaks + unicode (#2584)
Fix source mapping of Window-style line breaks in presence of Unicode chars.

`content.chars().nth(i + 1)` gets the `i + 1`th *char*, but `i` is a byte offset not a char offset.

The replacement `content.as_bytes().get(i + 1)` gets the `i + 1`th *byte*, and should also be faster as doesn't require iterating through `chars` again.
2024-03-04 12:27:28 +08:00
overlookmotel
517026b1db
fix(codegen): correct sourcemaps when unicode chars (#2583)
#2565 added source map support in codegen. But there was a bug in creating the line offset tables for Unicode. This PR fixes that.

This function could probably be made more efficient, but I think this at least makes it correct.
2024-03-04 12:22:47 +08:00
Boshen
8bb1084863
feat(codegen): add sourcemap (#2565)
Co-authored-by: underfin <2218301630@qq.com>
2024-03-03 14:44:49 +08:00