ClojureScript

top-level symbol reference doesn't get an automatically inserted ns-name

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Environment:
    org.clojure/clojurescript "0.0-2030"

Description

I'm trying to use a Node.js module (with nested namespaces) in ClojureScript - the code goes like this:

(ns myapp)
(def evernote (js/require "evernote"))
(def token "TOKEN")
(defn do-sth []
  (let [client (evernote.Evernote.Client. (js-obj "token" token))]
    (.log js/console client)))
(do-sth)

which gets compiled (with :simple optimization) to:

var myapp = {}
myapp.evernote = require("evernote")
myapp.token = "TOKEN"
myapp.do_sth = function() {
  var a = new evernote.Evernote.Client({token:myapp.token})
  return console.log(a)
}
myapp.do_sth()

which will obviously fail with error "Uncaught ReferenceError: evernote is not defined".

Activity

David Nolen made changes -
Field Original Value New Value
Description I'm trying to use a Node.js module (with nested namespaces) in ClojureScript - the code goes like this:

    (ns myapp)
    (def evernote (js/require "evernote"))
    (def token "TOKEN")
    (defn do-sth []
      (let [client (evernote.Evernote.Client. (js-obj "token" token))]
        (.log js/console client)))
    (do-sth)

which gets compiled (with :simple optimization) to:

    var myapp = {}
    myapp.evernote = require("evernote")
    myapp.token = "TOKEN"
    myapp.do_sth = function() {
      var a = new evernote.Evernote.Client({token:myapp.token})
      return console.log(a)
    }
    myapp.do_sth()

which will obviously fail with error "Uncaught ReferenceError: evernote is not defined".
I'm trying to use a Node.js module (with nested namespaces) in ClojureScript - the code goes like this:

{code}
(ns myapp)
(def evernote (js/require "evernote"))
(def token "TOKEN")
(defn do-sth []
  (let [client (evernote.Evernote.Client. (js-obj "token" token))]
    (.log js/console client)))
(do-sth)
{code}

which gets compiled (with :simple optimization) to:

{code}
var myapp = {}
myapp.evernote = require("evernote")
myapp.token = "TOKEN"
myapp.do_sth = function() {
  var a = new evernote.Evernote.Client({token:myapp.token})
  return console.log(a)
}
myapp.do_sth()
{code}

which will obviously fail with error "Uncaught ReferenceError: evernote is not defined".
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: