要解决你的编译问题,请确保你已经安装@types/d3
npm install @types/d3
要解决的AOT相对路径问题(假设你指的是相对于模板的URL),您应内嵌您的模板文件,在使用rollup
之前进行预构建步骤。
例如,使用内嵌咕嘟咕嘟你的HTML组件模板和工具,称为inlineNg2Template
:
gulp.task('compile:es6', function() {
return gulp.src(['./src/**/*.ts'])
.pipe(inlineNg2Template({ base: '/src', useRelativePaths:true }))
.pipe(tsc({
"target": "es5",
"module": "es6",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"lib": ["es6", "dom"]
}))
.pipe(gulp.dest('./dist/src'));
});
注:module
系统必须es6
的汇总工作。虚假
gulp.task('rollup:module', function() {
return rollup.rollup({
entry: pkg.main,
onwarn: function (warning) {
// Skip certain warnings
// should intercept ... but doesn't in some rollup versions
if (warning.code === 'THIS_IS_UNDEFINED') { return; }
// intercepts in some rollup versions
if (warning.message.indexOf("The 'this' keyword is equivalent to 'undefined'") > -1) { return; }
if (warning.message.indexOf("treating it as an external dependency") > -1) { return; }
if (warning.message.indexOf("No name was provided for external module") > -1) { return; }
// console.warn everything else
console.warn(warning.message);
}
}).then(function (bundle) {
bundle.write({
dest: `dist/${pkg.name}.bundle.umd.js`,
format: 'umd',
exports: 'named',
moduleName: pkg.name,
globals: {
}
});
bundle.write({
dest: `dist/${pkg.name}.bundle.cjs.js`,
format: 'cjs',
exports: 'named',
moduleName: pkg.name,
globals: {
}
});
bundle.write({
dest: `dist/${pkg.name}.bundle.amd.js`,
format: 'amd',
exports: 'named',
moduleName: pkg.name,
globals: {
}
});
});
});
Demo Starter App with AOT
在你tsconfig.json集 “noImplicitAny”:
然后你
rollup
咕嘟咕嘟任务可以创建UMD,AMD和CJS束。 –