Skip to content

Commit

Permalink
type: fix lib type error.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 14, 2023
1 parent 2d8a488 commit d8ca46c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/less-modules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ const createLessModule = (lessLoaderOptions = {} as LessLoaderOptions) => {
});

// Exclude all less files (including module files) from file-loader
conf.module.rules = conf.module.rules.map((rule) => {
if (typeof rule === 'object' && rule.oneOf) {
loaders.forEach((item) => rule.oneOf.splice(rule.oneOf.length - 1, 0, item));
conf.module!.rules = conf.module?.rules?.map((rule) => {
if (rule && typeof rule === 'object' && rule.oneOf) {
loaders.forEach((item) => rule.oneOf?.splice(rule.oneOf.length - 1, 0, item));
}
return rule;
});
Expand Down
4 changes: 2 additions & 2 deletions packages/raw-modules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const rawModules = (conf: Configuration, env: string, options = {} as ReactLibra
},
];
// Exclude all less files (including module files) from file-loader
conf.module.rules = conf.module.rules.map((rule) => {
if (typeof rule === 'object' && rule.oneOf && Array.isArray(rule.oneOf)) {
conf.module!.rules = conf.module?.rules?.map((rule) => {
if (rule && typeof rule === 'object' && rule.oneOf && Array.isArray(rule.oneOf)) {
rule.oneOf = [...loaders, ...rule.oneOf];
}
return rule;
Expand Down
12 changes: 7 additions & 5 deletions packages/react-library/src/checkRequiredFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ export const checkRequiredFiles = (files: string[], isNotCheckHTML = true) => {
});
return true;
} catch (err) {
const dirName = path.dirname(currentFilePath);
const fileName = path.basename(currentFilePath);
console.log(chalk.red('Could not find a required file.'));
console.log(chalk.red(' Name: ') + chalk.cyan(fileName));
console.log(chalk.red(' Searched in: ') + chalk.cyan(dirName));
if (currentFilePath) {
const dirName = path.dirname(currentFilePath);
const fileName = path.basename(currentFilePath);
console.log(chalk.red('Could not find a required file.'));
console.log(chalk.red(' Name: ') + chalk.cyan(fileName));
console.log(chalk.red(' Searched in: ') + chalk.cyan(dirName));
}
return false;
}
};
2 changes: 1 addition & 1 deletion packages/react-library/src/overridesCheckRequiredFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { checkRequiredFiles } from './checkRequiredFiles';
const checkRequiredPath = `${reactDevUtils}/checkRequiredFiles`;
require(checkRequiredPath);
if (require.cache && require.cache[require.resolve(checkRequiredPath)]) {
require.cache[require.resolve(checkRequiredPath)].exports = checkRequiredFiles;
require.cache[require.resolve(checkRequiredPath)]!.exports = checkRequiredFiles;
}

0 comments on commit d8ca46c

Please sign in to comment.