ClojureScript

1.10.844 Release

06 April 2021
ClojureScript Team

We’re happy to announce a new release of ClojureScript. If you’re an existing user of ClojureScript please read over the following release notes carefully.

Noteworthy & Breaking Changes

  • Closure Compiler has been updated to v20210302

  • Closure Library has been updated to 0.0-20201211-3e6c510d

Note that the latest Closure Library release includes breaking changes that may impact your code:

  • goog.debug.Logger.Level has been renamed to goog.Logger.Level and the goog.log.Level/getLogger function now takes an additional argument.

  • The following JavaScript type checking predicates have been removed: goog/isString, goog/isArray, goog/isFunction, goog/isNumber, and goog/isBoolean.

  • Closure namespace loading logic has been revised, necessitating updates to some REPLs.

New Core Features

Library Property Namespaces

When consuming a JavaScript library which is exposed as a JavaScript object, you can now specify a property of this object to be used as a first-class namespace in ClojureScript. To do this, you use the $ delimiter.

For example, the SubLib property of a library object provided by npm-lib can be treated as a namespace like so:

(ns foo
  (:require [npm-lib$SubLib :as sub-lib :refer [...]]))

If needed, you can also employ string-based requires:

(ns foo
  (:require ["@npm/lib$SubLib" :as sub-lib :refer [...]]))

This feature can also be used to access default exports:

(ns foo
  (:require [npm-lib$default :as npm-lib :refer [...]]))

The $ delimiter is only needed to access the top-level object property; any nested properties are accessed via . as in the following example:

(ns foo
  (:require [react-native$NativeModules.SomeBridge :as woz]))

Notable Fixes

Accurate file name and line numbers in cljs.test

Instead of inaccurately inferring file name and line numbers from the call stack in do-report, they are now captured during macro-expansion based on metadata.

sort and sort-by retain meta

This simple change makes sort and sort-by consistent with Clojure. For example, the following evaluates to {:a true}:

(meta (sort (with-meta (range 10) {:a true})))

Floating point issues with range

Some floating point issues were addressed for range, making, for example (range 0 (+ 1 (/ 9)) (/ 9)) have 10 elements and (nth (range 0 1 0.1) 6) properly evaluate to 0.6.

#inst parsing and printing, reflect proleptic Gregorian

JavaScript employs a proleptic Gregorian date system and some bugs in ClojureScript’s #inst support is now fixed for very old dates with respect to parsing and printing #inst values.

Performance Improvements

Reduce code generated by destructure macro for maps

The code generated to implement map destructuring was optimized by introducing a shared helper to handle kw-args, reducing a portion of the Closure-optimized output from 35 bytes down to 5, a nice savings since map destructuring is frequently employed in code.

Change List

For a complete list of updates in ClojureScript 1.10.844 see Changes.

Contributors

Thanks to all of the community members who contributed to ClojureScript 1.10.844:

  • Arne Brasseur

  • Erik Assum

  • Hyunwoo Nam

  • Matthew Huebert

  • Thomas Heller