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

Allow --summary to work in watch for tooling #751

Closed
connor4312 opened this issue Feb 4, 2021 · 13 comments
Closed

Allow --summary to work in watch for tooling #751

connor4312 opened this issue Feb 4, 2021 · 13 comments

Comments

@connor4312
Copy link

In VS Code, task problem matchers are used to match against output and detect the state of the compilation.

A common pattern is to use a watch-mode compiler, like webpack --watch or tsc --watch, as a background task. In addition to their usefulness as standalone tasks the user can run, these can also be used in debugging to, for instance, wait for compilation to be complete before running or restarting a program.

esbuild's --watch mode is silent, and while it's usually super fast I ran into some cases where I would make a change and hit "debug" (which triggers a save) and the program would launch before the bundle was completely ready to go.

It would be great if there was a way to have esbuild output more information for tooling in watch mode to know when it starting compiling, when it finishes, and when it errors (errors are already detectable). The --summary flag in normal compilation does this, so making it work in watch mode could be a convenient way to do this without adding more knobs or api.

@evanw
Copy link
Owner

evanw commented Feb 4, 2021

It should be easy to do this with esbuild's build API. You can use onRebuild to know when a rebuild happens. More documentation here: https://esbuild.github.io/api/#watch.

@connor4312
Copy link
Author

That would require everyone who uses esbuild project and wants to use tasks to use the API to run their builds (and probably some package so that outputs would be standard) rather than the CLI. It'd be easy but less convenient for users -- more setup on their end.

@jasikpark
Copy link

Would it be possible to print something else than the bubble animation? I usually run esbuild concurrently with other tasks in the same terminal via https://www.npmjs.com/package/concurrently and a --summary or verbose output would be very helpful as a command line option rather than the 3 dots that overwrite the output of other commands...

@evanw
Copy link
Owner

evanw commented Feb 13, 2021

The next release will have more structured watch mode output, although it is not exactly the same as --summary (see the release notes for details). Closing this as I believe it will be sufficient to address this.

@evanw evanw closed this as completed Feb 13, 2021
@connor4312
Copy link
Author

Thanks, I have it working nicely with the output you added 🙂 https://marketplace.visualstudio.com/items?itemName=connor4312.esbuild-problem-matchers

@stolinski
Copy link

@connor4312 Did you have to add anything special to your esbuild watch code?

@connor4312
Copy link
Author

nope, just --watch

@stolinski
Copy link

nope, just --watch

Interesting. I've downloaded your extension. Using node build.js

    await esbuild.build({
      ...buildDefaults,
      incremental: true,
      watch: true,
    })

To build and VSCode doesn't seem to move past the task. ie, it starts the task and then hangs and never moves on to the executable.

I wonder if --watch is doing something different than watch: true.

@connor4312
Copy link
Author

connor4312 commented Apr 20, 2021

What does your stdout/err look like when running that?

@stolinski
Copy link

Just triggered failing build

> rm -rf ./dist/index.js; node ./scripts/buildWatch.js --trace-warnings && nodemon --trace-warnings ./dist/index.js --config ./scripts/serveWatch.json

 > src/config/graphqlAPI/startAPI.ts:13:23: error: Expected "from" but found "fro"
    13 │ import { Environment } fro
       ╵                        ~~~

@stolinski
Copy link

stolinski commented Apr 20, 2021

No output when files changed and no errors.

From looking at your package, I'm assuming your's outputs

[watch] build started
[watch] build finished

@connor4312
Copy link
Author

Hm, yea. In the CLI on the latest esbuild, even in an error case we have those started/finished bounds, e.g.

I haven't used the programmatic API much, could experiment with it later. PRs welcome as well.

@stolinski
Copy link

Will def do. I'll plug on this with the watch property function and submit a pr with the relevant info. Thank you @connor4312 great timing.

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

4 participants