Skip to content

Commit

Permalink
fix: handle default export. fixes #7 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Jan 3, 2019
1 parent 9af01ed commit 5737147
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ const loadConfig = async (argv) => {

let configExport = require(resolvedPath); // eslint-disable-line global-require, import/no-dynamic-require

if (configExport.default) {
configExport = configExport.default;
}

if (configName) {
if (!Array.isArray(configExport)) {
throw new TypeError(
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/webpack.config-default.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { resolve } from 'path';

const { error: sterr } = console;

export default {
context: __dirname,
entry: resolve(__dirname, 'entry.js'),
mode: 'development'
};

sterr('babel-default.js');
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ test('babel', async (t) => {
t.truthy(stderr.includes('⬡ webpack: Build Finished'));
});

test('babel default export', async (t) => {
const { stderr } = await run('--config', 'webpack.config-default.babel.js');
t.truthy(stderr.includes('babel-default'));
t.truthy(stderr.includes('⬡ webpack: Build Finished'));
});

test('bad', async (t) => {
try {
await run('--config', 'bad.config.js');
Expand Down

0 comments on commit 5737147

Please sign in to comment.