AlexRex / angular-event-service

:satellite: Service for sending global events with Angular 2 / 4.
4 stars 4 forks source link

Unexpected token: name (EventsServiceModule) #1

Open A50 opened 7 years ago

A50 commented 7 years ago

when my app, build in prod mode error: ERROR in vendor.774848f9d31e38c558d3.bundle.js from UglifyJs Unexpected token: name (EventsServiceModule) [vendor.774848f9d31e38c558d3.bundle.js:7767,4] How fix problem?

AlexRex commented 7 years ago

Which are the steps to reproduce the error? I am using it in prod mode and I have no errors so far.

A50 commented 7 years ago

i am migrate from angular2 to angular4. my app (angular4) in dev mode work without errors. I build app in prod mode, command ng build. Error in terminal Unexpected token: name (EventsServiceModule). And app not build.

AlexRex commented 7 years ago

Can you paste here your app.module.ts?

A50 commented 7 years ago
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { EventsServiceModule } from 'angular-event-service';

@NgModule({
  declarations: [
    AppComponent
    ....
  ],
  imports: [
    BrowserModule,  EventsServiceModule.forRoot(),
    .....
  ],
  providers: [...],
  bootstrap: [AppComponent]
})
export class AppModule { }
AlexRex commented 7 years ago

Could you try without the .forRoot() ?

imports: [
BrowserModule, EventsServiceModule,
.....
],
A50 commented 7 years ago

unfortunately it did not help me

A50 commented 7 years ago

reproduce error by: ng new testError npm i angular-event-service add app.module.ts EventsServiceModule ng build --prod

AlexRex commented 7 years ago

I just followed your instructions and I got it working.

Could you check your angular-cli version? Mine is 1.1.1, I also printed ng --version so you can checkout the versions I am using.

image

A50 commented 7 years ago

image error appears after adding the code in app.component.ts

import { Component } from '@angular/core';
import { EventsService } from 'angular-event-service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  constructor( private eventsService: EventsService) {
    this.eventsService.broadcast('test_error');
    this.eventsService.on('test_error', () => { console.log('test_error') });
  }
}
dt-designer commented 7 years ago

ERROR in vendor.774848f9d31e38c558d3.bundle.js from UglifyJs Unexpected token: name (EventsServiceModule) [vendor.774848f9d31e38c558d3.bundle.js:7767,4]

I have the same problem.

AlexRex commented 7 years ago

I will look for this when I have a bit more time.

A50 commented 7 years ago

i think, all the problems related to es6 syntax, one of the solutions to the problems that ng eject and the introduction of babel in the configuration of webpack. and try to run the command ng lint

flamasweb commented 7 years ago

Same problem here, any solution? I would avoid to eject the project..

----
@angular/cli: 1.4.3
node: 8.5.0
os: darwin x64
@angular/animations: 4.4.3
@angular/cdk: 2.0.0-beta.11
@angular/common: 4.4.3
@angular/compiler: 4.4.3
@angular/core: 4.4.3
@angular/forms: 4.4.3
@angular/http: 4.4.3
@angular/material: 2.0.0-beta.11
@angular/platform-browser: 4.4.3
@angular/platform-browser-dynamic: 4.4.3
@angular/router: 4.4.3
@angular/cli: 1.4.3
@angular/compiler-cli: 4.4.3
typescript: 2.5.2
behzad888 commented 6 years ago

What is the state of this issue?

behzad888 commented 6 years ago

I updated angular/cli to 1.6.7 then it works for me.