简体   繁体   English

在 IE11 中使用独立的 ES6 模块

[英]Using a standalone ES6 module in IE11

I have a small ES6 module I wrote that needs to now be integrated into a project that has to support IE11.我写了一个小的 ES6 模块,现在需要将它集成到一个必须支持 IE11 的项目中。 The rest of the project is written in ES5 and ideally I'd like to just transpile my module and import it as a Script in the project's HTML and have the value it exports attached to the window object.项目的其余部分是用 ES5 编写的,理想情况下,我只想转译我的模块并将其作为脚本导入项目的 HTML 中,并将其导出的值附加到window对象。

I've tried a few different configurations for babel but they all seemed to be geared towards transpiling a complete bundle of code or required importing polyfills into the original module (which currently has no dependencies), but nothing seems to be compatible with IE11.我已经为 babel 尝试了几种不同的配置,但它们似乎都是为了转译完整的代码包或需要将 polyfill 导入原始模块(目前没有依赖项),但似乎没有任何东西与 IE11 兼容。

Module structure:模块结构:

const MyModule = (() => {
    const moduleStuff = {}
    function moduleLogic(params) {
          doStuff(params)
    }

    return {
        init: initParams => doStuff(initParams),
        moduleMethod: moduleData => {
            doStuff(moduleMethod)
        }
    }
})();

export default MyModule;

Not intended to be an answer, but with the link is too long for a comment.无意作为答案,但链接太长而无法发表评论。

With the typo removed, seems to look fine to me删除错字后, 对我来说似乎很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM