question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Edge 18 (Object.fromEntries) not supported even with correct polyfills

See original GitHub issue

Bug report

using the following .babel.rc leads to a build that should in theory support edge 18.

{
    "presets": [
        [
            "next/babel",
            {
                "preset-env": {
                    "targets": "> 0.25%"
                }
            }
        ]
    ],
    "plugins": [
        ["styled-components", { "ssr": true }],
        [
            "module-resolver",
            {
                "root": ["."],
                "alias": {
                    "@/Components": "components",
                   ...
                    "@/Functions": "components/Concepts/Functions"
                }
            }
        ]
    ]
}

This can be confirmed by running npx browserslist "> 0.25%". However, when testing live via browserstack (as its pretty hard to actually install edge 18), it seems like this is not the case, as the following bug pops up:

TypeError
Object doesn't support property or method 'fromEntries'

To Reproduce

Unfortunately, it’s pretty hard for me to reliably reproduce the bug in a minimal example as I can’t even run edge 18 locally. However, navigating to https://staging-viteach.com/concepts/rational numbers with edge 18 AND logging in - no validation required - will produce the bug.

Expected behavior

Would think that the config creates the correct polyfill.

Screenshots

image

System information

  • OS: Windows 10 (runtime)
  • Browser (if applies) edge 18 (runtime)
  • Version of Next.js: 9.4.4 (buildtime)
  • Version of Node.js: 13.13 (buildtime)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

8reactions
tkrotoffcommented, Feb 1, 2021

Check https://nextjs.org/docs/basic-features/supported-browsers-features#custom-polyfills

Create src/polyfills.js:

// https://github.com/vercel/next.js/pull/15772#discussion_r463984612
import 'core-js/features/object/from-entries';

and import it inside your custom src/pages/_app.js:

// https://nextjs.org/docs/basic-features/supported-browsers-features#custom-polyfills
import '../polyfills';

function App({ Component, pageProps }) {
  return (
    <Component {...pageProps} />
  );
}

export default App;

Why do we have to do this? Because Next.js does not include all polyfills. Instead @timneutkens decided to include only the most common ones (https://github.com/vercel/next.js/pull/15772#discussion_r463984612, https://github.com/vercel/next.js/issues/11714) to avoid increasing the bundle size.

Be ready for hours of IE/old Edge debugging in a VM to understand what fails (can be hard considering how basic and slow IE dev tools are).

In a regular React app without Next.js, you would simply import 'core-js' and be done: no worries about a npm dependency update that might introduce the use of a basic JS feature not polyfilled by Next.js.

FYI Object.fromEntries() core-js polyfill is 5 lines of code.

0reactions
github-actions[bot]commented, Sep 7, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Edge 18 (Object.fromEntries) not supported even with correct ...
Would think that the config creates the correct polyfill. Screenshots. image. System information. OS: Windows 10 (runtime); Browser (if applies) edge 18 ( ......
Read more >
Object doesn't support property or method 'entries'
2/10/2020 UPDATE: Like @Monomachus said, first try adding this line to polyfill.ts: import 'core-js/es7/object';. If this fixes it, ...
Read more >
Object.fromEntries() - JavaScript - MDN Web Docs
The Object.fromEntries() method transforms a list of key-value pairs into an object.
Read more >
Angular < 13: How to support IE11 - DEV Community ‍ ‍
I'm actually going to disagree. It was still possible to support IE11, fully, despite the polyfills and ponyfills.
Read more >
Changes - HtmlUnit - SourceForge
2.53.0, September 18, 2021, Bugfixes, Chrome/Edge 93, Firefox 92 ... postMessage now supports arbitary js objects as message instead of converting them into ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found