Skip to content

Commit

Permalink
Fix up caching
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Jun 3, 2024
1 parent 28b2434 commit e75f0e9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/knip/src/CacheConsultant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fileEntryCache, { type FileEntryCache, type FileDescriptor } from 'file-e
import { timerify } from './util/Performance.js';
import parsedArgValues from './util/cli-arguments.js';
import { cwd, join } from './util/path.js';
import { version } from './version.js';

const defaultCacheLocation = join(cwd, 'node_modules', '.cache', 'knip');

Expand All @@ -24,8 +25,6 @@ const dummyFileDescriptor = { key: '', changed: true, notFound: true, meta: unde

const isEnabled = isCache || isWatch;

const version = '4';

export class CacheConsultant<T> {
private cache: undefined | FileEntryCache;
constructor(name: string) {
Expand Down
3 changes: 1 addition & 2 deletions packages/knip/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ export const main = async (unresolvedConfiguration: CommandLineOptions) => {

const file = serializableMap.get(filePath) ?? {};

if (imports) file.imports = { ...imports, internal: new Map<string, SerializableImports>() };

file.imports = imports;
file.exports = exports;
file.scripts = scripts;

Expand Down
7 changes: 6 additions & 1 deletion packages/knip/src/util/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ const deserializeObj = (obj: any) => {
return obj;
};

const serialize = (data: SerializableFile): SerializedFile => serializeObj(structuredClone(data));
const serialize = (data: SerializableFile): SerializedFile => {
const clone = structuredClone(data);
clone.imported = undefined;
clone.internalImportCache = undefined;
return serializeObj(clone);
};

const deserialize = (data: SerializedFile): SerializableFile => deserializeObj(data);

Expand Down

0 comments on commit e75f0e9

Please sign in to comment.