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

Mention that build report only works for :browser target #1163

Closed
DerGuteMoritz opened this issue Nov 21, 2023 · 9 comments
Closed

Mention that build report only works for :browser target #1163

DerGuteMoritz opened this issue Nov 21, 2023 · 9 comments

Comments

@DerGuteMoritz
Copy link

At the moment, the user guide doesn't mention that the build report feature only works for the :browser target. Would be nice if it did to save new users some head scratching 🙏

@thheller
Copy link
Owner

Technically it works for multiple targets, but most other targets don't care about build size that much.

What was the confusion? Only builds without source maps technically shouldn't work?

@DerGuteMoritz
Copy link
Author

Technically it works for multiple targets, but most other targets don't care about build size that much.

Ah, thanks for the clarification!

What was the confusion? Only builds without source maps technically shouldn't work?

In my case it's a :node-library build which AFAIUI fails because the report builder expects a main module which my build doesn't have (it only has :exports-var). It runs into an error like this:

Hook [0 shadow.cljs.build-report/hook] failed in stage :flush
NoSuchFileException: .shadow-cljs/builds/<my-build>/release/out/main.js

Maybe a :node-library build like this can be made compatible, too, somehow?

@thheller
Copy link
Owner

thheller commented Nov 21, 2023

Try adding :output-dir "out" (or whatever the actual folder of :output-to is), to the build config. Maybe thats enough?

@thheller
Copy link
Owner

Its mostly all a configuration issue. The build reports works by analyzing the source maps for the generated output files.

So, in case of :browser it just takes the :output-dir and each defines :module. Some build targets just don't have defined modules and or spread them to different location it doesn't look for.

Happy to fix exact problems if you have a repro. In theory there is nothing stopping the build reports from working for any build, just often not super useful thus I never worked on it.

@DerGuteMoritz
Copy link
Author

Try adding :output-dir "out" (or whatever the actual folder of :output-to is), to the build config. Maybe thats enough?

Nope, that alone didn't do the trick, same error. I'll try to prepare a self-contained repro!

@DerGuteMoritz
Copy link
Author

@thheller
Copy link
Owner

You get a working report, if you change the config to

{:source-paths ["src"]

 :builds
 {:foo
  {:target :node-library
   :output-to "out/main.js"
   :output-dir "out"
   :build-hooks [(shadow.cljs.build-report/hook
                   {:output-to "out/report.html"})]
   :exports-var foo/exports}}}

Note that the :release nesting isn't strictly necessary, so I just removed it. The build report hook only runs for release builds by default anyway.

@thheller
Copy link
Owner

As of 2.26.1 it should also work without any adjustments, e.g. no :output-dir.

@DerGuteMoritz
Copy link
Author

Note that the :release nesting isn't strictly necessary, so I just removed it. The build report hook only runs for release builds by default anyway.

Ah good to know, thanks! AFAICT this isn't mentioned in the user guide, at least not in the Build Hooks section. It only mentions that :shadow.build/mode can either be :dev or :release which to me implied that they run in both cases. Also, I couldn't find how one would make it so that build hooks are run in dev builds, too - might be worth adding.

As of 2.26.1 it should also work without any adjustments, e.g. no :output-dir.

Great! It works now with an :output-to that doesn't point to out/main.js indeed but it still requires me to specify an :output-dir. I've updated the repro accordingly.

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