-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(napi/transform): align output
SourceMap
with Rollup's `Existin…
- Loading branch information
Showing
4 changed files
with
74 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use napi_derive::napi; | ||
|
||
// Aligned with Rollup's sourcemap input. | ||
// | ||
// <https://github.com/rollup/rollup/blob/766dbf90d69268971feaafa1f53f88a0755e8023/src/rollup/types.d.ts#L80-L89> | ||
// | ||
// ``` | ||
// export interface ExistingRawSourceMap { | ||
// file?: string; | ||
// mappings: string; | ||
// names: string[]; | ||
// sourceRoot?: string; | ||
// sources: string[]; | ||
// sourcesContent?: string[]; | ||
// version: number; | ||
// x_google_ignoreList?: number[]; | ||
// } | ||
// ``` | ||
#[napi(object)] | ||
pub struct SourceMap { | ||
pub file: Option<String>, | ||
pub mappings: Option<String>, | ||
pub names: Option<Vec<String>>, | ||
pub source_root: Option<String>, | ||
pub sources: Option<Vec<Option<String>>>, | ||
pub sources_content: Option<Vec<Option<String>>>, | ||
pub version: u8, | ||
#[napi(js_name = "x_google_ignoreList")] | ||
pub x_google_ignorelist: Option<Vec<u32>>, | ||
} | ||
|
||
impl From<oxc_sourcemap::SourceMap> for SourceMap { | ||
fn from(source_map: oxc_sourcemap::SourceMap) -> Self { | ||
let json = source_map.to_json(); | ||
Self { | ||
file: json.file, | ||
mappings: json.mappings, | ||
names: json.names, | ||
source_root: json.source_root, | ||
sources: json.sources, | ||
sources_content: json.sources_content, | ||
version: 3, | ||
x_google_ignorelist: None, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters