diff --git a/next.config.js b/next.config.js index a321e10b..e3ca6bce 100644 --- a/next.config.js +++ b/next.config.js @@ -29,6 +29,20 @@ module.exports = { publicRuntimeConfig, serverRuntimeConfig, webpack(config, { isServer }) { + const originalEntryFn = config.entry; + + // Inserting polyfill for old Browsers + // https://github.com/zeit/next.js/blob/canary/examples/with-polyfills/next.config.js + config.entry = async () => { + const entry = await originalEntryFn(); + if (entry['main.js'] && !entry['main.js'].includes('core-js')) { + // As specified by React official doc + // https://reactjs.org/docs/javascript-environment-requirements.html + entry['main.js'].unshift('core-js'); + } + return entry; + }; + // // Simplified from https://github.com/twopluszero/next-images/blob/master/index.js // diff --git a/package-lock.json b/package-lock.json index 6d81c9ad..4956705c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4532,9 +4532,9 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" }, "core-js": { - "version": "2.6.10", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.10.tgz", - "integrity": "sha512-I39t74+4t+zau64EN1fE5v2W31Adtc/REhzWN+gWRRXg6WH5qAsZm62DHpQ1+Yhe4047T55jvzz7MUqF/dBBlA==" + "version": "2.6.11", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz", + "integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==" }, "core-js-compat": { "version": "3.1.4",