-
Notifications
You must be signed in to change notification settings - Fork 789
Enhanced JavaScript Module Support
There are many JavaScript module formats in the wild. The variety of formats present challenges for ClojureScript consumption as ClojureScript is designed to work with the Google Closure Compiler. Maria Geller's Google Summer of Code work addressed fundamental support issues by patching the Closure Compiler as well the ClojureScript compiler. This work allows JavaScript module formats to be processed much like the way we process ClojureScript - into Google Closure namespaces. However challenges remain with respect to intuitive usage for the end user. These are some of the issues present today:
-
:module-type
cannot be applied to:libs
-
:libs
only supports files or directories, not library specs (maps) -
:language-in
&:language-out
cannot be specified at module level - missing source mapping support
This page outlines some approaches to potential solutions.
{:foreign-libs [{:file "./path/to/my/foo.js"
:provides ["my.foo"]
:language-in :ecmascript6
:language-out :ecmascript5}]}
We could support library specs in :libs
instead of only supporting a vector strings specifying files (individual files or directories):
{:libs ["./path/to/my/closure/libs",
{:path "./node_modules/react/src"
:module-type :commonjs
:language-in :ecmascript5
:preprocess :jsx}]}
Unlike :foreign-libs
, :libs
entries provide dependency information in the source file. This is true for any JavaScript using a popular module format that we support. This means that we can support directory "entry points" and simply compile all JavaScript files under the given directory using the provided options.
As with existing :libs
support we can simply compile to :output-to
preserving the directory structure. This would avoid the file name clash issues.
This is a nice follow up to have. We have existing support for merging source maps, we should simply do the same for all :libs
.
- Rationale
- Quick Start
- Differences from Clojure
- [Usage of Google Closure](Google Closure)