[Proposal ] Make node async environment to allow remote !text loading.#649
[Proposal ] Make node async environment to allow remote !text loading.#649KaneCohen wants to merge 1 commit intorequirejs:masterfrom KaneCohen:async
Conversation
|
I do appreciate wanting to have this. It was made sync originally for two reasons:
I would like to allow for at least the optimizer to be async based. The first case though I think needs more study. If I were to do this sort of change though, it would be a 3.0 thing, since it is a fairly big baseline assumption change, so putting it in that bucket. In the meantime though, if you are using the requirejs/text loader plugin, it should operate in the sync environment fine as long as the target resource is a local file that is available. |
|
Thanks for the explanation, James. And thanks for keeping that in mind. I've no idea how many people actually need async optimization as described in PR, so if it's a fraction of all the users it might not be productive to change it in the future. But, that's completely up to you and your vision for r.js. |
I found myself in a situation, when some of the files used in the app should be generated by the server. Template files to be exact. I've got bunch of
text!calls in the main.js file that are being used to load dozen webpages containing raw template files which are later added to the built file during build process. Problem is, since those files are generated by the back-end and node is used to grab them, whole process fails because node is set to be synchronous environment that won't wait for the remote file to be generated and loaded.Network-loaded scripts are being skipped as expected.