Skip to content
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

Extract the ES usage analyzer from the ES minifier crate #6586

Merged
merged 8 commits into from Dec 7, 2022

Conversation

alexkirsz
Copy link
Contributor

@alexkirsz alexkirsz commented Dec 6, 2022

Description:

This PR extracts the EcmaScript usage analyzer from the ES minifier crate into its own crate, to make it reusable by third parties. Notably, we plan on using this in Turbopack to implement tree shaking.

BREAKING CHANGE:

The swc_ecma_minifier::marks::Marks type is now exported from swc_ecma_usage_analyzer::marks::Marks instead. It might make sense to also re-export it from the swc_ecma_minifier crate.

Related issue (if exists):

Fixes WEB-269

wbinnssmith
wbinnssmith previously approved these changes Dec 6, 2022
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

I'm bit worried about the number of breaking changes

@@ -234,7 +234,7 @@ enum RecursiveUsage {

/// Analyzed info of a whole program we are working on.
#[derive(Debug, Default)]
pub(crate) struct ProgramData {
pub struct ProgramData {
Copy link
Member

Choose a reason for hiding this comment

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

Are you going to use this type directly?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer storing this type in swc_ecma_minifier, to reduce breaking changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current definition of UsageAnalyzer depends on it: UsageAnalyzer<S = ProgramData>. But I agree this makes more sense to live in swc_ecma_minifier for now so I'll move it and remove the default type.

From what I can tell the only breaking change is the marks::Marks type changing crates, and we can always re-export it from swc_ecma_minifier.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think it's fine. Thank you!

kdy1
kdy1 previously approved these changes Dec 7, 2022
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thank you!


swc-bump:

  • swc_ecma_minifier

@kdy1 kdy1 enabled auto-merge (squash) December 7, 2022 10:11
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

@kdy1 kdy1 self-assigned this Dec 7, 2022
auto-merge was automatically disabled December 7, 2022 10:35

Head branch was pushed to by a user without write access

@alexkirsz alexkirsz force-pushed the alexkirsz/extract-usage-analyzer branch from 06e071f to 7aa4e29 Compare December 7, 2022 10:35
@kdy1 kdy1 enabled auto-merge (squash) December 7, 2022 11:47
@kdy1 kdy1 merged commit e1d01d8 into swc-project:main Dec 7, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.22 Dec 9, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Jan 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants