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

The onRebuild hook didn't pass the meta of changed files #2700

Open
1aron opened this issue Nov 24, 2022 · 2 comments
Open

The onRebuild hook didn't pass the meta of changed files #2700

1aron opened this issue Nov 24, 2022 · 2 comments
Labels

Comments

@1aron
Copy link

1aron commented Nov 24, 2022

esbuild config:

await esbuild.build({
    watch: watch ? {
        onRebuild(error: string, result) {
            console.log(result)
        }
    } : false,
    ...
} as esbuild.BuildOptions)
    .then(result => {
        consola.start(`[${format}] watching ${reveal(entryPoints, 'entries')}`)
    })

Output result:

{ errors: [], warnings: [], stop: [Function: stop] }

I don't see any meta for file changes, so I can't print out the changes.

It's accessible within esbuild itself. esbuild src/index.ts --log-level=info

Screenshot 2022-11-24 at 12 44 34 PM

@evanw
Copy link
Owner

evanw commented Nov 24, 2022

I could potentially provide this information. But just so you know, this information is only intended for debugging esbuild's watch mode itself. It consists of a single path and represents the first "thing" that watch mode found that triggered the rebuild, for esbuild's internal representation of "thing." For example, if the number of directory entries changed and esbuild's previous build needed to iterate over the files of that directory, then the "thing" is the directory. It does not represent the changed files at all. And even if the "thing" is a file instead of a directory, watch mode starts the new build as soon as it detects a single difference. It does not continue checking all of the files in the previous build to see what files have changed. So what you are asking for may actually not be what you wanted.

@1aron
Copy link
Author

1aron commented Nov 25, 2022

@evanw Generally understand.

I'm using esbuild in my monorepo ecosystem.

In fact, this requirement comes from obsessive-compulsive disorder. I created a semantic log package for a more beautiful console with esbuild.

Screenshot 2022-11-25 at 1 09 49 PM

Xnapper-2022-11-26-02 54 30

I don't know the GO language, otherwise I would PR to optimize the log 😂

Not sure if the following is the fastest solution for existing architectures, and you don't need to care about the rationale, just mark it with --log-level

result: {
    logs: {
        verbose: {},
        error: {},
        warning: {},
        info: {},
        debug: {}
    }
}

Put any log context you currently have for different levels directly. I think it is enough.

Thank you for all you do, it's great. 🥰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants