question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

removing node-shims in v6.0.0 breaks ngx-mqtt

See original GitHub issue

I understand the motivation of removing node-shims, but it breaks my library and I currently don’t know how to work around this.

Versions

Angular CLI: 6.0.0-rc.5
Node: 8.11.1
OS: linux x64
Angular: 6.0.0-rc.3
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.5.4
@angular-devkit/build-angular      0.5.4
@angular-devkit/build-ng-packagr   0.5.4
@angular-devkit/build-optimizer    0.5.4
@angular-devkit/core               0.5.4
@angular-devkit/schematics         0.5.7
@angular/cli                       6.0.0-rc.5
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.0.0-rc.2.4
@schematics/angular                0.5.7
@schematics/update                 0.5.7
rxjs                               6.0.0-tactical-rc.1
typescript                         2.7.2
webpack                            4.5.0

Repro steps

Running an application with a ngx-mqtt@6.0.0-alpha.8 build of my library results in an error that process is not defined.

Observed behavior

index.js:3 Uncaught ReferenceError: process is not defined
    at Object../node_modules/process-nextick-args/index.js (index.js:3)
    at __webpack_require__ (bootstrap:74)
    at Object../node_modules/readable-stream/lib/_stream_readable.js (_stream_readable.js:26)
    at __webpack_require__ (bootstrap:74)
    at Object../node_modules/readable-stream/readable-browser.js (readable-browser.js:1)
    at __webpack_require__ (bootstrap:74)
    at Object../node_modules/mqtt/lib/store.js (store.js:8)
    at __webpack_require__ (bootstrap:74)
    at Object../node_modules/mqtt/lib/client.js (client.js:7)
    at __webpack_require__ (bootstrap:74)
./node_modules/process-nextick-args/index.js @ index.js:3
__webpack_require__ @ bootstrap:74
./node_modules/readable-stream/lib/_stream_readable.js @ _stream_readable.js:26
__webpack_require__ @ bootstrap:74
./node_modules/readable-stream/readable-browser.js @ readable-browser.js:1
__webpack_require__ @ bootstrap:74
./node_modules/mqtt/lib/store.js @ store.js:8
__webpack_require__ @ bootstrap:74
./node_modules/mqtt/lib/client.js @ client.js:7
__webpack_require__ @ bootstrap:74
./node_modules/mqtt/lib/connect/index.js @ index.js:3
__webpack_require__ @ bootstrap:74
./node_modules/ngx-mqtt/esm5/ngx-mqtt.js @ validations.js:52
__webpack_require__ @ bootstrap:74
./src/app/app.component.ts @ main.js:72
__webpack_require__ @ bootstrap:74
./src/app/app.module.ts @ app.component.ts:15
__webpack_require__ @ bootstrap:74
./src/main.ts @ environment.ts:16
__webpack_require__ @ bootstrap:74
0 @ main.ts:12
__webpack_require__ @ bootstrap:74
checkDeferredModules @ bootstrap:43
webpackJsonpCallback @ bootstrap:30
(anonymous) @ main.js:1

Desired behavior

I would like to either optionally add node-shims or maybe a possibility to add browserified code to the bundle. I added mqtt directly to my library dependencies and since mqtt provides a browserified bundle, this would be an option too. But ng-packagr currently has no option to directly embedd javascript files into the bundle.

Mention any other details that might be useful (optional)

ngx-mqtt has a branch 6.0.0-alpha with the library code.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
hassan-yonomicommented, Sep 9, 2018

@sclausen i just recently ran into this issue while trying to integrate aws-iot-device-sdk with my angular 6 app. This is how i got around this “ReferenceError: process is not defined” issue.

Added process module via npm “process”: “^0.11.10”

Added this to polyfill.ts file (window as any).process = require(‘process/browser’);

This fixes the issue for me, not an ideal solution though. Would love to see a better fix

3reactions
IAMtheIAMcommented, Sep 26, 2018

@hassan-yonomi You sir, are the man! I struggled with this for weeks, your solution immediately worked. I wonder what caused this breaking change? Thank you either way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngx-mqtt - npm
Start using ngx-mqtt in your project by running `npm i ngx-mqtt`. There are 2 other projects in the npm registry using ngx-mqtt.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found