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

refactor: integrate deno_graph 0.20.0 #13495

Merged
merged 13 commits into from
Jan 31, 2022
Merged

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Jan 26, 2022

Down to 53 errors... just a chore to get the rest of them...

cli/Cargo.toml Outdated Show resolved Hide resolved
@kitsonk
Copy link
Contributor Author

kitsonk commented Jan 29, 2022

Everything updates and compiles, but there are some regressions in the test cases that I need to dig into.

@bartlomieju
Copy link
Member

I'm getting a lot of:

Don't know how to create cache name for scheme: flags
Don't know how to create cache name for scheme: flags

in tests. These originate in:

error!("Don't know how to create cache name for scheme: {}", scheme);

I feel like this should be an error rather than error log. If it happens it most likely means that we screwed up something in Deno internals.

This flags actually originates from here:

deno/cli/compat/mod.rs

Lines 85 to 86 in a2e4fa4

static COMPAT_IMPORT_URL: Lazy<Url> =
Lazy::new(|| Url::parse("flags:compat").unwrap());

@kitsonk
Copy link
Contributor Author

kitsonk commented Jan 30, 2022

I'm getting a lot of:

Don't know how to create cache name for scheme: flags
Don't know how to create cache name for scheme: flags

Ok, yeah, I know the problem... Because we got rid of the seperate "Synthetic" modules, CLI is trying to cache all modules in the graph, including the synthetic ones. Need to filter those out.

@kitsonk
Copy link
Contributor Author

kitsonk commented Jan 31, 2022

@bartlomieju ok, I've got a few more challenges to fix, but there is one that I see what the problem is, but I am not totally sure why it is occurring now and the best way to fix it. If you run test native_modules_as_global_vars you will get a panic that the file being passed is not local. If you look at the stack trace, when the graph is being built, the node resolver is getting a request to resolve a remote URL and then is "blowing up". I believe the remote URL is being injected to the graph as part of the injected modules, but I am not totally sure why when building the graph, these injected dependencies weren't resolved before and why this isn't working now, nor why the compat code doesn't handle resolution of these "gracefully".

@kitsonk kitsonk marked this pull request as draft January 31, 2022 03:01
@kitsonk
Copy link
Contributor Author

kitsonk commented Jan 31, 2022

@bartlomieju it does look just like the compat failures with trying to find the package.json for the shim is the only outstanding issue.

@bartlomieju
Copy link
Member

@bartlomieju ok, I've got a few more challenges to fix, but there is one that I see what the problem is, but I am not totally sure why it is occurring now and the best way to fix it. If you run test native_modules_as_global_vars you will get a panic that the file being passed is not local. If you look at the stack trace, when the graph is being built, the node resolver is getting a request to resolve a remote URL and then is "blowing up". I believe the remote URL is being injected to the graph as part of the injected modules, but I am not totally sure why when building the graph, these injected dependencies weren't resolved before and why this isn't working now, nor why the compat code doesn't handle resolution of these "gracefully".

@kitsonk there is a single path that injects resolved specifier for built-in Node modules (pointing to https://deno.land/std/node). Unfortunately I made a mistake when mapping these specifiers to ResolveResult. I now fixed it and the tests should pass. I think I will need to reorganize this code further when working on the CJS/ESM integration, because it is indeed unfortunate that there a single "special" code path that needs to handle http/https imports inside that resolution algorithm. Most likely it would be removed in the future if we decided to move std/node into an extension crate.

@kitsonk kitsonk changed the title [WIP] refactor: integrate deno_graph 0.20.0 refactor: integrate deno_graph 0.20.0 Jan 31, 2022
@kitsonk kitsonk requested a review from dsherret January 31, 2022 21:23
@kitsonk kitsonk marked this pull request as ready for review January 31, 2022 21:23
@kitsonk
Copy link
Contributor Author

kitsonk commented Jan 31, 2022

@bartlomieju obviously a topic for another day, but it would be really sad if we can't integrate Deno code and Node.js code in the same workload.

I fixed what I hope are the last fixture issues so the CI can go green.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one small fix needed though.

@@ -121,9 +129,23 @@ fn node_resolve(
let conditions = DEFAULT_CONDITIONS;
let url = module_resolve(specifier, &parent_url, conditions)?;

let resolve_response = if url.as_str().starts_with("http") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: check url.scheme() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartlomieju do you want to address or should I?

@@ -121,9 +129,23 @@ fn node_resolve(
let conditions = DEFAULT_CONDITIONS;
let url = module_resolve(specifier, &parent_url, conditions)?;

let resolve_response = if url.as_str().starts_with("http") {
ResolveResponse::Esm(url)
} else if url.as_str().ends_with(".js") {
Copy link
Member

@dsherret dsherret Jan 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be doing case insensitive comparisons. It seems like we often forget about this so maybe we should create a helper function somewhere that does it efficiently and just in case, also checks url.path() instead of the full url?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartlomieju same again

} else {
ResolveResponse::CommonJs(url)
}
} else if url.as_str().ends_with(".cjs") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too (case insensitive, path comparison)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bartlomieju same again

@bartlomieju
Copy link
Member

@bartlomieju obviously a topic for another day, but it would be really sad if we can't integrate Deno code and Node.js code in the same workload.

I fixed what I hope are the last fixture issues so the CI can go green.

I don't think there's any problem with that - you can mix and match http/https imports with bare specifiers. I was mentioning situation with remapping of Node.js built in modules to std URLs.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too. I'll apply David's suggestions in a follow up PR tomorrow morning. Let's land this!

@kitsonk kitsonk merged commit 7d35625 into denoland:main Jan 31, 2022
@kitsonk kitsonk deleted the reaf_graph_0.20.0 branch January 31, 2022 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants