Skip to content

Commit

Permalink
(fix) don't ignore d.ts file in .svelte-kit in file watch (#1566)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlyu123 committed Jul 26, 2022
1 parent bb81b91 commit 612a390
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -455,7 +455,12 @@ export class TypeScriptPlugin
for (const { fileName, changeType } of onWatchFileChangesParas) {
const pathParts = fileName.split(/\/|\\/);
const dirPathParts = pathParts.slice(0, pathParts.length - 1);
if (ignoredBuildDirectories.some((dir) => dirPathParts.includes(dir))) {
const declarationExtensions = [ts.Extension.Dcts, ts.Extension.Dts, ts.Extension.Dmts];
const canSafelyIgnore =
declarationExtensions.every((ext) => !fileName.endsWith(ext)) &&
ignoredBuildDirectories.some((dir) => dirPathParts.includes(dir));

if (canSafelyIgnore) {
continue;
}

Expand Down
Expand Up @@ -940,6 +940,10 @@ function test(useNewTransformation: boolean) {
}
});

it('should add declaration file snapshot when added to known build directory', async () => {
await testForOnWatchedFileAdd(path.join('.svelte-kit', 'ambient.d.ts'), true);
});

it('should update ts/js file after document change', async () => {
const { snapshotManager, projectJsFile, plugin } =
await setupForOnWatchedFileUpdateOrDelete();
Expand Down

0 comments on commit 612a390

Please sign in to comment.