Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: write globalTypes into dist for correct export #4740

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/language-core/lib/codegen/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ScriptCodegenOptions {
export function* generateScript(options: ScriptCodegenOptions): Generator<Code, ScriptCodegenContext> {
const ctx = createScriptCodegenContext(options);

yield `/// <reference types="${options.vueCompilerOptions.lib}/__globalTypes_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}" />${newLine}`;
yield `/// <reference types="${options.vueCompilerOptions.lib}/dist/__globalTypes_${options.vueCompilerOptions.target}_${options.vueCompilerOptions.strictTemplates}.d.ts" />${newLine}`;

if (options.sfc.script?.src) {
yield* generateSrc(options.sfc.script, options.sfc.script.src);
Expand Down
2 changes: 1 addition & 1 deletion packages/tsc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down
2 changes: 1 addition & 1 deletion packages/tsc/tests/dts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
Expand Down