-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promise based module loading #1769
Comments
Nice idea, but... Many browser supports now ES6 module by default https://caniuse.com/#feat=es6-module and that support will only increase :) |
Not to start a flame war here, but, that ES6 module support (via script type=module) is no where close to a fully formed module loading system. They still need to work out loading semantics and name resolution before any of this goes anywhere (basically all the framework stuff you get with a loader like RequireJS). |
@chrisknoll do you have any article where I can read about it? It sounds interesting |
There's a few resources on the web that will give you the history, but the main source of info comes out of the WhatWG working group that is developing the standard: https://github.com/whatwg/loader. Here's a fun nugget from their main README: StatusA good chunk of this spec is out of date and is undergoing revision to realign it with Service Worker, the JS Realms API, and the dynamic import() feature. Yikes. They've only been working on it for about 8 years now, and the're back at the drawing board. If you look at how the node community is handling it, they decided to implement an extension So, it's a mess, and from the node community standpoint, they have so much use of their code system, they can basically call the shots which leaves the asynchronous folks who work exclusively out of the web to rely on transpilers and build chains. Of course any node developer will tell you that build chains is a fact of life, but whenever I observe a node dev doing server side programming, there's no build step there! only for the browser....hmm Anyways, do a couple of searches, you'll find how far ES6 is from being a complete solution. |
So, is there a techincal reason that we cannot return a Promise and just resolve as when we would call the callback? I must be missing something but it feels straight forward? If we only need someone to do it then that should be easy enough but I guess there are other things blocking. |
@AllNamesRTaken it would require a Polyfil because older browsers does not support Promise |
For what it’s worth, you can wrap a call to RequireJS’s async function main() {
const [dep1, dep2, dep3] = await new Promise((resolve, reject) => {
require(['dep1', 'dep2', 'dep3'], resolve, reject);
});
}
main(); Compared to awaiting multiple dynamic |
If requirejs used for Web, so I suggest to add new syntax, based on
await
/async
. Also, I suggest make script loading and caching, based on FileSystem API and file system URL.Or
The text was updated successfully, but these errors were encountered: