Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Documentation of how to use modules with CommonJS syntax or in CoffeeScript #13

Merged

Conversation

GeoffreyBooth
Copy link
Contributor

Okay, one last time! Moving here from meteor/meteor#6636.

This PR expands the Modules » Syntax section to include subsections for CommonJS and CoffeeScript syntax. There’s a bit of repetition between the two, since CoffeeScript is just compiling into CommonJS, but I think we should keep the duplication since I doubt most people would read the syntax section that doesn’t apply to them. I also cribbed a little from the CommonJS section of the Guide; I’m not sure what should go here versus there. If anything I think the CommonJS discussion is probably better off here, if the point of the Guide is to explain recommended practices (which obviously CommonJS is not). The caveat that the Guide points out, about how CommonJS is required (sorry, I can’t believe I just made a JavaScript pun) when importing within an if block, I would think is probably best explained in the docs and linked to from the Guide.

Also the end of the CoffeeScript section includes a warning about backticks. If meteor/meteor#6691 is merged, we will have to remember to come back here and remove the warning.

@GeoffreyBooth GeoffreyBooth mentioned this pull request May 20, 2016
@lorensr lorensr self-assigned this May 20, 2016

You can also simply write `exports` instead of `module.exports` if you prefer.

Note that [backticks](http://coffeescript.org/#embedded) do *[not](https://github.com/meteor/meteor/issues/6000)* work; your `.coffee` files will be transpiled into JavaScript, but not then handed off to the `ecmascript` package for further transpiling. Any JavaScript you type in backticks will be passed through unmodified all the way to the browser or Node.js runtime.
Copy link
Contributor

@lorensr lorensr May 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that backticks do not work;

maybe "Note that putting ecmascript inside backticks does not work" ?

something to make clear from the start you're not saying they don't work period.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I’ve updated that paragraph to clarify. Though it looks like there might be action on meteor/meteor#6691 soon, so hopefully I can come back and remove that paragraph entirely.

@lorensr lorensr merged commit bc88d49 into meteor:version-NEXT May 22, 2016
@lorensr
Copy link
Contributor

lorensr commented May 22, 2016

Thanks a lot! 🙌

@GeoffreyBooth GeoffreyBooth deleted the modules-commonjs-coffeescript-syntax branch May 22, 2016 22:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants