Skip to content

Commit 4367980

Browse files
authored
fix: respect vueCompilerOptions (#60)
1 parent 2d0010f commit 4367980

File tree

8 files changed

+429
-10
lines changed

8 files changed

+429
-10
lines changed

src/tsc/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ function createTsProgram({
126126
context = globalContext,
127127
}: TscOptions): TscModule {
128128
const fsSystem = createFsSystem(context.files)
129+
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd
129130
const parsedCmd = ts.parseJsonConfigFileContent(
130131
tsconfigRaw,
131132
fsSystem,
132-
tsconfig ? path.dirname(tsconfig) : cwd,
133+
baseDir,
133134
)
134135

135136
// If the tsconfig has project references, build the project tree.
@@ -140,6 +141,8 @@ function createTsProgram({
140141
const compilerOptions: ts.CompilerOptions = {
141142
...defaultCompilerOptions,
142143
...parsedCmd.options,
144+
$configRaw: parsedCmd.raw,
145+
$rootDir: baseDir,
143146
}
144147
const rootNames = [
145148
...new Set(

src/tsc/vue.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ export function createVueProgramFactory(
4141
ts,
4242
ts.createProgram,
4343
(ts, options) => {
44-
const { configFilePath } = options.options
45-
const vueOptions =
46-
typeof configFilePath === 'string'
47-
? vue.createParsedCommandLine(
48-
ts,
49-
ts.sys,
50-
configFilePath.replaceAll('\\', '/'),
51-
).vueOptions
52-
: vue.getDefaultCompilerOptions()
44+
const $rootDir = options.options.$rootDir as string
45+
const $configRaw = options.options.$configRaw as
46+
| (Ts.TsConfigSourceFile & { vueCompilerOptions?: any })
47+
| undefined
48+
49+
const resolver = new vue.CompilerOptionsResolver()
50+
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir)
51+
const vueOptions = resolver.build()
52+
5353
const vueLanguagePlugin = vue.createVueLanguagePlugin<string>(
5454
ts,
5555
options.options,

0 commit comments

Comments
 (0)