Skip to content

refactor: use realDependencyLocation instead of range in dependency#7892

Merged
h-a-n-a merged 5 commits intoweb-infra-dev:mainfrom
shulaoda:feat/dependency-range
Sep 23, 2024
Merged

refactor: use realDependencyLocation instead of range in dependency#7892
h-a-n-a merged 5 commits intoweb-infra-dev:mainfrom
shulaoda:feat/dependency-range

Conversation

@shulaoda
Copy link
Copy Markdown
Contributor

Summary

Related to #7422

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Sep 13, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Sep 13, 2024

Deploy Preview for rspack ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5e758c9
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/66ed3f370e9ef5000849ef63
😎 Deploy Preview https://deploy-preview-7892--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@shulaoda
Copy link
Copy Markdown
Contributor Author

          I introduced `DependencyRange` because some dependencies's `span` are only used as `range` and don't require `to_loc`. This approach reduces memory usage since `RealDependencyLocation` has an additional `source: Option<Arc<dyn SourceLocation>>`.

Originally posted by @shulaoda in #7871 (comment)

@LingyuCoder
Copy link
Copy Markdown
Contributor

LGTM, cc @h-a-n-a

LingyuCoder
LingyuCoder previously approved these changes Sep 15, 2024
@h-a-n-a
Copy link
Copy Markdown
Contributor

h-a-n-a commented Sep 18, 2024

Do you have other purpose of introducing this data structure other than its size?

@shulaoda
Copy link
Copy Markdown
Contributor Author

Do you have other purpose of introducing this data structure other than its size?

Perhaps it can be used as a substitute for ErrorSpan?

@h-a-n-a
Copy link
Copy Markdown
Contributor

h-a-n-a commented Sep 18, 2024

Do you have other purpose of introducing this data structure other than its size?

Perhaps it can be used as a substitute for ErrorSpan?

That's the question I was wondering. If we have ErrorSpan, why bother creating another DependencyRange? I'm still thinking about to unify these locations and ranges into RealDependencyLocation.

@shulaoda
Copy link
Copy Markdown
Contributor Author

That's the question I was wondering. If we have ErrorSpan, why bother creating another DependencyRange? I'm still thinking about to unify these locations and ranges into RealDependencyLocation.

If an additional usize memory overhead is acceptable, we can do it this way. Alternatively, we could place the Sourcemap into the Dependency and use range.to_loc(self.sourcemap) for location transformation.

@h-a-n-a
Copy link
Copy Markdown
Contributor

h-a-n-a commented Sep 18, 2024

If an additional usize memory overhead is acceptable, we can do it this way.

I do think it's non-trivial. Let's keep RealDependencyLocation as small as 8-bytes.

Alternatively, we could place the Sourcemap into the Dependency and use range.to_loc(self.sourcemap) for location transformation.

Your suggestion sounds promising. Would you please give it a try?

@shulaoda shulaoda changed the title feat: add DepedencyRange refactor: use realDependencyLocation instead of range in dependency Sep 18, 2024
@github-actions github-actions bot removed the release: feature release: feature related release(mr only) label Sep 18, 2024
@shulaoda
Copy link
Copy Markdown
Contributor Author

Your suggestion sounds promising. Would you please give it a try?

I will complete it in the next PR. Additionally, I propose replacing RealDependencyLocation and SyntheticDependencyLocation with RealDependencyRange and SyntheticDependencyName respectively. Our implementation ultimately differs somewhat from Webpack.

@h-a-n-a
Copy link
Copy Markdown
Contributor

h-a-n-a commented Sep 19, 2024

Your suggestion sounds promising. Would you please give it a try?

I will complete it in the next PR. Additionally, I propose replacing RealDependencyLocation and SyntheticDependencyLocation with RealDependencyRange and SyntheticDependencyName respectively. Our implementation ultimately differs somewhat from Webpack.

LGTM. You could also replace name RealDependencyRange with DependencyRange and remove ErrorSpan. Both of them looks good to me.

@shulaoda shulaoda force-pushed the feat/dependency-range branch from 979b3c5 to 5e758c9 Compare September 20, 2024 09:24
Copy link
Copy Markdown
Contributor

@h-a-n-a h-a-n-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work!

@h-a-n-a h-a-n-a merged commit 1d125ac into web-infra-dev:main Sep 23, 2024
@shulaoda shulaoda deleted the feat/dependency-range branch September 23, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants