Skip to content

3rd Party Library Installation with webpack #1696

@carlosfaria94

Description

@carlosfaria94

Hi, I'm trying to install a 3rd party library, generated with browsify (https://github.com/bitpay/bitcore-wallet-client), works well with Angular 1 in production.

But now trying to install with webpack, and fail.

angular-cli: 1.0.0-beta.11-webpack.2
node: 4.4.7
os: darwin x64 (Mac OSX El Capitan)

I'm doing this in a component, for example:

import * as Client from 'bitcore-wallet-client';

...

ngOnInit() {
    var bwc = new Client({
      baseUrl: 'https://bws.bitpay.com/bws/api',
      verbose: true
    });
}

The problem is with request (request/request#1529) library used.

The log:

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in '/node_modules/forever-agent'
 @ ./~/forever-agent/index.js 6:10-24
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./~/bitcore-wallet-client/lib/api.js
 @ ./~/bitcore-wallet-client/lib/index.js
 @ ./~/bitcore-wallet-client/index.js
 @ ./src/app/wallet/import/import.component.ts
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/node_modules/forever-agent'
 @ ./~/forever-agent/index.js 7:10-24
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./~/bitcore-wallet-client/lib/api.js
 @ ./~/bitcore-wallet-client/lib/index.js
 @ ./~/bitcore-wallet-client/index.js
 @ ./src/app/wallet/import/import.component.ts
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in '/node_modules/tough-cookie/lib'
 @ ./~/tough-cookie/lib/cookie.js 32:10-24
 @ ./~/request/lib/cookies.js
 @ ./~/request/index.js
 @ ./~/bitcore-wallet-client/lib/api.js
 @ ./~/bitcore-wallet-client/lib/index.js
 @ ./~/bitcore-wallet-client/index.js
 @ ./src/app/wallet/import/import.component.ts
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in '/node_modules/tunnel-agent'
 @ ./~/tunnel-agent/index.js 3:10-24
 @ ./~/request/lib/tunnel.js
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./~/bitcore-wallet-client/lib/api.js
 @ ./~/bitcore-wallet-client/lib/index.js
 @ ./~/bitcore-wallet-client/index.js
 @ ./src/app/wallet/import/import.component.ts
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/node_modules/tunnel-agent'
 @ ./~/tunnel-agent/index.js 4:10-24
 @ ./~/request/lib/tunnel.js
 @ ./~/request/request.js
 @ ./~/request/index.js
 @ ./~/bitcore-wallet-client/lib/api.js
 @ ./~/bitcore-wallet-client/lib/index.js
 @ ./~/bitcore-wallet-client/index.js
 @ ./src/app/wallet/import/import.component.ts
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

ERROR in [default] /src/app/wallet/import/import.component.ts:5:24 
Cannot find module 'bitcore-wallet-client'.

So, adding a webpack-config.js in https://github.com/bitpay/bitcore-wallet-client will solve the problem? Or we need to add this...

    net: 'empty',
    tls: 'empty'

in angular-cli webpack config file? Like we done here (#1599) with fs ?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenttype: bug/fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions