Merge pull request #10974 from luke-j/next

Core: Log swallowed errors when requiring stories
This commit is contained in:
Michael Shilman 2020-05-29 10:47:38 +08:00 committed by GitHub
commit a38451fdda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,13 +24,17 @@ const loadStories = (
if (reqs) {
reqs.forEach((req) => {
req.keys().forEach((filename: string) => {
const fileExports = req(filename);
currentExports.set(
fileExports,
// todo discuss: types infer that this is RequireContext; no checks needed?
// NOTE: turns out `babel-plugin-require-context-hook` doesn't implement this (yet)
typeof req.resolve === 'function' ? req.resolve(filename) : null
);
try {
const fileExports = req(filename);
currentExports.set(
fileExports,
// todo discuss: types infer that this is RequireContext; no checks needed?
// NOTE: turns out `babel-plugin-require-context-hook` doesn't implement this (yet)
typeof req.resolve === 'function' ? req.resolve(filename) : null
);
} catch (error) {
logger.warn(`Unexpected error: ${error}`);
}
});
});
} else {