-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
discuss: asynchronous module.import #10956
Comments
Have you considered joining the discussion on ES modules? I think discussing features like async module loading is best had there IMHO. |
@mscdex I've already mentioned above playground there and they believed I was just sponsoring my library, while I'm actually proposing a CommonJS pattern, which is also something they're not interested in (if they were, the current ES2015 import/export status wouldn't be where it is now). The idea is to use the only two things agreed by TC39, the Would NodeJS community consider implementing this feature, maybe they will have a precedent to consider and work with, instead of the other way around. Does this answer your question? |
What I meant was why not voice your support for async ES module loading instead of adding it on to CommonJS modules? |
more than bringing their own proposal into a well known and used env as NodeJS via 3 lines of code and a little utility library that demonstrates all problems mentioned in there are solved, I am not sure what to do. I am active in the ML and I've mentioned this approach already but we all know it takes ages for all vendors to agree and implement something so here there's hopefully more freedom, being CommonJS a de-facto standard? Since AFAIK the agreement on the Or you are saying that any new feature in NodeJS should be agreed as ECMAScript standard first? I've opened a thread here to discuss what NodeJS people think (so yes, I might keep bothering TC39 people too with exact same idea, but they already have it there) |
At this point creating another defacto standard on our own instead of collaborating with other vendors and make it a ECMAScript standard(even though that would be slow) would only make things worse IMHO. What are the benefits of this proposal over dynamic import(except it would be faster to roll out)? What will happen to this API when dynamic import becomes fully usable? |
Dynamic import is unpolyfillable (reserved word, unless you pass through My lil' utility makes this experimentation easily portable to any browser too so that developers could start using this right away. Every modern API is also shipping Promise based, see This pattern would benefit both worlds and it could do it sooner than dynamic
Well, that's not something to ignore neither, and quite possibly one of the major points. Having an already adopted solution also could speed-up rolling out on standards since those work counting implementors too. (it's in ES stages process). They won't adopt CommonJS, it was never the plan, but they can verify what they have proposed is already working at scale.
What is happening, or will happen, to Transpiled code will fallback to synchronous require or to dynamic In other words, this 3 LOC feature can move both client and server forward with, as far as I can tell, full backward compatibility and zero risks in shipping it. Eventually, like every feature in every language, we'll see low adoption but if it doesn't go out we're somehow in a Catch-22 like situation, hence my proposal to roll it on the most used CommonJS based environment. |
I see, so this proposal is like another bridge between I think this discussion should go to https://github.com/nodejs/node-eps/? (Not sure if something like this has been raised there before). EDIT: And yes, this is irrelevant to |
hopefully it's the only needed bridge, accordingly with current dynamic
Like I've said, this idea is indeed strictly a CommonJS related one but it's fully based on this standard prototype/proposal without any of those issues described in there. Thanks for the hint on node-esp, I wasn't aware of the special repo for these kind of discussions. I'l try to search for similar proposals and, if none, I'll PR this one. Cheers |
Glad to help. I think this issue over here can be closed now. |
Also I think nodejs/node-eps#39 (diff) is discussing the same thing as the proposal? |
I am not fully sure this is the right place to discuss CommonJS patterns but I'd like to understand if there's the possibility to discuss a possible new
Module.prototype
method like the following one:This would enable asynchronous import and asynchronous exports out of the box.
To export asynchronously the module has to simply export a
Promise
Multiple dependencies can be easily handled via
Promise.all
.I'm testing already these patterns on both server and client [1], and there's nothing I can spot that could cause troubles, in terms of backward compatibility, but it could enable new kind of possibilities for both client and server.
Thank you for your consideration.
[1] https://medium.com/@WebReflection/asynchronous-module-import-path-b9f56675e109#.ehnofaj2q
The text was updated successfully, but these errors were encountered: