在 webpack 中使用 Set polyfill 不能解决错误

Using Set polyfill in webpack doesn't resolve errors

我在旧版浏览器上发现一些 "Can't find variable: Set" 生产错误。我认为这是 Typescript 和 Webpack 对 es6 功能的使用雄心勃勃,没什么大不了的,我可以像我为 React Object.assign polyfill 一样进行 polyfill。

现在我的 webpack Polyfill 配置如下所示:

// using include in the callback selection requires a polyfill for ie
require('string.prototype.includes');

// some older browsers don't support Set, which apparently something compiles to
require('es6-set');

// fetch() polyfill for making API calls.
require('whatwg-fetch');

// Object.assign() is commonly used with React.
// It will use the native implementation if it's present and isn't buggy.
Object.assign = require('object-assign');

但在发布并验证发布后,我仍然看到旧版浏览器中与 Set 相关的错误。我查看了将 polyfill 添加到 webpack 的文档,但我不知道我是否遗漏了一个步骤或为什么这不起作用。

我做错了什么,或者我还能尝试什么?

您的代码:

// some older browsers don't support Set, which apparently something compiles to
require('es6-set');

不遵循项目的自述文件:https://www.npmjs.com/package/es6-set

修复

来自自述文件:

require('es6-set/implement');