Почему я получаю «ReferenceError:« TextEncoder »не определен» в IE11 после импорта текстового кодирования polyfill? - PullRequest
0 голосов
/ 13 февраля 2019

Я пытаюсь выполнить pollyfill библиотеку fetch-readablestream (https://github.com/jonnyreeves/fetch-readablestream). Я добавил polyfill, и большинство вещей работает, но я продолжаю получать сообщение об ошибке TextEncoder ERROR ReferenceError: 'TextEncoder' is undefined

добавил необходимые pollyfills: web-streams-polyfill, text-encoding и babel-polyfill. Я пробовал другие эквиваленты этих polyfill, но у меня возникает та же проблема.

My polyfills.ts файл после требуемого импорта IEчто я раскомментировал.

import 'web-streams-polyfill'; // Run `npm install --save web-streams-polyfill`.
import 'text-encoding'; // Run `npm install --save text-encoding`.
import 'babel-polyfill'; // Run `npm install --save babel-polyfill`.

Я также пытался добавить сценарии к index.html

<script src="node_modules/text-encoding/lib/encoding-indexes.js"></script>
<script src="node_modules/text-encoding/lib/encoding.js"></script>

Я не ожидаю никаких ошибок, но получаю следующее:

ERROR ReferenceError: 'TextEncoder' is undefined
   "ERROR"
   {
      [functions]: ,
      __proto__: { },
      description: "'TextEncoder' is undefined",
      message: "'TextEncoder' is undefined",
      name: "ReferenceError",
      number: -2146823279,
      stack: "ReferenceError: 'TextEncoder' is undefined
   at responseParserFactory (http://localhost:4200/vendor.js:139703:3)
   at xhrTransport (http://localhost:4200/vendor.js:139960:1)
   at fetchStream (http://localhost:4200/vendor.js:139795:4)
   at DevicewiseService.prototype.getNotifications (http://localhost:4200/main.js:6577:9)
   at Anonymous function (http://localhost:4200/main.js:159:17)
   at SafeSubscriber.prototype.__tryOrUnsub (http://localhost:4200/vendor.js:145834:9)
   at SafeSubscriber.prototype.next (http://localhost:4200/vendor.js:145772:13)
   at Subscriber.prototype._next (http://localhost:4200/vendor.js:145715:5)
   at Subscriber.prototype.next (http://localhost:4200/vendor.js:145692:9)
   at MapSubscriber.prototype._next (http://localhost:4200/vendor.js:150984:5)",
      Symbol([[Cancel]])_g.r6fxkqwxet3: undefined,
      Symbol([[Pull]])_h.r6fxkqwxet3: undefined,
      Symbol(INITIAL_VALUE)_p.r6fxkqwxet3: undefined,
      Symbol(rxSubscriber)_o.r6fxkqwxet3: undefined
   }

Мы видим, как это происходит в вызове fetchStream.

...