diff options
| author | 2026-02-13 19:36:09 -0600 | |
|---|---|---|
| committer | 2026-02-13 19:36:09 -0600 | |
| commit | 2a54154976979e9c91bd20a10c2311ae4ce78869 (patch) | |
| tree | bdda7d32ac14b821e6defaa272ab88bacf61941f | |
| parent | Merge branch 'make-modules-easier' (diff) | |
Don't use preload on absolute paths.
When importing full paths, the old preload code was preventing
(import <fullpath> :fresh true) from working as expected.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | src/boot/boot.janet | 10 |
2 files changed, 8 insertions, 3 deletions
@@ -12,6 +12,7 @@ janet /src/include/generated/*.h janet-*.tar.gz dist +/tmp # jpm lockfile lockfile.janet diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 1923eb46..3e103009 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -2874,7 +2874,8 @@ (defn- check-dyn-relative [x] (if (string/has-prefix? "@" x) x)) (defn- check-relative [x] (if (string/has-prefix? "." x) x)) -(defn- check-not-relative [x] (if-not (string/has-prefix? "." x) x)) +# Don't try to preload absolute or relative paths +(defn- check-preloadable [x] (if-not (or (string/has-prefix? "/" x) (string/find "." x) (string/find "@" x)) x)) (defn- check-is-dep [x] (unless (or (string/has-prefix? "/" x) (string/has-prefix? "@" x) (string/has-prefix? "." x)) x)) (defn- check-project-relative [x] (if (string/has-prefix? "/" x) x)) @@ -2949,7 +2950,10 @@ (module/add-paths "/init.janet" :source) (module/add-paths ".janet" :source) (module/add-paths ".jimage" :image) -(array/insert module/paths 0 [(fn is-cached [path] (if (in (dyn *module-cache* module/cache) path) path)) :preload check-not-relative]) +(array/insert module/paths 0 + [(fn is-cached [path] (if (in (dyn *module-cache* module/cache) path) path)) + :preload + check-preloadable]) # Version of fexists that works even with a reduced OS (defn- fexists @@ -3219,7 +3223,7 @@ (def prefix (or (and as (string as "/")) prefix - (string (last (string/split "/" path)) "/"))) + (string (first (string/split "." (last (string/split "/" path)))) "/"))) (merge-module env newenv prefix ep only)) (defmacro import |
