CrossClj

1.10.339 docs

SourceDocs



RECENT
    VARS
    ->JavaScriptFile
    absolute-parent
    absolute-path?
    add-converted-source
    add-core-macros-if-cljs-js
    add-dep-string
    add-dependencies
    add-dependency-sources
    add-externs-sources
    add-goog-base
    add-header
    add-implicit-options
    add-js-sources
    add-preloads
    add-source-map-link
    add-wrapper
    alive?
    aot-cache-core
    aot-cache?
    build
    build-modules
    build-provides
    check-cache-analysis-format
    check-level
    check-main
    check-node-target
    check-npm-deps
    check-output-dir
    check-output-to
    check-output-wrapper
    check-preloads
    check-source-map
    check-source-map-path
    check-unprovided
    cljs-dependencies
    cljs-dependents-for-macro-namespaces
    cljs-source-for-namespace
    Compilable
    compilable-input-paths
    compile
    compile-client-js
    compile-dir
    compile-file
    compile-form-seq
    compile-from-jar
    compile-inputs
    compile-loader
    compile-ns
    compile-sources
    compile-task
    compiled-file
    compute-upstream-npm-deps
    const-expr-form
    constants-filename
    constants-javascript-file
    convert-js-modules
    copy-from-cache
    create-client-js-file
    deps-file
    elide-strict
    emit-optimized-source-map
    ensure-cljs-base-module
    ensure-module-opts
    expand-libs
    find-cljs-dependencies
    find-jar-sources
    find-sources
    foreign-deps-str
    foreign-source?
    get-closure-sources
    get-compiled-cljs
    get-data-readers
    get-data-readers*
    get-js-root
    get-source-files
    get-upstream-deps
    get-upstream-deps*
    GITLIBS-CACHE-DIR
    gitlibs-cache-dir
    gitlibs-src?
    handle-js-modules
    in-same-dir?
    index-node-modules
    index-node-modules-dir
    Inputs
    ISourceMap
    jar-file-to-disk
    javascript-file
    javascript-name
    js-dependencies
    js-source-file
    js-transforms
    known-opts
    lang-key->lang-mode
    lib-rel-path
    load-data-reader-file
    load-data-readers!
    load-externs
    make-closure-compiler
    make-convert-js-module-options
    make-options
    make-preamble
    map->javascript-file
    map->JavaScriptFile
    mark-cljs-ns-for-recompile!
    maybe-install-node-deps!
    module-entries
    module-type->keyword
    name-chars
    node-file-seq->libs-spec
    node-file-seq->libs-spec*
    node-inputs
    node-module-deps
    normalize-closure-defines
    optimize
    optimize-modules
    opts-fn
    output-bootstrap
    output-deps-file
    output-directory
    output-main-file
    output-modules
    output-one-file
    output-unoptimized
    package-json-entries
    parallel-compile-sources
    parse-js-ns
    path-from-jarfile
    path-relative-to
    pipe
    preamble-from-paths
    preloads
    preprocess-js
    process-js-modules
    random-char
    random-string
    read-js
    rel-output-path
    remove-goog-base
    report-failure
    same-or-subdirectory-of?
    set-options
    shim-process?
    source-for-namespace
    source-on-disk
    src-file->goog-require
    src-file->target-file
    string->charset
    sym->var
    target-file-for-cljs-ns
    to-absolute-path
    to-charset
    USER-HOME-WRITABLE
    validate-opts
    warning-types
    watch
    write-javascript
    write-js?
    write-variable-maps

    « Index of all namespaces of this project

    Compile ClojureScript to JavaScript with optimizations from Google
    Closure Compiler producing runnable JavaScript.
    
    The Closure Compiler (compiler.jar) must be on the classpath.
    
    Use the 'build' function for end-to-end compilation.
    
    build = find-sources -> add-dependencies -> compile -> optimize -> output
    
    Two protocols are defined: IJavaScript and Compilable. The
    Compilable protocol is satisfied by something which can return one
    or more IJavaScripts.
    
    With IJavaScript objects in hand, calling add-dependencies will
    produce a sequence of IJavaScript objects which includes all
    required dependencies from the Closure library and ClojureScript,
    in dependency order. This function replaces the closurebuilder
    tool.
    
    The optimize function converts one or more IJavaScripts into a
    single string of JavaScript source code using the Closure Compiler
    API.
    
    The produced output is either a single string of optimized
    JavaScript or a deps file for use during development.
    
    (->JavaScriptFile foreign url source-url provides requires lines source-map)
    Positional factory function for class cljs.closure.JavaScriptFile.
    
    (absolute-parent path)
    (absolute-path? path)
    (add-converted-source closure-compiler result-nodes opts {:keys [file-min file], :as ijs})
    Private
    (add-core-macros-if-cljs-js compiled)
    If a compiled entity is the cljs.js namespace, explicitly
    add the cljs.core macros namespace dependency to it.
    (add-dep-string opts input)
    Return a goog.addDependency string for an input.
    
    (add-dependencies opts & inputs)
    Given one or more IJavaScript objects in dependency order, produce
    a new sequence of IJavaScript objects which includes the input list
    plus all dependencies in dependency order.
    (add-dependency-sources inputs)(add-dependency-sources inputs compile-opts)
    Given list of IJavaScript objects, produce a new sequence of IJavaScript objects
    of all dependencies of inputs.
    (add-externs-sources opts)
    (add-goog-base inputs)
    (add-header opts js)
    (add-implicit-options {:keys [optimizations output-dir], :or {optimizations :none, output-dir "out"}, :as opts})
    (add-js-sources inputs opts)
    Given list of IJavaScript objects, add foreign-deps, constants-table
    IJavaScript objects to the list.
    (add-preloads inputs opts)
    Add :preloads to a given set of inputs (IJavaScript). Returns a new
    list of inputs where the preloaded namespaces and their deps come immediately after
    cljs.core or the constants table depending on the optimization setting. Any
    files needing copying or compilation will be compiled and/or copied to the
    appropiate location.
    (add-source-map-link {:keys [source-map output-to], :as opts} js)
    (add-wrapper {:keys [output-wrapper], :as opts} js)
    Private
    (alive? proc)
    (build source opts)(build source opts compiler-env)
    Given a source which can be compiled, produce runnable JavaScript.
    
    (build-modules sources opts)
    Given a list of IJavaScript sources in dependency order and compiler options
    return a dependency sorted list of module name / description tuples. The
    module descriptions will be augmented with a :closure-module entry holding
    the Closure JSModule. Each module description will also be augmented with
    a :foreign-deps vector containing foreign IJavaScript sources in dependency
    order.
    (build-provides provides)
    Given a vector of provides, builds required goog.provide statements
    
    (check-cache-analysis-format {:keys [cache-analysis cache-analysis-format], :as opts})
    (check-node-target {:keys [target optimizations], :as opts})
    (check-npm-deps {:keys [npm-deps]})
    (check-output-dir {:keys [output-dir], :as opts})
    (check-output-to {:keys [output-to], :as opts})
    (check-output-wrapper {:keys [output-wrapper optimizations]})
    (check-preloads {:keys [preloads optimizations], :as opts})
    (check-source-map {:keys [output-to source-map output-dir optimizations], :as opts})
    (check-source-map-path {:keys [source-map-path], :as opts})
    (check-unprovided inputs)
    (cljs-dependencies opts requires)
    Given a list of all required namespaces, return a list of
    IJavaScripts which are the cljs dependencies. The returned list will
    not only include the explicitly required files but any transitive
    dependencies as well. JavaScript files will be compiled to the
    working directory if they do not already exist.
    
    Only load dependencies from the classpath.
    (cljs-dependents-for-macro-namespaces state namespaces)
    (cljs-source-for-namespace ns)
    Given a namespace return the corresponding source with either a .cljs or
    .cljc extension.
    protocol
    (-compile this opts)
    Returns one or more IJavaScripts.
    
    (-find-sources this opts)
    Returns one or more IJavascripts, without compiling them.
    
    (compile compilable opts)
    Given a Compilable, compile it and return an IJavaScript.
    
    (compile-dir src-dir opts)
    Recursively compile all cljs files under the given source
    directory. Return a list of JavaScriptFiles.
    (compile-file file {:keys [output-file], :as opts})
    Compile a single cljs file. If no output-file is specified, returns
    a string of compiled JavaScript. With an output-file option, the
    compiled JavaScript will written to this location and the function
    returns a JavaScriptFile. In either case the return value satisfies
    IJavaScript.
    (compile-form-seq forms)(compile-form-seq forms opts)
    Compile a sequence of forms to a JavaScript source string.
    
    (compile-from-jar jar-file {:keys [output-file], :as opts})
    Compile a file from a jar if necessary. Returns IJavaScript.
    
    (compile-loader inputs {:keys [modules], :as opts})
    Special compilation pass for cljs.loader namespace. cljs.loader must be
    compiled last after all inputs. This is because all inputs must be known and
    they must already be sorted in dependency order.
    (compile-sources inputs opts)(compile-sources inputs compiler-stats opts)
    Takes dependency ordered list of IJavaScript compatible maps from parse-ns
    and compiles them.
    (compile-task deque input-set compiled opts failed)
    (compiled-file m)
    Given a map with at least a :file key, return a map with
    {:file .. :provides .. :requires ..}.
    
    Compiled files are cached so they will only be read once.
    (compute-upstream-npm-deps)(compute-upstream-npm-deps {:keys [npm-deps]})
    Private
    (constants-filename opts)
    Returns the filename of the constants table.
    
    Private
    (constants-javascript-file opts)
    Returns the constants table as a JavaScriptFile.
    
    (convert-js-modules js-modules opts)
    Takes a list JavaScript modules as an IJavaScript and rewrites them into a Google
    Closure-compatible form. Returns list IJavaScript with the converted module
    code set as source.
    (deps-file opts sources)
    Return a deps file string for a sequence of inputs.
    
    (emit-optimized-source-map sm-json sources name opts)
    Given a JSON parsed Google Closure JavaScript to JavaScript source map,
    the entire list of original IJavaScript sources output a merged JavaScript
    to ClojureScript source map file with the given file name. opts should
    supply :preamble-line-count and :foreign-deps-line-count if they are
    relevant.
    (ensure-cljs-base-module modules)(ensure-cljs-base-module modules opts)
    Ensure that compiler :modules map has :cljs-base module with defined
    :output-to. If :output-to not provided will default to :output-dir location
    and the name of the file will be "cljs_base.js."
    (ensure-module-opts opts)
    (expand-libs libs)
    EXPERIMENTAL. Given a set of libs expand any entries which only name
    directories into a sequence of lib entries for all JS files recursively
    found in that directory. All other options will be shared with the original
    entry. The computed :provides assumes the specified directory is on the
    classpath.
    (find-cljs-dependencies requires)
    Given set of cljs namespace symbols, find IJavaScript objects for the namespaces.
    
    (find-jar-sources this opts)
    (foreign-deps-str opts sources)
    (foreign-source? js)
    (get-closure-sources closure-compiler)
    Gets map of source file name -> Node, for files in Closure Compiler js root.
    
    (get-compiled-cljs opts {:keys [relative-path uri]})
    Return an IJavaScript for this file. Compiled output will be
    written to the working directory.
    (get-data-readers*)(get-data-readers* classloader)
    returns a merged map containing all data readers defined by libraries
    on the classpath.
    (get-js-root closure-compiler)
    (get-source-files js-modules opts)
    (get-upstream-deps*)(get-upstream-deps* classloader)
    returns a merged map containing all upstream dependencies defined
    by libraries on the classpath.
    Private
    (gitlibs-cache-dir)
    Returns the gitlibs cache dir, a string.
    
    Private
    (gitlibs-src? file)
    Returns true if the file comes from the gitlibs cache.
    
    (handle-js-modules {:keys [npm-deps target], :as opts} js-sources compiler-env)
    Given all Cljs sources (build inputs and dependencies in classpath)
    
    - index all the node node modules
    - process the JS modules (preprocess + convert to Closure JS)
    - save js-dependency-index for compilation
    (in-same-dir? path-1 path-2)
    (index-node-modules modules)(index-node-modules modules opts)
    (index-node-modules-dir)(index-node-modules-dir opts)
    protocol
    (-paths this)
    Returns the file paths to the source inputs
    
    protocol
    (-source-map this)
    Return the CLJS compiler generated JS source mapping
    
    (-source-url this)
    Return the CLJS source url
    
    (jar-file-to-disk url out-dir)(jar-file-to-disk url out-dir opts)
    Copy a file contained within a jar to disk. Return the created file.
    
    (javascript-file foreign url provides requires)(javascript-file foreign url source-url provides requires lines source-map)
    (js-dependencies opts requires)
    Given a sequence of Closure namespace strings, return the list of
    all dependencies. The returned list includes all Google and
    third-party library dependencies.
    
    Third-party libraries are configured using the :libs option where
    the value is a list of directories containing third-party
    libraries.
    multimethod
    Takes an IJavaScript with the source code set as source, transforms the
    source code and returns an IJavascript with the new code set as source.
    Set of all known compiler options.
    
    (lang-key->lang-mode key)
    (lib-rel-path {:keys [lib-path url provides], :as ijs})
    Private
    (load-data-reader-file mappings url)
    (load-data-readers! compiler)
    (load-externs {:keys [externs use-only-custom-externs target ups-externs infer-externs], :as opts})
    Externs are JavaScript files which contain empty definitions of
    functions which will be provided by the environment. Any function in
    an extern file will not be renamed during optimization.
    
    Options may contain an :externs key with a list of file paths to
    load. The :use-only-custom-externs flag may be used to indicate that
    the default externs should be excluded.
    (make-closure-compiler)
    (make-convert-js-module-options opts)
    (make-options opts)
    Create a CompilerOptions object and set options from opts map.
    
    (make-preamble {:keys [target preamble hashbang]})
    (map->javascript-file m)
    (map->JavaScriptFile m__7585__auto__)
    Factory function for class cljs.closure.JavaScriptFile, taking a map of keywords to field values.
    
    (mark-cljs-ns-for-recompile! ns-sym output-dir)
    (maybe-install-node-deps! {:keys [npm-deps verbose], :as opts})
    Private
    (module-entries compile-opts)
    Return the module entries of compile-opts as a set.
    
    Private
    (node-file-seq->libs-spec* module-fseq)
    (node-inputs entries)(node-inputs entries opts)
    EXPERIMENTAL: return the foreign libs entries as computed by running
    the module-deps package on the supplied JavaScript entry points. Assumes
    that the @cljs-oss/module-deps NPM package is either locally or globally
    installed.
    (node-module-deps entry)(node-module-deps {:keys [file]} {:keys [target], :as opts})
    EXPERIMENTAL: return the foreign libs entries as computed by running
    the module-deps package on the supplied JavaScript entry point. Assumes
    that the @cljs-oss/module-deps NPM package is either locally or globally
    installed.
    (optimize opts & sources)
    Use the Closure Compiler to optimize one or more JavaScript files.
    
    (optimize-modules opts & sources)
    Use the Closure Compiler to optimize one or more Closure JSModules. Returns
    a dependency sorted list of module name and description tuples.
    Private
    (opts-fn kw opts)
    Extracts a function from opts, by default expecting a function value, but
    converting from a namespaced symbol if needed.
    (output-deps-file opts sources)
    (output-directory opts)
    (output-main-file opts)
    Output an entry point. In the non-modules case, opts is simply compiler
    options. When emitting a module entry point, opts must contain :module-name.
    (output-modules opts js-sources modules)
    Given compiler options, original IJavaScript sources and a sequence of
    module name and module description tuples output module sources to disk.
    Modules description must define :output-to and supply :source entry with
    the JavaScript source to write to disk.
    (output-one-file {:keys [output-to], :as opts} js)
    (output-unoptimized {:keys [modules], :as opts} & sources)
    Ensure that all JavaScript source files are on disk (not in jars),
    write the goog deps file including only the libraries that are being
    used and write the deps file for the current project.
    
    The deps file for the current project will include third-party
    libraries.
    (parallel-compile-sources inputs compiler-stats opts)
    (path-from-jarfile url)
    Given the URL of a file within a jar, return the path of the file
    from the root of the jar.
    (path-relative-to base input)
    Generate a string which is the path to the input IJavaScript relative
    to the specified base file.
    Private
    (pipe proc in out)
    (preamble-from-paths paths)
    (preloads syms)(preloads syms mode)
    (preprocess-js {:keys [preprocess], :as js-module} opts)
    Given js-module map, apply preprocessing defined by :preprocess value in the map.
    
    (process-js-modules opts)
    Given the current compiler options, converts JavaScript modules to Google
    Closure modules and writes them to disk. Adds mapping from original module
    namespace to new module namespace to compiler env. Returns modified compiler
    options where new modules are passed with :libs option.
    (random-string length)
    (read-js f)
    Read a JavaScript file returning a map of file information.
    
    (rel-output-path js)(rel-output-path js opts)
    Given a IJavaScript which points to a .js file either in memory, in a jar file,
    or is a foreign lib, return the path relative to the output directory.
    (report-failure result)
    (same-or-subdirectory-of? dir path)
    (set-options opts compiler-options)
    TODO: Add any other options that we would like to support.
    
    (shim-process? {:keys [target process-shim], :as opts})
    (source-for-namespace ns compiler-env)
    Given a namespace and compilation environment return the relative path and
    uri of the corresponding source regardless of the source language extension:
    .cljs, .cljc, .js
    (source-on-disk opts js)
    Ensure that the given IJavaScript exists on disk in the output directory.
    Return updated IJavaScript with the new location if necessary.
    (src-file->goog-require src)(src-file->goog-require src {:keys [wrap all-provides macros-ns], :as options})
    (src-file->target-file src)(src-file->target-file src opts)
    Private
    (sym->var sym kw ex-data)
    Converts a namespaced symbol to a var, loading the requisite namespace if
    needed. For use with a function defined under a keyword in opts. The kw and
    ex-data arguments are used to form exceptions.
    (target-file-for-cljs-ns ns-sym output-dir)
    Private
    (to-absolute-path file-str)
    (to-charset charset)
    (watch source opts)(watch source opts compiler-env)(watch source opts compiler-env quit)
    Given a source directory, produce runnable JavaScript. Watch the source
    directory for changes rebuilding when necessary. Takes the same arguments as
    cljs.closure/build in addition to some watch-specific options:
     - :watch-fn, a function of no arguments to run after a successful build.
     - :watch-error-fn, a function receiving the exception of a failed build.
    (write-javascript opts js)
    Write or copy a JavaScript file to output directory. Only write if the file
    does not already exist. Return IJavaScript for the file on disk at the new
    location.
    (write-js? js)
    Returns true if IJavaScript instance needs to be written/copied to output
    directory. True when in memory, in a JAR, or if foreign library.