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

fix(build): clean up of build-www rewriteImports (follow-up to #5995) #5999

Merged
merged 3 commits into from
May 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions scripts/www/rewriteImports.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ async function transformFlowFileContents(source) {
node.docblock.comment &&
node.docblock.comment.value.includes('@flow strict')
) {
// This is mutated in-place because I couldn't find a mutation that
// did not fail for replacing the Program node.
node.docblock.comment.value = node.docblock.comment.value.replace(
/ \* @flow strict/g,
' * @flow strict\n * @generated\n * @oncall lexical_web_text_editor',
);
// Let the transform know we actually did something.
// Could not figure out the right way to update the
// docblock without an in-place update
context.addLeadingComments(node, '');
// We need the mutations array to be non-empty, so remove something
// that is not there. The AST traversals use object identity in a
// Set so we don't have to worry about some other line changing.
context.removeComments(t.LineComment({value: ''}));
Copy link
Member

Choose a reason for hiding this comment

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

Yeah sorry mutating the program node is not really supported atm, i have a task to fix it. Your solution looks roughly reasonable. The other maybe more correct (but still not ideal) solution is to find the doc block comment within the program. It will be attached to the first statement of the program, then you can use the standard comment remove and add API's.

}
},
}),
Expand Down
Loading