akserg / ng2-slim-loading-bar

Angular 2 component shows slim loading bar at the top of the page.
MIT License
358 stars 93 forks source link

Trouble when switching to 2.0.5 from 2.0.4 #28

Open nlko opened 7 years ago

nlko commented 7 years ago

Hello,

I'm submitting a ... (check one with "x")

[X] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

My angular2 project is using ng2-slim-loading-bar and as such it is referenced in package.json and systemjs config file and other ts files.

I tried to upgrade from 2.0.4 to 2.0.5 (using npm) and I had some issues in firefox and chrome (see below). I've no need for switching to 2.0.5 for now so I'll stay to 2.0.4 but tell me if I can be of any help.

Error message in the firefox console :

Error: patchProperty/desc.set/wrapFn@http://manager.loc/node_modules/zone.js/dist/zone.js:698:26
    ZoneDelegate.prototype.invokeTask@http://manager.loc/node_modules/zone.js/dist/zone.js:265:21
    Zone.prototype.runTask@http://manager.loc/node_modules/zone.js/dist/zone.js:154:28
    ZoneTask/this.invoke@http://manager.loc/node_modules/zone.js/dist/zone.js:335:28

    Error loading http://manager.loc/traceur
    Error loading http://manager.loc/node_modules/ng2-slim-loading-bar/index.js as "ng2-slim-loading-bar" from http://manager.loc/app/app.module.js

Chrome console has a similar error :

GET http://manager.loc/traceur 404 (Not Found)
scheduleTask @ zone.js:1382
ZoneDelegate.scheduleTask @ zone.js:245
Zone.scheduleMacroTask @ zone.js:171
(anonymous) @ zone.js:1405
send @ VM889:3
fetchTextFromURL @ system.src.js:1156
(anonymous) @ system.src.js:1739
ZoneAwarePromise @ zone.js:518
(anonymous) @ system.src.js:1738
(anonymous) @ system.src.js:2764
(anonymous) @ system.src.js:3338
(anonymous) @ system.src.js:3605
(anonymous) @ system.src.js:3990
(anonymous) @ system.src.js:4453
(anonymous) @ system.src.js:4705
(anonymous) @ system.src.js:408
ZoneDelegate.invoke @ zone.js:232
Zone.run @ zone.js:114
(anonymous) @ zone.js:502
ZoneDelegate.invokeTask @ zone.js:265
Zone.runTask @ zone.js:154
drainMicroTaskQueue @ zone.js:401
ZoneTask.invoke @ zone.js:339
(index):37 Error: Error: XHR error (404 Not Found) loading http://manager.loc/traceur
        at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://manager.loc/node_modules/zone.js/dist/zone.js:698:29)
        at ZoneDelegate.invokeTask (http://manager.loc/node_modules/zone.js/dist/zone.js:265:35)
        at Zone.runTask (http://manager.loc/node_modules/zone.js/dist/zone.js:154:47)
        at XMLHttpRequest.ZoneTask.invoke (http://manager.loc/node_modules/zone.js/dist/zone.js:335:33)
    Error loading http://manager.loc/traceur
    Error loading http://manager.loc/node_modules/ng2-slim-loading-bar/index.js as "ng2-slim-loading-bar" from http://manager.loc/app/app.module.js

Some people tend to say that this error could come from systemjs so here is my config

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function(global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },

    map: {

...
      'ng2-slim-loading-bar': 'npm:ng2-slim-loading-bar',
...

    },

    packages: {
...
      'ng2-slim-loading-bar': {
        main: 'index.js',
        defaultExtension: 'js'
      },

...
    }
  });
})(this);

Expected/desired behavior

Same as in 2.0.4

Reproduction of the problem

Difficult to say, maybe specificaly linked to my project but I don't think I'm using it in a border line way.

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

vchuquimia commented 7 years ago

having the same issue, any news ?

akserg commented 7 years ago

Hi @nlko and @vchuquimia,

Try to update your config file such that:

map: {
   'ng2-slim-loading-bar': 'npm:ng2-slim-loading-bar'
},
packages: {
  'ng2-slim-loading-bar':  { defaultExtension: 'js' },
}

Let me know if it fixes your issue?

cacogr commented 7 years ago

I also get an error using v2.0.5 (2.0.7 too) and angular-cli last version (beta.24). It was working fine with v2.0.4 and angular-cli beta.22-1 which was the last version that allowed non-AoT compatible libraries.

Inspecting the index.d.ts file in the npm package I see a lambda in the providers, which is not allowed in AoT (see https://github.com/rangle/angular-2-aot-sandbox#func-in-providers-usefactory-top)

index.d.ts

import { ModuleWithProviders } from "@angular/core";
import { SlimLoadingBarService } from './src/slim-loading-bar.service';
export * from './src/slim-loading-bar.component';
export * from './src/slim-loading-bar.service';
export declare let providers: {
    provide: typeof SlimLoadingBarService;
    useFactory: () => SlimLoadingBarService;  // <-- HERE
}[];
export declare class SlimLoadingBarModule {
    static forRoot(): ModuleWithProviders;
}

@akserg Checking index.ts in master it looks like an older version of declaration files were being published, but I might be wrong. Can you check please?

EDIT: nevermind. I have a wrapper module and the problem was that the way of providing the loading bar service changed and I was getting "No provider for EventEmmiter". Working fine for me now.

akserg commented 7 years ago

Hi @cacogr Can you please delete node_modules and reinstall them again via the npm install command. After that please try to run server.