Fix getLazy

- Fix getLazy not passing options to getModule
- Fix rm, rmSync missing in fs
- Remove useless code in searchExports iterator
This commit is contained in:
Zack Rauen 2022-10-09 19:42:53 -04:00
parent af1a26c333
commit a984bf08b0
3 changed files with 25 additions and 10 deletions

View File

@ -44,6 +44,14 @@ export function renameSync(oldPath, newPath) {
return fs.renameSync(oldPath, newPath);
}
export function rm(pathToFile) {
return fs.rmSync(pathToFile);
}
export function rmSync(pathToFile) {
return fs.rmSync(pathToFile);
}
export function unlinkSync(fileToDelete) {
return fs.unlinkSync(fileToDelete);
}

View File

@ -168,9 +168,6 @@ export default class WebpackModules {
let foundModule = null;
const wrappedExport = exports[key];
if (!wrappedExport) continue;
if (wrappedExport.Z && wrappedFilter(wrappedExport.Z, module, index)) foundModule = defaultExport ? wrappedExport.Z : wrappedExport;
if (wrappedExport.ZP && wrappedFilter(wrappedExport.ZP, module, index)) foundModule = defaultExport ? wrappedExport.ZP : wrappedExport;
if (wrappedExport.__esModule && wrappedExport.default && wrappedFilter(wrappedExport.default, module, index)) foundModule = defaultExport ? wrappedExport.default : wrappedExport;
if (wrappedFilter(wrappedExport, module, index)) foundModule = wrappedExport;
if (!foundModule) continue;
if (first) return foundModule;
@ -228,9 +225,6 @@ export default class WebpackModules {
let foundModule = null;
const wrappedExport = exports[key];
if (!wrappedExport) continue;
if (wrappedExport.Z && wrappedFilter(wrappedExport.Z, module, index)) foundModule = defaultExport ? wrappedExport.Z : wrappedExport;
if (wrappedExport.ZP && wrappedFilter(wrappedExport.ZP, module, index)) foundModule = defaultExport ? wrappedExport.ZP : wrappedExport;
if (wrappedExport.__esModule && wrappedExport.default && wrappedFilter(wrappedExport.default, module, index)) foundModule = defaultExport ? wrappedExport.default : wrappedExport;
if (wrappedFilter(wrappedExport, module, index)) foundModule = wrappedExport;
if (!foundModule) continue;
if (first) returnedModules[q] = foundModule;
@ -343,7 +337,7 @@ export default class WebpackModules {
*/
static getLazy(filter, options = {}) {
const {signal: abortSignal, defaultExport = true, searchExports = false} = options;
const fromCache = this.getModule(filter);
const fromCache = this.getModule(filter, {defaultExport, searchExports});
if (fromCache) return Promise.resolve(fromCache);
const wrappedFilter = wrapFilter(filter);
@ -359,9 +353,6 @@ export default class WebpackModules {
foundModule = null;
const wrappedExport = exports[key];
if (!wrappedExport) continue;
if (wrappedExport.Z && wrappedFilter(wrappedExport.Z)) foundModule = defaultExport ? wrappedExport.Z : wrappedExport;
if (wrappedExport.ZP && wrappedFilter(wrappedExport.ZP)) foundModule = defaultExport ? wrappedExport.ZP : wrappedExport;
if (wrappedExport.__esModule && wrappedExport.default && wrappedFilter(wrappedExport.default)) foundModule = defaultExport ? wrappedExport.default : wrappedExport;
if (wrappedFilter(wrappedExport)) foundModule = wrappedExport;
}
}

View File

@ -76,6 +76,20 @@ export const rmdirSync = function (path, options) {
Remote.filesystem.deleteDirectory(path, options);
};
export const rm = function (path, options, callback) {
try {
const result = Remote.filesystem.rm(path, options);
callback(null, result);
}
catch (error) {
callback(error, null);
}
};
export const rmSync = function (path, options) {
Remote.filesystem.rmSync(path, options);
};
export const exists = function (path, options, callback) {
try {
const result = Remote.filesystem.exists(path, options);
@ -161,6 +175,8 @@ export default {
realpathSync,
rename,
renameSync,
rm,
rmSync,
rmdir,
rmdirSync,
unlink,