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

Client bundles contain non es5 code #33314

Closed
tfkhim opened this issue Jan 14, 2022 · 3 comments
Closed

Client bundles contain non es5 code #33314

tfkhim opened this issue Jan 14, 2022 · 3 comments

Comments

@tfkhim
Copy link

tfkhim commented Jan 14, 2022

Run next info (available from version 12.0.8 and up)

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT Wed, 05 Jan 2022 16:20:59 +0000
Binaries:
  Node: 16.7.0
  npm: 7.20.3
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.0.8
  react: 17.0.2
  react-dom: 17.0.2

What version of Next.js are you using?

12.0.8

What version of Node.js are you using?

16.7.0

What browser are you using?

Chromium, Firefox

What operating system are you using?

Linux

How are you deploying your application?

next start

Describe the Bug

The update to 12.0.8 introduced a regression w.r.t. es5 compatibility. If running the command series given below the following error occurs:

ES-Check Error:
          ----
          · erroring file: ./.next/static/chunks/main-1e7421553b9673ee.js
          · error: SyntaxError: The keyword 'const' is reserved (1:97874)
          · see the printed err.stack below for context
          ----

          SyntaxError: The keyword 'const' is reserved (1:97874)

I think this is related to the changes in #33159 which added a new method getProperError to the ìs-error.js file. This method is used on the client side in next/client/index.tsx. The previously used isError function was very simple and es5 compatible. The new method uses the isPlainObject method which contains a const declaration.

I think the root cause is that dist/lib isn't transpiled during building. Looking at the Babel loader regex only dist/shared/lib seems to be transpiled. So moving those files there might be a solution for this problem.

Expected Behavior

The Webpack bundle files contain only es5 compatible JavaScript code.

To Reproduce

  • npx create-next-app@latest --typescript
  • npx next build
  • npx es-check es5 './.next/static/**/*.js'
@tfkhim tfkhim added the bug Issue was opened via the bug report template. label Jan 14, 2022
@balazsorban44 balazsorban44 added kind: bug and removed bug Issue was opened via the bug report template. labels Jan 15, 2022
@balazsorban44
Copy link
Member

balazsorban44 commented Jan 20, 2022

Hi, I just double-checked and const is partially supported in IE11 https://caniuse.com/const, which covers our use case of it.

You can verify this by visiting https://33314.vercel.app in IE11 and it will work fine.

That's the lowest possible browser we intend to support, I could actually not find a claim of direct ES5 compatibility in our docs: https://nextjs.org/docs/basic-features/supported-browsers-features

@PizzaPete
Copy link
Contributor

@balazsorban44 we're facing the same issue. Everything is compiled to ES5 but is-plain-object isn't and this is also causing issues for our project.

@balazsorban44
Copy link
Member

Please open a separate bug report with a reproduction.

In this case, I would appreciate a minimal one with the source code, that is also deployed somewhere, so I can verify from an IE11 browser that it is actually happening.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 26, 2022
kodiakhq bot pushed a commit that referenced this issue Jan 27, 2022
## Bug

- [ ] Related issues linked using `fixes #33314` #33314
- [ ] Moved the `is-plain-object` file to the shared directory since it's emitted to the client and thus needs to be transpiled.

This is just my 2nd PR so if I'm missing something please let me know.
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
…cel#33690)

## Bug

- [ ] Related issues linked using `fixes vercel#33314` vercel#33314
- [ ] Moved the `is-plain-object` file to the shared directory since it's emitted to the client and thus needs to be transpiled.

This is just my 2nd PR so if I'm missing something please let me know.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants