Vue.js website is blank in Internet Explorer 11

Viewed 1043

Package.json

{
“name”: “Chatwidget”,
“version”: “0.1.0”,
“private”: true,
“scripts”: {
“serve”: “vue-cli-service serve”,
“build”: “vue-cli-service build”,
“lint”: “vue-cli-service lint”,
“deploy”: “rsync -aczv dist/ kuncom@kunden.comspace.de:/home/kunden.comspace.de/pages/mememru/”
},
“dependencies”: {
“date-fns”: “^1.30.1”,
“debounce”: “^1.2.0”,
“leaflet”: “^1.4.0”,
“leaflet-defaulticon-compatibility”: “^0.1.1”,
“loglevel”: “^1.6.1”,
“marked”: “^1.1.1”,
“node-fetch”: “^2.3.0”,
“sanitize-html”: “^2.3.2”,
“url-search-params-polyfill”: “^5.1.0”,
“uuid”: “^3.3.2”,
“v-emoji-picker”: “^2.3.1”,
“vue”: “^2.5.21”,
“whatwg-fetch”: “^3.0.0”
},
“devDependencies”: {
“@vue/cli-plugin-babel”: “^3.3.0”,
“@vue/cli-plugin-eslint”: “^3.3.0”,
“@vue/cli-service”: “^4.5.8”,
“babel-eslint”: “^10.0.1”,
“eslint”: “^5.12.0”,
“eslint-plugin-vue”: “^5.1.0”,
“node-sass”: “^4.11.0”,
“sass-loader”: “^7.1.0”,
“vue-template-compiler”: “^2.5.21”
},
“eslintConfig”: {
“root”: true,
“env”: {
“node”: true,
“jquery”: true
},
“extends”: [
“plugin:vue/essential”,
“eslint:recommended”
],
“rules”: {},
“parserOptions”: {
“parser”: “babel-eslint”
}
},
“postcss”: {
“plugins”: {
“autoprefixer”: {}
}
},
“browserslist”: [
“> 1%”,
“last 2 versions”,
“not ie <= 8”
]

babel.config.js

module.exports = {
  presets: [
    '@vue/app'
  ]
}

vue.config.js

const conf = {
    publicPath: './',
    css: {
        loaderOptions: {
            // pass options to sass-loader
            sass: {
                // @/ is an alias to src/
                data: `@import "@/global/css/style.scss";`
            }
        }
    },
    configureWebpack: {},
    productionSourceMap: false,
}
if (process.env.NODE_ENV === 'production') {
    conf.filenameHashing = false;
    conf.configureWebpack.optimization = {
        splitChunks: false
    };
}

module.exports = conf;



When i execute npm run serve i get following error

eval("var rng = __webpack_require__(/*! ./lib/rng */ \"./node_modules/uuid/lib/rng-browser.js\");\nvar bytesToUuid = __webpack_require__(/*! ./lib/bytesToUuid */ \"./node_modules/uuid/lib/bytesToUuid.js\");\n\nfunction v4(options, buf, offset) {\n  var i = buf && offset || 0;\n\n  if (typeof(options) == 'string') {\n    buf = options === 'binary' ? new Array(16) : null;\n    options = null;\n  }\n  options = options || {};\n\n  var rnds = options.random || (options.rng || rng)();\n\n  // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n  rnds[6] = (rnds[6] & 0x0f) | 0x40;\n  rnds[8] = (rnds[8] & 0x3f) | 0x80;\n\n  // Copy bytes to buffer, if provided\n  if (buf) {\n    for (var ii = 0; ii < 16; ++ii) {\n      buf[i + ii] = rnds[ii];\n    }\n  }\n\n  return buf || bytesToUuid(rnds);\n}\n\nmodule.exports = v4;\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9ub2RlX21vZHVsZXMvdXVpZC92NC5qcy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL25vZGVfbW9kdWxlcy91dWlkL3Y0LmpzP2M2NGUiXSwic291cmNlc0NvbnRlbnQiOlsidmFyIHJuZyA9IHJlcXVpcmUoJy4vbGliL3JuZycpO1xudmFyIGJ5dGVzVG9VdWlkID0gcmVxdWlyZSgnLi9saWIvYnl0ZXNUb1V1aWQnKTtcblxuZnVuY3Rpb24gdjQob3B0aW9ucywgYnVmLCBvZmZzZXQpIHtcbiAgdmFyIGkgPSBidWYgJiYgb2Zmc2V0IHx8IDA7XG5cbiAgaWYgKHR5cGVvZihvcHRpb25zKSA9PSAnc3RyaW5nJykge1xuICAgIGJ1ZiA9IG9wdGlvbnMgPT09ICdiaW5hcnknID8gbmV3IEFycmF5KDE2KSA6IG51bGw7XG4gICAgb3B0aW9ucyA9IG51bGw7XG4gIH1cbiAgb3B0aW9ucyA9IG9wdGlvbnMgfHwge307XG5cbiAgdmFyIHJuZHMgPSBvcHRpb25zLnJhbmRvbSB8fCAob3B0aW9ucy5ybmcgfHwgcm5nKSgpO1xuXG4gIC8vIFBlciA0LjQsIHNldCBiaXRzIGZvciB2ZXJzaW9uIGFuZCBgY2xvY2tfc2VxX2hpX2FuZF9yZXNlcnZlZGBcbiAgcm5kc1s2XSA9IChybmRzWzZdICYgMHgwZikgfCAweDQwO1xuICBybmRzWzhdID0gKHJuZHNbOF0gJiAweDNmKSB8IDB4ODA7XG5cbiAgLy8gQ29weSBieXRlcyB0byBidWZmZXIsIGlmIHByb3ZpZGVkXG4gIGlmIChidWYpIHtcbiAgICBmb3IgKHZhciBpaSA9IDA7IGlpIDwgMTY7ICsraWkpIHtcbiAgICAgIGJ1ZltpICsgaWldID0gcm5kc1tpaV07XG4gICAgfVxuICB9XG5cbiAgcmV0dXJuIGJ1ZiB8fCBieXRlc1RvVXVpZChybmRzKTtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSB2NDtcbiJdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./node_modules/uuid/v4.js\n");



I added following stuff in my vue.config.js The stuff in configureWebpack: {} for debugging and transpileDependencies:[] to transpile all dependencies to older Ecmascript Syntax to get my Website running in Internet Explorer 11.

configureWebpack: {
        optimization: {
      runtimeChunk: 'single',
        splitChunks: {
          chunks: 'all',
          maxInitialRequests: Infinity,
          minSize: 0,
          cacheGroups: {
            vendor: {
              test: /[\\/]node_modules[\\/]/,
              name(module) {
              // get the name. E.g. node_modules/packageName/not/this/part.js
              // or node_modules/packageName
              const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];

              // npm package names are URL-safe, but some servers don't like @ symbols
              return `npm.${packageName.replace('@', '')}`;
            }
          }
        }
      }
    }
    },
    productionSourceMap: false,
    transpileDependencies: ['date-fns','debounce','leaflet','leaflet-defaulticon-compatibility',
    'loglevel','marked','node-fetch','sanitize-html','url-search-params-polyfill','uuid','v-emoji-picker','vue','whatwg-fetch','escape-string-regexp'
    ],

But unfortunately it didnt help.

On npm run serve i get following Error in Internet Explorer 11:

npm.escape-string-regexp.js (11,1)

On npm run build i get following Error if i start Index.html in Internet Explorer 11:

identifier expected: (function(e){let{existsSync:r,readFileSync:i}=n(3),{dirname:o,join:s}=n(“df7c”),a=n(“dc74”);function c(t){return e?e.from(t,“base64”).toString():window.atob(t)}class u
Chatwidget is undefined in Index.html: window.addEventListener(‘DOMContentLoaded’, function(){
Chatwidget.initChatWidget(document.getElementById(‘chatwidget’), ChatwidgetConfig, ChatwidgetUser);
2 Answers

Thanks to you all. My problem was solved. Problem for Internet Explorer is the “sanitize-html”: “^2.3.2” and "emoji-picker”: “^2.3.1” . Both dependencies arent compatible with IE 11. Solution: Build 2 versions: 1 for IE and 1 for modern browsers like Chrome, Firefox and Edge.

It could be that some dependency of yours is using ES6 syntax.

By default babel-loader ignores all files inside node_modules. If you want to explicitly transpile a dependency with Babel, you can list it in this option

transpileDependencies

You need to find out which one it is and add it to transpileDependencies - vue.config.js

Also the error message is very strange - function(e){let{existsSync:r,readFileSync:i} - both existsSync and readFileSync look like Node API. So check you don't use any Node package for browser app (for example node-fetch is definitely Node only lib and will not work inside the browser)

Related