Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.2.1](https://github.com/oxc-project/oxc-sourcemap/compare/v4.2.0...v4.2.1) - 2025-09-27

### Other

- reduce memory usage by replacing Vec<Token> with Box<[Token]>
- replace !0 with INVALID_ID constant for better readability ([#175](https://github.com/oxc-project/oxc-sourcemap/pull/175))
- remove outdated comment for `TokenChunk`

## [4.2.0](https://github.com/oxc-project/oxc-sourcemap/compare/v4.1.6...v4.2.0) - 2025-09-26

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oxc_sourcemap"
version = "4.2.0"
version = "4.2.1"
authors = ["Boshen <[email protected]>"]
categories = []
edition = "2024"
Expand Down
11 changes: 6 additions & 5 deletions src/concat_sourcemap_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl ConcatSourceMapBuilder {
None,
self.sources,
self.source_contents,
self.tokens,
self.tokens.into_boxed_slice(),
Some(self.token_chunks),
)
}
Expand Down Expand Up @@ -179,7 +179,7 @@ where
None,
vec!["foo.js".into()],
vec![],
vec![Token::new(1, 1, 1, 1, Some(0), Some(0))],
vec![Token::new(1, 1, 1, 1, Some(0), Some(0))].into_boxed_slice(),
None,
);
let sm2 = SourceMap::new(
Expand All @@ -188,7 +188,7 @@ where
None,
vec!["bar.js".into()],
vec![],
vec![Token::new(1, 1, 1, 1, Some(0), Some(0))],
vec![Token::new(1, 1, 1, 1, Some(0), Some(0))].into_boxed_slice(),
None,
);
let sm3 = SourceMap::new(
Expand All @@ -197,7 +197,7 @@ where
None,
vec!["abc.js".into()],
vec![],
vec![Token::new(1, 2, 2, 2, Some(0), Some(0))],
vec![Token::new(1, 2, 2, 2, Some(0), Some(0))].into_boxed_slice(),
None,
);

Expand All @@ -213,7 +213,8 @@ where
Token::new(1, 1, 1, 1, Some(0), Some(0)),
Token::new(3, 1, 1, 1, Some(1), Some(2)),
Token::new(3, 2, 2, 2, Some(2), Some(3)),
],
]
.into_boxed_slice(),
None,
);
let concat_sm = builder.into_sourcemap();
Expand Down
2 changes: 1 addition & 1 deletion src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn decode(json: JSONSourceMap) -> Result<SourceMap> {
.sources_content
.map(|content| content.into_iter().map(|c| c.map(Arc::from)).collect())
.unwrap_or_default(),
tokens,
tokens: tokens.into_boxed_slice(),
token_chunks: None,
x_google_ignore_list: json.x_google_ignore_list,
debug_id: json.debug_id,
Expand Down
2 changes: 1 addition & 1 deletion src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ fn test_encode_escape_string() {
None,
vec!["\0".into()],
vec![Some("emoji-👀-\0".into())],
vec![],
vec![].into_boxed_slice(),
None,
);
sm.set_x_google_ignore_list(vec![0]);
Expand Down
6 changes: 3 additions & 3 deletions src/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct SourceMap {
pub(crate) source_root: Option<String>,
pub(crate) sources: Vec<Arc<str>>,
pub(crate) source_contents: Vec<Option<Arc<str>>>,
pub(crate) tokens: Vec<Token>,
pub(crate) tokens: Box<[Token]>,
pub(crate) token_chunks: Option<Vec<TokenChunk>>,
/// Identifies third-party sources (such as framework code or bundler-generated code), allowing developers to avoid code that they don't want to see or step through, without having to configure this beforehand.
/// The `x_google_ignoreList` field refers to the `sources` array, and lists the indices of all the known third-party sources in that source map.
Expand All @@ -31,7 +31,7 @@ impl SourceMap {
source_root: Option<String>,
sources: Vec<Arc<str>>,
source_contents: Vec<Option<Arc<str>>>,
tokens: Vec<Token>,
tokens: Box<[Token]>,
token_chunks: Option<Vec<TokenChunk>>,
) -> Self {
Self {
Expand Down Expand Up @@ -286,7 +286,7 @@ fn test_sourcemap_source_view_token() {
None,
vec!["foo.js".into()],
vec![],
vec![Token::new(1, 1, 1, 1, Some(0), Some(0))],
vec![Token::new(1, 1, 1, 1, Some(0), Some(0))].into_boxed_slice(),
None,
);
let mut source_view_tokens = sm.get_source_view_tokens();
Expand Down
2 changes: 1 addition & 1 deletion src/sourcemap_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl SourceMapBuilder {
None,
self.sources,
self.source_contents,
self.tokens,
self.tokens.into_boxed_slice(),
self.token_chunks,
)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ fn invalid_token_position() {
Token::new(0, 0, 0, 0, Some(0), None),
Token::new(0, 10, 0, 0, Some(0), None),
Token::new(0, 0, 0, 10, Some(0), None),
],
]
.into_boxed_slice(),
None,
);
let js = "abc\ndef\n";
Expand Down
Loading