Skip to content

[Tracking]: Improve dependency structure specification #7422

@shulaoda

Description

@shulaoda

What problem does this feature solve?

Among many dependencies, they mark the scope of the dependency as span, range, or start&end. This behavior is very chaotic in Dependency.

pub struct HarmonyExportHeaderDependency {
id: DependencyId,
loc: ErrorLocation,
range: Option<ErrorSpan>,
range_stmt: ErrorSpan,
}

pub struct HarmonyImportSideEffectDependency {
pub request: Atom,
pub source_order: i32,
pub id: DependencyId,
pub loc: ErrorLocation,
pub span: ErrorSpan,
pub source_span: ErrorSpan,
pub dependency_type: DependencyType,
pub export_all: bool,
attributes: Option<ImportAttributes>,
resource_identifier: String,
}

pub struct CachedConstDependency {
pub start: u32,
pub end: u32,
pub identifier: Box<str>,
pub content: Box<str>,
}

This 0-based range is based on the 1-based SWC's Span conversion, and I think we should name it range which used in webpack to avoid ambiguity.

In addition, I think it may be better to name the types of loc and range as DependencyLocation and DependencyRange.

What's your opinion? @h-a-n-a

What does the proposed API of configuration look like?

pub struct Dependency {
  loc: DependencyLocation,
  range: DependencyRange
}
### Tasks
- [ ] https://github.com/web-infra-dev/rspack/issues/7336
- [ ] https://github.com/web-infra-dev/rspack/pull/7576
- [ ] https://github.com/web-infra-dev/rspack/pull/7635
- [ ] https://github.com/web-infra-dev/rspack/pull/7641
- [ ] https://github.com/web-infra-dev/rspack/pull/7671
- [ ] https://github.com/web-infra-dev/rspack/pull/7841
- [ ] https://github.com/web-infra-dev/rspack/pull/7871
- [ ] https://github.com/web-infra-dev/rspack/pull/7892

Metadata

Metadata

Assignees

Labels

featNew feature or requeststale

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions