Skip to content

Commit b18c8af

Browse files
committed
refactor(component-meta): split files
1 parent 45ab3d5 commit b18c8af

File tree

6 files changed

+914
-915
lines changed

6 files changed

+914
-915
lines changed

packages/component-meta/index.ts

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,68 @@
1+
import * as core from '@vue/language-core';
2+
import { posix as path } from 'path-browserify';
13
import * as ts from 'typescript';
2-
import { createCheckerBase, createCheckerByJsonConfigBase } from './lib/base';
4+
import { createCheckerBase } from './lib/checker';
35
import type { MetaCheckerOptions } from './lib/types';
46

57
export * from './lib/types';
68

79
export function createCheckerByJson(
8-
rootPath: string,
10+
rootDir: string,
911
json: any,
1012
checkerOptions: MetaCheckerOptions = {},
1113
) {
12-
return createCheckerByJsonConfigBase(
14+
rootDir = rootDir.replace(/\\/g, '/');
15+
return createCheckerBase(
1316
ts,
14-
rootPath,
15-
json,
17+
() => {
18+
const commandLine = core.createParsedCommandLineByJson(ts, ts.sys, rootDir, json);
19+
const { fileNames } = ts.parseJsonConfigFileContent(
20+
json,
21+
ts.sys,
22+
rootDir,
23+
{},
24+
undefined,
25+
undefined,
26+
core.getAllExtensions(commandLine.vueOptions)
27+
.map(extension => ({
28+
extension: extension.slice(1),
29+
isMixedContent: true,
30+
scriptKind: ts.ScriptKind.Deferred,
31+
})),
32+
);
33+
return [commandLine, fileNames];
34+
},
1635
checkerOptions,
36+
rootDir,
1737
);
1838
}
1939

2040
export function createChecker(
2141
tsconfig: string,
2242
checkerOptions: MetaCheckerOptions = {},
2343
) {
44+
tsconfig = tsconfig.replace(/\\/g, '/');
2445
return createCheckerBase(
2546
ts,
26-
tsconfig,
47+
() => {
48+
const commandLine = core.createParsedCommandLine(ts, ts.sys, tsconfig);
49+
const { fileNames } = ts.parseJsonSourceFileConfigFileContent(
50+
ts.readJsonConfigFile(tsconfig, ts.sys.readFile),
51+
ts.sys,
52+
path.dirname(tsconfig),
53+
{},
54+
tsconfig,
55+
undefined,
56+
core.getAllExtensions(commandLine.vueOptions)
57+
.map(extension => ({
58+
extension: extension.slice(1),
59+
isMixedContent: true,
60+
scriptKind: ts.ScriptKind.Deferred,
61+
})),
62+
);
63+
return [commandLine, fileNames];
64+
},
2765
checkerOptions,
66+
path.dirname(tsconfig),
2867
);
2968
}

0 commit comments

Comments
 (0)