From 9e6e660a930855e38c3faac4f246300d0c2696c2 Mon Sep 17 00:00:00 2001 From: Josh Ponelat Date: Mon, 19 Jun 2017 18:40:42 +0200 Subject: [PATCH] Add polyfill for Promise ( only ) This is needed for whatwg-fetch + IE11. An alternative is to include "node_modules/whatwg-fetch" in the transform-runtime. But my guess is that someone is likely going to add a lib that in turn uses Promises, without adding it to the whitelist. This is safter. --- src/polyfills.js | 2 ++ webpack-dist-bundle.config.js | 1 + webpack-dist-standalone.config.js | 1 + webpack-dist.config.js | 1 + webpack-hot-dev-server.config.js | 2 ++ 5 files changed, 7 insertions(+) create mode 100644 src/polyfills.js diff --git a/src/polyfills.js b/src/polyfills.js new file mode 100644 index 00000000..295898a6 --- /dev/null +++ b/src/polyfills.js @@ -0,0 +1,2 @@ +// Promise global, Used ( at least ) by 'whatwg-fetch'. And required by IE 11 +require("core-js/fn/promise") diff --git a/webpack-dist-bundle.config.js b/webpack-dist-bundle.config.js index 7f1c0223..99eae0a1 100644 --- a/webpack-dist-bundle.config.js +++ b/webpack-dist-bundle.config.js @@ -13,6 +13,7 @@ module.exports = require('./make-webpack-config.js')({ entry: { 'swagger-ui-bundle': [ + './src/polyfills', './src/core/index.js' ] }, diff --git a/webpack-dist-standalone.config.js b/webpack-dist-standalone.config.js index 47915879..570859cc 100644 --- a/webpack-dist-standalone.config.js +++ b/webpack-dist-standalone.config.js @@ -13,6 +13,7 @@ module.exports = require('./make-webpack-config.js')({ entry: { 'swagger-ui-standalone-preset': [ + './src/polyfills', './src/standalone/index.js' ] }, diff --git a/webpack-dist.config.js b/webpack-dist.config.js index 95c361de..eaef68a8 100644 --- a/webpack-dist.config.js +++ b/webpack-dist.config.js @@ -15,6 +15,7 @@ module.exports = require("./make-webpack-config.js")({ entry: { "swagger-ui": [ "./src/style/main.scss", + "./src/polyfills", "./src/core/index.js" ] }, diff --git a/webpack-hot-dev-server.config.js b/webpack-hot-dev-server.config.js index ded7b61e..457ac353 100644 --- a/webpack-hot-dev-server.config.js +++ b/webpack-hot-dev-server.config.js @@ -10,10 +10,12 @@ module.exports = require("./make-webpack-config")({ devtool: "eval", entry: { 'swagger-ui-bundle': [ + './src/polyfills', './src/core/index.js' ], 'swagger-ui-standalone-preset': [ 'webpack/hot/dev-server', + './src/polyfills', './src/standalone/index.js', ] },