-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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: deno vendor #13670
feat: deno vendor #13670
Conversation
- Remove windows 260 limit code because it was terrible and I thought of a better solution that can come after the initial implementation. - Remove other code that's no longer used
- fix directory paths in import map (bug in url crate) - starting to add integration tests
I agree not that important for a first pass, but I don't agree it's super rare. Often you see in deps.ts files when people re-export both types and symbols: export { foo } from "https://example.com/";
export type { foo } from "https://example.com/"; |
@@ -2497,8 +2574,8 @@ mod tests { | |||
|
|||
/// Creates vector of strings, Vec<String> | |||
macro_rules! svec { | |||
($($x:expr),*) => (vec![$($x.to_string()),*]); | |||
} | |||
($($x:expr),* $(,)?) => (vec![$($x.to_string()),*]); |
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.
Trailing comma support.
@@ -362,6 +362,32 @@ pub fn path_has_trailing_slash(path: &Path) -> bool { | |||
} | |||
} | |||
|
|||
/// Gets a path with the specified file stem suffix. | |||
pub fn path_with_stem_suffix(path: &Path, suffix: &str) -> PathBuf { | |||
if let Some(file_name) = path.file_name().map(|f| f.to_string_lossy()) { |
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.
to_string_lossy
🤷♂️
@@ -0,0 +1,331 @@ | |||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. |
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.
Most of the tests aren't in this file. They'll be in cli/tools/vendor/build.rs
. This is just the final integration tests.
.unwrap(); | ||
let output = deno.wait_with_output().unwrap(); | ||
assert_eq!( | ||
String::from_utf8_lossy(&output.stderr).trim(), |
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.
Would be neat if we had a less verbose way of running the deno process and getting the output in the tests.
@lucacasonato it will just be an issue where the module specifiers differ and don't match the file name like: export { foo } from "https://example.com/mod";
export type { foo } from "https://example.com/redirect_to_mod"; |
26ecbea
to
3d097a5
Compare
Removes displaying the output directory in the message because it's a pain to test obviously.
It'd be nice to add a little message after
|
let mut text = from.make_relative(&to).unwrap(); | ||
if is_dir && !text.ends_with('/') && to.query().is_none() { | ||
text.push('/'); | ||
} |
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.
Because of some of this nitty gritty heuristics, it would be good to have a little unit test for relative_path()
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.
It's a bit of a pain to test this struct because it involves creating a module graph. I thought about extracting some of the functionality in here out, but it adds a bit of indirection. The logic is temporary workarounds and the code in here is tested transitively—if I delete either of the if statements or start flipping conditions then the vendor tests will fail.
&self, | ||
from: &ModuleSpecifier, | ||
to: &ModuleSpecifier, | ||
) -> String { |
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.
Might as well have a unit test for relative_specifier_text()
too...
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 great. After fixing the issue that Luca discovered in the dotcom repo, I think this would be ready to land.
@lucacasonato I added the message and fixed the issue seen on the dotcom repo. |
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! All the code i tested now works as expected. 🎉
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, I have a few nitpicks, but they can be addressed after this PR lands
cli/tools/vendor/mappings.rs
Outdated
}, | ||
)) = &module.maybe_types_dependency | ||
{ | ||
// hack to tell if it's a x-typescript-types header |
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.
I don't get what this hack does :(
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.
The hack is to check if the range start and end in the file is zero.
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! Tested it on a bunch of projects, its perfect!
Not part of this first pass:
Differences with proposal:
vendor
folder instead of_vendor
by default (seemed like in the meeting people wantedvendor
instead?).--force
flag to potentially overwrite the contents.--info
flag--import-map ...
located within the output directory will error.Closes #13346