Skip to content

Commit 215867b

Browse files
authored
Describe Babel solution to make fix IE11
Better tip for jhipster/generator-jhipster#10184 issue describing full solution in order to use Babel to make IE11 correctly working with JHipster generated applications.
1 parent fa96bdb commit 215867b

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

tips/028_tip_ie_support.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ lastmod: 2019-03-05T18:20:00-00:00
88

99
# Provide Internet Explorer support
1010

11-
**Tip submitted by [@wmarques](https://github.com/wmarques)**
11+
**Tip submitted by [@wmarques](https://github.com/wmarques)** & [@anthony-o](https://github.com/anthony-o)
1212

1313
JHipster supports only evergreen browsers.
1414
However you can still easily support some older browsers like Internet Explorer.
@@ -19,3 +19,63 @@ In order to do that you have to:
1919
2. Then you have two options:
2020
1. Add the correct polyfills from 'core-js', if you don't know which one you should use, check the Angular CLI project and their polyfills.
2121
2. Or use babel + [Babel preset-env](https://babeljs.io/docs/en/babel-preset-env#usebuiltins) to automatically import the correct core-js polyfills based on a browserslist file.
22+
23+
## Full tip using Babel
24+
25+
First, add those `package.json` dependencies: `@babel/core`, `@babel/preset-env` and `babel-loader`. Example with `yarn`:
26+
```bash
27+
yarn add @babel/core @babel/preset-env babel-loader --exact --dev
28+
```
29+
(tested with the following versions for a working IE11 version on a JHipster v6.3.1 generated application:
30+
```json
31+
"@babel/core": "7.6.4",
32+
"@babel/preset-env": "7.6.3",
33+
"babel-loader": "8.0.6",
34+
```
35+
)
36+
37+
Now add the following lines at the top of `src/main/webapp/app/polyfills.ts`:
38+
```ts
39+
import 'core-js/stable';
40+
import 'regenerator-runtime/runtime';
41+
```
42+
43+
In `webpack/webpack.common.js`, after
44+
```js
45+
{
46+
test: /manifest.webapp$/,
47+
loader: 'file-loader',
48+
options: {
49+
name: 'manifest.webapp'
50+
}
51+
},
52+
```
53+
add the following lines:
54+
```js
55+
{
56+
test: /\.js/,
57+
use: {
58+
loader: 'babel-loader',
59+
options: {
60+
"presets": [
61+
[
62+
"@babel/preset-env",
63+
{
64+
"targets": {
65+
"firefox": "60",
66+
"ie": "11"
67+
},
68+
"useBuiltIns": "entry",
69+
"corejs": 3
70+
}
71+
]
72+
]
73+
}
74+
},
75+
exclude: /@babel(?:\/|\\{1,2})runtime|core-js/,
76+
},
77+
```
78+
79+
And finally, change `target` to `es5` in `tsconfig.json` & `tsconfig-aot.json`.
80+
81+
See this [GitHub issue](https://github.com/jhipster/generator-jhipster/issues/10184#issuecomment-541650501) & [this SO answer](https://stackoverflow.com/a/58377002/535203) for more details.

0 commit comments

Comments
 (0)