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

Update with-react-esi example (type error) #8262

Closed
Quernest opened this issue Aug 6, 2019 · 7 comments
Closed

Update with-react-esi example (type error) #8262

Quernest opened this issue Aug 6, 2019 · 7 comments
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@Quernest
Copy link

Quernest commented Aug 6, 2019

Examples bug report

Example name

with-react-esi

Describe the bug

Unable to add custom _app.js file into a project. After creating and building the example via docker-compose up, an error occurs:

node_1 | TypeError: Class constructor App cannot be invoked without 'new' node_1 | at new MyApp (/usr/src/app/dist/.next/server/static/QWF1PHuowO_sU-px49ruG/pages/_app.js:196:102) node_1 | at c (/usr/src/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:33:323) node_1 | at Sa (/usr/src/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:1) node_1 | at a.render (/usr/src/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:467) node_1 | at a.read (/usr/src/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:58) node_1 | at renderToString (/usr/src/app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:83) node_1 | at render (/usr/src/app/node_modules/next-server/dist/server/render.js:80:16) node_1 | at renderPage (/usr/src/app/node_modules/next-server/dist/server/render.js:237:20) node_1 | at /usr/src/app/dist/.next/server/static/QWF1PHuowO_sU-px49ruG/pages/_document.js:236:17 node_1 | at Generator.next (<anonymous>)

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. clone the example
  2. add custom _app.js
  3. run docker-compose up --build
  4. go to the browser (localhost:80)
  5. see internal server error

Expected behavior

Wanted to add styled components provider to custom _app.js and run in production.

Screenshots

Screenshot_1
Screenshot_2

System information

  • OS: Windows 10
  • Browser (if applies) Chrome
  • Version of Next.js: latest

Additional context

@Timer
Copy link
Member

Timer commented Aug 15, 2019

You have incorrectly configured your Babel configuration to cause this error. Be sure to not invoke Babel yourself, as Next already handles compiling these files for you.

@Timer Timer closed this as completed Aug 15, 2019
@Timer
Copy link
Member

Timer commented Aug 15, 2019

Ah, it appears this example was designed incorrectly. @lfades should we delete it?

@Timer Timer reopened this Aug 15, 2019
@Timer Timer added this to the 9.0.4 milestone Aug 15, 2019
@Quernest
Copy link
Author

@Timer
I have found the solution, but I'm not sure if this is the right choice in this case.
To run a project in production I use @babel/register

index.js

require('@babel/register')({
  presets: ['@babel/preset-env'],
  ignore: ['node_modules', '.next'],
});

module.exports = require('./server.js');

package.json

  "scripts": {
    "start": "NODE_ENV=production node index.js"
  },

React-ESI looks like the best page caching solution. Please, could you fix your example?

@lfades
Copy link
Member

lfades commented Aug 15, 2019

the example needs an update, @Quernest @dunglas If you want to update the example please do 🙏

@Timer Timer modified the milestones: 9.0.4, 9.0.5 Aug 18, 2019
@Timer Timer changed the title bug in with-react-esi (type error) Update with-react-esi example (type error) Aug 23, 2019
@Timer Timer removed this from the 9.0.5 milestone Aug 23, 2019
@Timer Timer added good first issue Easy to fix issues, good for newcomers help wanted labels Aug 23, 2019
@sushilbansal
Copy link

sushilbansal commented Apr 14, 2020

Hi @Timer , this example project is no longer in the example repo.

@dunglas
Copy link
Contributor

dunglas commented May 18, 2020

@Timer the example wasn't designed incorrectly. This has been discussed in the original PR (#6225 (comment)), and AFAIK, there is no better options right now.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants