Firebase ionic2-rc0和汇总 - “汇总:强烈建议使用`eval`”
我已将我的离子应用程序从beta 11更新为rc0。所以这意味着我已经从angular2 rc4切换到了angular2 stable,从typescript 1.8到2以及使用rollupjs模块捆绑器。Firebase ionic2-rc0和汇总 - “汇总:强烈建议使用`eval`”
我照着这篇博客配置AngularFire2: Getting Started with Ionic 2 RC0, Firebase 3 + AngularFire 2
我不能编译,收到此错误:
rollup: Use ofeval(in c:\XXX\node_modules\angularfire2\node_modules\firebase\firebase.js) is strongly discouraged, as it poses security risks and may cause issues with minification. See https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval for more details
任何人都知道这是怎么回事,如何解决呢?
长期的解决方案是火力地堡从他们的代码中删除直接eval
,因为它实际上不是必要在这里(它只是被用来解析JSON。JSON.parse
的速度要快得多,并且支持基本上是一个不是问题的问题,这些天)。
在此期间,可能(虽然哈克)解决方法可能是该eval
转换成间接eval
(见troubleshooting note理解上的差异),用rollup-plugin-replace:
// rollup.config.js
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
// ...etc
export default {
// ...other config...
plugins: [
nodeResolve({...}),
commonjs({...}),
replace({
include: 'node_modules/firebase/firebase.js',
values: {
'eval(' : '[eval][0]('
}
})
]
};
您可以禁用此汇总配置中的警告:
// rollup.config.js
export default {
// ...other config...
onwarn: function (message) {
if (/Use of `eval` \(in .*\/node_modules\/firebase\/.*\) is strongly discouraged/.test(message)) {
return;
}
console.error(message);
}
};
谢谢您的回复。我想我在其他地方有更严重的错误,这就是为什么我无法编译。 我认为使用eval不是一个突破错误,所以我会保持原样。 再次感谢, – Dee