0

The release of AngularCLI abandon SystemJS in favor of WebPack.

However SyncFusion hasn't supported WebPack yet in there EJ2 library for Angular. They instruct to use SystemJS to map

"@syncfusion/ej2-grids": "node_modules/@syncfusion/ej2-grids/dist/ej2-grids.umd.min.js",
"@syncfusion/ej2-ng-grids": "node_modules/@syncfusion/ej2-ng-grids/dist/ej2-ng-grids.umd.min.js",

in this tutorial http://ej2.syncfusion.com/angular/documentation/grid/getting-started.html#configuring-system-js

How can I work around this dependency and make it compatible with WebPack while waiting for SyncFusion to support it?

2 Answers 2

1

Same thing is done in Webpack with resolve.alias:

...
resolve: {
  alias: {
    "@syncfusion/ej2-grids$": "@syncfusion/ej2-grids/dist/ej2-grids.umd.min.js",
    ...
}

The reason why mappings are used in SystemJS is that a single prebuilt UMD file can be transferred instead of transfering and building separate files. This is not an issue for Webpack. While UMD module can speed up the process a bit, using unbundled ES6 modules from a package (if available) allows to use tree shaking and may reduce application footprint.

8
  • I tried to use your solution after the project is ejected using "ng eject". After that the project failed to build with the message informs ""@syncfusion/ej2-grids" not found
    – LxL
    Aug 9, 2017 at 20:09
  • Did you have problems with it? Is there a reason why you decided to remap the module to UMD bundle? Usually it's never needed in Webpack for properly published packages, for the reasons listed in the answer. Aug 9, 2017 at 20:24
  • My main issue is about the GridComponent in the template that couldn't find the properties called datasource,groupsettings,allowgrouping which are not declared in GridComponent but in its parernt Grid which is not a angular component. The only thing I missed from the tutorial is the configure SystemJS part which does not exist when using AngularCLI. That's why I started looking for the alternative using Webpack
    – LxL
    Aug 9, 2017 at 21:28
  • I may have miss something here because I have not yet understood how the resolving dependencies works for inheritance in JavaScript.
    – LxL
    Aug 9, 2017 at 21:32
  • I'm not sure what you mean. Webpack and ES6 modules don't intervene with how components are used in Angular. Webpack just packs source files together. If you have problems with this package, they likely should be solved differently. As it was said above, usually it's unnecessary to fine-tune Webpack config like that if used packages were designed properly (and it looks like @syncfusion were). Aug 10, 2017 at 1:38
-2

Essential JS2 Angular components have Webpack support without any workaround. Please find the code snippet

var webpack = require('webpack');
module.exports = {
entry: {
    'app': './app/main.ts'
},

resolve: {
    extensions: ['.js']
},
output: {
    path: __dirname + '/dist',
    publicPath: '/',
    filename: 'app.js',
}
};

webpack sample link: https://github.com/Madhust/ej2-grid-angular-webpack

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.