Skip to content

Commit

Permalink
fix: nextConfig was memoized too early (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsaylevine authored May 3, 2021
1 parent f3f597e commit c5d88a4
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ module.exports = {
return failBuild('Could not find a package.json for this project')
}

const nextConfig = await getNextConfig(utils.failBuild)
await restoreCache({ cache: utils.cache, distDir: nextConfig.distDir })

if (await doesNotNeedPlugin({ netlifyConfig, packageJson, failBuild })) {
return
const pluginNotNeeded = await doesNotNeedPlugin({ netlifyConfig, packageJson, failBuild })

if (!pluginNotNeeded) {
const nextConfigPath = await findUp('next.config.js')
if (nextConfigPath === undefined) {
// Create the next config file with target set to serverless by default
const nextConfig = `
module.exports = {
target: 'serverless'
}
`
await pWriteFile('next.config.js', nextConfig)
}
}

const nextConfigPath = await findUp('next.config.js')
if (nextConfigPath === undefined) {
// Create the next config file with target set to serverless by default
const nextConfig = `
module.exports = {
target: 'serverless'
}
`
await pWriteFile('next.config.js', nextConfig)
}
// Because we memoize nextConfig, we need to do this after the write file
const nextConfig = await getNextConfig(utils.failBuild)
await restoreCache({ cache: utils.cache, distDir: nextConfig.distDir })
},
async onBuild({
netlifyConfig,
Expand Down

0 comments on commit c5d88a4

Please sign in to comment.