shadow-cljs icon indicating copy to clipboard operation
shadow-cljs copied to clipboard

Failure to load namespace with dashes using `goog:` prefix on JS files

Open aisamu opened this issue 4 years ago • 0 comments

(From clojurians, as requested)

The documentation states that we can access CLJS ns's on consumed JS files using a goog: prefix (i.e. import something from "goog:namespace") When we use such a JS file from Shadow and the CLJS ns contains dashes, things break.

;;;;;;;;;;;
;; company/name_with_dashes.cljs

(ns company.name-with-dashes)
(def ^:export Thing '...)
///////////
// company/folder-with-dashes/helper.js

import {Thing} from 'goog:company.name-with-dashes'
;;;;;;;;;;;
;; company/component.cljs

(ns company.component
  (:require ["company/folder-with-dashes/helper.js" :as helper]))

While running tests involving company.component via :browser-test, shadow issues a warning:

shadow-cljs - failed to load module$node_modules$company$folder_with_dashes$helper
shadow.js.jsRequire @ js.js:71

failed to load company.component.js ReferenceError: with is not defined
    at Object.shadow$provide.module$node_modules$company$folder_with_dashes$helper (helper.js:xx)
    at Object.shadow.js.jsRequire (js.js:63)
    at Object.shadow.js.require (js.js:97)
    at eval (/js/cljs-runtime/company.component.js:xx)
    at eval (<anonymous>)
    at Object.goog.globalEval (test.js:827)
    at Object.env.evalLoad (test.js:2174)
    at test.js:2373
env.evalLoad @ test.js:2176

Digging into module$node_modules$company$folder_with_dashes$helper reveals:

...
var _immutable = require("module$node_modules$immutable$dist$immutable"),
_googCompany = global.company.name-with-dashes
                              // ^ can't have dashes on JS symbol, right?

aisamu avatar Dec 23 '19 19:12 aisamu