Skip to content

Commit a08f2dd

Browse files
committed
Revert build changes
1 parent ff43deb commit a08f2dd

File tree

2 files changed

+10
-46
lines changed

2 files changed

+10
-46
lines changed

rewatch/src/build/compile.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,7 @@ fn get_dependency_paths(
535535
.as_ref()
536536
.map(|package| package.path.clone())
537537
} else {
538-
packages::read_dependency(package_name, project_root, project_root, workspace_root)
539-
.map(|(p, _)| p)
540-
.ok()
538+
packages::read_dependency(package_name, project_root, project_root, workspace_root).ok()
541539
}
542540
.map(|canonicalized_path| {
543541
vec![

rewatch/src/build/packages.rs

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::build_types::*;
22
use super::namespaces;
33
use super::packages;
4-
use crate::build::packages::DependencySymLink::{NoSymlink, Symlink};
54
use crate::config;
65
use crate::helpers;
76
use crate::helpers::StrippedVerbatimPath;
@@ -40,22 +39,13 @@ impl Namespace {
4039
}
4140
}
4241

43-
#[derive(Debug, Clone)]
44-
pub enum DependencySymLink {
45-
NoSymlink,
46-
Symlink(PathBuf),
47-
}
48-
4942
#[derive(Debug, Clone)]
5043
struct Dependency {
5144
name: String,
5245
config: config::Config,
5346
path: PathBuf,
5447
is_pinned: bool,
5548
dependencies: Vec<Dependency>,
56-
// Track if the original dependency path actually a symbolic link.
57-
// We need to know this to later assert if a package is local or not.
58-
sym_link: DependencySymLink,
5949
}
6050

6151
#[derive(Debug, Clone)]
@@ -264,7 +254,7 @@ pub fn read_dependency(
264254
parent_path: &Path,
265255
project_root: &Path,
266256
workspace_root: &Option<PathBuf>,
267-
) -> Result<(PathBuf, DependencySymLink), String> {
257+
) -> Result<PathBuf, String> {
268258
let path_from_parent = PathBuf::from(helpers::package_path(parent_path, package_name));
269259
let path_from_project_root = PathBuf::from(helpers::package_path(project_root, package_name));
270260
let maybe_path_from_workspace_root = workspace_root
@@ -287,17 +277,6 @@ pub fn read_dependency(
287277
)),
288278
}?;
289279

290-
// There could be a symbolic link because the package.json has:
291-
// "dependencies": {
292-
// "my-package": "link:my-package",
293-
// }
294-
// In this case, there will be a link from node_modules/my-package to a local path.
295-
let symlink = match fs::symlink_metadata(&path).map(|m| m.file_type().is_symlink()) {
296-
Err(_) => NoSymlink,
297-
Ok(false) => NoSymlink,
298-
Ok(true) => Symlink(path.clone()),
299-
};
300-
301280
let canonical_path = match path
302281
.canonicalize()
303282
.map(StrippedVerbatimPath::to_stripped_verbatim_path)
@@ -311,7 +290,7 @@ pub fn read_dependency(
311290
)),
312291
}?;
313292

314-
Ok((canonical_path, symlink))
293+
Ok(canonical_path)
315294
}
316295

317296
/// # Make Package
@@ -352,7 +331,7 @@ fn read_dependencies(
352331
// Read all config files in parallel instead of blocking
353332
.par_iter()
354333
.map(|package_name| {
355-
let (config, canonical_path, sym_link) =
334+
let (config, canonical_path) =
356335
match read_dependency(package_name, parent_path, project_root, &workspace_root) {
357336
Err(error) => {
358337
if show_progress {
@@ -371,9 +350,9 @@ fn read_dependencies(
371350

372351
std::process::exit(2)
373352
}
374-
Ok((canonical_path, sym_link)) => {
353+
Ok(canonical_path) => {
375354
match read_config(&canonical_path) {
376-
Ok(config) => (config, canonical_path, sym_link),
355+
Ok(config) => (config, canonical_path),
377356
Err(error) => {
378357
let parent_path_str = parent_path.to_string_lossy();
379358
log::error!(
@@ -407,7 +386,6 @@ fn read_dependencies(
407386
path: canonical_path,
408387
is_pinned,
409388
dependencies,
410-
sym_link
411389
}
412390
})
413391
.collect()
@@ -438,13 +416,7 @@ pub fn read_package_name(package_dir: &Path) -> Result<String> {
438416
.ok_or_else(|| anyhow!("No name field found in package.json"))
439417
}
440418

441-
fn make_package(
442-
config: config::Config,
443-
package_path: &Path,
444-
is_pinned_dep: bool,
445-
is_root: bool,
446-
is_local_dep: bool,
447-
) -> Package {
419+
fn make_package(config: config::Config, package_path: &Path, is_pinned_dep: bool, is_root: bool) -> Package {
448420
let source_folders = match config.sources.to_owned() {
449421
Some(config::OneOrMore::Single(source)) => get_source_dirs(source, None),
450422
Some(config::OneOrMore::Multiple(sources)) => {
@@ -497,7 +469,7 @@ This inconsistency will cause issues with package resolution.\n",
497469
.expect("Could not canonicalize"),
498470
dirs: None,
499471
is_pinned_dep,
500-
is_local_dep,
472+
is_local_dep: !package_path.components().any(|c| c.as_os_str() == "node_modules"),
501473
is_root,
502474
}
503475
}
@@ -512,7 +484,7 @@ fn read_packages(
512484

513485
// Store all packages and completely deduplicate them
514486
let mut map: AHashMap<String, Package> = AHashMap::new();
515-
let root_package = make_package(root_config.to_owned(), project_root, false, true, true);
487+
let root_package = make_package(root_config.to_owned(), project_root, false, true);
516488
map.insert(root_package.name.to_string(), root_package);
517489

518490
let mut registered_dependencies_set: AHashSet<String> = AHashSet::new();
@@ -527,13 +499,7 @@ fn read_packages(
527499
));
528500
dependencies.iter().for_each(|d| {
529501
if !map.contains_key(&d.name) {
530-
let is_local_dep = match &d.sym_link {
531-
NoSymlink => !d.path.components().any(|c| c.as_os_str() == "node_modules"),
532-
Symlink(original_path) => !original_path
533-
.components()
534-
.any(|c| c.as_os_str() == "node_modules"),
535-
};
536-
let package = make_package(d.config.to_owned(), &d.path, d.is_pinned, false, is_local_dep);
502+
let package = make_package(d.config.to_owned(), &d.path, d.is_pinned, false);
537503
map.insert(d.name.to_string(), package);
538504
}
539505
});

0 commit comments

Comments
 (0)