summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2019-07-31 16:42:11 -0700
committerEd Tanous <ed.tanous@intel.com>2019-08-05 09:30:26 -0700
commitdc25db0301ae6d4dabab6d98fb8447832a8c30e2 (patch)
tree265013c005542be82c1d1a1c39c495810a245b72
parentc9c8e67bce63b13d81f1860f39832655d521b4ec (diff)
downloadphosphor-webui-dc25db0301ae6d4dabab6d98fb8447832a8c30e2.tar.gz
phosphor-webui-dc25db0301ae6d4dabab6d98fb8447832a8c30e2.zip
Fix IE11 support
While we don't really officially support IE, it would be nice if _most_ non-complicated things actually worked. Given where transpilation is, and the fact that we already have webpack, this isn't actually that riddiculous of an idea. using babel was the intent with the original webpack stuff, but it turns out babel-loader wasn't pulling in the babelrc properly when it was in the root dir, so babel wasn't actually transpiling anything properly. Functionally, this commit does 3 things: 1. Fixes the published Accepts header, as the ajax call confuses IE if it doesn't have an encoding. 2. Includes core-js, to allow us to not really have to worry about javascript features that aren't present in a given browser. 4. Includes the config to support all browsers with > 0.25% market share, which should keep us compatible with most stuff. Requires a patch to bmcweb for the updated charset header, as we didn't handle that properly previously. https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/24063 Tested: Loaded the bmcweb patch. Started the webui in IE11 with the console open. Observed that webui launches and logs in properly with no errors on the console. Opened the webui in chrome to verify that nothing was broken. Appears working as it was before. Measured the pre-rootfs size before and after this patchset. It adds 36KB to the final package size. (404KB to 440KB). For supporting IE11 (and probably other browsers) I think this is well worth the cost. Signed-off-by: Ed Tanous <ed.tanous@intel.com> Signed-off-by: Gunnar Mills <gmills@us.ibm.com> Change-Id: Ie402e3296deede466a7a05726ebd7a18bead0b80
-rw-r--r--.babelrc10
-rw-r--r--app/index.js13
-rw-r--r--package-lock.json29
-rw-r--r--package.json2
-rw-r--r--webpack.config.js13
5 files changed, 47 insertions, 20 deletions
diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index 88172bd..0000000
--- a/.babelrc
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "presets": [
- [
- "@babel/preset-env",
- {
- "useBuiltIns": "entry"
- }
- ]
- ]
-} \ No newline at end of file
diff --git a/app/index.js b/app/index.js
index cbc763b..a4d4bee 100644
--- a/app/index.js
+++ b/app/index.js
@@ -6,6 +6,11 @@
* @exports app/index
*
*/
+import 'core-js/stable';
+import 'regenerator-runtime/runtime';
+import 'core-js/es/symbol';
+
+
import 'angular/angular-csp.css';
import 'bootstrap/dist/css/bootstrap.css';
@@ -133,16 +138,16 @@ window.angular && (function(angular) {
function($httpProvider) {
$httpProvider.interceptors.push('apiInterceptor');
$httpProvider.defaults.headers.common = {
- 'Accept': 'application/json'
+ 'Accept': 'application/json; charset=utf-8'
};
$httpProvider.defaults.headers.post = {
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json; charset=utf-8'
};
$httpProvider.defaults.headers.put = {
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json; charset=utf-8'
};
$httpProvider.defaults.headers.patch = {
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json; charset=utf-8'
};
}
])
diff --git a/package-lock.json b/package-lock.json
index 43aba65..3ff8fd0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1682,6 +1682,12 @@
"regenerator-runtime": "^0.10.5"
},
"dependencies": {
+ "core-js": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz",
+ "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==",
+ "dev": true
+ },
"regenerator-runtime": {
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz",
@@ -1703,6 +1709,14 @@
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"source-map-support": "^0.4.15"
+ },
+ "dependencies": {
+ "core-js": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz",
+ "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==",
+ "dev": true
+ }
}
},
"babel-runtime": {
@@ -1713,6 +1727,14 @@
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
+ },
+ "dependencies": {
+ "core-js": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz",
+ "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==",
+ "dev": true
+ }
}
},
"babel-template": {
@@ -2772,10 +2794,9 @@
}
},
"core-js": {
- "version": "2.5.7",
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz",
- "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==",
- "dev": true
+ "version": "3.1.4",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.1.4.tgz",
+ "integrity": "sha512-YNZN8lt82XIMLnLirj9MhKDFZHalwzzrL9YLt6eb0T5D0EDl4IQ90IGkua8mHbnxNrkj1d8hbdizMc0Qmg1WnQ=="
},
"core-js-compat": {
"version": "3.1.4",
diff --git a/package.json b/package.json
index 0ae4c28..6b68739 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"files": [
"dist"
],
+ "browserslist": "> 0.25%, not dead",
"keywords": [
"node"
],
@@ -44,6 +45,7 @@
"angular-ui-bootstrap": "2.5.6",
"angular-ui-router": "1.0.22",
"bootstrap": "4.3.1",
+ "core-js": "3.1.4",
"ng-toast": "2.0.0",
"xterm": "3.14.5"
},
diff --git a/webpack.config.js b/webpack.config.js
index b1c8808..be579cb 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -13,6 +13,10 @@ var path = require('path');
var FilterChunkWebpackPlugin = require('filter-chunk-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
+const isPathInside = require('is-path-inside')
+const pkgDir = require('pkg-dir')
+const coreJsDir = pkgDir.sync(require.resolve('core-js'))
+
module.exports = (env, options) => {
var isProd = options.mode === 'production';
@@ -71,8 +75,13 @@ module.exports = (env, options) => {
// Transpile .js files using babel-loader
// Compiles ES6 and ES7 into ES5 code
test: /\.js$/,
- use: 'babel-loader',
- exclude: /node_modules/
+ exclude: (input) => isPathInside(input, coreJsDir),
+ use: {
+ loader: 'babel-loader',
+ options: {
+ presets: [['@babel/preset-env', {useBuiltIns: 'entry', corejs: 3}]]
+ }
+ }
},
{
// ASSET LOADER
OpenPOWER on IntegriCloud