schultek / jaspr

Modern web framework for building websites in Dart. Supports SPAs, SSR and SSG.
https://jasprpad.schultek.de
MIT License
1.07k stars 65 forks source link

fix: Show failure in output when main.dart.js was not generated #113

Closed kaboc closed 7 months ago

kaboc commented 11 months ago

Description

It is not clear in the output that main.dart.js was not generated due to dependency on a package not supporting the web.

Steps To Reproduce

  1. Create an app that depends on a package not supporting the web. (e.g. universal_io 2.2.2)
  2. Run jaspr build --input xxxx with or without the --verbose flag.
  3. See the output in the console.

Expected Behavior

The output clearly states that the build has failed. It might be better to show it in some colour.

Additional Context

Thank you for the great package. I've been using jaspr for my blog.

I was able to build the site successfully some months ago, but recently noticed that builds would fail for some reason. It later turned out that it was because one of the packages that the app depended on had (accidentally) removed support for the web. However, it was a bit difficult to identify the cause of the issue since jaspr build ended as if there was no error nor warning most of the time.

With cache

Without --verbose

✓ [CLI] Completed building web assets. (15.7s)
[CLI] Completed building project to /build.

With --verbose

[CLI] Building web assets...
[BUILDER] Generating build script...
[BUILDER] Generating build script completed, took 344ms
[BUILDER] Starting daemon...
[BUILDER] Initializing inputs
[BUILDER] Reading cached asset graph...
[BUILDER] Reading cached asset graph completed, took 250ms
[BUILDER] Checking for updates since last build...
[BUILDER] Checking for updates since last build completed, took 713ms
[BUILDER] [ERROR] Initializing inputs
[BUILDER] [ERROR] Reading cached asset graph...
[BUILDER] [ERROR] Reading cached asset graph completed, took 250ms
[BUILDER] [ERROR] Checking for updates since last build...
[BUILDER] [ERROR] Checking for updates since last build completed, took 713ms
[BUILDER] [ERROR] Setting up file watchers...
[BUILDER] [ERROR] Setting up file watchers completed, took 2ms
[BUILDER] About to build [web]...
[BUILDER] Running build...
[BUILDER] Running build completed, took 174ms
[BUILDER] Caching finalized dependency graph...
[BUILDER] Caching finalized dependency graph completed, took 179ms
[BUILDER] Reading manifest at build/jaspr\.build.manifest...
[BUILDER] Reading manifest at build/jaspr\.build.manifest completed, took 0ms
[BUILDER] Deleting previous outputs in `build/jaspr`...
[BUILDER] Deleting previous outputs in `build/jaspr` completed, took 69ms
[BUILDER] Creating merged output dir `build/jaspr`...
[BUILDER] Creating merged output dir `build/jaspr` completed, took 402ms
[BUILDER] Writing asset manifest...
[BUILDER] Writing asset manifest completed, took 1ms
[BUILDER] Succeeded after 846ms with 0 outputs (0 actions)
[CLI] Completed building web assets.
[CLI] Completed building project to /build.

Without cache

Without --verbose

✓ [CLI] Completed building web assets. (15.7s)
[CLI] Completed building project to /build.

With --verbose

[CLI] Building web assets...
[BUILDER] Generating build script...
[BUILDER] Generating build script completed, took 318ms
[BUILDER] Precompiling build script......
[BUILDER] Precompiling build script... completed, took 8.1s
[BUILDER] Starting daemon...
[BUILDER] Initializing inputs
[BUILDER] Building new asset graph...
[BUILDER] Building new asset graph completed, took 2.0s
[BUILDER] Checking for unexpected pre-existing outputs....
[BUILDER] Checking for unexpected pre-existing outputs. completed, took 0ms
[BUILDER] [ERROR] Initializing inputs
[BUILDER] [ERROR] Building new asset graph...
[BUILDER] [ERROR] Building new asset graph completed, took 2.0s
[BUILDER] [ERROR] Checking for unexpected pre-existing outputs....
[BUILDER] [ERROR] Checking for unexpected pre-existing outputs. completed, took 0ms
[BUILDER] [ERROR] Setting up file watchers...
[BUILDER] [ERROR] Setting up file watchers completed, took 3ms
[BUILDER] About to build [web]...
[BUILDER] Running build...
[BUILDER] 1.0s elapsed, 207/222 actions completed.
[BUILDER] 2.1s elapsed, 464/484 actions completed.
[BUILDER] [WARNing] Skipping compiling blog|web/main.dart with dart2js because some of its
[BUILDER] [WARNing] transitive libraries have sdk dependencies that are not supported on this platform:
[BUILDER] [WARNing] 
[BUILDER] [WARNing] universal_io|lib/src/_exports_in_vm.dart
[BUILDER] [WARNing] universal_io|lib/src/internet_address.dart
[BUILDER] [WARNing] universal_io|lib/src/http_client.dart
[BUILDER] [WARNing] 
[BUILDER] [WARNing] https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings
[BUILDER] Running build completed, took 3.4s
[BUILDER] Caching finalized dependency graph...
[BUILDER] Caching finalized dependency graph completed, took 168ms
[BUILDER] Creating merged output dir `build/jaspr`...
[BUILDER] Creating merged output dir `build/jaspr` completed, took 267ms
[BUILDER] Writing asset manifest...
[BUILDER] Writing asset manifest completed, took 2ms
[BUILDER] Succeeded after 3.9s with 841 outputs (4221 actions)
[CLI] Completed building web assets.
[CLI] Completed building project to /build.

So, it looks like the warnings are included in the output only when there is no cache and the command was run with --verbose. In fact, however, main.dart.js has not been generated, meaning the build has failed. Therefore I think the failure and its reason should be more obvious in the output regardless of whether a cache exists or whether the command was run with some particular flag.

kaboc commented 11 months ago

It would also be great if jaspr provided a way of clearing the cache. I wasn't sure how to clear it, but I deleted .dart_tool/build/ to check if the behaviour differed depending on the existing of the cache.

kaboc commented 11 months ago
[BUILDER] [ERROR] Initializing inputs
[BUILDER] [ERROR] Building new asset graph...
[BUILDER] [ERROR] Building new asset graph completed, took 2.0s
[BUILDER] [ERROR] Checking for unexpected pre-existing outputs....
[BUILDER] [ERROR] Checking for unexpected pre-existing outputs. completed, took 0ms
[BUILDER] [ERROR] Setting up file watchers...
[BUILDER] [ERROR] Setting up file watchers completed, took 3ms

Is this really an error? The output always has these lines and they are printed in red. I think it is better to show these lines as just [INFO] or something if the error is not critical.

schultek commented 11 months ago

Thanks for the issue.

  1. Including error logs also in non-verbose mode is a good idea, will try to implement it.

  2. You can clean the buildrunner cache using 'dart eun build_runner clean'

  3. I noticed this too, but this comes from the build runner daemon, I'm not sure I can do something about this.

schultek commented 7 months ago

I think this is resolved by now, as I improved the logging of the cli and added jaspr clean command.