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

Add --built-in-only flag to module migrator #259

Merged
merged 5 commits into from
Oct 11, 2024
Merged

Add --built-in-only flag to module migrator #259

merged 5 commits into from
Oct 11, 2024

Conversation

jathak
Copy link
Member

@jathak jathak commented Jul 17, 2024

Also fixes some built-in functions that weren't being migrated.

jathak added 2 commits July 12, 2024 16:13
Also fixes some built-in functions that weren't being migrated.
@jathak jathak requested a review from nex3 July 17, 2024 23:16
_upstreamStylesheets.add(currentUrl);
if (migrateDependencies) visitDependency(ruleUrl, import.span);
_upstreamStylesheets.remove(currentUrl);
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why return eagerly here? What if there are multiple imports in a single @import that all need to be traversed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. Fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a lot of special cases for builtInOnly in the module migrator. It could probably use a few more tests to exercise more of them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jathak jathak requested a review from nex3 October 9, 2024 18:25
Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

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

Consider naming the flag --built-in-only, since "built-in" is usually spelled with a hyphen.

@@ -613,7 +630,7 @@ class _ModuleMigrationVisitor extends MigrationVisitor {
});
}

if (node.name == "get-function") {
if (node.name == "get-function" && !builtInOnly) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about get-function() calls for functions from built-in modules?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 797 to 799
_upstreamStylesheets.add(currentUrl);
if (migrateDependencies) visitDependency(ruleUrl, import.span);
_upstreamStylesheets.remove(currentUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since modifying _upstreamStylesheets doesn't do anything when migrateDependencies is false anyway, this makes it clearer when those lines are relevant:

Suggested change
_upstreamStylesheets.add(currentUrl);
if (migrateDependencies) visitDependency(ruleUrl, import.span);
_upstreamStylesheets.remove(currentUrl);
if (migrateDependencies) {
_upstreamStylesheets.add(currentUrl);
visitDependency(ruleUrl, import.span);
_upstreamStylesheets.remove(currentUrl);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jathak jathak changed the title Add --builtin-only flag to module migrator Add --built-in-only flag to module migrator Oct 10, 2024
@jathak jathak requested a review from nex3 October 10, 2024 17:44
@jathak jathak merged commit c5f8ac8 into main Oct 11, 2024
17 checks passed
@jathak jathak deleted the builtin-only branch October 11, 2024 00:04
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.

2 participants