gulpsignalrbabelify

Can not find modules while building the project with signalr package


I'm trying to use signalR in my react app. When I'm importing it like this:

import { HubConnection } from '@aspnet/signalr-client';

The build is going fine without uglify. But when I use uglify() it fails because of incompatibility of uglify and es6. I found the workaround:

import { HubConnection } from '@aspnet/signalr-client/dist/browser/signalr-clientES5-1.0.0-alpha2-final.js';

but now when I'm trying to build the project, I'm getting errors like that:

Cannot find module './HttpClient' from '...\node_modules\@aspnet\signalr-client\dist\browser'

These modules are located in

'...\node_modules\@aspnet\signalr-client\dist\src\...'

So, how to fix the build in this case?

The build task itself:

gulp.task('build', () => {
return browserify({
    entries: './wwwroot/js/client/app.jsx',
    extensions: ['.jsx'],
    debug: true
})
.transform('babelify', {
    presets: ['es2015', 'react'],
    plugins: ['transform-class-properties']
})
.bundle()
.on('error', function (err) {
    gutil.log(gutil.colors.red.bold('[browserify error]'));
    gutil.log(err.message);
    this.emit('end');
})
.pipe(source('app.bundle.js'))
.pipe(streamify(uglify().on('error', function(e){
    console.log(e);
 })))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('wwwroot/dist/client'));
});

Thanks in advance!


Solution

  • Use https://www.npmjs.com/package/@aspnet/signalr. You're using a deprecated and unsupported package.