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

add contributor RenatoFX #11

Merged
merged 1 commit into from
Dec 4, 2015
Merged

Conversation

rfxavier
Copy link
Contributor

@rfxavier rfxavier commented Dec 4, 2015

No description provided.

@ascott1
Copy link
Member

ascott1 commented Dec 4, 2015

Welcome @rfxavier! I hope that you're enjoying the course. Please feel free to reach out if you have any questions.

ascott1 added a commit that referenced this pull request Dec 4, 2015
add contributor RenatoFX
@ascott1 ascott1 merged commit 8ff164a into LearnFrontEnd:master Dec 4, 2015
@rfxavier
Copy link
Contributor Author

rfxavier commented Dec 5, 2015

Yes, great course indeed! Very useful and helpful content!

There is one thing I would like you to help me understand:

How does javascript "know" and "resolve" the require function, when using node.js. My point is: plain javascript alone cannot track content that's outside the scope of the current .js file, or better putting, outside the window scope in case of browsers... In your course project, there is one single <script> tag referencing the main.js file, this is what the browser is supposed to load, content from one js file and then hook up everything to the window object.

How does the fact of installing node.js on the machine and javascript getting to recognize and resolve require function correlate? It is still obscure to me. I tried examining the final rendered source code from the Marsbq project, only to notice that all "required" javascript gets loaded and bundled together in main.js file in the dist folder... but how? At which point in the execution or build chain does this happen? The final rendered source code does not contain explicitly calls to require function... as the original main.js file in src folder does...

Please help me clarify these points. I hope I could express myself clear enough...

Thanks in advance!

@rfxavier

@ascott1
Copy link
Member

ascott1 commented Dec 6, 2015

Great question @rfxavier! In this course, we're using the tool Browserify to bundle JavaScript files for the browser. This allows us to write our JavaScript using the Node.JS style 'require` statements (also referred to as CommonJS modules). What Browserify does is bundles those files into a single file for us. This helps us to keep the files organized and use modules from npm in the browser.

If you're interested the author of Browserify has written a "Browserify Handbook" that explains these things in some more detail: https://github.com/substack/browserify-handbook

I hope that helps to clarify, but please don't hesitate to follow up if you still have questions.

@rfxavier
Copy link
Contributor Author

rfxavier commented Dec 7, 2015

Yes Adam! Thank you, your insight was very helpful. It is clear to me now. I also understood what was the source of my confusion: node.js is server side javascript, I believe the first use of javascript on marsbq project run by node.js in your course was through the use of gulp, where the "requires" where there in gulpfile.js, as usual, as key elements on the code. What became clear to me now is that the code in gulpfile.js is executed OUTSIDE of the browser, through node.js server installed on the machine...Moving along through the course, the transition from the concept of node.js delivering functionality with javascript server-side to delivering functionality with javascript client-side was not well understood by me at first... The case is that on the client side, browsers don't understand require and node modules... main.js in src directory is never sent directly to be interpreted by the browser, but is processed first by a gulp task with browserify, then the output as main.js in dist folder is what comprises the final content to be served to the browser.

@ascott1
Copy link
Member

ascott1 commented Dec 7, 2015

This is great feedback, thanks @rfxavier! I apologize for the confusion that introducing Gulp first may have caused. If I get a chance to revisit this course, that is something I will either try to explain more clearly or shuffle around in the course order.

Please let me know if you have any other questions!

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