Skip to content

fix: preprocessor options for the default preprocessor#187

Merged
webdiscus merged 1 commit intowebdiscus:masterfrom
itsyoboieltr:fix/preprocessor-options
Nov 27, 2025
Merged

fix: preprocessor options for the default preprocessor#187
webdiscus merged 1 commit intowebdiscus:masterfrom
itsyoboieltr:fix/preprocessor-options

Conversation

@itsyoboieltr
Copy link
Copy Markdown
Contributor

Types of changes

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • docs change
  • breaking change

Motivation / Use-Case

When using HtmlBundlerPlugin with only preprocessorOptions and relying on the default preprocessor, the options were silently ignored.

Example:

new HtmlBundlerPlugin({
  // no explicit `preprocessor` set, rely on default
  preprocessorOptions: { useWith: false },
  // ...
});

In this case, preprocessorOptions never reached the loader or the preprocessor.

Breaking Changes

None.

The behavior only changes for configurations where preprocessorOptions were previously ignored when using the default preprocessor. In those cases, the options now correctly take effect as originally intended.

Additional Info

Root cause:

In PluginService.init, preprocessorOptions were only copied into loaderOptions inside the conditional that checks for an explicitly defined preprocessor. When preprocessor is not set (default preprocessor), this condition is false, and preprocessorOptions are never forwarded.

Fix:
Keep the preprocessor assignment guarded as before and move the preprocessorOptions assignment out of that guard so it always propagates when defined, even for the default preprocessor.

This aligns behavior with user expectations and the documented configuration pattern: preprocessorOptions should work whether or not preprocessor is explicitly set.

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have updated the CHANGELOG.md.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Appreciation for the useful project

  • Do not forget to give a star ⭐

@itsyoboieltr itsyoboieltr changed the title fix: preprocessor options fix: preprocessor options for the default preprocessor Nov 27, 2025
@itsyoboieltr itsyoboieltr force-pushed the fix/preprocessor-options branch from bba5601 to 3bf642a Compare November 27, 2025 17:32
@webdiscus webdiscus added this to the analysis milestone Nov 27, 2025
@webdiscus webdiscus added the enhancement New feature or request label Nov 27, 2025
@webdiscus
Copy link
Copy Markdown
Owner

@itsyoboieltr

The use of preprocessor options was intentionally applyed only when the preprocessor itself is explicitly specified.
But your improvement might also make sense.
Thank you!

@webdiscus webdiscus merged commit 7ce4561 into webdiscus:master Nov 27, 2025
4 checks passed
@webdiscus webdiscus modified the milestones: analysis, test Nov 27, 2025
@webdiscus
Copy link
Copy Markdown
Owner

@itsyoboieltr , the new v4.22.0 is released. Thank you.

@webdiscus webdiscus modified the milestones: test, done Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants