diff --git a/packages/gatsby/src/bootstrap/__mocks__/require/exports.js b/packages/gatsby/src/bootstrap/__mocks__/require/exports.js index 18940aa15ea3b..a7000a162d857 100644 --- a/packages/gatsby/src/bootstrap/__mocks__/require/exports.js +++ b/packages/gatsby/src/bootstrap/__mocks__/require/exports.js @@ -1,2 +1,3 @@ exports.foo = () => {} exports.bar = () => {} +exports.__esModule = true diff --git a/packages/gatsby/src/bootstrap/__mocks__/require/unusual-exports.js b/packages/gatsby/src/bootstrap/__mocks__/require/unusual-exports.js index aa7a6390900d1..d9f791258d9b2 100644 --- a/packages/gatsby/src/bootstrap/__mocks__/require/unusual-exports.js +++ b/packages/gatsby/src/bootstrap/__mocks__/require/unusual-exports.js @@ -4,3 +4,6 @@ Object.defineProperty(exports, `foo`, { return () => {} }, }) +Object.defineProperty(exports, `__esModule`, { + value: true, +}) diff --git a/packages/gatsby/src/bootstrap/resolve-module-exports.js b/packages/gatsby/src/bootstrap/resolve-module-exports.js index 368329ac77817..de6ca6eb57b3a 100644 --- a/packages/gatsby/src/bootstrap/resolve-module-exports.js +++ b/packages/gatsby/src/bootstrap/resolve-module-exports.js @@ -123,7 +123,9 @@ https://gatsby.dev/no-mixed-modules module.exports = (modulePath, { mode = `analysis`, resolver } = {}) => { if (mode === `require`) { try { - return Object.keys(require(modulePath)) + return Object.keys(require(modulePath)).filter( + exportName => exportName !== `__esModule` + ) } catch { return [] }