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

[core] Fix next using stale pages #24635

Merged
merged 6 commits into from
Jan 27, 2021
Merged

[core] Fix next using stale pages #24635

merged 6 commits into from
Jan 27, 2021

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Jan 26, 2021

We're currently computing all the available pages in /api at runtime. Since we rely on the filesystem, we're using babel-preval to compute the api pages at transpile time. However, transpiled files are cached and we cannot invalidate that the cache for a particular file. This leads to netlify deploys failing on a cache hit when pages changed (e.g. in #24626: https://app.netlify.com/sites/material-ui/deploys/60103453834bf5000813eeee).

Invalidating just babel-preval is currently not possible (kentcdodds/babel-plugin-preval#19).

We're now hardcoding /api pages just like any other page. This reduces complexity of what is considered a page. Since we already require committing yarn docs:api changes, we can leverage that script to generate the necessary page entries.

TODO:

  • remove babel-plugin-preval
  • generate pagesAPI in docs:api

Aside: src/pages is currently the wrong abstraction. It doesn't contain nextjs pages but items for the nav. Not every nav item is a nextjs page e.g. /components/data-grid is hosted somewhere else and handled via netlify redirects. Or https://medium.com/material-ui which is just an external link. Might be worth entangling but I'm waiting for another bug to arise from this premature abstraction.

@eps1lon eps1lon added the core Infrastructure work going on behind the scenes label Jan 26, 2021
@mui-pr-bot
Copy link

mui-pr-bot commented Jan 26, 2021

Details of bundle changes

Generated by 🚫 dangerJS against c9c37e5

This reverts commit 6fe3884.
* Creates .js file containing all /api nextjs pages
*/
function generateApiPagesManifest(outputPath: string, prettierConfigPath: string): void {
const [{ children: apiPages }] = findPages({ front: true });
Copy link
Member Author

Choose a reason for hiding this comment

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

findPages({ front: true }) was what we pre-evaled previously in findPage.js.

@eps1lon eps1lon marked this pull request as ready for review January 27, 2021 10:59
@eps1lon eps1lon merged commit 0959a94 into mui:next Jan 27, 2021
@eps1lon eps1lon deleted the docs/fix-deploys branch January 27, 2021 14:43
xs9627 added a commit to xs9627/material-ui that referenced this pull request Jan 27, 2021
* next: (34 commits)
  [Tab] Migrate to emotion (mui#24651)
  [TextField] Migrate Input component to emotion (mui#24638)
  [ImageList] Migrate ImageListItemBar to emotion (mui#24632)
  [CircularProgress] Migrate to emotion (mui#24622)
  [DataTable] Add example in docs for data table (mui#24428)
  [Card] Migrate CardActionArea to emotion (mui#24636)
  [core] Fix `next` using stale pages (mui#24635)
  [List] Migrate ListItemIcon to emotion (mui#24630)
  [ClickAwayListener] Fix `children` and `onClickAway` types (mui#24565)
  [docs] Include in docs directive to silence `eslint` erroneous warning (mui#24644)
  [Fab] Migrate to emotion (mui#24618)
  [TextField] Migrate FilledInput to emotion (mui#24634)
  [Card] Migrate CardHeader to emotion (mui#24626)
  [Card] Migrate CardMedia to emotion (mui#24625)
  [ImageList] Migrate ImageListItem to emotion (mui#24619)
  [website] Add vision block (mui#24603)
  [docs] Add sorting section (mui#24637)
  [TextField] Prepare removal of labelWidth prop (mui#24595)
  [Dialog] Migrate DialogTitle to emotion (mui#24623)
  [ImageList] Migrate to emotion (mui#24615)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants