Skip to content

Commit

Permalink
fix: allow unknown files to use default require as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Aug 19, 2020
1 parent 5b49061 commit 13e323c
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions packages/webpack-cli/lib/groups/ConfigGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,16 @@ const getDefaultConfigFiles = () => {
};

const getConfigInfoFromFileName = (filename) => {
const fileMetaData = parse(filename);
// .cjs is not available on interpret side, handle it manually for now
if (filename.endsWith('.cjs')) {
return [
{
path: resolve(filename),
ext: '.cjs',
module: null,
},
];
}
return Object.keys(extensions)
.filter((ext) => ext.includes(fileMetaData.ext))
.filter((ext) => fileMetaData.base.substr(fileMetaData.base.length - ext.length) === ext)
.map((ext) => {
const { ext } = parse(filename);
// since we support only one config for now
const allFiles = [filename];
// return all the file metadata
return allFiles
.map((file) => {
return {
path: resolve(filename),
path: resolve(file),
ext: ext,
module: extensions[ext],
module: extensions[ext] || null,
};
})
.filter((e) => existsSync(e.path));
Expand Down

0 comments on commit 13e323c

Please sign in to comment.