Skip to content

Commit

Permalink
Disable strictExportPresence when webpack 5 is enabled
Browse files Browse the repository at this point in the history
Solves an issue some users ran into where enabling webpack 5 highlighted a wrong JSON import where named exports were used for JSON data.

> Should not import the named export 'myValue' (imported as 'myValue') from default-exporting module (only default export is available soon)
  • Loading branch information
timneutkens committed Apr 19, 2021
1 parent 0bcc694 commit c286658
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/next/build/webpack/config/blocks/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isWslBoolean from 'next/dist/compiled/is-wsl'
import curry from 'next/dist/compiled/lodash.curry'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { webpack, isWebpack5 } from 'next/dist/compiled/webpack/webpack'
import { ConfigurationContext } from '../utils'

const isWindows = process.platform === 'win32' || isWslBoolean
Expand Down Expand Up @@ -46,7 +46,9 @@ export const base = curry(function base(
if (!config.module) {
config.module = { rules: [] }
}
config.module.strictExportPresence = true

// TODO: add codemod for "Should not import the named export" with JSON files
config.module.strictExportPresence = !isWebpack5

return config
})

0 comments on commit c286658

Please sign in to comment.