Skip to content

Commit

Permalink
chore: fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Sep 23, 2023
1 parent 90ee103 commit 3703147
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,25 @@ export default defineConfig({
renderChunk: {
order: 'post',
async handler(code) {
function annotate(statement?: babel.types.Expression | null): void {
if (statement?.type !== 'CallExpression' && statement?.type !== 'NewExpression') return
if (!statement.leadingComments) statement.leadingComments = []
statement.leadingComments.push({
type: 'CommentBlock',
value: ' @__PURE__ ',
})
}
return babel.transform(code, {
plugins: [
{
visitor: {
Program(path) {
for (const statement of path.node.body) {
if (babel.types.isExpressionStatement(statement)) {
if (
babel.types.isCallExpression(statement.expression) ||
babel.types.isNewExpression(statement.expression)
) {
statement.expression.leadingComments ||= []
statement.expression.leadingComments.push({
type: 'CommentBlock',
value: ' @__PURE__ ',
})
}
annotate(statement.expression)
} else if (babel.types.isVariableDeclaration(statement)) {
for (const declaration of statement.declarations) {
if (
declaration.init?.type === 'CallExpression' ||
declaration.init?.type === 'NewExpression'
) {
declaration.init.leadingComments ||= []
declaration.init.leadingComments.push({
type: 'CommentBlock',
value: ' @__PURE__ ',
})
}
annotate(declaration.init)
}
}
}
Expand Down

0 comments on commit 3703147

Please sign in to comment.