Unable to transpile ES6 to ES5 for IE11
See original GitHub issueBug report
Describe the bug
As per my knowledge next/babel in presets should transpile the code for non ES6 supporting browsers. But I can still find arrow functions, class, etc, in my /out folder. Also when I try to deploy this build it only works for chrome but not for IE or older versions of firefox.
To Reproduce
Repo Link: Steps to reproduce the behavior, please provide code snippets or a repository: `
- git clone https://github.com/mdvkmd/nextTranspileIssue.git nextTranspileIssue
- cd nextTranspileIssue
- npm install
- npm run start `
Expected behavior
It should produce ES5 transpiled code in out folder and should work on IE 11, Firefox 30, etc
System information
- OS: macOS
- Browser : [IE11, mozilla 30]
- Version of Next.js: [^9.1.6]
Additional context
I’ve also tried the below babel.config (Will also attach more babel.configs that I have tried)
module.exports = function (api) {
api.cache(true);
const presets = [
[
'next/babel',
{
'preset-env': {
targets: {
browsers: ['last 2 versions', 'ie > 9']
},
corejs: '2',
useBuiltIns: 'usage',
loose: true
},
'transform-runtime': {
useESModules: false
}
}
]
];
const plugins = [
'inline-dotenv',
['module-resolver', { root: ['./src'] }],
['import', { libraryName: 'antd', style: 'css' }],
['emotion']
];
const env = {
test: { presets: [['next/babel']] },
production: { presets: [['next/babel', { 'preset-env': { modules: false } }]] }
};
return {
presets,
plugins,
env
};
};
But the above results in
Error occurred prerendering page "/recharge" https://err.sh/zeit/next.js/prerender-error: TypeError: Class constructor App cannot be invoked without 'new'
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Webpack 5 won't transpile to ES5 for Internet Explorer 11
I'm trying to create a webpack 5 : babel 7 configuration that transpiles down to es5 that IE11 can read. It's a static...
Read more >Internet Explorer 11 testing - Office Add-ins - Microsoft Learn
Write your code in ECMAScript 2015 (also called ES6) or later JavaScript, or in TypeScript, and then compile your code to ES5 JavaScript ......
Read more >Is it possible to convert ES6 to ES5 for IE11 support?
Hello everyone,. I recently started using Adapt (Framework 2.4.0, Authoring 0.10.1) and created some extensions and components using ES6.
Read more >Why does my ReactJS app not able to render in IE11?
Recently one of my ReactJS App was unable to be supported in IE11, what a heck? ... We can actually transpile the Arrow...
Read more >IE11, Babel, Polyfills and You - Colin Burr
We reached for Babel to transpile our ES6 down to ES5, which IE11 can definitely handle. We popped some code into our Webpack...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@abhinavnigam2207
In my experience it’s not related to nextjs… as @jamesmosier mentioned this too often comes with npm thirdparty. So here’s something that might help :
Locate problems with es-check
Add scripts in your package.json
Then run
yarn clean && yarn check:es:build
for exampleYou’ll probably end up with an error message. The tricky part is now to locate the incriminated package in the file (I generally open it, then format in webstorm, and guess the culprit).
Transpile the package with next-transpile-modules
Activate it in your
next.config.js
Then retry a build and a check.
Notes
Hope it helps
For anyone coming here and finding the the answer from @belgattitude as helpful as I did… Here is a small node script for creating a CLI that might help you figure out where in the third party scripts the culprit is.
Note that you have to install the
source-map
andyargs
dependencies from NPM.