I'm learning more about Webpack and am running into an issue where my use of this
at the top level is getting replaced by (void 0)
.
(我正在学习有关Webpack的更多信息,并且遇到了一个问题,在该问题上,我在顶级使用this
正被(void 0)
代替。)
For context, the environment that is reading this JS requires my functions to exist on this
.(对于上下文,正在读取此JS的环境要求我的函数存在于this
。)
I assume it's converting this
into (void 0)
because it can't resolve the value of this
.
(我以为它转换this
成(void 0)
因为它不能解析的值this
。)
My configuration right now is very basic:
(我现在的配置非常基础:)
{
entry: inputPath,
output: {
path: outputPath,
filename: outputFilename
}
}
The JS in question looks like this:
(有问题的JS看起来像这样:)
Object.keys(commands).forEach((handler) => {
this[handler] = commands[handler];
});
And then the part of the Webpack compilation that I'm having trouble with looks like this:
(然后,我遇到问题的Webpack编译部分如下所示:)
Object.keys(o).forEach(n => {
(void 0)[n] = o[n]
})
So my question is, how can I tell Webpack to leave this
alone?
(所以我的问题是,我怎么能告诉的WebPack离开this
人吗?)
Form Googling around I can't seem to find a specific answer to the problem.(围绕Google搜索,我似乎无法找到该问题的具体答案。)
ask by Jody Heavener translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…