Skip to content

Commit 4f349cc

Browse files
committed
fix: use isomorphic __dirname
1 parent d39df59 commit 4f349cc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import path, { dirname } from 'path'
44
import { fileURLToPath } from 'url'
55
const _require = createRequire(import.meta.url)
66

7-
const __filename = fileURLToPath(import.meta.url)
8-
const __dirname = dirname(__filename)
7+
// isomorphic __dirname https://antfu.me/posts/isomorphic-dirname
8+
const _filename = fileURLToPath(import.meta.url)
9+
const _dirname = dirname(_filename)
910

1011
const proxyPath = _require.resolve('vue-tsc/out/proxy')
1112

@@ -43,7 +44,7 @@ const textToReplace: { target: string; replacement: string }[] = [
4344

4445
export function prepareVueTsc() {
4546
// 1. copy typescript to folder
46-
const targetTsDir = path.resolve(__dirname, 'typescript-vue-tsc')
47+
const targetTsDir = path.resolve(_dirname, 'typescript-vue-tsc')
4748
const vueTscFlagFile = path.resolve(targetTsDir, 'vue-tsc-resolve-path')
4849

4950
let shouldPrepare = true

0 commit comments

Comments
 (0)