Skip to content

Commit

Permalink
Merge branch 'main' into feat/vitest-no-restricted-test-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda authored Aug 19, 2024
2 parents d81d259 + 247120f commit 58a12b4
Show file tree
Hide file tree
Showing 33 changed files with 2,617 additions and 519 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:
with:
restore-cache: false
if: steps.filter.outputs.src == 'true'
- uses: cargo-bins/cargo-binstall@v1.10.0
- uses: cargo-bins/cargo-binstall@v1.10.2
if: steps.filter.outputs.src == 'true'
- run: cargo binstall --no-confirm cargo-shear@1
if: steps.filter.outputs.src == 'true'
Expand Down
47 changes: 24 additions & 23 deletions Cargo.lock

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

21 changes: 15 additions & 6 deletions crates/oxc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ workspace = true
test = false
doctest = false

[[example]]
name = "compiler"
path = "examples/compiler.rs"
required-features = ["full"]

[dependencies]
oxc_allocator = { workspace = true }
oxc_ast = { workspace = true }
Expand All @@ -37,14 +42,18 @@ oxc_sourcemap = { workspace = true, optional = true }
oxc_isolated_declarations = { workspace = true, optional = true }

[features]
serialize = ["oxc_ast/serialize", "oxc_semantic?/serialize", "oxc_span/serialize", "oxc_syntax/serialize"]
semantic = ["oxc_semantic"]
transformer = ["oxc_transformer"]
minifier = ["oxc_mangler", "oxc_minifier"]
codegen = ["oxc_codegen"]
isolated_declarations = ["oxc_isolated_declarations"]
full = ["codegen", "minifier", "semantic", "transformer"]

semantic = ["oxc_semantic"]
transformer = ["oxc_transformer"]
minifier = ["oxc_mangler", "oxc_minifier"]
codegen = ["oxc_codegen"]

serialize = ["oxc_ast/serialize", "oxc_semantic?/serialize", "oxc_span/serialize", "oxc_syntax/serialize"]

sourcemap = ["oxc_sourcemap"]
sourcemap_concurrent = ["oxc_sourcemap/concurrent", "sourcemap"]

isolated_declarations = ["oxc_isolated_declarations"]

wasm = ["oxc_transformer/wasm"]
32 changes: 32 additions & 0 deletions crates/oxc/examples/compiler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![allow(clippy::print_stdout)]

use std::{env, io, path::Path};

use oxc::{span::SourceType, Compiler};

// Instruction:
// 1. create a `test.js`
// 2. run either
// * `cargo run -p oxc --example compiler --features="full"`
// * `just watch 'run -p oxc --example compiler --features="full"'`

fn main() -> io::Result<()> {
let name = env::args().nth(1).unwrap_or_else(|| "test.js".to_string());
let path = Path::new(&name);
let source_text = std::fs::read_to_string(path)?;
let source_type = SourceType::from_path(path).unwrap();

match Compiler::default().execute(&source_text, source_type, path) {
Ok(printed) => {
println!("{printed}");
}
Err(errors) => {
for error in errors {
let error = error.with_source_code(source_text.to_string());
println!("{error:?}");
}
}
}

Ok(())
}
Loading

0 comments on commit 58a12b4

Please sign in to comment.