rollup-plugin-esbuild icon indicating copy to clipboard operation
rollup-plugin-esbuild copied to clipboard

[feature] log error details/context to console

Open bmcminn opened this issue 5 years ago • 4 comments

Currently utilizing this plugin in my Vue app build process and I keep getting very vague error indications making this process virtually useless...

bundles client/main.js → public\assets\bundle.js...
[!] (plugin esbuild) Error: Transform failed with 1 error
client\store\auth.js
Error: Transform failed with 1 error
    at failureErrorWithLog (C:\github\my-watch-list\node_modules\esbuild\lib\main.js:62:17)
    at Object.transform (C:\github\my-watch-list\node_modules\esbuild\lib\main.js:279:38)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)

I'm doing some more research into ESBuild in general, however it's unacceptable that this tool should warn me of errors and give me zero context for where the error was actually found...

The documentation doesn't mention anything about a verbose mode either.

bmcminn avatar May 25 '20 20:05 bmcminn

This is unfortunate. I didn't include the errors here because esbuild can potentially generate hundreds of errors and I didn't want the exception string to ever be huge. The errors are in an array in the errors property on the exception. But I can definitely include the first few errors in the exception message. I'm sure this library isn't the only one with this problem. This will be in the new 0.4.0 release that will be coming sometime soon.

evanw avatar May 26 '20 01:05 evanw

@evanw Glad to hear it :)

I got around this issue by making esbuild an optional step for production only in my rolloup.config.js file. Kinda defeats the purpose of using ESBuild in the first place, but this is a decent stopgap in the meantime.

// ...

const production = !process.env.ROLLUP_WATCH

export default {

    // ...

    plugins: [
        // ...

        production && esbuild({
            minify: production,
            // target: 'es2015'
        }),

        // ...
    ],
}

It would be awesome if it were possible to configure how many errors I would want to see in the console, so it could default to -1 or 1, but a user could override it with whatever number made sense for their purposes.

bmcminn avatar May 27 '20 08:05 bmcminn

It shows the error detail now but the filename is shown as stdin, maybe allow the transform API to pass in a filename too?

image

egoist avatar Jul 18 '20 15:07 egoist

maybe allow the transform API to pass in a filename too?

Just saw this, sorry. This option already exists and is called sourcefile.

evanw avatar Aug 13 '20 05:08 evanw

Fixed in #118

sxzz avatar Sep 20 '23 15:09 sxzz