【发布时间】:2020-09-01 18:50:24
【问题描述】:
自从我在我的 Svelte 应用程序上安装了 svelte-i18n 库后,我在编译 Rollup 时收到了以下警告。
(!) `this` has been rewritten to `undefined`
我还插入了整个错误堆栈跟踪,因为它可能有用:
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules\intl-messageformat\lib\core.js
4: See the accompanying LICENSE file for terms.
5: */
6: var __assign = (this && this.__assign) || function () {
^
7: __assign = Object.assign || function(t) {
8: for (var s, i = 1, n = arguments.length; i < n; i++) {
...and 1 other occurrence
node_modules\intl-messageformat\lib\formatters.js
1: var __extends = (this && this.__extends) || (function () {
^
2: var extendStatics = function (d, b) {
3: extendStatics = Object.setPrototypeOf ||
...and 3 other occurrences
node_modules\intl-format-cache\lib\index.js
4: See the accompanying LICENSE file for terms.
5: */
6: var __spreadArrays = (this && this.__spreadArrays) || function () {
^
7: for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
8: for (var r = Array(s), k = 0, i = 0; i < il; i++)
...and 1 other occurrence
...and 3 other files
created public\build\bundle.js in 1.3s
如果与此处描述的不同,我相信此错误非常相似: https://github.com/kaisermann/svelte-i18n/blob/master/docs/FAQ.md#this-keyword-is-equivalent-to-undefined
本应用中提到的库有以下版本:
"svelte": 3.22.2
"svelte-i18n": 3.0.3
似乎这个警告不是问题,但是对我来说非常烦人。 我真的不喜欢他们在这种情况下给出的解决方案(“学会忍受那个警告并忽略它”)。有什么方法可以指示编译器忽略该错误或有人已经设法修复它?
编辑:
我的问题是在 windows 上(因此是反斜杠),库如下:
'node_modules\\intl-messageformat\\lib\\core.js',
'node_modules\\intl-messageformat\\lib\\compiler.js',
'node_modules\\intl-messageformat\\lib\\formatters.js',
'node_modules\\intl-format-cache\\lib\\index.js',
'node_modules\\intl-messageformat-parser\\lib\\skeleton.js',
'node_modules\\intl-messageformat-parser\\lib\\normalize.js',
'node_modules\\intl-messageformat-parser\\lib\\parser.js',
【问题讨论】: