diff --git a/packages/cli/lib/lib/webpack/transform-config.js b/packages/cli/lib/lib/webpack/transform-config.js index a6ea20425..ffecda629 100644 --- a/packages/cli/lib/lib/webpack/transform-config.js +++ b/packages/cli/lib/lib/webpack/transform-config.js @@ -107,7 +107,13 @@ module.exports = async function (env, webpackConfig, isServer = false) { ); } - const m = require('esm')(module)(myConfig); + let m = require('esm')(module)(myConfig); + + // The line above results in an empty object w/ Jest, + // so we need to do the following in order to load it: + if (Object.keys(m).length === 0) { + m = require(myConfig); + } const transformers = parseConfig((m && m.default) || m); diff --git a/packages/cli/tests/build.test.js b/packages/cli/tests/build.test.js index d610c5241..afc715606 100644 --- a/packages/cli/tests/build.test.js +++ b/packages/cli/tests/build.test.js @@ -176,14 +176,12 @@ describe('preact build', () => { }); it('should use custom `preact.config.js`', async () => { - // app with custom template set via preact.config.js + // app with stable output name via preact.config.js let dir = await subject('custom-webpack'); await build(dir); - let file = join(dir, 'build/index.html'); - let html = await readFile(file, 'utf-8'); - - looksLike(html, images.webpack); + let file = join(dir, 'build/bundle.js'); + expect(existsSync(file)).toBe(true); }); it('should use template from the code folder', async () => { diff --git a/packages/cli/tests/images/build.js b/packages/cli/tests/images/build.js index 42ea16206..0ce2a4f28 100644 --- a/packages/cli/tests/images/build.js +++ b/packages/cli/tests/images/build.js @@ -191,21 +191,6 @@ exports.prerender.htmlSafe = `
-`; -exports.webpack = ` - - -
- -
- -
-