Skip to content

Empty files are no longer empty with 5.3.15 #642

@anomiex

Description

@anomiex

Bug Description

When running with terser-webpack-plugin 5.3.15, a generated file that should be empty is no longer empty.

Link to Minimal Reproduction and step to reproduce

  1. In an empty directory, run npm add webpack webpack-cli terser-webpack-plugin
  2. Create the following webpack.config.js:
    module.exports = {
        mode: 'production',
        entry: './src/index.js',
    };
  3. Create the following file at src/index.js:
    // This module is empty.
  4. Run npm exec webpack
  5. Examine the generated dist/main.js file.

Expected Behavior

The file dist/main.js is 0 bytes.

Actual Behavior

The file dist.main.js has the following content:

/******/ (() => { // webpackBootstrap
// This module is empty.

/******/ })()

Environment

System:
    OS: Linux 6.17 Debian GNU/Linux forky/sid
    CPU: (16) x64 AMD Ryzen 7 7840U w/ Radeon  780M Graphics
    Memory: 23.73 GB / 30.66 GB
  Binaries:
    Node: 22.21.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.4 - /usr/bin/npm
    pnpm: 10.25.0 - /usr/local/bin/pnpm
  Browsers:
    Firefox: 145.0.1
    Firefox Developer Edition: 145.0.1
  Packages:
    terser-webpack-plugin: ^5.3.15 => 5.3.15 
    webpack: ^5.103.0 => 5.103.0 
    webpack-cli: ^6.0.1 => 6.0.1

Is this a regression?

Yes (please specify version below)

Last Working Version

5.3.14

Additional Context

In production, what we're mostly seeing is

/******/ (() => { // webpackBootstrap
/******/        "use strict";
// extracted by mini-css-extract-plugin

/******/ })()
;

for modules where https://www.npmjs.com/package/mini-css-extract-plugin has extracted the CSS and there is no JS code in the module. With earlier versions of terser-webpack-plugin these were empty files.

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