Created
October 10, 2022 17:40
-
-
Save hanford/39680e8183942e41d8bac1b7602dc61f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Append "'client';" to beginnging of all Pages | |
export const parser = "tsx"; | |
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const root = j(file.source); | |
const clientCommentBlock = j.expressionStatement(j.stringLiteral("client")); | |
const firstNode = root.find(j.Program).get("body", 0); | |
if (firstNode.comments) { | |
clientCommentBlock.comments = firstNode.comments; | |
} | |
firstNode.insertBefore(clientCommentBlock); | |
return root.toSource(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment