Babel generated code causes error exports is undefined

前端 未结 2 2004
忘了有多久
忘了有多久 2021-01-04 06:09

When this code (generated from babel) runs I get an error exports is undefined

Object.defineProperty(exports, \'__esModule\', {
<
2条回答
  •  情深已故
    2021-01-04 06:58

    I read an article about how ES6 import and export are only supposed to work in browser with "statically analyzable files" and Babel removed import and export support in the browser because of this. Something to do with async or possibly security?

    If you want to skip the server-side bundling for dev purposes, you can put

    window.MyModule = MyModule at the bottom, then import

    var MyModule = window.MyModule at the top of your next file

提交回复
热议问题