这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
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
6 changes: 5 additions & 1 deletion crates/turborepo-lib/src/boundaries/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use crate::{
/// All the places a dependency can be declared
#[derive(Clone, Copy)]
pub struct DependencyLocations<'a> {
// The containing package's name. We allow a package to import itself for testing purposes
pub(crate) package: &'a PackageName,
pub(crate) internal_dependencies: &'a HashSet<&'a PackageNode>,
pub(crate) package_json: &'a PackageJson,
pub(crate) unresolved_external_dependencies: Option<&'a BTreeMap<String, String>>,
Expand All @@ -36,7 +38,9 @@ impl<'a> DependencyLocations<'a> {
/// it's a valid import. We don't use `oxc_resolver` because there are some
/// cases where you can resolve a package that isn't declared properly.
fn is_dependency(&self, package_name: &PackageNode) -> bool {
self.internal_dependencies.contains(package_name)
// We allow a package to import itself for testing purposes
self.package == package_name.as_package_name()
|| self.internal_dependencies.contains(package_name)
|| self
.unresolved_external_dependencies
.is_some_and(|external_dependencies| {
Expand Down
1 change: 1 addition & 0 deletions crates/turborepo-lib/src/boundaries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ impl Run {
let mut finder = ImportFinder::default();
module.visit_with(&mut finder);
let dependency_locations = DependencyLocations {
package: package_name,
internal_dependencies: &internal_dependencies,
package_json: &package_info.package_json,
implicit_dependencies: &implicit_dependencies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ import { walkThePlank } from "module-package";
// @boundaries-ignore one more reason

import { walkThePlank } from "module-package";

// Allow importing own package
import { walkThePlank } from "my-app";
Loading