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

Bundler silently fails in case of an error #237

Closed
Kikimora opened this issue Oct 27, 2022 · 2 comments · Fixed by #239
Closed

Bundler silently fails in case of an error #237

Kikimora opened this issue Oct 27, 2022 · 2 comments · Fixed by #239
Labels
bug Something isn't working

Comments

@Kikimora
Copy link

Not sure what was the original rational behind this particular try...catch block but it cased me a good bit of a headache today. In my case the build silently failed without producing any assets and CDK complained "Bundling did not produce any output". buildSync could not load esbuild-darwin-arm64 (I'm on M1 Mac) and the try...catch block ate the error without giving a notice.

Here is the problematic block of code.

        try {
          const buildFn = this.props.buildFn ?? EsbuildProvider.require(props.esbuildModulePath).buildSync;
          const buildSync = EsbuildProvider.withEsbuildBinaryPath(buildFn, this.props.esbuildBinaryPath);

          buildSync({
            entryPoints,
            color: process.env.NO_COLOR ? Boolean(process.env.NO_COLOR) : undefined,
            ...(this.props?.buildOptions || {}),
            ...this.getOutputOptions(outputDir, { normalize, join }),
          });
        } catch (error) {
          if (errorHasCode(error, 'MODULE_NOT_FOUND')) {
            throw error;
          }
        }
@Kikimora Kikimora added the bug Something isn't working label Oct 27, 2022
@mrgrain
Copy link
Owner

mrgrain commented Oct 27, 2022

Hi and thanks for reporting this!

Looking back at the history, PR #212 and the issue #205 are the background for the current implementation.

I guess I later added a special case to handle Module Not Found errors, likely because of a similar issue you encountered.


Looking at the code now, I reckon we can move the first two lines out of the try...catch block. That should keep all important errors and stop any esbuild ones. 🤔

@mrgrain
Copy link
Owner

mrgrain commented Oct 27, 2022

It's also tracked as breaking change for the next major version, see #202

Not sure I still agree with my past self here. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants