|
1 | 1 | import { runTsc } from '@volar/typescript/lib/quickstart/runTsc.js';
|
2 | 2 | import { createGtsLanguagePlugin } from '../volar/gts-language-plugin.js';
|
3 | 3 | import { loadConfig } from '../config/index.js';
|
4 |
| -// import * as vue from '@vue/language-core'; |
5 | 4 |
|
6 |
| -// const windowsPathReg = /\\/g; |
| 5 | +import { createRequire } from 'node:module'; |
| 6 | +const require = createRequire(import.meta.url); |
7 | 7 |
|
8 | 8 | export function run() {
|
9 |
| - |
10 | 9 | let runExtensions = ['.js', '.ts', '.gjs', '.gts', '.hbs'];
|
11 | 10 | let cwd = process.cwd();
|
12 | 11 |
|
13 |
| - // const extensionsChangedException = new Error('extensions changed'); |
14 |
| - const main = () => runTsc( |
15 |
| - require.resolve('typescript/lib/tsc'), |
16 |
| - runExtensions, |
17 |
| - (ts, options) => { |
18 |
| - |
| 12 | + const main = () => |
| 13 | + runTsc(require.resolve('typescript/lib/tsc'), runExtensions, (ts, options) => { |
19 | 14 | const glintConfig = loadConfig(cwd);
|
20 | 15 | const gtsLanguagePlugin = createGtsLanguagePlugin(glintConfig);
|
21 | 16 | return [gtsLanguagePlugin];
|
22 |
| - |
23 |
| - // const { configFilePath } = options.options; |
24 |
| - // const vueOptions = typeof configFilePath === 'string' |
25 |
| - // ? vue.createParsedCommandLine(ts, ts.sys, configFilePath.replace(windowsPathReg, '/')).vueOptions |
26 |
| - // : vue.resolveVueCompilerOptions({}); |
27 |
| - // const allExtensions = [ |
28 |
| - // ...vueOptions.extensions, |
29 |
| - // ...vueOptions.vitePressExtensions, |
30 |
| - // ...vueOptions.petiteVueExtensions, |
31 |
| - // ]; |
32 |
| - // if ( |
33 |
| - // runExtensions.length === allExtensions.length |
34 |
| - // && runExtensions.every(ext => allExtensions.includes(ext)) |
35 |
| - // ) { |
36 |
| - // const writeFile = options.host!.writeFile.bind(options.host); |
37 |
| - // options.host!.writeFile = (fileName, contents, ...args) => { |
38 |
| - // return writeFile(fileName, removeEmitGlobalTypes(contents), ...args); |
39 |
| - // }; |
40 |
| - |
41 |
| - // const glintConfig = loadConfig(cwd); |
42 |
| - // const gtsLanguagePlugin = createGtsLanguagePlugin(glintConfig); |
43 |
| - // return [gtsLanguagePlugin]; |
44 |
| - // } |
45 |
| - // else { |
46 |
| - // runExtensions = allExtensions; |
47 |
| - // throw extensionsChangedException; |
48 |
| - // } |
49 |
| - } |
50 |
| - ); |
51 |
| - |
| 17 | + }); |
52 | 18 | main();
|
53 |
| - // try { |
54 |
| - // } catch (err) { |
55 |
| - // if (err === extensionsChangedException) { |
56 |
| - // main(); |
57 |
| - // } else { |
58 |
| - // console.error(err); |
59 |
| - // } |
60 |
| - // } |
61 | 19 | }
|
62 |
| - |
63 |
| -// const removeEmitGlobalTypesRegexp = /^[^\n]*__VLS_globalTypesStart[\w\W]*__VLS_globalTypesEnd[^\n]*\n?$/mg; |
64 |
| - |
65 |
| -// export function removeEmitGlobalTypes(dts: string) { |
66 |
| -// return dts.replace(removeEmitGlobalTypesRegexp, ''); |
67 |
| -// } |
0 commit comments