Skip to content

Fix next.config.js resolution #35

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 1 commit into from
Nov 16, 2020
Merged

Fix next.config.js resolution #35

merged 1 commit into from
Nov 16, 2020

Conversation

ehmicky
Copy link

@ehmicky ehmicky commented Nov 13, 2020

Fixes #24

In a monorepo setup, it is possible that next.config.js might be in a parent directory if the user has set a base directory.
Next.js is searching next.config.js in parent directories using find-up:

https://github.com/vercel/next.js/blob/497cac4b93de9ecf6c7ed79bd6557dcd3bb51be5/packages/next/next-server/server/config.ts#L450

However we are not currently searching it in parent directories:

https://github.com/netlify/netlify-plugin-nextjs/blob/2849dc5f7c57e9fd827a939e067a871e4cb487b1/index.js#L57

Using find-up should fix this bug.

This also adds a test for it.

@ehmicky ehmicky added the type: bug code to address defects in shipped code label Nov 13, 2020
@ehmicky ehmicky self-assigned this Nov 13, 2020
`next.config.js must be one of: ${acceptableTargets.join(', ')}`,
)
})
test.each(['invalid_next_config', 'deep_invalid_next_config'])(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:O

expect(utils.build.failBuild.mock.calls[0][0]).toEqual(
`next.config.js must be one of: ${acceptableTargets.join(', ')}`,
)
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

friendly reminder to update this with the new fixture and failBuild logic whenever you merge everything :) <3

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and fixed! 👍

@ehmicky ehmicky merged commit 1f90614 into main Nov 16, 2020
@ehmicky ehmicky deleted the bug/find-config branch November 16, 2020 12:14
ascorbic added a commit that referenced this pull request Oct 4, 2021
ascorbic added a commit that referenced this pull request Oct 4, 2021
serhalp pushed a commit that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support next.config.js in parent directories
2 participants