Skip to content

Commit

Permalink
chore: compatible with webpack-virtual-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hardfist committed Sep 15, 2024
1 parent 9577a0c commit 5232fdf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions packages/rspack/src/FileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,34 @@ class ThreadsafeReadableNodeFS implements ThreadsafeNodeInputFS{
Object.assign(this, NOOP_FILESYSTEM);
return;
}
this.readToString = memoizeFn(() => (p:string) => {
const t= fs.readFileSync!(p, 'utf-8');
return t;
})
this.canonicalize = memoizeFn(() => (p:string)=> {
this.readToString =(p:string) => {
const buffer= fs.readFileSync!(p);
return buffer.toString('utf8')
};
this.canonicalize = (p:string)=> {
let linkedPath = fs!.readlinkSync!(p,{});
let absolutePath= path.resolve(path.dirname(p), linkedPath);
return absolutePath;

})
this.metadata = memoizeFn(() => (p:string) => {
};
this.metadata =(p:string) => {
const stat = fs.statSync!(p);
let res= {
isFile: stat.isFile(),
isDir: stat.isDirectory(),
isSymlink: stat.isSymbolicLink()
};
return res;
})
this.symlinkMetadata = memoizeFn(() => (p:string) => {
};
this.symlinkMetadata = (p:string) => {
const stat = fs.lstatSync!(p);
let res = {
isFile: stat.isFile(),
isDir: stat.isDirectory(),
isSymlink: stat.isSymbolicLink()
};
return res;
})
};
}
static __to_binding(fs?: InputFileSystem) {
return new this(fs);
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/src/util/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export type ReadFile = {
export type ReadFileSync = {
(
path: PathOrFileDescriptor,
options: {
options?: {
encoding: null | undefined;
flag?: string;
} | null
Expand Down

0 comments on commit 5232fdf

Please sign in to comment.