BetterThanTomorrow / joyride

Making VS Code Hackable like Emacs since 2022
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.joyride
Other
469 stars 17 forks source link

Requiring a script that require a js file fails #128

Closed PEZ closed 1 year ago

PEZ commented 1 year ago

Given a structure like:

.joyride
├── scripts
│   ├── require_cljs_requiring_js_script.cljs
│   ├── require_js_script.cljs
│   └── workspace_activate.cljs
└── src
    ├── js-file.js
    ├── require_cljs_requiring_js.cljs
    ├── require_js.cljs
    ├── require_sub_dir_cljs_requiring_js.cljs
    └── sub_dir
        ├── require_cljs_requiring_js.cljs
        └── require_js.cljs

Where .joyride/src/js-file,js looks like so:

exports.fortytwo = 42;

.joyride/src/require_js.cljs:

(ns require-js
  (:require ["./js-file.js" :as js-file]))

(def fortytwo js-file/fortytwo)

fortytwo

.joyride/scripts/require_js_script.cljs:

(ns require-js-script
  (:require ["../src/js-file.js" :as js-file]))

(def fortytwo js-file/fortytwo)

fortytwo

.joyride/scripts/require_cljs_requiring_js_script.cljs

(ns require-cljs-requiring-js-script
  (:require [require-js]))

(def fortytwo require-js/fortytwo)

fortytwo

I can Run Workspace Script: require_js_script.cljs, and get the expected result (42 printed in the Joyride output channel).

However, running require_cljs_requiring_js_script.cljs fails with:

 Evaluating file: require_cljs_requiring_js.cljs
; Cannot find module './js-file.js'
; Require stack:
; - /require_js.cljs
; Evaluation of file require_cljs_requiring_js.cljs failed: #error {:message "Cannot find module './js-file.js'\nRequire stack:\n- /require_js.cljs", :data {:type :sci/error, :line 2, :column 3, :message "Cannot find module './js-file.js'\nRequire stack:\n- /require_js.cljs", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 2, :column 3, :file "/Users/pez/Projects/joyride/vscode-test-runner/workspace-1/.joyride/src/require_cljs_requiring_js.cljs", :ns #object[sci.lang.Namespace]} {:line 2, :column 3, :file "require_js.cljs", :ns #object[sci.lang.Namespace]})}], :file "require_js.cljs"}, :cause #object[Error Error: Cannot find module './js-file.js'

Though, if I first load .joyride/src/require_js.cljs in the REPL, I can run the require_cljs_requiring_js_script.cljs script with the expected results. (Not so strange probably, just noticing it as a possible clue to what goes wrong.)