title: Next.js working with polyfills and jQuery package
body: <p>Having an issue that specifically involves the Next.js <a href="https://github.com/vercel/next.js/blob/0af3b526408bae26d6b3f8cab75c4229998bf7cb/packages/next-polyfill-module/src/index.js#L53" rel="nofollow noreferrer">array-flat polyfill</a>. I need compatibility with older versions of Chrome, in this instance (v60-68). The application I'm working on uses a video player package that was built using jQuery 3.4. The package uses <code>$selector).replaceWith(elem)</code> and is where the error occurs.</p>
  <p><a href="https://api.jquery.com/replacewith/" rel="nofollow noreferrer">$.replaceWith</a> eventually runs:</p>
  <pre><code>  var flat = arr.flat ? function(array) {
      return arr.flat.call(array);
    } : function(array) {
      return arr.concat.apply([], array);
    }
  </code></pre>
  <p>The problem is an incompatible browser will run <code>arr.flat.call(array)</code> because of the Next.js polyfill and will fail inside the <code>polyfill-module.js</code> with an undefined reference. When going into the <code>node_modules/@next/polyfill-module/src/index.js</code>, removing the array-flat polyfill, and rebuilding; the app will work as expected and run <code>arr.concant.apply([], array);</code> as jQuery expects.  </p>
  <p>So I’m at a cross roads on how to handle the situation. Ideally want to maintain some support with Next's polyfills and migrating from jQuery is a non-starter. Is there a way each can coexist? For example, does Next provide a way to disable the <code>polyfill-module.js</code> file from loading on particular pages/instances? Or is there any suggestions to allow jQuery to run as expected in this particular situation?</p>