Ido*_*dov 8 javascript rollupjs angular
我正在尝试使用Rollup.js捆绑Angular2模块.这是我的rollup.config.vendor.js文件:
import typescript from 'rollup-plugin-typescript2';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
export default {
entry: 'vendor.ts',
dest: './Bundle/vendor.js',
format: 'iife',
moduleName: 'vendor',
plugins: [
typescript(),
resolve({
jsnext: true,
main: true,
browser: true
}),
commonjs({
include: 'node_modules/rxjs/**',
}),
]
}
Run Code Online (Sandbox Code Playgroud)
它创建了一个捆绑的js,但在这个过程中它会不断打印这种消息:
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
node_modules\@angular\forms\@angular\forms.es5.js (1:25)
1: var __extends = (this && this.__extends) || function (d, b) {
^
2: for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3: function __() { this.constructor = d; }
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
我做错了什么,或者它应该是这样的?
Dar*_*rov 14
您可以安全地忽略这些警告,如documentation通过将onwarn属性添加到您的rollup-config.js文件中所述:
onwarn: function(warning) {
// Skip certain warnings
// should intercept ... but doesn't in some rollup versions
if ( warning.code === 'THIS_IS_UNDEFINED' ) { return; }
// console.warn everything else
console.warn( warning.message );
}
Run Code Online (Sandbox Code Playgroud)
引用:
它会覆盖默认的onwarn方法,以便跳过有关AOT编译器使用this关键字的恼人消息.
您可以使用该context选项并将其设置为this:它避免重写thisto undefined(实际上this被重写为... this)。
请参阅汇总文档:
| 归档时间: |
|
| 查看次数: |
2383 次 |
| 最近记录: |