diff --git a/src/oxc/explore.md b/src/oxc/explore.md index 4b0b025..7fd5a88 100644 --- a/src/oxc/explore.md +++ b/src/oxc/explore.md @@ -2,6 +2,33 @@ +## oxc_codegen + +See more about sourcemaps on [oxc::oxc_sourcemaps](#oxc_sourcemap). + +📄 + +## oxc_sourcemap + +> 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(). + +The main interface for creating sourcemaps from existing files seems to be [`oxc::oxc_codegen::CodeGen::new().enable_source_map(&filename, &source_text).build()`](https://github.com/oxc-project/oxc/blob/main/crates/oxc_codegen/src/lib.rs) (or any other options allowed by the builder pattern). + +### Understand the relation about SourceMap between oxc_codegen and oxc_sourcemap + +- [`oxc::oxc_codegen::SourcemapBuilder`](https://github.com/oxc-project/oxc/blob/main/crates/oxc_codegen/src/sourcemap_builder.rs) vs [`oxc::oxc_sourcemap::SourceMapBuilder`](https://github.com/oxc-project/oxc/blob/main/crates/oxc_sourcemap/src/sourcemap_builder.rs) (map vs Map - may be a typo ?) + - [`oxc::oxc_codegen::Codegen`](https://github.com/oxc-project/oxc/blob/main/crates/oxc_codegen/src/lib.rs) contains a field `sourcemap_builder`: [`Option`](https://github.com/oxc-project/oxc/blob/main/crates/oxc_codegen/src/sourcemap_builder.rs) + - `oxc::oxc_codegen::SourcemapBuilder` contains a field `sourcemap_builder`: [`oxc::oxc_sourcemap::SourceMapBuilder`](https://github.com/oxc-project/oxc/blob/main/crates/oxc_sourcemap/src/sourcemap_builder.rs) +- `oxc::oxc_codegen::SourcemapBuilder` has `into_sourcemap(self) -> oxc::oxc_sourcemap::SourceMap`, which calls: + - `oxc::oxc_sourcemap::SourceMapBuilder` with `into_sourcemap(self) -> SourceMap` + +See more in [`oxc::oxc_codegen`](#oxc_codegen). + +📄 + ## oxc_span [`oxc::oxc_span::span::types`](https://github.com/oxc-project/oxc/blob/main/crates/oxc_span/src/span/types.rs) @@ -14,3 +41,5 @@ let text = "foo bar baz"; let span = Span::new(4, 7); assert_eq!(&text[span], "bar"); ``` + +📄 diff --git a/src/rolldown/explore-shared.md b/src/rolldown/explore-shared.md index 4425292..dea8e35 100644 --- a/src/rolldown/explore-shared.md +++ b/src/rolldown/explore-shared.md @@ -127,6 +127,10 @@ Exposes `rolldown_rstr::Rstr` which is a thin wrapper over [`oxc::span::CompactS ## rolldown_sourcemap -Exposes `collapse_sourcemaps(mut sourcemap_chain: Vec<&SourceMap>) -> SourceMap`. +Exposes [`collapse_sourcemaps(mut sourcemap_chain: Vec<&SourceMap>) -> SourceMap`](https://github.com/rolldown/rolldown/blob/main/crates/rolldown_sourcemap/src/lib.rs). + +It collapses multiple sourcemaps generated by calls to `oxc::oxc_codegen::CodeGen::new().enable_source_map(&filename, &source_text).build()` into one giant sourcemap. Relies on [`oxc::sourcemap::*`](https://github.com/oxc-project/oxc/tree/main/crates/oxc_sourcemap). + +📄