From f4caba3fafd4be89e30ba706e1a2324b969f8394 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 23 Aug 2024 21:25:24 +0200 Subject: [PATCH 01/18] Support reloading of JS file --- src/nbb/core.cljs | 54 ++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index c0f4662..8bd3d09 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -135,7 +135,7 @@ (defn register-module [mod internal-name] (swap! loaded-modules assoc internal-name mod)) -(defn load-js-module [libname internal-name] +(defn load-js-module [libname internal-name reload?] (-> (if-let [resolve (:resolve @ctx)] (-> (resolve libname) (.catch @@ -143,11 +143,14 @@ ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) (.then (fn [path] - (esm/dynamic-import - (let [path (if (and windows? (fs/existsSync path)) - (str (url/pathToFileURL path)) - path)] - path)))) + (let [path (if reload? + (str path "?uuid=" (random-uuid)) + path)] + (esm/dynamic-import + (let [path (if (and windows? (fs/existsSync path)) + (str (url/pathToFileURL path)) + path)] + path))))) (.then (fn [mod] (register-module mod internal-name) mod)))) @@ -233,7 +236,8 @@ feat (load-module feat libname as refer rename libspecs ns-opts) (string? libname) (let [libname (if (str/starts-with? libname "./") - (path/resolve (path/dirname (:file ns-opts)) libname) + (path/resolve (path/dirname (or (:file ns-opts) ".")) + libname) libname) [libname properties*] (split-libname libname) munged (munge libname) @@ -262,19 +266,21 @@ (sci/add-class! internal-subname mod-field) (sci/add-import! current-ns internal-subname field)))))) (handle-libspecs (next libspecs) ns-opts)) - mod (js/Promise.resolve - (-> - (or - ;; skip loading if module was already loaded - (some-> (get @loaded-modules internal-name) - js/Promise.resolve) - (load-js-module libname internal-name) - ;; else load module and register in loaded-modules under internal-name - ) - (.then (fn [mod] - (if properties - (gobj/getValueByKeys mod properties) - mod)))))] + mod (let [reload? (contains? (:opts ns-opts) :reload)] + (js/Promise.resolve + (-> + (or + ;; skip loading if module was already loaded + (and (not reload?) + (some-> (get @loaded-modules internal-name) + js/Promise.resolve)) + (load-js-module libname internal-name reload?) + ;; else load module and register in loaded-modules under internal-name + ) + (.then (fn [mod] + (if properties + (gobj/getValueByKeys mod properties) + mod))))))] (-> mod (.then after-load))) :else @@ -337,6 +343,7 @@ (defn eval-require [require-form] (let [args (rest require-form) + args (remove keyword? args) libspecs (mapv #(sci/eval-form (store/get-ctx) %) args) sci-ns @sci/ns sci-file @sci/file] @@ -658,8 +665,11 @@ (if *old-require* (apply old-require args) (await (.then (identity ;; with-async-bindings {sci/file @sci/file} - (handle-libspecs args {:ns @sci/ns - :file @sci/file})) + (let [opts (into #{} (filter keyword? args)) + args (remove keyword? args)] + (handle-libspecs args {:ns @sci/ns + :file @sci/file + :opts opts}))) (fn [_])))))) (def ^:dynamic *file* sci/file) ;; make clj-kondo+lsp happy From 9c8ac68687c93b86651e9fdba1f5e720a1e9b582 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 23 Aug 2024 21:33:49 +0200 Subject: [PATCH 02/18] Also support ns form --- src/nbb/core.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 8bd3d09..1d4026d 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -338,8 +338,10 @@ ns-obj (sci/binding [sci/ns @sci/ns] (sci/eval-form (store/get-ctx) (list 'do (list* 'ns ns-name other-forms) '*ns*))) libspecs (mapcat rest require-forms) + ns-opts (into #{} (filter keyword? libspecs)) + libspecs (remove keyword? libspecs) opts (assoc opts :ns ns-obj)] - (handle-libspecs libspecs opts))) + (handle-libspecs libspecs (assoc opts :opts ns-opts)))) (defn eval-require [require-form] (let [args (rest require-form) From e909557d522754ea118b0bba55591f16311debda Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Fri, 23 Aug 2024 23:01:16 +0200 Subject: [PATCH 03/18] fix node:fs --- src/nbb/core.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 1d4026d..f0771a2 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -143,7 +143,9 @@ ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) (.then (fn [path] - (let [path (if reload? + (let [path (if (and reload? + ;; "node:fs" etc + (not= libname path)) (str path "?uuid=" (random-uuid)) path)] (esm/dynamic-import From 25e42476ac767bdc1696ef864cde6a3313095052 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 12:17:53 +0100 Subject: [PATCH 04/18] Fix #343: support `:reload` for reloading CLJS namespaces and JS code --- .gitignore | 1 + CHANGELOG.md | 4 ++++ src/nbb/core.cljs | 3 ++- test-scripts/reload.cljs | 9 +++++++++ test-scripts/reload.js | 3 +++ test/nbb/main_test.cljs | 8 ++++++++ 6 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test-scripts/reload.cljs create mode 100644 test-scripts/reload.js diff --git a/.gitignore b/.gitignore index f9bd904..8c0a335 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ bun.lockb scratch.mjs scratch.cljs *.bun-build +scratch diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a9420c..a699530 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ For a list of breaking changes, check [here](#breaking-changes). [Nbb](https://github.com/babashka/nbb): Scripting in Clojure on Node.js using [SCI](https://github.com/babashka/sci) +## 1.3.195 (2024-11-07) + +- [#343](https://github.com/babashka/nbb/issues/343): support `:reload` for reloading CLJS namespaces and JS code + ## 1.3.194 (2024-10-23) - Fix issue with loading `cljs.spec.alpha` by upgrading shadow-cljs diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 090f893..edb70e4 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -291,7 +291,8 @@ (.then after-load))) :else ;; assume symbol - (if (sci/eval-form (ctx/get-ctx) (list 'clojure.core/find-ns (list 'quote libname))) + (if (and (not (contains? (:opts ns-opts) :reload)) + (sci/eval-form (ctx/get-ctx) (list 'clojure.core/find-ns (list 'quote libname)))) ;; built-in namespace (do (sci/binding [sci/ns (:ns ns-opts) sci/file (:file ns-opts)] diff --git a/test-scripts/reload.cljs b/test-scripts/reload.cljs new file mode 100644 index 0000000..df384a5 --- /dev/null +++ b/test-scripts/reload.cljs @@ -0,0 +1,9 @@ +(ns reload + (:require ["./reload.js"] :reload)) + +(defonce my-atom (atom 0)) + +(swap! my-atom inc) + +(def x js/globalThis.x) + diff --git a/test-scripts/reload.js b/test-scripts/reload.js new file mode 100644 index 0000000..0fe1328 --- /dev/null +++ b/test-scripts/reload.js @@ -0,0 +1,3 @@ +var x = globalThis.x || 0; +globalThis.x = x + 1; + diff --git a/test/nbb/main_test.cljs b/test/nbb/main_test.cljs index 8276426..4af68c7 100644 --- a/test/nbb/main_test.cljs +++ b/test/nbb/main_test.cljs @@ -337,6 +337,14 @@ result") (fn [val] (is (number? val)))))) +(deftest-async reload-test + (is (.then (nbb/load-string "(require 'reload) +(require 'reload :reload) + +[@reload/my-atom reload/x]") + (fn [val] + (is (= [2 2] val)))))) + (defn init [] (t/run-tests 'nbb.main-test 'nbb.test-test)) From 9dc60b99ae4e5863726b48f1f5a59525894abd80 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 14:09:18 +0100 Subject: [PATCH 05/18] debug win --- src/nbb/core.cljs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index edb70e4..6dddf92 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -146,11 +146,13 @@ ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) (.then (fn [path] + (prn :libname libname :path path) (let [path (if (and reload? ;; "node:fs" etc (not= libname path)) (str path "?uuid=" (random-uuid)) path)] + (prn :path path) (esm/dynamic-import (let [path (if (and windows? (fs/existsSync path)) (str (url/pathToFileURL path)) From 7d9442c097abd8693a07ba4a502027294c55d6b4 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 14:25:17 +0100 Subject: [PATCH 06/18] wip --- src/nbb/core.cljs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 6dddf92..d84b034 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -138,6 +138,11 @@ (defn register-module [mod internal-name] (swap! loaded-modules assoc internal-name mod)) +#_(if (str/starts-with? libname "./") + (path/resolve (path/dirname (or (:file ns-opts) ".")) + libname) + libname) + (defn load-js-module [libname internal-name reload?] (-> (if-let [resolve (:resolve @ctx)] (-> (resolve libname) @@ -243,10 +248,7 @@ (cond feat (load-module feat libname as refer rename libspecs ns-opts) (string? libname) - (let [libname (if (str/starts-with? libname "./") - (path/resolve (path/dirname (or (:file ns-opts) ".")) - libname) - libname) + (let [libname libname [libname properties*] (split-libname libname) munged (munge libname) properties (when properties* (.split properties* ".")) From f123c8de799aee7863cd54ce20ef0c7a915fc0ef Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 15:04:11 +0100 Subject: [PATCH 07/18] yeah --- src/nbb/core.cljs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index d84b034..3a4a49d 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -138,11 +138,6 @@ (defn register-module [mod internal-name] (swap! loaded-modules assoc internal-name mod)) -#_(if (str/starts-with? libname "./") - (path/resolve (path/dirname (or (:file ns-opts) ".")) - libname) - libname) - (defn load-js-module [libname internal-name reload?] (-> (if-let [resolve (:resolve @ctx)] (-> (resolve libname) @@ -151,13 +146,13 @@ ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) (.then (fn [path] - (prn :libname libname :path path) (let [path (if (and reload? ;; "node:fs" etc - (not= libname path)) + (and (not= libname path) + (or (not windows?) + (fs/existsSync path)))) (str path "?uuid=" (random-uuid)) path)] - (prn :path path) (esm/dynamic-import (let [path (if (and windows? (fs/existsSync path)) (str (url/pathToFileURL path)) @@ -248,7 +243,10 @@ (cond feat (load-module feat libname as refer rename libspecs ns-opts) (string? libname) - (let [libname libname + (let [libname (if (str/starts-with? libname "./") + (path/resolve (path/dirname (or (:file ns-opts) ".")) + libname) + libname) [libname properties*] (split-libname libname) munged (munge libname) properties (when properties* (.split properties* ".")) From 43253f6b719973094d77192ba03e17be46fd12fb Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 15:47:35 +0100 Subject: [PATCH 08/18] wip --- src/nbb/core.cljs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 3a4a49d..855a7d9 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -146,11 +146,13 @@ ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) (.then (fn [path] - (let [path (if (and reload? - ;; "node:fs" etc - (and (not= libname path) - (or (not windows?) - (fs/existsSync path)))) + (let [file (if (str/starts-with? path "file:") + (url/fileURLToPath path) + path) + file? (fs/existsSync file) + path (if (and reload? + ;; not "node:fs" etc + file?) (str path "?uuid=" (random-uuid)) path)] (esm/dynamic-import From f1cb8b86dba0d5d767bebcd8fa2922cc3a447b68 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 16:17:11 +0100 Subject: [PATCH 09/18] file --- src/nbb/core.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 855a7d9..c1f19d4 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -153,7 +153,7 @@ path (if (and reload? ;; not "node:fs" etc file?) - (str path "?uuid=" (random-uuid)) + (str file "?uuid=" (random-uuid)) path)] (esm/dynamic-import (let [path (if (and windows? (fs/existsSync path)) From d197e13397c7d3bcdabc9473ecb99e1cf635bd98 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 16:52:35 +0100 Subject: [PATCH 10/18] wip --- src/nbb/core.cljs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index c1f19d4..6c77391 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -150,16 +150,17 @@ (url/fileURLToPath path) path) file? (fs/existsSync file) - path (if (and reload? + path* (if (and reload? ;; not "node:fs" etc file?) (str file "?uuid=" (random-uuid)) - path)] - (esm/dynamic-import - (let [path (if (and windows? (fs/existsSync path)) - (str (url/pathToFileURL path)) - path)] - path))))) + path) + path (if (and windows? (fs/existsSync path*)) + (str (url/pathToFileURL path*)) + path*)] + (when windows? + (prn :path path :reload reload? :path* path*)) + (esm/dynamic-import path)))) (.then (fn [mod] (register-module mod internal-name) mod)))) From 8bde6667dc2681ede1bdb8c3f42fbaedd2905db6 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 17:00:05 +0100 Subject: [PATCH 11/18] this should work --- src/nbb/core.cljs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 6c77391..1a94717 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -155,11 +155,9 @@ file?) (str file "?uuid=" (random-uuid)) path) - path (if (and windows? (fs/existsSync path*)) + path (if (and windows? file?) (str (url/pathToFileURL path*)) path*)] - (when windows? - (prn :path path :reload reload? :path* path*)) (esm/dynamic-import path)))) (.then (fn [mod] (register-module mod internal-name) From 25b0e6e9383e1496cb6ad5bbc3c26e76502e70e7 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 17:01:31 +0100 Subject: [PATCH 12/18] delay --- src/nbb/core.cljs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 1a94717..2389ce7 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -149,13 +149,13 @@ (let [file (if (str/starts-with? path "file:") (url/fileURLToPath path) path) - file? (fs/existsSync file) + file? (delay (fs/existsSync file)) path* (if (and reload? ;; not "node:fs" etc - file?) + @file?) (str file "?uuid=" (random-uuid)) path) - path (if (and windows? file?) + path (if (and windows? @file?) (str (url/pathToFileURL path*)) path*)] (esm/dynamic-import path)))) From 2f75d6c332479238f8a0ed1c69f7988384aafc43 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 17:19:31 +0100 Subject: [PATCH 13/18] add github workflow --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0502050 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: build + +on: [push, pull_request] + +jobs: + build: + runs-on: windows-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + submodules: 'true' + + - name: Cache deps + uses: actions/cache@v2 + id: cache-deps + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('deps.edn') }} + restore-keys: ${{ runner.os }}-maven- + + - name: Prepare java + uses: actions/setup-java@v2 + with: + distribution: 'adopt-hotspot' + java-version: '19' + + - name: Install clojure tools + uses: DeLaGuardo/setup-clojure@5.0 + with: + cli: latest + bb: latest + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + + - name: Run tests + run: | + bb ci:test From 1abc090d3cb3dbc18ebf5b2bf1e9f3b316b87832 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 17:23:20 +0100 Subject: [PATCH 14/18] fix yaml --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0502050..c2c9fff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,12 @@ on: [push, pull_request] jobs: build: + runs-on: windows-latest + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: - name: Git checkout uses: actions/checkout@v4 @@ -34,8 +37,8 @@ jobs: cli: latest bb: latest - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 - name: Run tests run: | From a7a4fce52e4e21276f2ab11fb17e20f8580864ec Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 18:28:20 +0100 Subject: [PATCH 15/18] wip --- src/nbb/core.cljs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 2389ce7..9a3b01a 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -146,18 +146,16 @@ ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) (.then (fn [path] - (let [file (if (str/starts-with? path "file:") - (url/fileURLToPath path) - path) - file? (delay (fs/existsSync file)) - path* (if (and reload? + ;; (prn :path path) + (let [file-url (if (str/starts-with? path "file:") + path + (when (fs/existsSync path) + (url/pathToFileURL path))) + path (if (and reload? ;; not "node:fs" etc - @file?) - (str file "?uuid=" (random-uuid)) - path) - path (if (and windows? @file?) - (str (url/pathToFileURL path*)) - path*)] + file-url) + (str file-url "?uuid=" (random-uuid)) + path)] (esm/dynamic-import path)))) (.then (fn [mod] (register-module mod internal-name) From c33c6263bacf49a272f9d3b12b2be41300104805 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 20:20:51 +0100 Subject: [PATCH 16/18] wip --- src/nbb/core.cljs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 9a3b01a..4615544 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -138,6 +138,10 @@ (defn register-module [mod internal-name] (swap! loaded-modules assoc internal-name mod)) +(defn debug [& xs] + (binding [*print-fn* *print-err-fn*] + (apply prn xs))) + (defn load-js-module [libname internal-name reload?] (-> (if-let [resolve (:resolve @ctx)] (-> (resolve libname) @@ -145,17 +149,16 @@ (fn [_] ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) - (.then (fn [path] - ;; (prn :path path) - (let [file-url (if (str/starts-with? path "file:") + (.then (fn [path] + (let [file-url (if (str/starts-with? (str path) "file:") path - (when (fs/existsSync path) - (url/pathToFileURL path))) + (when (fs/existsSync path) + (str (url/pathToFileURL path)))) path (if (and reload? ;; not "node:fs" etc file-url) (str file-url "?uuid=" (random-uuid)) - path)] + (or file-url path))] (esm/dynamic-import path)))) (.then (fn [mod] (register-module mod internal-name) From 507b6fd96033e058f4460a715f380a9542a013ab Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 20:22:26 +0100 Subject: [PATCH 17/18] remove tmate --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2c9fff..d3210f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,8 +37,8 @@ jobs: cli: latest bb: latest - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 + # - name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 - name: Run tests run: | From 1d1b941adc7db0a6bd2eca8561744d4213f98def Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 7 Nov 2024 20:29:23 +0100 Subject: [PATCH 18/18] tweak --- src/nbb/core.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nbb/core.cljs b/src/nbb/core.cljs index 4615544..3d7f795 100644 --- a/src/nbb/core.cljs +++ b/src/nbb/core.cljs @@ -149,10 +149,10 @@ (fn [_] ((.-resolve (:require @ctx)) libname)))) (js/Promise.resolve ((.-resolve (:require @ctx)) libname))) - (.then (fn [path] + (.then (fn [path] (let [file-url (if (str/starts-with? (str path) "file:") path - (when (fs/existsSync path) + (when (and (or windows? reload?) (fs/existsSync path)) (str (url/pathToFileURL path)))) path (if (and reload? ;; not "node:fs" etc