Bundler & Minifier 因使用严格而失败
Bundler & Minifier failing because of using strict
我正在使用 libman.json 将客户端库从 cdnjs 拉到我项目的文件夹中。然后我想将这些库捆绑并缩小到一个 js 文件中,该文件将在 Web 应用程序中部署和引用。为此,我使用了一个名为 Bundler & Minifier 的 visual studio 扩展。我在我的 bundle.config 中设置了所有内容,但我 运行 遇到了我试图捆绑的库之一的问题。具体来说,如果我尝试在捆绑包中包含 Chart.js (2.8.0),我会在构建时收到以下错误:
(Bundler & Minifer) Strict-mode does not allow assignment to undefined
variables: r
这不应该是警告而不是错误吗?我看不出这应该如何防止 bundling/minification 并导致构建失败。有没有办法覆盖此行为?
Shouldn't this be a warning and not an error?
不,因为这就是使用严格模式的全部意义所在,我们希望得到错误(而不是警告)。来自 mozilla developer refernce
Strict mode changes some previously-accepted mistakes into errors.
JavaScript was designed to be easy for novice developers, and
sometimes it gives operations which should be errors non-error
semantics. Sometimes this fixes the immediate problem, but sometimes
this creates worse problems in the future. Strict mode treats these
mistakes as errors so that they're discovered and promptly fixed.
如果你的第三方库有错误,你可以修复问题或者放弃库...如果你不想在你的本地项目中修复它,你可以提出一个问题here
undefined variables assignment issue 于 2019 年 3 月 18 日在 Chart.js GitHub 中提出。
为了手动修复它,在 Chart.js hwb2rgb(hwb)
函数中添加以下变量声明(第 343 行,v2.8.0):
var r, g, b;
我正在使用 libman.json 将客户端库从 cdnjs 拉到我项目的文件夹中。然后我想将这些库捆绑并缩小到一个 js 文件中,该文件将在 Web 应用程序中部署和引用。为此,我使用了一个名为 Bundler & Minifier 的 visual studio 扩展。我在我的 bundle.config 中设置了所有内容,但我 运行 遇到了我试图捆绑的库之一的问题。具体来说,如果我尝试在捆绑包中包含 Chart.js (2.8.0),我会在构建时收到以下错误:
(Bundler & Minifer) Strict-mode does not allow assignment to undefined variables: r
这不应该是警告而不是错误吗?我看不出这应该如何防止 bundling/minification 并导致构建失败。有没有办法覆盖此行为?
Shouldn't this be a warning and not an error?
不,因为这就是使用严格模式的全部意义所在,我们希望得到错误(而不是警告)。来自 mozilla developer refernce
Strict mode changes some previously-accepted mistakes into errors. JavaScript was designed to be easy for novice developers, and sometimes it gives operations which should be errors non-error semantics. Sometimes this fixes the immediate problem, but sometimes this creates worse problems in the future. Strict mode treats these mistakes as errors so that they're discovered and promptly fixed.
如果你的第三方库有错误,你可以修复问题或者放弃库...如果你不想在你的本地项目中修复它,你可以提出一个问题here
undefined variables assignment issue 于 2019 年 3 月 18 日在 Chart.js GitHub 中提出。
为了手动修复它,在 Chart.js hwb2rgb(hwb)
函数中添加以下变量声明(第 343 行,v2.8.0):
var r, g, b;