Skip to content
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

Move pages/_component.js to components/Component.js #1450

Closed
wagerfield opened this issue Mar 17, 2017 · 3 comments
Closed

Move pages/_component.js to components/Component.js #1450

wagerfield opened this issue Mar 17, 2017 · 3 comments

Comments

@wagerfield
Copy link

  • pages/_document.js > components/Document.js
  • pages/_error.js > components/Error.js

Neither of the above are pages —they are special components. Since everyone adopts the convention of having a components folder alongside pages, it would be a lot nicer and "more correct" IMO to move them here and document that these are reserved component names that are used by Next.

I think this is both neater and will simplify your code splitting and bundling logic, since you can read all JS files in pages and not have to filter out these special cases. It would also eradicate the slightly ugly underscore named file...that's just my opinion though!

@arunoda
Copy link
Contributor

arunoda commented Mar 17, 2017

Thanks. You got a valid point.
But in the short term, we are not going to change it.

@arunoda arunoda closed this as completed Mar 17, 2017
@wagerfield
Copy link
Author

With 2.0.0 being released soon, I thought it might be a good opportunity to introduce a breaking change like this. Could you not provide support for both options and log a warning to those using pages/_document.js and pages/_error.js, advising them to move and rename their files? That way it wouldn't break anything but would allow people to migrate.

@wagerfield
Copy link
Author

wagerfield commented Mar 17, 2017

Having just read through this PR #936, this proposal could also be tackled in the next.config.js object just like pagesDirectory has been.

You could pass another couple of props like documentComponent and errorComponent:

// next.config.js
module.exports = {
  pagesDirectory: 'views',
  documentComponent: 'components/Document.js',
  errorComponent: 'components/Error.js'
}

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants