Skip to content

Commit

Permalink
RSC: Better typings for acorn-loose usage (redwoodjs#10681)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed May 24, 2024
1 parent c1c91de commit 6e6c9ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/vite/modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,4 @@ declare module 'react-server-dom-webpack/server' {
): PipeableStream
}

declare module 'acorn-loose'
declare module 'vite-plugin-cjs-interop'
7 changes: 4 additions & 3 deletions packages/vite/src/plugins/vite-plugin-rsc-transform-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'node:path'

import type { Statement, ModuleDeclaration } from 'acorn'
import * as acorn from 'acorn-loose'
import type { Plugin } from 'vite'

Expand All @@ -26,7 +27,7 @@ export function rscTransformUseClientPlugin(
return code
}

let body
let body: (Statement | ModuleDeclaration)[]

try {
body = acorn.parse(code, {
Expand Down Expand Up @@ -125,7 +126,7 @@ function addExportNames(names: Array<string>, node: any) {
*/
async function parseExportNamesIntoNames(
code: string,
body: any,
body: (Statement | ModuleDeclaration)[],
names: Array<string>,
): Promise<void> {
for (let i = 0; i < body.length; i++) {
Expand Down Expand Up @@ -186,7 +187,7 @@ async function parseExportNamesIntoNames(

async function transformClientModule(
code: string,
body: any,
body: (Statement | ModuleDeclaration)[],
url: string,
clientEntryFiles: Record<string, string>,
): Promise<string> {
Expand Down

0 comments on commit 6e6c9ec

Please sign in to comment.