Skip to content

Commit

Permalink
refactor(oxc_napi): remove source_map - moved to its crate (#7614)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 3, 2024
1 parent adee0d1 commit b4f3812
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 65 deletions.
7 changes: 5 additions & 2 deletions 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
Expand Up @@ -122,7 +122,7 @@ unicode-id-start = "1"
oxc-browserslist = "1.1.0"
oxc_index = "1.0.0"
oxc_resolver = "2.0.0"
oxc_sourcemap = "1"
oxc_sourcemap = "1.0.2"

aho-corasick = "1.1.3"
allocator-api2 = "0.2.18"
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_napi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ doctest = false

[dependencies]
oxc_isolated_declarations = { workspace = true }
oxc_sourcemap = { workspace = true }
oxc_sourcemap = { workspace = true, features = ["napi"] }
oxc_span = { workspace = true }
oxc_syntax = { workspace = true }
oxc_transformer = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_napi/src/isolated_declarations.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use napi_derive::napi;

use super::source_map::SourceMap;
use oxc_sourcemap::napi::SourceMap;

#[napi(object)]
pub struct IsolatedDeclarationsResult {
Expand Down
2 changes: 0 additions & 2 deletions crates/oxc_napi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pub mod parse;

pub mod source_map;

pub mod isolated_declarations;

pub mod transform;
48 changes: 0 additions & 48 deletions crates/oxc_napi/src/source_map.rs

This file was deleted.

3 changes: 2 additions & 1 deletion crates/oxc_napi/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use napi::Either;
use napi_derive::napi;
use rustc_hash::FxHashMap;

use oxc_sourcemap::napi::SourceMap;
use oxc_transformer::{EnvOptions, JsxRuntime, RewriteExtensionsMode};

use super::{isolated_declarations::IsolatedDeclarationsOptions, source_map::SourceMap};
use super::isolated_declarations::IsolatedDeclarationsOptions;

#[derive(Default)]
#[napi(object)]
Expand Down
1 change: 1 addition & 0 deletions napi/transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ doctest = false
[dependencies]
oxc = { workspace = true, features = ["full", "napi"] }
oxc_napi = { workspace = true }
oxc_sourcemap = { workspace = true, features = ["napi"] }

napi = { workspace = true }
napi-derive = { workspace = true }
Expand Down
6 changes: 2 additions & 4 deletions napi/transform/src/isolated_declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ use oxc::{
parser::Parser,
span::SourceType,
};
use oxc_napi::{
isolated_declarations::{IsolatedDeclarationsOptions, IsolatedDeclarationsResult},
source_map::SourceMap,
};
use oxc_napi::isolated_declarations::{IsolatedDeclarationsOptions, IsolatedDeclarationsResult};
use oxc_sourcemap::napi::SourceMap;

use crate::errors::wrap_diagnostics;

Expand Down
6 changes: 2 additions & 4 deletions napi/transform/src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ use oxc::{
transformer::{InjectGlobalVariablesConfig, InjectImport, ReplaceGlobalDefinesConfig},
CompilerInterface,
};
use oxc_napi::{
source_map::SourceMap,
transform::{TransformOptions, TransformResult},
};
use oxc_napi::transform::{TransformOptions, TransformResult};
use oxc_sourcemap::napi::SourceMap;

use crate::errors::wrap_diagnostics;

Expand Down
2 changes: 1 addition & 1 deletion npm/oxc-parser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import oxc from 'oxc-parser';

const sourceText = "let foo: Foo = 'foo';";
// Filename extension is used to determine which dialect to parse source as.
const filename = "test.tsx";
const filename = 'test.tsx';

test(oxc.parseSync(filename, sourceText, options));
test(await oxc.parseAsync(filename, sourceText, options));
Expand Down

0 comments on commit b4f3812

Please sign in to comment.