-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Babel polyfill doesn't seem to be injected #2468
Comments
Sample project @ https://github.com/jonaswindey/next-polyfill-bug |
The only fix I have is adding a custom layout.js and adding |
@arunoda We've seen this before right 🤔 |
As a hot-fix you could do this: import 'core-js/fn/array/find'
const test = ['hi', 'there'].find(item => item === 'hi')
export default () => (
<div>{test}, welcome to next.js!</div>
) Let me see what's going on here. |
I checked this with a normal babel app and the behaviour is the same. So, I'm closing this since it's not exactly a Next specific issue. |
But I open to more suggestions. |
@arunoda I tried this hotfix with I had to go with the solution to include it like this: I'm using Next.js V3.0.6. Any Idea how i could solve this in a nicer way? |
Hey, all. module.exports = {
// eslint-disable-next-line no-unused-vars
webpack(config, _) {
const entry = async () => {
const resolvedEntry = await config.entry()
const entryWithPolyfill = Object.assign(
{ 'babel-polyfill': ['babel-polyfill'] },
resolvedEntry
)
// console.log(entryWithPolyfill)
return entryWithPolyfill
}
return Object.assign(
config,
entryWithPolyfill
)
}
} Sadly this file won't be transpiled by babel, which is why it does not work yet. |
Best thing would be to include |
@arunoda what do you think? |
any updates on this? Including the polyfill is not the best solution |
Also interested in this 🤔 |
I fixed this importing babel polyfills:
|
Importing the entire |
@sholzmayer where did you use |
@klaemo so what's your suggestion? |
Adding
|
@hugotox as an app developer you could use https://polyfill.io to only load the polyfills needed or you do that manually. In our app we have a // Language features presented by https://github.com/zloirock/core-js
import 'core-js/fn/object/assign'
import 'core-js/fn/string/ends-with'
import 'core-js/fn/string/starts-with'
import 'core-js/fn/string/includes'
import 'core-js/fn/array/includes'
import 'core-js/fn/weak-map'
// browser features
import 'raf/polyfill'
import 'isomorphic-fetch'
import 'js-polyfills/url' Alternatively, nextjs could import and bundle all the polyfills it needs from |
@igimanaloto this solution worked for me |
I also use {
"plugins": [
"source-map-support",
"transform-runtime"
],
"presets": [
["env", {
"targets": {
"node": "6.10"
}
}],
["stage-3"],
[
"next/babel",
{
"styled-jsx": {
"optimizeForSpeed": true,
"vendorPrefixes": true,
"sourceMaps": true,
"plugins": [
"styled-jsx-plugin-sass"
]
}
}
]
]
} |
@bliitzkrieg Don't import Usually, it's recommended to include it in your layout, basically any file that is loaded by all pages will do fine. |
Update: Fixed my example for IE 10, 11: changed Here's a Dockerized [Original question] What is the usage of Here's the initial result |
I was trying to run |
Seems like this bug still exists! I am facing the same issue in IE 11 and none of the solutions is helping. Problems seems to be ansi-regex package which uses a arrow function and this being a dependency of next.js. @arunoda @timneutkens can we re-open this issue? |
Yes still exists. I’m using yarn resolutions to downgrade |
Had to add I found this helpful: https://github.com/aspnet/JavaScriptServices/wiki/Supporting-Internet-Explorer-11-(or-older) |
Please add an official documentation about ES6 transpilation for node modules. |
here is a workaround but this bug has to be reopened. @arunoda i had errors with Object.assign, String.endsWith on ie11 (on [email protected]) const {basedir} = require('./server/config'); // polyfills required for non-evergreen browsers (mainly ie)
|
actually i sometimes get
|
I followed this example to include polyfills. import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/fn/object/assign';
import 'core-js/fn/string/ends-with';
import 'core-js/fn/string/starts-with';
import 'core-js/fn/string/includes';
import 'core-js/fn/array/includes';
import 'core-js/fn/array/find';
import 'core-js/fn/number/is-finite'; I am not sure whenever there are some libraries that e.g. needed isFinite, but my app is pretty minimal. This works, but is very cumbersome to figure out what polyfills that are actually needed. |
anyone knows what polyfill is requiired to get the class syntax working in IE11? class Foo extends ... |
in your polyfills uncomment 'import 'core-js/es6/object';' line |
I followed the example you mentioned @peec and it worked for me. |
@peec is this the expected behavior, though? Why would I need to re-polyfill something that was inlcluded? |
I'm trying to support IE11 for my app to fix the error
TypeError: Object doesn't support property or method 'find'
Using next
2.4.6
but also not working on latest betaAdded a custom .babelerc together with
babel-preset-env
with the following config:Enabled the debug flag so on startup I get the following log, which seems to mean that the polyfill are added.
However, at runtime, I still get the error on IE11 when I call the .find() method on an array.
Anything I can do to double check to make sure the polyfills are injected correctly?
The text was updated successfully, but these errors were encountered: