thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.23k stars 173 forks source link

failed to load errors on karma browser test build in versions >= 2.23.6 #1152

Closed cap10morgan closed 9 months ago

cap10morgan commented 9 months ago

Starting in shadow-cljs 2.23.6 (and tested up through 2.25.7) our karma browser test build logs several warnings like this:

Chrome Headless 117.0.5938.92 (Mac OS 10.15.7) WARN: 'shadow-cljs - failed to load'

...and then fails with:

Uncaught TypeError: Cannot read properties of undefined (reading 'from')
  at browser-tests.js:8683:249

TypeError: Cannot read properties of undefined (reading 'from')
      at shadow$provide.<computed> (browser-tests.js:81:137)
      at shadow.js.jsRequire (browser-tests.js:8683:120)
      at shadow$provide.<computed> (browser-tests.js:141:313)
      at shadow.js.jsRequire (browser-tests.js:8683:120)
      at shadow$provide.<computed> (browser-tests.js:158:50)
      at shadow.js.jsRequire (browser-tests.js:8683:120)
      at shadow$provide.<computed> (browser-tests.js:159:85)
      at shadow.js.jsRequire (browser-tests.js:8683:120)
      at shadow$provide.<computed> (browser-tests.js:166:85)
      at shadow.js.jsRequire (browser-tests.js:8683:120)

Version 2.23.5 and other recent older ones work fine.

Here's our browser test build config:

:browser-test
{:target           :karma
 :output-to        "out/browser-test/browser-tests.js"
 :closure-defines  {fluree.db.platform/BROWSER true
                    cljs.core/*global*         "window"}
 :compiler-options {:pretty-print true
                    :pseudo-names true}
 :js-options       {:resolve {"fs"      false
                              "path"    false
                              "process" false
                              "buffer"  false
                              "crypto"  false}}}}}
cap10morgan commented 9 months ago

Let me know if a minimal repro of this would be helpful.

thheller commented 9 months ago

Yes, a repro helps. I have not looked or used :karma for many years. The only notable change in 2.23.6 was adding support for package.json "exports", which may affect which files end up in your build. Can you trying setting :js-options {:ignore-exports true} in your build config? That should revert back to the old behavior.

cap10morgan commented 9 months ago

Can you trying setting :js-options {:ignore-exports true} in your build config? That should revert back to the old behavior.

Yeah that fixed it. The browser tests build and pass w/ shadow-cljs 2.25.7 when I set that option. We don't have any exports in our package.json file, but perhaps some of the dependencies do (assuming it's transitive?).

thheller commented 9 months ago

Yes, "exports" in your own package.json wouldn't do anything. It is for packages that want finer control over what files are accessible. Could be that you have some mix of dependencies that turns out to be incompatible.

Is this the full list of npm packages you use? https://github.com/fluree/db/blob/main/package.json

cap10morgan commented 9 months ago

Is this the full list of npm packages you use? https://github.com/fluree/db/blob/main/package.json

I believe so

cap10morgan commented 9 months ago

Updating all of my npm deps to their latest versions seems to have fixed this as well. Thanks for that clue!

And at any rate, it seems clear that this was never a bug in shadow-cljs. Closing.