From 194e77c7f3f5aa19943ce2e5e74eed37a26bd3ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=B1=E5=90=B9=E8=89=B2=E5=BE=A1=E5=AE=88?= <85992002+KazariEX@users.noreply.github.com> Date: Thu, 29 Aug 2024 15:40:58 +0800 Subject: [PATCH] fix: write globalTypes into `dist` for correct export (#4740) --- packages/language-core/lib/codegen/script/index.ts | 2 +- packages/tsc/index.ts | 2 +- packages/tsc/tests/dts.spec.ts | 2 +- packages/typescript-plugin/index.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/language-core/lib/codegen/script/index.ts b/packages/language-core/lib/codegen/script/index.ts index 3ae28f41a5..30dccd3426 100644 --- a/packages/language-core/lib/codegen/script/index.ts +++ b/packages/language-core/lib/codegen/script/index.ts @@ -51,7 +51,7 @@ export interface ScriptCodegenOptions { export function* generateScript(options: ScriptCodegenOptions): Generator { const ctx = createScriptCodegenContext(options); - yield `/// ${newLine}`; + yield `/// ${newLine}`; if (options.sfc.script?.src) { yield* generateSrc(options.sfc.script, options.sfc.script.src); diff --git a/packages/tsc/index.ts b/packages/tsc/index.ts index cf6e4bf8b7..865d09ca10 100644 --- a/packages/tsc/index.ts +++ b/packages/tsc/index.ts @@ -27,7 +27,7 @@ export function run(tscPath = require.resolve('typescript/lib/tsc')) { : options.host?.getCurrentDirectory() ?? ts.sys.getCurrentDirectory(); const libDir = require.resolve(`${vueOptions.lib}/package.json`, { paths: [rootDir] }) .slice(0, -'package.json'.length); - const globalTypesPath = `${libDir}__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`; + const globalTypesPath = `${libDir}dist/__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`; const globalTypesContents = vue.generateGlobalTypes(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates); ts.sys.writeFile(globalTypesPath, globalTypesContents); } catch { } diff --git a/packages/tsc/tests/dts.spec.ts b/packages/tsc/tests/dts.spec.ts index 9ab452793e..0554dfdcc7 100644 --- a/packages/tsc/tests/dts.spec.ts +++ b/packages/tsc/tests/dts.spec.ts @@ -37,7 +37,7 @@ describe('vue-tsc-dts', () => { : options.host?.getCurrentDirectory() ?? ts.sys.getCurrentDirectory(); const libDir = require.resolve(`${vueOptions.lib}/package.json`, { paths: [rootDir] }) .slice(0, -'package.json'.length); - const globalTypesPath = `${libDir}__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`; + const globalTypesPath = `${libDir}dist/__globalTypes_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`; const globalTypesContents = vue.generateGlobalTypes(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates); ts.sys.writeFile(globalTypesPath, globalTypesContents); } catch { } diff --git a/packages/typescript-plugin/index.ts b/packages/typescript-plugin/index.ts index 2f321ddd9b..677f6528a2 100644 --- a/packages/typescript-plugin/index.ts +++ b/packages/typescript-plugin/index.ts @@ -63,7 +63,7 @@ const plugin: ts.server.PluginModuleFactory = mods => { try { const libDir = require.resolve(`${options.lib}/package.json`, { paths: [proj.getCurrentDirectory()] }) .slice(0, -'package.json'.length); - const globalTypesPath = `${libDir}__globalTypes_${options.target}_${options.strictTemplates}.d.ts`; + const globalTypesPath = `${libDir}dist/__globalTypes_${options.target}_${options.strictTemplates}.d.ts`; const globalTypesContents = vue.generateGlobalTypes(options.lib, options.target, options.strictTemplates); proj.writeFile(globalTypesPath, globalTypesContents); } catch { }