cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
Oliver George 2020-04-23T02:44:30.207900Z

I'm using krell (so unreleased cljs version). The code generated when i use default seems broken... It seems to get a "$" postfix. Note how module/default becomes .default$ but (.-default) becomes .default For for example...

(ns connect-app.utils.rnc-datetimepicker
  (:require ["@react-native-community/datetimepicker" :as module :refer [default abc]]
            [goog.object :as gobj]))

(def RNDateTimePicker1 module/default)
(def RNDateTimePicker2 (.-default module))
(def RNDateTimePicker3 (gobj/get module "default"))
(def RNDateTimePicker4 default)
Produces this...
// Compiled by ClojureScript 0.0.1780021040 {:target :nodejs}
goog.provide('connect_app.utils.rnc_datetimepicker');
goog.require('cljs.core');
goog.require('goog.object');
connect_app.utils.rnc_datetimepicker.node$module$_CIRCA_react_native_community$datetimepicker = require('@react-native-community/datetimepicker');
connect_app.utils.rnc_datetimepicker.RNDateTimePicker1 = connect_app.utils.rnc_datetimepicker.node$module$_CIRCA_react_native_community$datetimepicker.default$;
connect_app.utils.rnc_datetimepicker.RNDateTimePicker2 = connect_app.utils.rnc_datetimepicker.node$module$_CIRCA_react_native_community$datetimepicker.default;
connect_app.utils.rnc_datetimepicker.RNDateTimePicker3 = goog.object.get(connect_app.utils.rnc_datetimepicker.node$module$_CIRCA_react_native_community$datetimepicker,"default");
connect_app.utils.rnc_datetimepicker.RNDateTimePicker4 = connect_app.utils.rnc_datetimepicker.node$module$_CIRCA_react_native_community$datetimepicker.default$;

Oliver George 2020-04-23T02:45:47.208600Z

The variants which produce .default$ don't work for accessing default exports from npm libs.

thheller 2020-04-23T06:58:52.210200Z

@olivergeorge default used to be a reserved name in JS so CLJS mangles it unless configured not to.

thheller 2020-04-23T07:00:48.210700Z

but might be that the code that covers this doesn't handle the ns alias properly

thheller 2020-04-23T07:01:00.210900Z

certainly looks like that

👍 1
dnolen 2020-04-23T12:18:12.211600Z

@olivergeorge you need to configure :language-out

dnolen 2020-04-23T12:19:12.212700Z

I'm pretty sure this was sorted a couple of years ago - I'm assuming it should work for :es6 if not - a bug

Oliver George 2020-04-23T12:34:20.214200Z

Thanks. I’ll give that a try.

Oliver George 2020-04-23T22:49:16.215100Z

Confirmed, adding :language-out :es6 did the trick all variants working now.

Oliver George 2020-04-23T22:49:39.215500Z

@dnolen seems like that might be a sensible default for krell.

dnolen 2020-04-23T23:40:11.215700Z

sure