DreaMinder / nuxt-payload-extractor

Nuxt.js module that makes `nuxt generate` command to store html and payload separately.
MIT License
145 stars 18 forks source link

nuxt-generate: "Payload-extractor had to duplicate some nested routes data in extracted payload" #14

Closed kyrsquir closed 4 years ago

kyrsquir commented 4 years ago

I'm getting lots of Payload-extractor had to duplicate some nested routes data in extracted payload warnings when using nuxt-generate-cluster's nuxt-generate.

With Nuxt's built-in nuxt generate I get no such messages at all. EDIT: Sometimes I do. Couldn't figure out the rule yet.

Could you please elaborate a bit on this message and its impact on build time and size? Also let me know if there is something to optimise on my end.

nuxt.config.js:

const axios = Axios.create({
  baseURL: process.env.API_URL
})

module.exports = {
  <...>
  generate: {
    workers: 8,
    async routes() {
      const [
        { data: authors },
        { data: yearsIssues },
        { data: issues },
        { data: articles }
      ] = await Promise.all([
        axios.get(`/all_authors_contribution`),
        axios.get(`/all_issues_by_year`),
        axios.get(`/all_issues`),
        axios.get(`/articles`)
      ])
      const authorsRoutes = authors.map(entry => ({
        route: `/authors/${entry.author.author_id}`,
        payload: entry
      }))
      const yearsRoutes = yearsIssues.map(yearIssues => ({
        route: `/archive/${yearIssues.year}`,
        payload: yearIssues.issues
      }))
      const issuesRoutes = issues.map(issue => ({
        route: `/archive/${issue.feature || issue.year}/${issue.order_within_year}`,
        payload: issue
      }))
      const articlesRoutes = articles
        .filter(article => !!article.issue)
        .map(article => ({
          route: `/archive/${article.issue.feature || article.issue.year}/${article.issue.order_within_year}/${article.section.order_within_issue}/${article.order_within_section}`,
          payload: article
        }))
      return [
        ...authorsRoutes,
        ...yearsRoutes,
        ...issuesRoutes,
        ...articlesRoutes
      ]
    },
    <...>
  }
}
DreaMinder commented 4 years ago

@kyrsquir this warning is not related to your case as long as you don't have nested routes (with <nuxt-child />, to render 2 routes at the same time: parent and child). Sadly, I don't see any way to distinguish nested-routes and nested paths (ex. /archive/:id, /archive/:id/:id), so this warning appears in both cases. I'll probably remove it to avoid confusion, thank you for writing to me about your concern.

kyrsquir commented 4 years ago

I'm not using <nuxt-child/>, just the nested paths. So I shouldn't worry about this at all, great. Feel free to close the issue unless you want to keep it until you remove the warning.