Uploaded image for project: 'ClojureScript'
  1. CLJS-1820

"No such namespace" warning when referring to JS module namespace without using alias

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects versions: 1.9.76
    • Fix versions: None
    • Labels:
      None

      Description

      Currently, when requiring a JS module it is not possible to refer to it using the original namespace. For example, the following code will result in a warning:

      (ns my-calculator.core
        (:require [my.calc]))
      
      (println (my.calc/add 5 5))
      
      WARNING: No such namespace: my.calc, could not locate my/calc.cljs, my/calc.cljc, or Closure namespace "" at line 4 src/my_calculator/core.cljs
      WARNING: Use of undeclared Var my.calc/add at line 4 src/my_calculator/core.cljs
      

      And the resulting JavaScript will throw the following error:

      Uncaught ReferenceError: my is not defined
      

      However, defining an alias for the JS module and using it works fine, for example:

      (ns my-calculator.core
        (:require [my.calc :as calc]))
      
      (println (calc/add 5 5))
      

      Here is a minimal repo to reproduce this problem: https://github.com/mneise/my-calculator.

        Attachments

          Activity

            People

            • Assignee:
              dnolen David Nolen
              Reporter:
              mneise Maria Geller
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: