Skip to content

Commit cea1867

Browse files
committed
docs(Angular): document workaround for Angular 6 global issue
Fixes NODE-1893
1 parent ea558b4 commit cea1867

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ Depending on your settings, webpack will under the hood resolve to one of the fo
117117

118118
For more information, see [this page on webpack's `resolve.mainFields`](https://webpack.js.org/configuration/resolve/#resolvemainfields) and [the `package.json` for this project](./package.json#L52)
119119

120+
### Usage with Angular
121+
122+
Starting with Angular 6, Angular CLI removed the shim for `global` and other node built-in variables (original comment [here](https://github.com/angular/angular-cli/issues/9827#issuecomment-386154063)). If you are using BSON with Angular, you may need to add the following shim to your `polyfills.ts` file:
123+
124+
```js
125+
// In polyfills.ts
126+
(window as any).global = window;
127+
```
128+
129+
- [Original Comment by Angular CLI](https://github.com/angular/angular-cli/issues/9827#issuecomment-386154063)
130+
- [Original Source for Solution](https://stackoverflow.com/a/50488337/4930088)
131+
120132
## Installation
121133

122134
`npm install bson`

0 commit comments

Comments
 (0)