CirclonGroup / angular-tree-component

A simple yet powerful tree component for Angular (>=2)
https://angular2-tree.readme.io/docs
MIT License
1.09k stars 490 forks source link

Issue with mobx and SystemJs in 3.1.0 #210

Closed dae721 closed 7 years ago

dae721 commented 7 years ago

Trying to upgrade from 2.7 to 3.1. The only way I've been able to get it to work is to include mobx and ng2-mobx in my systemjs.config.js like this:

  var map = {
    ...
    'angular2-tree-component':    'angular2-tree-component/dist/angular2-tree-component.umd.js',
    'ng2-mobx':                   'ng2-mobx/dist',
    'mobx':                       'mobx/lib'
  };

  var packages = {
    ...
    'ng2-mobx':                   { main: 'ng2-mobx.umd.js', defaultExtension: 'js' },
    'mobx':                       { main: 'mobx.umd.js', defaultExtension: 'js' }
  };

Without this, I get the following ZoneAwareError when starting up (in this stack trace, folder-tree.component is my component which is doing this import: import { TreeComponent, TreeNode, ITreeOptions, IActionMapping, TreeModel, TREE_ACTIONS } from 'angular2-tree-component';)

"Unexpected token <
  Evaluating http://localhost:3000/ng2-mobx
  Evaluating http://localhost:3000/client/app/project/folder-tree.component.js
  Evaluating http://localhost:3000/client/app/project/project-view.component.js
  Evaluating http://localhost:3000/client/app/app.routes.js
  Evaluating http://localhost:3000/client/app/app.module.js
  Evaluating http://localhost:3000/client/app/main.js
  Loading app"

Not sure if I'm doing something wrong, or if there's an issue with the component.

dandee commented 7 years ago

+1 and why do I even need these additional dependencies installed? I've got tree-component working with version 1.x, tried to migrate to version 2.x but got some cryptic error so I held the migration back. Today I tried to migrate to the newest version and this stuff happened. I'm on the verge of abandoning this component in my app and starting looking up for something else. It's really frustrating.

Edit: even demo page does not load up successfully: https://angular2-tree.readme.io/v3.2.0 - DEMO: 404: Not Found.

adamkleingit commented 7 years ago

I just noticed that lodash and mobx are not bundled in my UMD bundle. I managed to bundle them together but tree-shaking is not working and the bundle is 850KB. I'll publish a new version and open an issue to reduce bundle size.

adamkleingit commented 7 years ago

Please upgrade to 3.2.2 - should resolve this.

BTW, can I ask what's the motivation to use SystemJS and not @angular/cli with webpack?

adamkleingit commented 7 years ago

Sorry, please use 3.2.3. Version 3.2.2 had a problem with lodash-es

dandee commented 7 years ago

Thank you! I've got it running now. Although I've got a 41 warning messages now on my debugging console: [mobx.array] Attempt to read an array index (0) that is out of bounds (0). Please check length first. Out of bound indices will not be tracked by MobX angular-tree-component.umd.js:1971

adamkleingit commented 7 years ago

Yes you can ignore that warning for now, but I will solve it some day....