New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UglifyJs compile exception with @aspnet/signalr-client #867

Closed
damienbod opened this Issue Sep 13, 2017 · 10 comments

Comments

Projects
None yet
5 participants
@damienbod

damienbod commented Sep 13, 2017

The following 2 lines causes an UglifyJs compile exception:

UglifyJs Unexpected token: name (NullLogger)

const httpConnection = new HttpConnection('/loopy');
this._hubConnection = new HubConnection(httpConnection);

https://dotnet.myget.org/feed/aspnetcore-ci-dev/package/npm/@aspnet/signalr-client

package version: 1.0.0-alpha1-26985

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Sep 13, 2017

Member

@damienbod Just as an FYI, that can be simplified to:

this._hubConnection = new HubConnection('/loopy');

The Uglify issue came up before here #729 (comment). It's an ES5 vs ES6 issue.

Member

davidfowl commented Sep 13, 2017

@damienbod Just as an FYI, that can be simplified to:

this._hubConnection = new HubConnection('/loopy');

The Uglify issue came up before here #729 (comment). It's an ES5 vs ES6 issue.

@damienbod

This comment has been minimized.

Show comment
Hide comment
@damienbod

damienbod Sep 13, 2017

@davidfowl This fix did not work. I replaced the lines here:

https://github.com/damienbod/AspNetCoreAngularSignalR/blob/master/src/AspNetCoreAngularSignalR/config/webpack.prod.js#L100

This is where I do the Uglify configuration for the production build
package.json

https://github.com/damienbod/AspNetCoreAngularSignalR/blob/master/src/AspNetCoreAngularSignalR/package.json

tried:

new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            },
            parallel: {
                cache: true,
                workers: 2
            },
            sourceMap: false
        }),

damienbod commented Sep 13, 2017

@davidfowl This fix did not work. I replaced the lines here:

https://github.com/damienbod/AspNetCoreAngularSignalR/blob/master/src/AspNetCoreAngularSignalR/config/webpack.prod.js#L100

This is where I do the Uglify configuration for the production build
package.json

https://github.com/damienbod/AspNetCoreAngularSignalR/blob/master/src/AspNetCoreAngularSignalR/package.json

tried:

new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            },
            parallel: {
                cache: true,
                workers: 2
            },
            sourceMap: false
        }),
@damienbod

This comment has been minimized.

Show comment
Hide comment
@damienbod

damienbod Sep 13, 2017

Looks like webpack.optimize.UglifyJsPlugin is not ready yet for this, so The SignalR lib cannot be uglified.

damienbod commented Sep 13, 2017

Looks like webpack.optimize.UglifyJsPlugin is not ready yet for this, so The SignalR lib cannot be uglified.

@damienbod

This comment has been minimized.

Show comment
Hide comment
@damienbod

damienbod Sep 13, 2017

This works if you use the new uglify packages, not the old. new packages => S is a capital letter... @FabianGosebrink thanks for your help.

The fix:

Step 1:

in the package.json add:

"uglifyjs-webpack-plugin": "1.0.0-beta.2",

Step 2:

add the UglifyJSPlugin webpack plugin (S is capital), in the webpack production build file

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

Step 3:

Update the webpack production build

        new UglifyJSPlugin({
            parallel: {
                cache: true,
                workers: 2
            }
        }),

damienbod commented Sep 13, 2017

This works if you use the new uglify packages, not the old. new packages => S is a capital letter... @FabianGosebrink thanks for your help.

The fix:

Step 1:

in the package.json add:

"uglifyjs-webpack-plugin": "1.0.0-beta.2",

Step 2:

add the UglifyJSPlugin webpack plugin (S is capital), in the webpack production build file

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

Step 3:

Update the webpack production build

        new UglifyJSPlugin({
            parallel: {
                cache: true,
                workers: 2
            }
        }),
@moozzyk

This comment has been minimized.

Show comment
Hide comment
@moozzyk

moozzyk Sep 13, 2017

Contributor

This is because of Uglify not supporting ES6. See also #729 (which contains the same workaround you have)

Contributor

moozzyk commented Sep 13, 2017

This is because of Uglify not supporting ES6. See also #729 (which contains the same workaround you have)

@damienbod damienbod closed this Sep 14, 2017

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Sep 14, 2017

Member

Lets put this in the known issues

Member

davidfowl commented Sep 14, 2017

Lets put this in the known issues

@moozzyk

This comment has been minimized.

Show comment
Hide comment
@moozzyk

moozzyk Sep 14, 2017

Contributor

Done

Contributor

moozzyk commented Sep 14, 2017

Done

@williamBurgeson

This comment has been minimized.

Show comment
Hide comment
@williamBurgeson

williamBurgeson Sep 25, 2017

This might be fixed with angular/angular-cli#7610 - I will probably be checking this in the near future...

williamBurgeson commented Sep 25, 2017

This might be fixed with angular/angular-cli#7610 - I will probably be checking this in the near future...

@pieterlouw1974

This comment has been minimized.

Show comment
Hide comment
@pieterlouw1974

pieterlouw1974 Sep 29, 2017

What i did to get it working
tsconfig.app.json
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2017",
"dom"
],
"outDir": "../out-tsc/app",
"target": "es6",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}

tsconfig.jason
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}

package,jason
"devDependencies": {
"@angular/cli": "1.5.0-beta.1",
"@angular/compiler-cli": "4.4.4",

angular 4.4.4

pieterlouw1974 commented Sep 29, 2017

What i did to get it working
tsconfig.app.json
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2017",
"dom"
],
"outDir": "../out-tsc/app",
"target": "es6",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}

tsconfig.jason
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}

package,jason
"devDependencies": {
"@angular/cli": "1.5.0-beta.1",
"@angular/compiler-cli": "4.4.4",

angular 4.4.4

selfdeceited added a commit to selfdeceited/bird-aggregator that referenced this issue Jan 4, 2018

aiten added a commit to aiten/CNCLib that referenced this issue Feb 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment