-
Notifications
You must be signed in to change notification settings - Fork 27k
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
polyfills and redirect on dev environment #4636
Comments
Having same issue |
Similar issue to #4643. I wonder if, since |
Currently I add necessary polyfills as suggested in the example: // polyfill.js
/* eslint no-extend-native: 0 */
// core-js comes with Next.js. So, you can import it like below
import includes from 'core-js/library/fn/array/virtual/includes';
import find from 'core-js/library/fn/array/virtual/find';
import assign from 'core-js/library/fn/object/assign';
// Add your polyfills
// This files runs at the very beginning (even before React and Next.js core)
Array.prototype.includes = includes;
Array.prototype.find = find;
Object.prototype.assign = assign; // next.config.js
const withTypescript = require('@zeit/next-typescript');
module.exports = withTypescript({
webpack: function(config, {dev}) {
if(!dev) {
const originalEntry = config.entry;
config.entry = async() => {
const entries = await originalEntry();
if(entries['main.js'] && !entries['main.js'].includes('./src/polyfills.js')) {
entries['main.js'].unshift('./src/polyfills.js');
}
return entries;
};
}
return config;
},
}); It's actually pretty straight forward and works with Any suggestions or ideas why? |
@yves-s |
Thanks @exogen for your quick answer. |
Going to close this in favor of something like #4754 |
Bug report [tested on IE11, Chrome/Firefox supports without polyfills]
object.assign
) can't be recognized by the browser.Describe the bug
Polyfills added by default have no effect: Here is the webpack-bundle-analyzer report: https://d.pr/f/EMnBSM. It shows bundler already added polyfills like
object.assign
fromcore-js
(https://d.pr/i/drxC87). But we experience that browsers (IE11) can't recognize those. didn't test on Chrome/Firefox as those support without polyfills.Browser can't recognize the following way as suggested by with-polyfills example
Need to do like this: (
polyfills.js
)Our
next.config.js
code without css stuff:Expected behavior
Describe above.
Screenshots
System information
The text was updated successfully, but these errors were encountered: