Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include statically analyzable dynamic imports in the eszip #115

Merged
merged 2 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/eszip_wasm.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
}
function __wbg_adapter_40(arg0, arg1, arg2) {
wasm
._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h727a9742b57a49c2(
._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdb89611f6af59487(
arg0,
arg1,
addHeapObject(arg2),
Expand Down Expand Up @@ -263,7 +263,7 @@ function handleError(f, args) {
}
}
function __wbg_adapter_98(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__h42ffd00376d3baaa(
wasm.wasm_bindgen__convert__closures__invoke2_mut__h73ff6ec860ceda5d(
arg0,
arg1,
addHeapObject(arg2),
Expand Down Expand Up @@ -434,9 +434,6 @@ const imports = {
const ret = getObject(arg0) === getObject(arg1);
return ret;
},
__wbindgen_object_drop_ref: function (arg0) {
takeObject(arg0);
},
__wbindgen_error_new: function (arg0, arg1) {
const ret = new Error(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand Down Expand Up @@ -555,6 +552,9 @@ const imports = {
wasm.__wbindgen_free(arg0, arg1);
}
},
__wbindgen_object_drop_ref: function (arg0) {
takeObject(arg0);
},
__wbindgen_is_function: function (arg0) {
const ret = typeof (getObject(arg0)) === "function";
return ret;
Expand Down Expand Up @@ -675,7 +675,7 @@ const imports = {
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
return addHeapObject(ret);
},
__wbindgen_closure_wrapper7226: function (arg0, arg1, arg2) {
__wbindgen_closure_wrapper7237: function (arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 256, __wbg_adapter_40);
return addHeapObject(ret);
},
Expand Down
Binary file modified lib/eszip_wasm_bg.wasm
Binary file not shown.
10 changes: 2 additions & 8 deletions src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,6 @@ impl EszipV2 {

ordered_modules.push(specifier.to_string());
for dep in module.dependencies.values() {
if dep.is_dynamic {
continue;
}
if let Some(specifier) = dep.get_code() {
visit_module(
graph,
Expand Down Expand Up @@ -735,11 +732,8 @@ mod tests {
fn load(
&mut self,
specifier: &ModuleSpecifier,
is_dynamic: bool,
_is_dynamic: bool,
) -> deno_graph::source::LoadFuture {
if is_dynamic {
return Box::pin(async { Ok(None) });
}
assert_eq!(specifier.scheme(), "file");
let path = format!("./src/testdata/source{}", specifier.path());
Box::pin(async move {
Expand Down Expand Up @@ -939,7 +933,7 @@ mod tests {
let _source_map = module.source_map().await.unwrap();
assert_eq!(module.kind, ModuleKind::JavaScript);
let module = eszip.get_module("file:///data.json");
assert!(module.is_none());
assert!(module.is_some()); // we include statically analyzable dynamic imports
}

#[tokio::test]
Expand Down