Comments (4)
You are able to do this if you are using import
or require
.
import Promise from 'promise-polyfill';
window.Promise = Promise;
Does that work?
from promise-polyfill.
This does not work if the polyfill is externally bundled as its own bundle.
So the scenario for this build system: it takes in third party libraries and bundles them into standalone bundles.
Then modules requiring the third party libraries get them loaded in via AMD.
It's difficult to single out libraries for non bundling as that generates too many special cases in the procedure.
from promise-polyfill.
@Diniden I am confused how you want the library to work. You said you wanted to do this
import polyfill from 'promise-polyfill';
polyfill(window);
I gave you that ability
import Promise from 'promise-polyfill';
window.Promise = Promise;
You can even create the polyfill function
import Promise from 'promise-polyfill';
function polyfill(globalObj) {
globalObj.Promise = Promise;
}
polyfill(window)
I feel like you want the library to do something that is not possible with Javascript. There is no way to magically return a module without attaching to this
, using module.exports
or using define
. Do you just want define
? You mentioned you are using AMD.
If you could tell me how to change this library's code to make it work for you, that would be really helpful.
from promise-polyfill.
It seems I am a bit of a dummy. Yes:
import Promise from 'promise-polyfill';
window.Promise = Promise;
Works for me :)
Me being a dummy though, I gave my question a lot of un-needed thought and came up with a solution I thought I needed:
var promisePolyfill = (function polyfill(root) {
// The code....
return polyfill;
})(this);
// I could now:
promisePolyfill(myOwnContext);
But that being said....I don't really need that...You may close this and hide my shame now :) thanks for your time regarding this!
from promise-polyfill.
Related Issues (20)
- dist/polyfill.min.js missing v8.1.2 fix HOT 1
- catch causing `expected identifier` in IE8, it seems promise is not returned for chaining HOT 1
- Exception not rejected? HOT 1
- Using promise in a 'for' loop behaves differently on IE11 HOT 2
- Unhandled Promise Rejection - Desktop Safari 13.0.2 HOT 4
- Use window.queueMicrotask where available HOT 4
- Promise.prototype.finally is not aligned with the most current spec draft HOT 3
- Conditional check insufficient due to legacy HTML by ID conflict
- Missing Promise.allSettled HOT 4
- Invalid calls to wrapped setTimeout on IE7 and IE8 HOT 12
- Document meanings of _state values HOT 3
- ' import 'promise-polyfill/src/polyfill' 'has syntaxerror when i excute 'npm run test' HOT 2
- unhandledrejection event not fired HOT 2
- v8.2.1: setImmediate in IE11 can lose its context and throw "Invalid calling object" HOT 1
- zte HOT 1
- Could you support Promise.any() ? HOT 1
- Has Promise-Polyfill replaced the use of Bluebird? HOT 1
- Set minimum permissions for workflows HOT 1
- Add Security Policy HOT 1
- error in ie8 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from promise-polyfill.