Skip to content

fix: next 10.0.8 changes loadConfig to be async #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helpers/doesNotNeedPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const doesNotNeedPlugin = async ({ netlifyConfig, packageJson, utils }) => {
return (
isStaticExportProject({ build, scripts }) ||
doesSiteUseNextOnNetlify({ packageJson }) ||
!hasCorrectNextConfig({ nextConfigPath, failBuild: utils.build.failBuild })
!(await hasCorrectNextConfig({ nextConfigPath, failBuild: utils.build.failBuild }))
)
}

Expand Down
4 changes: 2 additions & 2 deletions helpers/hasCorrectNextConfig.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')

// Checks if site has the correct next.cofig.js
const hasCorrectNextConfig = ({ nextConfigPath, failBuild }) => {
const hasCorrectNextConfig = async ({ nextConfigPath, failBuild }) => {
// In the plugin's case, no config is valid because we'll make it ourselves
if (nextConfigPath === undefined) return true

Expand All @@ -14,7 +14,7 @@ const hasCorrectNextConfig = ({ nextConfigPath, failBuild }) => {
const acceptableTargets = ['serverless', 'experimental-serverless-trace']
let nextConfig
try {
nextConfig = loadConfig(PHASE_PRODUCTION_BUILD, path.resolve('.'))
nextConfig = await loadConfig(PHASE_PRODUCTION_BUILD, path.resolve('.'))
} catch (error) {
return failBuild('Error loading your next.config.js.', { error })
}
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = {

await makeDir(PUBLISH_DIR)

nextOnNetlify({ functionsDir: FUNCTIONS_SRC, publishDir: PUBLISH_DIR })
await nextOnNetlify({ functionsDir: FUNCTIONS_SRC, publishDir: PUBLISH_DIR })
},
}

Expand Down
237 changes: 211 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"scripts": {
"format": "prettier --write .",
"build": "next build test/sample",
"test": "npm run build && jest && jest --config src/tests/jest.config.js",
"test:plugin": "npm run build && jest",
"test:src": "jest --config src/tests/jest.config.js",
"test": "npm run test:plugin && npm run test:src",
"cypress:local": "env CYPRESS_DEPLOY=local cypress run --project ./src --config-file false --config video=false",
"cypress:netlify": "env CYPRESS_DEPLOY=netlify cypress run --project ./src --config-file false --config video=false",
"cypress:local:testonly": "env CYPRESS_SKIP_DEPLOY=true npm run cypress:local",
Expand Down
Loading