Accessing webpack bundled libraries in the browser

后端 未结 3 937
余生分开走
余生分开走 2021-02-05 07:59

I\'m having trouble accessing a webpack bundled library from the browser.

Example: I have a class Foo

// foo.js

\"use strict\";

export de         


        
3条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 08:49

    One of the major advantages of Webpack and ES2015 modules is that it stops polluting the global namespace by default.

    Because of this, if you want to publish something on the global object, you have to do it explicitly. I recommend namespacing your classes to something unique to the application or company, so you don't risk a naming collision with anything else.

提交回复
热议问题