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

[web] allow imports to line-break #57170

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Dec 12, 2024

We are about to dart format all the Dart code in the repo, which line-breaks some of our imports.

This PR updates sdk_rewriter.dart to support line-broken imports.

@yjbanov yjbanov requested a review from goderbauer December 12, 2024 23:00
@github-actions github-actions bot added the platform-web Code specifically for the web engine label Dec 12, 2024
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -79,6 +79,7 @@ List<Replacer> generatePartsPatterns(String libraryName, bool isPublic) {
// Remove library directives.
AllReplacer(RegExp(r'\nlibrary .+;'), ''),
// Remove imports/exports from all part files.
AllReplacer(RegExp(r"\nimport '.+'\n\s*if \(dart.library.html\) '.*';"), ''),
Copy link
Member

Choose a reason for hiding this comment

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

can we not hardcode dart.library.html or maybe also allow for dart.library.js_interop as well, so our code doesn't mysteriously break when we migrate the code to not referencing dart.library.html? Bugs in the sdk rewriter are very hard to pinpoint :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@yjbanov yjbanov changed the title [web] allows imports to line-break [web] allow imports to line-break Dec 12, 2024
@yjbanov yjbanov force-pushed the allow-imports-to-line-break branch from 045cd24 to 81816cc Compare December 13, 2024 00:20
@goderbauer
Copy link
Member

Looks like something is still failing with the line breaks…

@mdebbar
Copy link
Contributor

mdebbar commented Dec 13, 2024

@yjbanov I think we need to remove this restriction now:

if (!isProperlyFormattedImport) {
violations.add('on line $lineNumber: import is broken up into multiple lines: $line');
continue;
}

(this is what's causing the CI failure)

@yjbanov
Copy link
Contributor Author

yjbanov commented Dec 13, 2024

Yep, fixed.

@yjbanov yjbanov added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants