With Angular 2 (cli), When running ng build --prod, I get a very strange error, that makes me believe that isn't the error at all.
He says there is something wrong on line 5 of this file:
import { Injectable } from '@angular/core';
import * as io from "socket.io-client";
@Injectable()
export default class SocketService {
socket;
//
// constructor() {}
//
init() {
// this.socket = io('localhost:3000');
}
}
It gives this error:
ERROR in main.b1e7bf5cf9ed04b8ff8d.bundle.js from UglifyJs
SyntaxError: Unexpected token: name (SocketService)
[/Users/kewinbrandsma/Projects/TradeJS/~/angular2-template-loader!/Users/kewinbrandsma/Projects/TradeJS/src/client/app/services/socket.service.ts:5,0][main.b1e7bf5cf9ed04b8ff8d.bundle.js:3265,4
While running it with ng serve (dev mode) gives no errors at all and works perfectly. So its really something UglifyJS doesn't like..
The error stack shows a line number for the 'pre-compiled bundle.js'. (main.b1e7bf5cf9ed04b8ff8d.bundle.js:3265,4) but I can't seem to find the file, as it probably still only lives in memory.
Is it always destroyed after a unsuccessful build, or is there a way to write to disk even when uglify complains? Cause it makes it impossible to debug the Uglify Error
It seems to have something todo with https://github.com/angular/angular-cli/issues/1333
So for now, just to run 1 (none minified) build, I disable Uglify entirely in webpack-build-production.js.. But this file lives in the angular node_modules, so its not a solution at all.