next.js: Some examples don't work

What example does this report relate to?

See list below

What version of Next.js are you using?

latest

What version of Node.js are you using?

14.x

What browser are you using?

Chrome

What operating system are you using?

MacOS

How are you deploying your application?

/

Describe the Bug

While testing all examples for this PR, I ran into a few examples that didn’t work. Here’s a list:

  • with-webpack-bundle-size-analyzer
  • with-webassembly (fixed in #26440)
  • with-i18n-next-intl (fixed in #25928)
    • MISSING_OTHER_CLAUSE
  • with-ant-design-mobile (fixed in #25929)
    • missing peer dependencies with yarn or our internal package manager turbo
  • with-kea (fixed in #26069)
    • missing peer dependencies with yarn or our internal package manager turbo@babel/core
  • with-lingui (fixed in #26076)
    • missing peer dependencies with yarn or our internal package manager turbo@babel/core
    • deprecation warnings
  • with-mobx (fixed in #26069)
    • missing peer dependencies with yarn or our internal package manager turbo@babel/core
  • with-mobx-react-lite (fixed in #26069)
    • missing peer dependencies with yarn or our internal package manager turbo@babel/core
  • with-mobx-state-tree (fixed in #26069)
    • missing peer dependencies with yarn or our internal package manager turbo@babel/core
  • with-mobx-state-tree-typescript (fixed in #25589)
    • missing peer dependencies with yarn or our internal package manager turbo@babel/core
  • with-next-page-transitions (fixed in #25901)
  • with-next-sitemap (fixed in #25866)
    • missing devDependenciestypescript
  • ssr-caching
  • with-rbx-bulma-pro (fixed in #25854)
  • with-react-md (fixed in #26001)
    • uses node-sass which doesn’t work on StackBlitz because it requires a binary and typically involves running an install script which builds the package. Would be nice if we could switch to sass instead, the typescript version of this example also uses sass.
  • with-react-multi-carousel (fixed in #25902)
    • Warning: Each child in a list should have a unique "key" prop
  • with-reflux
    • Warning: componentWillMount has been renamed
  • with-tailwindcss-emotion
    • matchUtilities is not a function
    • Cannot find module with-tailwindcss-emotion/.next/server/pages-manifest.json
  • with-typescript-graphql (fixed in #26010)
  • with-urql (fixed in #25987)
    • CORS errors for https://graphql-pokemon.vercel.app/, maybe we can add stackblitz.com to the allowed origins

Expected Behavior

The examples are expected to work locally.

After an example has been fixed, please add a Preview section to the README.md right above Deploy your own.

  • Replace DIRECTORY_NAME with the directory name you’re adding.
## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/DIRECTORY_NAME)

⚠️ If the example doesn’t work on StackBlitz, please let us know and file an issue here.

To Reproduce

Follow the steps in the README.md.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 29 (28 by maintainers)

Commits related to this issue

Most upvoted comments

I’m going to fix all of the examples with missed peer dependencies

with-react-md has been merged 👌

Example with-typescript-graphql is currenty not working. The fix above didn’t work.

In lib/resolvers.ts typescript throws an error and fails to compile.

Module '"*.graphqls"' has no exported member 'MutationResolvers'. Did you mean to use 'import MutationResolvers from "*.graphqls"' instead?ts(2614)

Ideas how to fix it?

Yay! Has been merged 🙌 Thanks @vitalybaev

Yes. It installs the latest version of @lingui/react and some exports were deprecated (removed actually). I think I can update the example.

Thanks @akellbl4 for fixing the with-typescript-grapql exmaple 🎉 🙏

@d3lm with-urql example has been fixed in #25987. I’ve also added StackBlitz button in readme. Please check it.

@d3lm good! Let me know if anything causes errors I’m ready to fix it 😉

Could you please convert this list to checkboxes? It would be much better to understand fixed cases 🙏

@d3lm thanks for reporting! It has been broken after releasing Next.js 11, that enabled webpack 5 by default. Let’s wait my PR to merge 😴

@akellbl4 @vitalybaev I just filed an issue for with-webassembly which broke recently. Maybe you have some time to check?

d3lm something went wrong on StackBlitz 😦 stackblitz/core#1505

Ops, that’s was my bad. Fixed in https://github.com/vercel/next.js/pull/26091

ssr-caching example does not work, even with current latest package versions. I made it working like this, but there is an issue when using next-i18next. locale is not available from next router, but locales is.

server.js

const cacheableResponse = require('cacheable-response')
const express = require('express')
const next = require('next')

const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })

const handle = app.getRequestHandler()

const ssrCache = cacheableResponse({
  ttl: 1000 * 60, // 1 minute
  getKey: ({ req }) => `${req.url}`,
  get: async ({ req, res, path, query }) => {
    const data = await app.renderToHTML(req, res, path, query)

    // Add here custom logic for when you do not want to cache the page, for
    // example when the page returns a 404 status code:
    if (res.statusCode === 404) {
      res.end(data)
      return
    }

    return { data }
  },
  send: ({ data, res }) => res.send(data)
})

app.prepare().then(() => {
  const server = express()

  server.get('/', (req, res) => ssrCache({ req, res, path: req.path, query: req.query, }))

  server.get('/blog/:id', (req, res) => ssrCache({ req, res, path: req.path, query: req.query, }))

  server.get('*', (req, res) => handle(req, res))

  server.listen(port, (err) => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}`)
  })
})

@akellbl4 I commented on your PRs with updates and can verify that the i18n example works now 👍 Good job!

@akellbl4 Thanks for the update! Let me test those examples again and update the checklist accordingly.

  • The warning in with-next-page-transitions has been fixed.
  • with-react-multi-carousel is fixed as well
  • I don’t see anything that we can fix in with-reflux example. The warning produced by reflux. Reflux hasn’t got updates last 4 years.

Good work, thanks! mobx-state-tree-typescript should be fixed in #25589