Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative Javascript imports are apparently being cached by "name", not by the resolved path #253

Closed
aisamu opened this issue Sep 1, 2022 · 6 comments

Comments

@aisamu
Copy link

aisamu commented Sep 1, 2022

version

❯ nbb --version       
nbb v0.7.132

platform

❯ node --version  
v18.7.0

❯ uname -a     
Darwin ... 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64 arm Darwin

problem

Relative Javascript imports are apparently being cached by "name" not by the resolved path

repro

Given the following "project":

───────┬──────────────────────────────────────────────────────────────────
       │ File: import_root.cljs
───────┼──────────────────────────────────────────────────────────────────
   1   │ (ns import-root
   2   │   (:require [import-1.core :as i1]
   3   │             [import-2.core :as i2]))
   4   │ 
   5   │ (println "loaded import_root")
───────┴──────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────
       │ File: import_1/core.cljs
───────┼──────────────────────────────────────────────────────────────────
   1   │ (ns import-1.core
   2   │   (:require ["./local-dep.mjs" :as local-dep]))
   3   │ 
   4   │ (println "loaded import 1 core")
───────┴──────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────
       │ File: import_1/local-dep.mjs
───────┼──────────────────────────────────────────────────────────────────
   1   │ console.log("Imported local dep 1");
───────┴──────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────
       │ File: import_2/core.cljs
───────┼──────────────────────────────────────────────────────────────────
   1   │ (ns import-2.core
   2   │   (:require ["./local-dep.mjs" :as local-dep]))
   3   │ 
   4   │ (println "loaded import 2 core")
───────┴──────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────
       │ File: import_2/local_dep.mjs
───────┼──────────────────────────────────────────────────────────────────
   1   │ console.log("Imported local dep 2");
───────┴──────────────────────────────────────────────────────────────────

Running it gives

❯ nbb import_root.cljs
Imported local dep 1
loaded import 1 core
loaded import 2 core
loaded import_root

expected behavior

❯ nbb import_root.cljs
Imported local dep 1
loaded import 1 core
+Imported local dep 2
loaded import 2 core
loaded import_root

Thanks for yet another incredible project! ❤️

@borkdude
Copy link
Collaborator

borkdude commented Sep 1, 2022 via email

@aisamu
Copy link
Author

aisamu commented Sep 1, 2022

It does - hopefully I'm not glossing over relevant import/require details!

───────┬───────────────────────────────────────────────────────────────────
       │ File: import_root.mjs
───────┼───────────────────────────────────────────────────────────────────
   1   │ import * as import_1 from "./import_1/index.mjs";
   2   │ import * as import_2 from "./import_2/index.mjs";
   3   │ 
   4   │ console.log("loaded import_root.mjs");
───────┴───────────────────────────────────────────────────────────────────
───────┬───────────────────────────────────────────────────────────────────
       │ File: import_1/index.mjs
───────┼───────────────────────────────────────────────────────────────────
   1   │ import * as i1 from "./local-dep.mjs";
   2   │ 
   3   │ console.log("loaded import 1 core");
───────┴───────────────────────────────────────────────────────────────────
───────┬───────────────────────────────────────────────────────────────────
       │ File: import_1/local-dep.mjs
───────┼───────────────────────────────────────────────────────────────────
   1   │ console.log("Imported local dep 1");
───────┴───────────────────────────────────────────────────────────────────
───────┬───────────────────────────────────────────────────────────────────
       │ File: import_2/index.mjs
───────┼───────────────────────────────────────────────────────────────────
   1   │ import * as i2 from "./local-dep.mjs";
   2   │ 
   3   │ console.log("loaded import 2 core");
───────┴───────────────────────────────────────────────────────────────────
───────┬───────────────────────────────────────────────────────────────────
       │ File: import_2/local-dep.mjs
───────┼───────────────────────────────────────────────────────────────────
   1   │ console.log("Imported local dep 2");
───────┴───────────────────────────────────────────────────────────────────
❯ node import_root.mjs
Imported local dep 1
loaded import 1 core
Imported local dep 2
loaded import 2 core
loaded import_root.mjs

@borkdude
Copy link
Collaborator

borkdude commented Sep 1, 2022

Makes sense, thanks.

@borkdude
Copy link
Collaborator

borkdude commented Sep 5, 2022

I hope to address this soon.

@aisamu
Copy link
Author

aisamu commented Sep 5, 2022

Thank you!

@borkdude
Copy link
Collaborator

borkdude commented Sep 9, 2022

Published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants