Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

In Javascript when a module is required you can omit the extension in the relative path form. If you do and the path is a directory and that directory contains an index.js, that file is treated as the main script.

So, this statement:

`javascript
const foo = require('./foo')
`

Can be resolved as ./foo.js or ./foo/index.js.

The module resolver should take this into account, and if an index.js is resolved in a required directory, it should also provide like both

module$Users$user$Documents$project$node_modules$foo$index module$Users$user$Documents$project$node_modules$foo

Actual repr here: (link: cljs-name-to-path-issue)(https://github.com/rangeoshun/cljs-name-to-path-issue)

It produced the following error in browser:

Undefined nameToPath for module$Users$range$Documents$cljs_name_to_path_issue$node_modules$deat_mui_core$colors

It is because node_modules/deat-mui-core/colors/index.js only provides the following in the compiled version:

`javascript
goog.provide("module$Users$range$Documents$cljs_name_to_path_issue$node_modules$deat_mui_core$colors$index");
`

It should also provide if that makes no confilct:

`javascript
goog.provide("module$Users$range$Documents$cljs_name_to_path_issue$node_modules$deat_mui_core$colors");
`

3 Answers

0 votes
by

Comment made by: range

Sorry for faulty markdown :(

0 votes
by

Comment made by: range

Please close, as looking through the tests it seems it works, so the lein-cljsbuild might be out of date on this dep.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2939 (reported by alex+import)
...