I'm using VS2015 RC3, Angular2 2.0.0 on an ASP.NET Core solution using IIS.
Whenever I try to add a new UI module such as dropdowns or inputs, I get a SystemJS error, but the weird thing is that my buttons work without any issue...
master.module.ts :
import { ButtonsModule } from '@progress/kendo-angular-buttons';
import { DropDownsModule } from '@progress/kendo-angular-dropdowns';
import { InputsModule } from '@progress/kendo-angular-inputs';
@NgModule({
imports: [
CommonModule,
MasterRouting,
ButtonsModule, // => Works fine and button is showing as expected
InputsModule, // Error : Unexpected Token
DropDownsModule // Error : Unexpected Token
],
[...]
I get these errors (depending on which module I try to add in my "imports" array :
InputsModule error : pointing at the import line in my master.modules.ts
zone.js:192 Error: (SystemJS) Unexpected token < SyntaxError: Unexpected token < at Object.eval (http://localhost:39351/app/master/master.module.js:35:30)
DropdownsModule error :
zone.js:192 Error: (SystemJS) Unexpected token < SyntaxError: Unexpected token < at Object.eval (http://localhost:39351/node_modules/@progress/kendo-angular-dropdowns/dist/npm/js/combobox.component.js:630:19)
this one shows me the import in the kendo library :
module.exports = require("@telerik/kendo-dropdowns-common/dist/npm/js/bundle");
which I made sure I had in my wwwroot...
EDIT : As you can see in the error list, it's trying to evaluate the @telerik bundle with an incorrect path, so I guess the error is coming from there, but then why don't they setup SystemJS configuration for the telerik packages in the documentation ? Am I missing something there ?
I'm completely lost, so any help with be greatly appreciated...
Here are some others files in case they help :
tsconfig.json :
{
"compilerOptions": {
"outDir": "./wwwroot/app/",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"inlineSourceMap": true,
"inlineSources": true
},
"exclude": [
"./node_modules/**",
"./wwwroot/**",
"./typings/**"
]
}
systemjs.config.js :
(function (global) {
// map tells the System loader where to look for things
var map = {
// Our components
'app': 'app', // 'dist',
// Angular2 + rxjs
'@angular': 'node_modules/@angular',
'rxjs': 'node_modules/rxjs',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
// Kendo Angular2
'@progress/kendo-angular-buttons': 'node_modules/@progress/kendo-angular-buttons',
'@progress/kendo-angular-dropdowns': 'node_modules/@progress/kendo-angular-dropdowns',
'@progress/kendo-angular-inputs': 'node_modules/@progress/kendo-angular-inputs',
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
// Our components
'app': { defaultExtension: 'js'},
// Angular2 + rxjs
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'@progress/kendo-angular-buttons': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'@progress/kendo-angular-dropdowns': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'@progress/kendo-angular-inputs': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
};
/**** node_modules basic config ! Do not touch ****/
// name of packages to assimilate (angular 2 only here)
var ngPackageNames = [
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade',
];
// Individual files (~300 requests):
function packIndex(pkgName) {
packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' };
}
// Bundled (~40 requests):
function packUmd(pkgName) {
packages['@angular/' + pkgName] = { main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}
// Most environments should use UMD; some (Karma) need the individual index files
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
// Add package entries for angular packages
ngPackageNames.forEach(setPackageConfig);
var config = {
map: map,
packages: packages
};
System.config(config);
/**** node_modules basic config ! Do not touch ****/
})(this);
Well I also have examined this problem and it seems their button quickstart systemjs.config.js is different then their button plunkr code sample systemjs.config.js so I am asking them for guidance as to the correct approach.
It was indeed because of the @telerik packages not being managed in SystemJS...
As you can follow the Telerik documentation, you can see in the plunkr links the @telerik packages to add to the systemjs.config.js file.
See this link : http://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/
I can see in the npm dependencies the different dependencies between the packages, and if the Telerik team is not mentionning them, it probably means one must not worry about it as it should be managed with dependencies.
This is the only logical explanation to me, and that means I don't use the systemJS file correctly. Comments are welcome to complete this answer.