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

refactor(typescript): packages/rspack/src/node/NodeWatchFileSystem #7528

Merged
merged 2 commits into from
Aug 11, 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
72 changes: 25 additions & 47 deletions packages/rspack/etc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4768,58 +4768,36 @@ const infrastructureLogging: z.ZodObject<{
}>;

// @public (undocumented)
interface IStats {
// (undocumented)
atime: Date;
// (undocumented)
atimeMs: number | bigint;
// (undocumented)
birthtime: Date;
// (undocumented)
birthtimeMs: number | bigint;
// (undocumented)
blksize: number | bigint;
// (undocumented)
blocks: number | bigint;
// (undocumented)
ctime: Date;
// (undocumented)
ctimeMs: number | bigint;
// (undocumented)
dev: number | bigint;
// (undocumented)
gid: number | bigint;
// (undocumented)
ino: number | bigint;
// (undocumented)
type IStats = IStatsBase<number>;

// @public (undocumented)
type IStatsBase<T> = {
isFile: () => boolean;
isDirectory: () => boolean;
isBlockDevice: () => boolean;
// (undocumented)
isCharacterDevice: () => boolean;
// (undocumented)
isDirectory: () => boolean;
// (undocumented)
isSymbolicLink: () => boolean;
isFIFO: () => boolean;
// (undocumented)
isFile: () => boolean;
// (undocumented)
isSocket: () => boolean;
// (undocumented)
isSymbolicLink: () => boolean;
// (undocumented)
mode: number | bigint;
// (undocumented)
dev: T;
ino: T;
mode: T;
nlink: T;
uid: T;
gid: T;
rdev: T;
size: T;
blksize: T;
blocks: T;
atimeMs: T;
mtimeMs: T;
ctimeMs: T;
birthtimeMs: T;
atime: Date;
mtime: Date;
// (undocumented)
mtimeMs: number | bigint;
// (undocumented)
nlink: number | bigint;
// (undocumented)
rdev: number | bigint;
// (undocumented)
size: number | bigint;
// (undocumented)
uid: number | bigint;
}
ctime: Date;
birthtime: Date;
};

// @public (undocumented)
class ItemCacheFacade implements BaseCache {
Expand Down
23 changes: 14 additions & 9 deletions packages/rspack/src/node/NodeWatchFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
import util from "node:util";
import Watchpack from "watchpack";

import type { FileSystemInfoEntry, WatchFileSystem, Watcher } from "../util/fs";
import type {
FileSystemInfoEntry,
InputFileSystem,
WatchFileSystem,
Watcher
} from "../util/fs";

export default class NodeWatchFileSystem implements WatchFileSystem {
inputFileSystem: any;
inputFileSystem: InputFileSystem;
watcherOptions: Watchpack.WatchOptions;
watcher: Watchpack;

constructor(inputFileSystem: any) {
constructor(inputFileSystem: InputFileSystem) {
this.inputFileSystem = inputFileSystem;
this.watcherOptions = {
aggregateTimeout: 0
Expand Down Expand Up @@ -87,10 +92,10 @@ export default class NodeWatchFileSystem implements WatchFileSystem {
if (this.inputFileSystem?.purge) {
const fs = this.inputFileSystem;
for (const item of changes) {
fs.purge(item);
fs.purge?.(item);
}
for (const item of removals) {
fs.purge(item);
fs.purge?.(item);
}
}
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
Expand Down Expand Up @@ -129,7 +134,7 @@ export default class NodeWatchFileSystem implements WatchFileSystem {
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
for (const item of items) {
fs.purge(item);
fs.purge?.(item);
}
}
return items;
Expand All @@ -143,7 +148,7 @@ export default class NodeWatchFileSystem implements WatchFileSystem {
if (items && this.inputFileSystem && this.inputFileSystem.purge) {
const fs = this.inputFileSystem;
for (const item of items) {
fs.purge(item);
fs.purge?.(item);
}
}
return items;
Expand Down Expand Up @@ -172,12 +177,12 @@ export default class NodeWatchFileSystem implements WatchFileSystem {
const fs = this.inputFileSystem;
if (removals) {
for (const item of removals) {
fs.purge(item);
fs.purge?.(item);
}
}
if (changes) {
for (const item of changes) {
fs.purge(item);
fs.purge?.(item);
}
}
}
Expand Down
Loading
Loading