Skip to content

Commit

Permalink
fix(tsc): composite projects
Browse files Browse the repository at this point in the history
composite projects currently do not rebuild efficently because we attach a fake
place holder vue file. This is used to generate global types once for the project.

As the fake placeholder file is added the the roots file, the second build will detect
a change because the root file does not exist for discovery with tsc.

> Project 'packages/design-system/tsconfig.json' is out of date because buildinfo file
> 'packages/design-system/tsconfig.tsbuildinfo' indicates that file '[.../path/to/fake-file.vue]'
> was root file of compilation but not any more.

As far as i can tell there is no need for this fake file, we just need the global types
generated the once per project when a vue file is detected. As such returning the first
vue file will generate the appropriate global types with that file and not cause
composite project to fail.
  • Loading branch information
blake-newman committed Apr 2, 2024
1 parent 5e521f2 commit 4ceed5d
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions packages/tsc/index.ts
Expand Up @@ -56,34 +56,5 @@ export function run() {

export function createFakeGlobalTypesHolder(options: ts.CreateProgramOptions) {
const firstVueFile = options.rootNames.find(fileName => fileName.endsWith('.vue'));
if (firstVueFile) {
const fakeFileName = firstVueFile + '__VLS_globalTypes.vue';

(options.rootNames as string[]).push(fakeFileName);

const fileExists = options.host!.fileExists.bind(options.host);
const readFile = options.host!.readFile.bind(options.host);
const writeFile = options.host!.writeFile.bind(options.host);

options.host!.fileExists = fileName => {
if (fileName.endsWith('__VLS_globalTypes.vue')) {
return true;
}
return fileExists(fileName);
};
options.host!.readFile = fileName => {
if (fileName.endsWith('__VLS_globalTypes.vue')) {
return '<script setup lang="ts"></script>';
}
return readFile(fileName);
};
options.host!.writeFile = (fileName, ...args) => {
if (fileName.endsWith('__VLS_globalTypes.vue.d.ts')) {
return;
}
return writeFile(fileName, ...args);
};

return fakeFileName.replace(windowsPathReg, '/');
}
if (firstVueFile) return firstVueFile;
}

0 comments on commit 4ceed5d

Please sign in to comment.