Skip to content

Commit

Permalink
fix: upgrade to deno_graph 0.43 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Feb 9, 2023
1 parent 1080a04 commit b22bf34
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 328 deletions.
501 changes: 230 additions & 271 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions lib/emit.generated.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @generated file from wasmbuild -- do not edit
// deno-lint-ignore-file
// deno-fmt-ignore-file
// source-hash: eaca51c4e0d425f2396de7263cfdb69efdee3351
// source-hash: 7b53d367d0f19d6e4ca1b10b9d8c553710734522
let wasm;

const heap = new Array(32).fill(undefined);
Expand Down Expand Up @@ -202,7 +202,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
}
function __wbg_adapter_16(arg0, arg1, arg2) {
wasm
._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb50d428606e91cff(
._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h7b708b590b69aa19(
arg0,
arg1,
addHeapObject(arg2),
Expand Down Expand Up @@ -283,7 +283,7 @@ function handleError(f, args) {
}
}
function __wbg_adapter_25(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h05af4b22b5ef3ea9(
wasm.wasm_bindgen__convert__closures__invoke2_mut__h2d18662a1ccf8bda(
arg0,
arg1,
addHeapObject(arg2),
Expand All @@ -296,23 +296,10 @@ const imports = {
__wbindgen_object_drop_ref: function (arg0) {
takeObject(arg0);
},
__wbindgen_cb_drop: function (arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
const ret = false;
return ret;
},
__wbindgen_string_new: function (arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
},
__wbindgen_json_parse: function (arg0, arg1) {
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
},
__wbindgen_json_serialize: function (arg0, arg1) {
const obj = getObject(arg1);
const ret = JSON.stringify(obj === undefined ? null : obj);
Expand All @@ -325,6 +312,19 @@ const imports = {
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
},
__wbindgen_json_parse: function (arg0, arg1) {
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
},
__wbindgen_cb_drop: function (arg0) {
const obj = takeObject(arg0).original;
if (obj.cnt-- == 1) {
obj.a = 0;
return true;
}
const ret = false;
return ret;
},
__wbg_new_651776e932b7e9c7: function (arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand Down Expand Up @@ -389,8 +389,8 @@ const imports = {
__wbindgen_throw: function (arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
},
__wbindgen_closure_wrapper367: function (arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 129, __wbg_adapter_16);
__wbindgen_closure_wrapper364: function (arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 123, __wbg_adapter_16);
return addHeapObject(ret);
},
},
Expand Down
Binary file modified lib/emit_bg.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions rs-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ license = "MIT"
[dependencies]
anyhow = "1.0.44"
base64 = "0.13.0"
deno_ast = { version = "0.23.2", features = ["bundler", "codegen", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "visit", "transpiling"] }
deno_graph = "0.42.0"
deno_ast = { version = "0.24.0", features = ["bundler", "codegen", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "visit", "transpiling"] }
deno_graph = "0.43.0"
escape8259 = "0.5.2"
futures = "0.3.17"
parking_lot = { version = "0.11.2" }
Expand Down
25 changes: 13 additions & 12 deletions rs-lib/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub fn bundle_graph(
.context("Unable to emit during bundling.")?;
}
let mut code = shebang_file(graph)
.map(|shebang| format!("{}\n", shebang))
.map(|shebang| format!("{shebang}\n"))
.unwrap_or_default();
code.push_str(
&String::from_utf8(buf).context("Emitted code is an invalid string.")?,
Expand Down Expand Up @@ -310,11 +310,10 @@ fn transpile_module(
#[cfg(test)]
mod test {
use deno_ast::ModuleSpecifier;
use deno_graph::create_graph;
use deno_graph::source::MemoryLoader;
use deno_graph::source::Source;
use deno_graph::BuildOptions;
use deno_graph::CapturingModuleAnalyzer;
use deno_graph::GraphOptions;
use deno_graph::ModuleGraph;
use pretty_assertions::assert_eq;

Expand All @@ -341,15 +340,17 @@ mod test {
let mut memory_loader = MemoryLoader::new(sources, vec![]);
let root = ModuleSpecifier::parse(root.as_ref()).unwrap();
let analyzer = CapturingModuleAnalyzer::default();
let graph = create_graph(
vec![root.clone()],
&mut memory_loader,
GraphOptions {
module_analyzer: Some(&analyzer),
..Default::default()
},
)
.await;
let mut graph = ModuleGraph::default();
graph
.build(
vec![root.clone()],
&mut memory_loader,
BuildOptions {
module_analyzer: Some(&analyzer),
..Default::default()
},
)
.await;
(graph, analyzer, root)
}

Expand Down
48 changes: 29 additions & 19 deletions rs-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ mod emit;
mod text;

use anyhow::Result;
use deno_graph::BuildOptions;
use deno_graph::CapturingModuleAnalyzer;
use deno_graph::GraphOptions;
use deno_graph::ModuleGraph;
use deno_graph::ParsedSourceStore;
use deno_graph::ReferrerImports;
use std::collections::HashMap;

pub use emit::bundle_graph;
Expand All @@ -27,15 +29,21 @@ pub async fn bundle(
maybe_imports_map: Option<Vec<(ModuleSpecifier, Vec<String>)>>,
bundle_options: BundleOptions,
) -> Result<BundleEmit> {
let graph = deno_graph::create_graph(
vec![root],
loader,
GraphOptions {
imports: maybe_imports_map,
..Default::default()
},
)
.await;
let mut graph = ModuleGraph::default();
graph
.build(
vec![root],
loader,
BuildOptions {
imports: maybe_imports_map
.unwrap_or_default()
.into_iter()
.map(|(referrer, imports)| (ReferrerImports { referrer, imports }))
.collect(),
..Default::default()
},
)
.await;

bundle_graph(&graph, bundle_options)
}
Expand All @@ -45,15 +53,17 @@ pub async fn transpile(
loader: &mut dyn Loader,
) -> Result<HashMap<String, String>> {
let analyzer = CapturingModuleAnalyzer::default();
let graph = deno_graph::create_graph(
vec![root],
loader,
GraphOptions {
module_analyzer: Some(&analyzer),
..Default::default()
},
)
.await;
let mut graph = ModuleGraph::default();
graph
.build(
vec![root],
loader,
BuildOptions {
module_analyzer: Some(&analyzer),
..Default::default()
},
)
.await;

graph.valid()?;

Expand Down
2 changes: 1 addition & 1 deletion rs-lib/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod test {

#[test]
fn strip_bom_with_bom() {
let text = format!("{}text", BOM_CHAR);
let text = format!("{BOM_CHAR}text");
assert_eq!(strip_bom(&text), "text");
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.65.0"
channel = "1.67.0"
components = [ "clippy", "rustfmt" ]
4 changes: 2 additions & 2 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ base64 = "0.13.0"
deno_emit = { path = "../rs-lib" }
js-sys = { version = "0.3.58" }
serde = { version = "1.0.130", features = ["derive", "rc"] }
wasm-bindgen = { version = "0.2.81", features = ["serde-serialize"] }
wasm-bindgen-futures = { version = "0.4.31" }
wasm-bindgen = { version = "=0.2.81", features = ["serde-serialize"] }
wasm-bindgen-futures = { version = "=0.4.31" }

[profile.release]
codegen-units = 1
Expand Down
3 changes: 1 addition & 2 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ pub async fn bundle(
Some("classic") => BundleType::Classic,
Some(value) => {
return Err(JsValue::from(js_sys::Error::new(&format!(
"Unsupported bundle type \"{}\"",
value
"Unsupported bundle type \"{value}\"",
))))
}
};
Expand Down

0 comments on commit b22bf34

Please sign in to comment.