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

nbb fails with ReferenceError: esm_import$path is not defined #287

Closed
gdanov opened this issue Nov 27, 2022 · 12 comments
Closed

nbb fails with ReferenceError: esm_import$path is not defined #287

gdanov opened this issue Nov 27, 2022 · 12 comments

Comments

@gdanov
Copy link

gdanov commented Nov 27, 2022

version

"version": "1.1.149",

platform

osx ventura

problem

~>nbb
file:///Users/gdanov/.nvm/versions/node/v18.12.1/lib/node_modules/nbb/lib/nbb_main.js:41
process.exit(0));$APP.n($APP.I3.g(b))&&($APP.ZB.l($APP.C([["nbb v",$APP.cx()].join("")])),process.exit(0));return $APP.n($APP.n(c)?c:$APP.n(d)?d:$APP.n(a)?a:$APP.n(e)?e:f)?($APP.BW.h($APP.FW,$APP.Eg($APP.MM.g(b))),Promise.resolve($APP.tZ($APP.n(e)?esm_import$path.resolve("script.cljs"):c,b)).then(function(){return($APP.n(c)?$APP.uZ(c):$APP.n(d)?$APP.vZ(d):$APP.n($APP.D3.g(b))?shadow_esm_import("./nbb_nrepl_server.js").then(function(){var g=$APP.D.h($APP.D.h($APP.Pq.g($APP.r($APP.Jq.g($APP.hw()))),
                                                                                                                                                                                                                                                        ^

ReferenceError: esm_import$path is not defined
    at file:///Users/gdanov/.nvm/versions/node/v18.12.1/lib/node_modules/nbb/lib/nbb_main.js:41:249
    at file:///Users/gdanov/.nvm/versions/node/v18.12.1/lib/node_modules/nbb/lib/nbb_main.js:43:283
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

Node.js v18.12.1

repro

nbb stopped working, not sure why. fresh node re-install does not help.

@borkdude
Copy link
Collaborator

do older versions still work for you? how did you install nbb, locally, globally? can you provide a repro repository?

@gdanov
Copy link
Author

gdanov commented Nov 27, 2022

I just erased everything in the node folder and ran npx i nbb -g then nbb
before that tested with npx, same.

@borkdude
Copy link
Collaborator

I can reproduce this locally too:

npm install -g [email protected]

gives this problem, but:

npm install -g [email protected]

doesn't.

@gdanov
Copy link
Author

gdanov commented Nov 27, 2022

right. 148 and 147 are good.

@borkdude
Copy link
Collaborator

Releasing 1.1.150 now. It seemed this bug is introduced by upgrading shadow-cljs. I tested with 2.20.6 and the bug first starts happening with 2.20.7. cc @thheller

@borkdude
Copy link
Collaborator

@thheller If you're interested in reproducing:

  • Edit deps.edn and change shadow's version
  • Run bb release
  • Then run ./cli.js for testing

@borkdude
Copy link
Collaborator

borkdude commented Nov 27, 2022

npm install -g [email protected] now works for me. Let's leave the issue open until we sorted it out with shadow. I'd be happy to create an issue with shadow-cljs if necessary.

@thheller
Copy link

thheller commented Nov 28, 2022

How do I turn on --pseudo-names for the release build? No clue what happens where.

Nevermind. It is passed through in the bb release command.

@thheller
Copy link

Found the problem. In 2.20.7 I changed how the ESM import statements are handled, so that JS tools can tree-shake them properly. What I guess I missed is that in this case it moves the code from the nbb-main-impl module to the nbb-main module and calls it there. The code does not account for ESM references moving cross modules, so this fails now.

@borkdude
Copy link
Collaborator

@thheller

bb release --pseudo-names

should work. Thanks for looking into it.

@thheller
Copy link

thheller commented Dec 1, 2022

Should be fine again in 2.20.13.

@borkdude
Copy link
Collaborator

borkdude commented Dec 7, 2022

@thheller Thanks!

@borkdude borkdude closed this as completed Dec 7, 2022
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

3 participants