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

Print result of assets compilation #129

Closed
wants to merge 1 commit into from

Conversation

katafrakt
Copy link

This comes as a result of a problems I had with the CI, where it reported missing assets even though I had hanami assets precompile step. The reason was quite dumb - I did not run npm install first. However, because hanami assets precompile swallows the output of an underlying esbuild command, the error was not visible to me.

This swings the pendulum to the opposite direction: it outputs stdout and stderr to the users both on successful compilation and failed one. While the use case for the latter is obvious, the one for the former might not be. But when I enable info logging level for my esbuild in the project, I can now see a nice results of what was generated:

$ be hanami assets compile
> assets
> node config/assets.mjs

public/assets/app-7PQYDDGS.css       81b 
  public/assets/app-LSLFPUMX.js        53b 
  public/assets/app-7PQYDDGS.css.map  196b 
  public/assets/app-LSLFPUMX.js.map    93b 

⚡ Done in 7ms

On error:

$ be hanami assets compile
> assets
> node config/assets.mjs

Errors on assets compilation:

node:internal/errors:466
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'hanami-assets' imported from /home/katafrakt/dev/palaver/config/assets.mjs
    at new NodeError (node:internal/errors:377:5)
    at packageResolve (node:internal/modules/esm/resolve:910:9)
    at moduleResolve (node:internal/modules/esm/resolve:959:20)
    at defaultResolve (node:internal/modules/esm/resolve:1174:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
    at link (node:internal/modules/esm/module_job:78:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.3.0


if result.err && result.err != ""
puts ""
puts result.err
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be $stderr.puts, but not sure.

@timriley timriley self-assigned this Jan 16, 2024
@timriley
Copy link
Member

Thanks for submitting this adjustment, @katafrakt! I agree it's the right way to go, and I've incorporated this style of output into my work in #131.

Because #131 runs multiple esbuild processes, the output will now look something like this, with the lines prefixed by their respective slice names:

[admin/nested]
[admin/nested]   public/assets/admin/nested/app-BFNXWPAN.js       96b
[admin/nested]   public/assets/admin/nested/app-BFNXWPAN.js.map  220b
[admin/nested]
[admin/nested] ⚡ Done in 2ms
[admin]
[admin]   public/assets/admin/app-5M36HUUW.css      107b
[admin]   public/assets/admin/app-44H5XHVO.js        87b
[admin]   public/assets/admin/app-5M36HUUW.css.map  261b
[admin]   public/assets/admin/app-44H5XHVO.js.map   230b
[admin]
[admin] ⚡ Done in 2ms
[my_assets]
[my_assets]   public/assets/app-GVDAEYEC.css      107b
[my_assets]   public/assets/app-ZKSHPHQH.js        82b
[my_assets]   public/assets/app-GVDAEYEC.css.map  249b
[my_assets]   public/assets/app-ZKSHPHQH.js.map   205b
[my_assets]
[my_assets] ⚡ Done in 2ms

@timriley timriley closed this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants