-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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(unstable): optional deno_modules
directory
#19977
Conversation
@marvinhagemeister I suspect that maybe something under the hood is spawning a new Deno process, which then uses the one defined globally. Maybe try replacing your global deno version?
I updated these to have a file extension on them now. |
We need to handle URLs which normalize to the same path. DemoRun this server: // deno run -A server.ts
Deno.serve((r) => {
const path = new URL(r.url).pathname;
console.log(path);
if (path == "/hello.ts") {
return new Response(
'console.log("Hello!");\n',
{ headers: { "Content-Type": "application/typescript" } },
);
} else if (path == "//hello.ts") {
return new Response(
'console.log("Hello with an extra leading slash!");\n',
{ headers: { "Content-Type": "application/typescript" } },
);
}
return new Response(null, { status: 404 });
}); And then this main module with // cargo run -- run main.ts
import "http:https://localhost:8000/hello.ts";
import "http:https://localhost:8000//hello.ts";
// Expected output:
// Hello!
// Hello with an extra leading slash! Currently the first run will look as expected, though the content of Rather than trying to come up with a readable but 1-to-1 path mapping, we could potentially put the manifest to use and just add But what happens if the first So something like: fn url_to_local_sub_path(url: Url, manifest: Manifest): PathBuf {
if let Some(path) = manifest.get_path(&url) {
return path;
}
let default_path = base_mapping_function(&url);
let mut path = default_path.clone();
let mut id = 1;
while manifest.has_path(&path) {
path.set_file_name(format!("{}_{}", default_path.file_stem().unwrap(), id));
if let Some(extension) = default_path.extension() {
path.set_extension(extension);
}
id = id + 1;
}
return path;
} |
@nayeemrmn thanks! I fixed that. |
Oh cool, that was the only example I tried so I didn't realise there was already a mechanism |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good to me! I have a few questions, but overall super cleanly implemented - the bulk of the PR is boilerplate and changing expected types, which is a great indication that your factory approach to various parts of the CLI is working well 👍
remote_modules
directory (without lsp support)deno_modules
directory
deno_modules
directorydeno_modules
directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great work. I literally have one question left
Overview: #15633 (comment)
This doesn't yet implement the LSP mapping the remote files to the local ones when doing stuff like "go to definition".
Closes #15633