Skip to content

DefaultsError: as is not a supported option with webpack 5.111.1 and terser 5.51.2 #22288

Closed

Description

@grgrzybek

Have you used AI?

None

Which part of webpack is affected?

optimization (tree-shaking, splitChunks, concatenation)

Bug Description

After upgrading to webpack 5.111.1, my index.html with embedded JS started causing problems.
terser package, minify() function was called with with:

files: {
  'index.html': ';(() => {
        if (localStorage && window.matchMedia) {...'

and

options: {
  as: 'script'
  ecma: 2020,
...
...

then terser's defaults function throws an exception for as property:

    if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
        throw new DefaultsError("`" + i + "` is not a supported option", defs);
    }

here's the call stack when minify is called:

minify(), bundle.min.js:34529
terserMinify(), 109:362
minify(), minify.js:407
renderEmbeddedSource(), minify.js:331
askEmbeddedRenderer(), dataURL.js:230
renderer(), 109:81
anonymous(), SourceProcessor.js:1094
processAsync(), SourceProcessor.js:1094
printDocument(), 109:107
minifyDocument(), 109:175
minimizer.implementation(), 109:177
minify(), minify.js:407
transform(), minify.js:454
execFunction(), threadChild.js:148
execHelper(), threadChild.js:127
execMethod(), threadChild.js:131
messageListener(), threadChild.js:49
[nodejs.internal.kHybridDispatch](), event_target:843

and where the worker throws an exception:

defaults(), bundle.min.js:78
minify_sync_or_async(), bundle.min.js:34269
minify(), bundle.min.js:34535

versions:

   ├─ html-webpack-plugin@npm:5.6.8 [e7565] (via npm:^5.6.8 [e7565])
   │  └─ html-minifier-terser@npm:6.1.0 (via npm:^6.0.2)
   │     └─ terser@npm:5.43.1 (via npm:^5.10.0)
   └─ webpack@npm:5.111.1 [e7565] (via npm:^5.111.1 [e7565])
      └─ minimizer-webpack-plugin@npm:5.8.0 [3db15] (via npm:^5.7.0 [3db15])
         └─ terser@npm:5.51.2 (via npm:^5.51.0)

Link to Minimal Reproduction and steps to reproduce

Described in the description

Expected Behavior

webpack works correctly with terser and html files.

Actual Behavior

terser throws an exception about invalid as option.

Environment

⬡ System:
────────────────────────────────────────────────────────────────────────
  OS:      Linux 7.2 Fedora Linux 44 (Forty Four)
  CPU:     (16) x64 AMD Ryzen 7 PRO 7840HS w/ Radeon 780M Graphics
  Memory:  41.96 GB / 61.43 GB

⬡ Binaries:
────────────────────────────────────────────────────────────────────────
  Node:  24.18.0 - /usr/bin/node
  Yarn:  4.18.0 - /usr/local/sbin/yarn
  npm:   11.16.0 - /usr/bin/npm

Is this a regression?

Yes (please specify version below)

Last Working Version

v5.110.3

Additional Context

No response

Activity

  1. added theissue type on Sep 24, 2026
  2. added
    area: optimizationTree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids)
    regressionWorked in a previous release; pair with the Affected version field
    on Sep 24, 2026
  3. alexander-akait commented on Sep 24, 2026

    @alexander-akait
    Member
  4. grgrzybek commented on Sep 24, 2026

    @grgrzybek
    Author

    Please migrate to https://webpack.js.org/guides/native-html/, html-webpack-plugin is outdated

    Thanks - I'll have a look. We also use Module Federation 1 (still), so it may take a while.
    But I appreciate the hint ;)

  5. alexander-akait commented on Sep 24, 2026

    @alexander-akait
    Member

    @grgrzybek fixed in the minimizer-webpack-plugin, just update it locally, feel free create a new issue if your faced with issue(s) again

  6. grgrzybek commented on Sep 25, 2026

    @grgrzybek
    Author

    Thank you very much @alexander-akait ! works now with

    ➤ YN0085: │ + minimizer-webpack-plugin@npm:5.12.0
    ➤ YN0085: │ - minimizer-webpack-plugin@npm:5.8.0
    

    It solves our problems.

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

    area: optimizationTree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids)needs: reproductionNo runnable minimal reproduction yetregressionWorked in a previous release; pair with the Affected version field

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions