Skip to content

EsbuildCompressor and minify.js silently fall back to uncompressed output #309

Description

@bjagg

Context

PR #303 introduced EsbuildCompressor.java (replacing YUI Compressor) and a build-time minify.js script. Both silently fall back to uncompressed output when esbuild is unavailable:

EsbuildCompressor.java:

} catch (IOException e) {
    logger.warn("esbuild not available, falling back to uncompressed output: " + e.getMessage());
}
// ...
try (FileReader fallbackReader = new FileReader(esbuildSucceeded ? outputFile.toFile() : inputFile.toFile())) {
    IOUtils.copy(fallbackReader, writer);
}

minify.js:

} catch (error) {
    console.warn(`Failed to minify ${file}: ${error.message}`);
    // Copy original file as fallback
    const minFile = file.replace(/\.js$/, '.min.js');
    fs.copyFileSync(file, minFile);
}

Problem

A deployment could ship a WAR with full-size .min.js files if esbuild fails or isn't on PATH. The only signal is a log warning, which is easy to miss in build output.

Proposed fix

  • EsbuildCompressor.java: throw IOException when esbuild is unavailable or exits non-zero. Let the aggregator fail loud.
  • minify.js: exit with non-zero on any minification failure. Do not create a .min.js that is actually full-size.
  • If a build-time fallback is desirable (e.g., for dev-mode incremental builds), make it explicit via a Maven property or env var.

Priority

Low — the release can proceed without this fix. Filing as a follow-up to PR #303 so it doesn't block the 1.5.1 release.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions