almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

vis network with Polymer 3 on Chrome TypeError: Cannot set property 'vis' of undefined at webpackUniversalModuleDefinition #4282

Open scenaristeur opened 5 years ago

scenaristeur commented 5 years ago

Starting point : Polymer3 starter-kit as described here : https://pwa-starter-kit.polymer-project.org/setup

with

git clone --depth 1 https://github.com/Polymer/pwa-starter-kit my-app
cd my-app

then i installed vis with "npm install --save vis"

I run it with 'npm run start'

My network is shown in Firefox 66, but in Chrome 73, I got this error

vis.js:26 Uncaught (in promise) TypeError: Cannot set property 'vis' of undefined
    at webpackUniversalModuleDefinition (vis.js:26)
    at vis.js:26

it looks that the root is undefind with Polymer and the modules so I added this two lines

    else if (typeof exports == 'undefined' && typeof module == 'undefined'&& typeof define == 'undefined')
      window['vis'] =  factory();

in webpackUniversalModuleDefinition of vis.js, like that


    if(typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if(typeof define === 'function' && define.amd)
        define([], factory);
    else if(typeof exports === 'object')
        exports["vis"] = factory();
    else if (typeof exports == 'undefined' && typeof module == 'undefined'&& typeof define == 'undefined')
      window['vis'] =  factory();
  else
        root["vis"] = factory();

here is the result after modification https://spoggyfr.netlify.com/ and the source is here https://github.com/scenaristeur/spoggyfr

and the network appear in Chrome. Do you think it is a problem with vis ? Polymer ? Webpack ? Thanks