Skip to content

Commit

Permalink
fix(plugin/fs-router-typegen): use swc.parseSync instead of parseFile…
Browse files Browse the repository at this point in the history
…Sync (#980)

It fails in StackBlitz as `@swc/was` will be used.
  • Loading branch information
dai-shi authored Oct 21, 2024
1 parent 822d426 commit 0685bcf
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Plugin } from 'vite';
import { readdir, writeFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { existsSync, readFileSync } from 'node:fs';
import { SRC_ENTRIES, EXTENSIONS } from '../constants.js';
import { joinPath } from '../utils/path.js';
import { parseFileSync } from '@swc/core';
import * as swc from '@swc/core';

const SRC_PAGES = 'pages';

Expand Down Expand Up @@ -118,7 +118,7 @@ export const fsRouterTypegenPlugin = (opts: { srcDir: string }): Plugin => {
if (!pagesDir) {
return false;
}
const file = parseFileSync(pagesDir + filePath, {
const file = swc.parseSync(readFileSync(pagesDir + filePath, 'utf8'), {
syntax: 'typescript',
tsx: true,
});
Expand Down

0 comments on commit 0685bcf

Please sign in to comment.