Supporting documentation for Angular 2.x use / consider removing dependency
See original GitHub issueIs your feature request related to a problem? Please describe. Integration of mermaid into an Angular 2.x project may result in an error like:
ERROR Error: Uncaught (in promise): ReferenceError: global is not defined
ReferenceError: global is not defined
at Object../node_modules/node-libs-browser/node_modules/buffer/index.js (index.js:43)
at __webpack_require__ (bootstrap:84)
at Object../node_modules/safe-buffer/index.js (index.js:2)
at __webpack_require__ (bootstrap:84)
at Object../node_modules/randombytes/browser.js (browser.js:15)
at __webpack_require__ (bootstrap:84)
at Object../node_modules/crypto-browserify/index.js (index.js:3)
at __webpack_require__ (bootstrap:84)
at Object../node_modules/crypto-random-string/index.js (index.js:2)
at __webpack_require__ (bootstrap:84)
at resolvePromise (zone-evergreen.js:797)
at resolvePromise (zone-evergreen.js:754)
at zone-evergreen.js:858
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39679)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
This can be resolved by polyfill’ng adding the following to polyfills.ts:
(window as any).global = window; // gets rid of the first error
global.Buffer = global.Buffer || require('buffer').Buffer; // which leads to buffer being required
(window as any).process = { // which leads to window.process.version needing to be parsed
env: { DEBUG: undefined }, // https://github.com/nodejs/readable-stream/issues/313
version: 'v0.9.'
};
(window as any).setImmediate = window.setTimeout; // which leads to setImmediate being required
Note that all of this is due to ‘crypto-random-string’ which relies on ‘crypto’ which pulls in a bunch of wedges intended to emulate node libs in the browser, some of which still have issues without the above polyfills.
Describe the solution you’d like At a minimum, documentation for the polyfills above. Ideally, I’d remove or change out the crypt string library for a simpler dependency chain (which would also be smaller).
Thanks for the cool library!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Angular coding style guide
Looking for an opinionated guide to Angular syntax, conventions, and application structure? Step right in. This style guide presents preferred conventions ...
Read more >Cheat Sheet - Angular
List of dependency injection providers visible both to the contents of this module and to importers of this module. bootstrap: [MyAppComponent]
Read more >Security - Angular
This topic describes Angular's built-in protections against common web-application vulnerabilities and attacks such as cross-site scripting attacks.
Read more >Upgrading from AngularJS to Angular
Pure AngularJS applications can be automatically bootstrapped by using an ng-app directive somewhere on the HTML page. But for hybrid applications, you manually ......
Read more >Angular versioning and releases
The practices described in this document apply to Angular 2.0 and later. ... We update peer dependencies in minor versions by expanding the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chris579 Indeed. Oops! Was on a temp phone when I commented…and must have clicked the wrong button. That’s a first for me. My apologies!
This is not just an issue in IE. If I recall, crypto-random-string is a nodejs module and does not work in any browser. I was testing in chrome when I ran into this issue.
On Thu, Feb 25, 2021, 3:13 PM Justin Greywolf notifications@github.com wrote: