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

[docs] Add trailingSlash: true #22008

Merged
merged 6 commits into from Aug 1, 2020

Conversation

oliviertassinari
Copy link
Member

Build on vercel/next.js#15598 (comment) and #21975 (comment). The main advantage is to reduce the gap between the development and production environment. I haven't noticed any regression. I'm happy to be able to remove the import of internal modules.

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Jul 31, 2020
@mui-pr-bot
Copy link

mui-pr-bot commented Jul 31, 2020

Details of bundle changes

Generated by 🚫 dangerJS against 24be237

@@ -128,6 +128,7 @@ module.exports = {
};
},
exportTrailingSlash: true,
Copy link
Member

Choose a reason for hiding this comment

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

if you want to force trailing slashes the recommendation is to just use trailingSlash: true

--vercel/next.js#15598 (comment)

Sounds like we can remove this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have tried without, it doesn't work correctly. We need to create a folder per route.

Copy link
Member

Choose a reason for hiding this comment

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

Could you ask for clarification then? The statement makes it pretty clear that we only need one. It's not obvious how these interact and why we need both.

Copy link
Member Author

Choose a reason for hiding this comment

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

exportTrailingSlash impacts the export output, it goes from /autocomplete.html to /autocomplete/index.html. On the other hand trailingSlash impacts how the links are generated. This is based on my observation, so far.

Copy link
Member Author

Choose a reason for hiding this comment

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

So while we can set exportTrailingSlash: false and trailingSlash: true, and have the navigation work, it leads to 301/308 redirection once you refresh the page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, if we look at the documentation, it's what it's described. https://nextjs.org/docs/api-reference/next.config.js/exportPathMap#adding-a-trailing-slash, change the HTML output.

I think that https://nextjs.org/docs/api-reference/next.config.js/trailing-slash would work if we weren't hosted on a CDN.

Copy link
Member

Choose a reason for hiding this comment

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

On the other hand trailingSlash impacts how the links are generated. This is based on my observation, so far.

Why would this be different? If next already generates links based on a trailing slash why would it then not export them as such?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why would this be different?

I think that in theory, trailingSlash is all we need. In practice, it's not enough. I think that it should lead to an issue on Next.js side. Let me do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Glad to see the private import droppted. But the indirection of routing and Link is a bit concerning. That was always a big pain point in next and I don't see them concerned with it at all.

@oliviertassinari oliviertassinari merged commit 6ad3152 into mui:next Aug 1, 2020
@oliviertassinari oliviertassinari deleted the trailingSlash branch August 1, 2020 18:01
kodai3 pushed a commit to kodai3/material-ui that referenced this pull request Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants