Skip to content

Commit

Permalink
WIP add example
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Apr 16, 2024
1 parent 7931cc1 commit 2927c5b
Show file tree
Hide file tree
Showing 5 changed files with 3,290 additions and 35 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions crates/test/Cargo.toml
@@ -0,0 +1,9 @@
[package]
authors = ["Devon Govett <devongovett@gmail.com>"]
name = "parcel-test"
version = "0.1.0"
edition = "2021"

[dependencies]
parcel-js-swc-core = { path = "../../packages/transformers/js/core" }
rayon = "1.7.0"
47 changes: 47 additions & 0 deletions crates/test/src/main.rs
@@ -0,0 +1,47 @@
use std::collections::HashMap;

fn main() {
let foo = std::fs::read_to_string("isbl.js").unwrap();

let config = parcel_js_swc_core::Config {
filename: "file.js".to_string(),
code: foo.into_bytes(),
module_id: "xyz".to_string(),
project_root: "/app/".to_string(),
replace_env: true,
env: HashMap::new(),
inline_fs: false,
insert_node_globals: false,
node_replacer: false,
is_browser: false,
is_worker: false,
is_type_script: false,
is_jsx: false,
jsx_pragma: None,
jsx_pragma_frag: None,
automatic_jsx_runtime: false,
jsx_import_source: None,
decorators: false,
use_define_for_class_fields: false,
is_development: false,
react_refresh: false,
targets: None,
source_maps: false,
scope_hoist: false,
source_type: parcel_js_swc_core::SourceType::Module,
supports_module_workers: false,
is_library: false,
is_esm_output: false,
trace_bailouts: false,
is_swc_helpers: false,
standalone: false,
inline_constants: false,
};

rayon::scope(|scope| {
scope.spawn(move |_| {
let result = parcel_js_swc_core::transform(config, None).unwrap();
println!("{:?}", String::from_utf8(result.code).unwrap());
})
});
}

0 comments on commit 2927c5b

Please sign in to comment.