preact-cli: Promise polyfill is not applied
Apps created via cli do not work on browsers without Promise
implementation. For Windows users the easiest way to reproduce is to open https://clidemo.preactjs.com in IE11 and look into dev console.
This is problems occurs because of polyfills reside in separate chunks - which would be fine if webpack didn’t use Promise
s in chunk loading code 😆 (which it does and states so in docs).
I’m thinking we can go several ways:
- drop non ES2015 browsers support (which means dropping PhantomJS and possibly large part of potential cli users)
- load promise polyfill eagerly
- load promise polyfill via some custom JS code (dynamic script tag?)
Steps to reproduce
preact create app
cd app
npm run serve
- Visit localhost:8080 in browser without ES6 support
- Click any navigation link (e.g. Profile)
Expected result:
- Page is changed
Actual result:
- Nothing happens. Error
Promise is not defined
is seen in console
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (14 by maintainers)
Was there any resolution on this? @thangngoc89, I’m developing for UC as well and am currently just importing and initializing
promise-polyfill
in myapp.js
, which obviously feels ridiculous given that it’s sitting in the polyfills chunk already.@thangngoc89 Correct, but in the majority case, Promise is supported already. A conditional tag (as provided) will load before the webpack runtime, which means
Promise
will always be ready.@developit good call I haven’t thought about that fetch requires promise implementation.
@developit @rkostrzewski Instead of a
defaultAttribute
across the board, we can specify a pattern to match everything except ~promise.polyfill.js
(or whatever name).Also, I would assume that this script be loaded under a HTML conditional: