Skip to content
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

[Proposal ] Make node async environment to allow remote !text loading. #649

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KaneCohen
Copy link

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.

@jrburke jrburke added this to the 3.0 milestone Mar 19, 2014
@jrburke
Copy link
Member

jrburke commented Mar 19, 2014

I do appreciate wanting to have this. It was made sync originally for two reasons:

  • Node's module system is sync, so if there was a mixed load of node modules and AMD modules, I wanted to keep that consistent.
  • The optimizer pathway was sync to maintain similar sync-ness in the other non-browser platforms, and it also made the optimizer tests easier.

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.

@KaneCohen
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants