Skip to content

Commit 6a5daa5

Browse files
committed
Updating to reflect current status of polyfills.
1 parent bc2ae4c commit 6a5daa5

File tree

1 file changed

+59
-52
lines changed

1 file changed

+59
-52
lines changed

_posts/2018-06-28-pollyfils-for-stompjs-v5.md

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,91 @@
11
---
22
layout: single
3-
title: 'StompJs v5: Polyfills'
3+
title: 'StompJs v5+: Polyfills'
44
date: 2018-06-29 07:59:22 +0530
55
categories: guide stompjs rx-stomp ng2-stompjs
66
toc: true
77
redirect_from:
8-
- /guide/stompjs/rx-stomp/ng2-stompjs/2018/06/28/pollyfils-for-stompjs-v5.html
9-
- /guide/stompjs/rx-stomp/ng2-stompjs/2018/06/29/pollyfils-for-stompjs-v5.html
10-
- /guide/stompjs/rx-stomp/ng2-stompjs/2018/06/30/pollyfils-for-stompjs-v5.html
8+
- /guide/stompjs/rx-stomp/ng2-stompjs/2018/06/28/pollyfils-for-stompjs-v5.html
9+
- /guide/stompjs/rx-stomp/ng2-stompjs/2018/06/29/pollyfils-for-stompjs-v5.html
10+
- /guide/stompjs/rx-stomp/ng2-stompjs/2018/06/30/pollyfils-for-stompjs-v5.html
1111
---
1212

13-
This guide covers critical dependencies and polyfills for version 5 of `@stomp/stompjs`;
14-
which is internally used by all versions of `@stomp/rx-stomp` and version 7
13+
This guide covers critical dependencies and polyfills for version 5+ of `@stomp/stompjs`;
14+
which is internally used by all versions of `@stomp/rx-stomp` and version 7+
1515
of `@stomp/ng2-stompjs`.
1616

1717
## Critical dependency
1818

19-
StompJs v5 uses newer Javascript features. Few these can be polyfilled in older
19+
StompJs v5+ uses newer Javascript features. Few of these can be polyfilled in older
2020
browsers.
2121
However [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
2222
([Browser Support](https://caniuse.com/#feat=typedarrays))
2323
is critically needed and not possible to be efficiently polyfilled (notably in IE9 or lower).
2424
If you need to support any browser that does not have native support for Uint8Array
2525
please continue using version 4 of this library.
2626

27-
## Polyfills
27+
## Older Microsoft Browsers
28+
29+
**The latest version of Edge does not need any polyfills.**
30+
31+
### TextEncoder/TextDecoder - IE and older Edge
2832

29-
- [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign).
30-
([Browser Support](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Browser_compatibility))
31-
It is not supported by IE (supported by Edge).
32-
It will need to be polyfilled from `npm` package `es6-object-assign`. A simple approach:
33-
```html
34-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/object-assign-auto.min.js"></script>
35-
```
3633
- [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)
3734
and
3835
[TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) -
3936
[Browser Support](https://caniuse.com/#search=textencoder)
40-
These are not supported by any of the MicroSoft browsers as of 2018.
41-
These will need to be polyfilled from `npm` package `text-encoding`. A simple approach:
37+
These are not supported by any older versions of MicroSoft browsers (supported by latest Edge).
38+
- These will need to be polyfilled from `npm` package `text-encoding`. A simple approach:
4239
```html
4340
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/encoding.min.js"></script>
4441
```
4542

43+
### Object.assign - IE
44+
45+
- [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign).
46+
([Browser Support](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Browser_compatibility))
47+
It is not supported by IE (supported by Edge).
48+
- It will need to be polyfilled from `npm` package `es6-object-assign`. A simple approach:
49+
```html
50+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/object-assign-auto.min.js"></script>
51+
```
52+
4653
## In NodeJS
4754

55+
### WebSocket
56+
57+
There are two alternate libraries `websocket` and `ws` which have been reported to work.
58+
59+
#### websocket
60+
61+
- Add `websocket` npm module:
62+
63+
```bash
64+
$ npm install websocket
65+
```
66+
67+
- Require the module and expose it through `global`
68+
69+
```javascript
70+
Object.assign(global, { WebSocket: require('websocket').w3cwebsocket });
71+
```
72+
73+
#### ws
74+
75+
- Instead of `websocket` lib `ws` has also been reported to work.
76+
See: [stompjs/issues/28](https://github.com/stomp-js/stompjs/issues/28).
77+
- Add `ws` npm module:
78+
79+
```bash
80+
$ npm install ws
81+
```
82+
83+
- Require the module and expose it through `global`
84+
85+
```javascript
86+
Object.assign(global, { WebSocket: require('ws') });
87+
```
88+
4889
### TextEncoder/TextDecoder
4990

5091
- Node JS v11 (tested with v11.2.0) has `TextEncoder`/`TextDecoder` built-in. See:
@@ -82,39 +123,5 @@ please continue using version 4 of this library.
82123
import * as encoding from 'text-encoding';
83124
```
84125

85-
- There is additional issues with React Native in some device/version combinations. Please see:
126+
- There are additional issues with React Native in some device/version combinations. Please see:
86127
[React Native - Additional Notes](/workaround/stompjs/rx-stomp/ng2-stompjs/react-native-additional-notes.html)
87-
88-
### WebSocket
89-
90-
There are two alternate libraries `websocket` and `ws` which has been reported to work.
91-
92-
#### websocket
93-
94-
- Add `websocket` npm module:
95-
96-
```bash
97-
$ npm install websocket
98-
```
99-
100-
- Require the module and expose it through `global`
101-
102-
```javascript
103-
Object.assign(global, { WebSocket: require('websocket').w3cwebsocket });
104-
```
105-
106-
#### ws
107-
108-
- Instead of `websocket` lib `ws` has also been reported to work.
109-
See: [stompjs/issues/28](https://github.com/stomp-js/stompjs/issues/28).
110-
- Add `ws` npm module:
111-
112-
```bash
113-
$ npm install ws
114-
```
115-
116-
- Require the module and expose it through `global`
117-
118-
```javascript
119-
Object.assign(global, { WebSocket: require('ws') });
120-
```

0 commit comments

Comments
 (0)