当我为我的 angular 4 应用程序执行 AOT 时,我遇到了一个问题,我在其中引用了 ap-angular2-fullcalendar。
以下是我在汇总配置中的配置.js
**
import rollup from 'rollup';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import includePaths from 'rollup-plugin-includepaths';
let includePathOptions = {
include: { 'core-module/core.module' : 'core-module/core.module.js' },
extensions: ['.js', '.json', '.html']
};
//paths are relative to the execution path
export default {
input: 'app/main-aot.js',
output : {
file: 'aot/dist/build.js', // output a single application bundle
format: 'iife'
},
sourcemap: true,
sourcemapFile: 'aot/dist/build.js.map',
plugins: [
includePaths(includePathOptions),
nodeResolve({jsnext: true, module: true}),
commonjs({
include: [
'core-module/**',
'app/**',
'node_modules/rxjs/**',
'node_modules/angular2-logger/**',
'node_modules/ng2-bs3-modal/**',
'node_modules/ng2-cookies/**',
'node_modules/ng2-toastr/**',
'node_modules/ng2-translate/**',
'node_modules/ng2-select/**',
'node_modules/jquery/**',
'node_modules/moment/**',
'node_modules/fullcalendar/**',
'node_modules/ap-angular2-fullcalendar/**'
],
namedExports: {
'node_modules/angular2-logger/core.js': [ 'Logger', 'Options', 'Level' ],
'node_modules/ng2-bs3-modal/ng2-bs3-modal.js' : [ 'ModalComponent' ],
'node_modules/ng2-cookies/ng2-cookies.js': [ 'Cookie' ],
'node_modules/ng2-select/index.js': ['SelectModule', 'SelectComponent']
}
}),
uglify()
]
}
**
然后在索引中.html我包括
<link rel="stylesheet" href="node_modules/fullcalendar/dist/fullcalendar.min.css"/>
<script src="/assets/References/jquery-3.2.1.min.js"></script>
<script src="/assets/References/jquery-2.2.0.min.js"></script>
<script src="node_modules/moment/min/moment.min.js"></script>
<script src="node_modules/fullcalendar/dist/fullcalendar.min.js"></script>
<script src="/aot/shim.min.js?v=2.1.4"></script>
<script src="/aot/zone.min.js?v=0.7.4"></script>
<script>window.module = 'aot';</script>
<script src="/aot/dist/build.js?v=2017.11.14"></script>
但是,当我浏览我的网站时,我在 fullcaledar.js 中出现以下错误。
未捕获的类型错误:"无法添加属性 fullCalendar,对象不可扩展">
在开发过程中,它可以工作,因为我正在使用systemjs.config.js并且它的配置如下
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
"app": 'app',
'jquery': 'node_modules/jquery/dist/jquery.min.js',
'bootstrap': 'node_modules/bootstrap/dist/js/bootstrap.min.js',
'moment': 'node_modules/moment',
'fullcalendar': 'node_modules/fullcalendar/dist/fullcalendar.js',
'ap-angular2-fullcalendar': 'node_modules/ap-angular2-fullcalendar'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
"app": {
main: './main.js',
defaultExtension: 'js'
},
'fullcalendar': {
defaultExtension: 'js'
},
'ap-angular2-fullcalendar': {
main: 'index.js',
defaultExtension: 'js'
}
}
});
})(this);
知道如何解决这个问题吗?我打算购买完整日历的许可证,但目前这是一种阻碍。
我可以看到FullCalendar.js是一个jQuery库。我从谷歌上的搜索中得到的,是对等依赖问题。避免在同一页面上使用多个版本的 jQuery。(索引.html(