clojure / clojure/clojurescript-site
Improve section on Google Closure import and require
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 107
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Description
I've just had to use Google Closure directly for the first time, and I found it difficult to understand the nuances in order to get things working properly on a real project even after reading all the documentation and linked blog posts. The areas that were unclear to me:
- Format to import in a namespace - surround with
[ ],( ), or nothing - particularly when importing multiple dependencies. - How to use import when importing multiple namespaces -
(:import [goog URI OtherNS])- the examples didn't explain this clearly to me. - Name collisions - for example, OpenLayers has classes
ol.source.Vectorandol.layer.Vector- What is the recommended way to work with these? Is there a way to import classes with a namespace to distinguish these? - How to use things after importing or requiring them in JS interop -
URI.orgoog.URI.- this is laid out in a limited form, but I think an example of more extended interop would be very useful. - More specific documentation, perhaps with examples, of how to tell whether things are a Closure class or not.
I also think it would be worthwhile to better explain the benefits of using import over require, but with the caveat that everything will still work fine if you just require everything - it may allow other beginners to this part of ClojureScript to get thing working quickly and improve or experiment as they understand things better.
I'm planning to work on a PR for this.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing documentation and linked blog posts covering Google Closure import and require. Clarify namespace syntax, multiple imports, name collisions, JavaScript interop, Closure classes, and the practical tradeoffs between import and require, with examples for each; done means these beginner questions are answered directly in the documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100