|
1 | 1 | ---
|
2 | 2 | layout: single
|
3 |
| -title: 'StompJs v5: Polyfills' |
| 3 | +title: 'StompJs v5+: Polyfills' |
4 | 4 | date: 2018-06-29 07:59:22 +0530
|
5 | 5 | categories: guide stompjs rx-stomp ng2-stompjs
|
6 | 6 | toc: true
|
7 | 7 | 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 |
11 | 11 | ---
|
12 | 12 |
|
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+ |
15 | 15 | of `@stomp/ng2-stompjs`.
|
16 | 16 |
|
17 | 17 | ## Critical dependency
|
18 | 18 |
|
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 |
20 | 20 | browsers.
|
21 | 21 | However [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
|
22 | 22 | ([Browser Support](https://caniuse.com/#feat=typedarrays))
|
23 | 23 | is critically needed and not possible to be efficiently polyfilled (notably in IE9 or lower).
|
24 | 24 | If you need to support any browser that does not have native support for Uint8Array
|
25 | 25 | please continue using version 4 of this library.
|
26 | 26 |
|
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 |
28 | 32 |
|
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 |
| - ``` |
36 | 33 | - [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)
|
37 | 34 | and
|
38 | 35 | [TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) -
|
39 | 36 | [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: |
42 | 39 | ```html
|
43 | 40 | < script src= "https://cdn.jsdelivr.net/npm/[email protected]/lib/encoding.min.js"></ script>
|
44 | 41 | ```
|
45 | 42 |
|
| 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 | + |
46 | 53 | ## In NodeJS
|
47 | 54 |
|
| 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 | + |
48 | 89 | ### TextEncoder/TextDecoder
|
49 | 90 |
|
50 | 91 | - 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.
|
82 | 123 | import * as encoding from 'text-encoding';
|
83 | 124 | ```
|
84 | 125 |
|
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: |
86 | 127 | [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