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

Tutorial: Consuming modules: Module ids #13

Open
teehemkay opened this issue Sep 10, 2013 · 3 comments · May be fixed by #14
Open

Tutorial: Consuming modules: Module ids #13

teehemkay opened this issue Sep 10, 2013 · 3 comments · May be fixed by #14

Comments

@teehemkay
Copy link

I think that one ../ is missing below:

// module app/billing/billTo/Customer
define(function (require) {
    [...]
    // BAD: normalizes to "../util/date" -- a URL, not an ID!
    var Date = require("../../../util/Date");

Should probably read:

// BAD: normalizes to "../util/date" -- a URL, not an ID!
var Date = require("../../../../util/Date");

Also congrats on a really awesome tutorial!

@briancavalier
Copy link
Member

Hey @Exidia, thanks, I think you're right. I think the intent was to show a module id that tries to back out "too far"--that is, beyond even the conceptual / (baseUrl). Three double dots backs out exactly to /, which would normalize to the valid id util/Date. So, four .. seems like it does what the comment says.

I definitely want @unscriptable have a look to verify, though.

@teehemkay
Copy link
Author

Hi Brian, thanks for your comment. That was my reasoning too.

And there's actually an example in the next tutorial, "Consuming modules: Locating modules in AMD" at
http://know.cujojs.com/tutorials/modules/consuming-locating-modules-in-amd, under the chapter "Why multiple ../ is a code smell" that provides an explanation similar to the one you gave above.

Oh and BTW, I think that the tutorials are really, really great: very clear and to the point, concise and very well balanced in terms of providing the right amount of details at both practical and conceptual levels.

@briancavalier
Copy link
Member

And there's actually an example in the next tutorial

Nice, I think that confirms it. I just sent #14 as a fix.

concise and very well balanced in terms of providing the right amount of details at both practical and conceptual levels.

Thanks! We appreciate the feedback. Finding that balance can be tough, so knowing that we've gotten it right so far definitely will help us when writing more tutorials.

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 a pull request may close this issue.

2 participants