5

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 ?

enter image description here

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);
Alex Beugnet
  • 4,003
  • 4
  • 23
  • 40

2 Answers2

1

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.

Josh
  • 11
  • 1
  • I made it work, so my advice would be to make something that looks like the plunkr so your systemJS takes the @telerik package dependencies as well. – Alex Beugnet Sep 19 '16 at 20:34
  • This should be a comment instead of an answer. Please either clarify your answer to remove the guesswork or remove the answer. Once you have sufficient reputation you can leave a comment instead. – David L Sep 19 '16 at 20:38
  • Well it was more like some helpful info that there was a delta between the 2 systemjs.config.js files, so people should examine that to solve the problem. Also Telerik has no guidance at this time they said. – Josh Sep 20 '16 at 13:26
  • I tried to match with plunkr and getting this error: Failed to load http://www.telerik.com/kendo-angular-ui/npm/node_modules/@progress/kendo-angular-dateinputs/dist/cdn/js/kendo-angular-dateinputs.js: The 'Access-Control-Allow-Origin' header has a value 'http://run.plnkr.co' that is not equal to the supplied origin. Origin 'http://localhost:5648' is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. – dev Sep 27 '17 at 19:54
0

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.

Alex Beugnet
  • 4,003
  • 4
  • 23
  • 40