Skip to content

Add webpack and rspack plugin support#9

Open
ottomao wants to merge 2 commits intomasterfrom
claude/cli-to-webpack-rspack-plugins-6ON24
Open

Add webpack and rspack plugin support#9
ottomao wants to merge 2 commits intomasterfrom
claude/cli-to-webpack-rspack-plugins-6ON24

Conversation

@ottomao
Copy link
Owner

@ottomao ottomao commented Mar 2, 2026

Summary

This PR adds webpack and rspack plugin support to bugfreejs, allowing users to integrate the comment injection functionality directly into their build pipelines. The package now supports both CLI usage and bundler plugins.

Key Changes

  • New BugfreePlugin class (lib/BugfreePlugin.js): Core plugin implementation that injects special comments into compiled JS and CSS assets. Supports three comment styles via the faith option ('default', 'alpaca', 'god') and can be enabled/disabled.
  • Plugin entry points: Added webpack-plugin.js and rspack-plugin.js as thin wrappers exporting the core plugin for webpack and rspack respectively.
  • Package.json updates:
    • Bumped version to 2.0.0
    • Added exports field for clean subpath imports (bugfreejs/webpack-plugin, bugfreejs/rspack-plugin)
    • Added files field to control published package contents
    • Added optional peer dependencies for webpack and rspack
  • Example projects: Added complete webpack and rspack example configurations demonstrating plugin usage with different faith options.
  • Build artifacts: Updated .gitignore to exclude dist/ and package-lock.json

Implementation Details

  • The plugin hooks into the processAssets stage (SUMMARIZE) to run after minification/optimization
  • Automatically detects and wraps comments appropriately for JS (//) and CSS (/* */) files
  • Handles both webpack 4/5+ and rspack by detecting available webpack sources at runtime
  • Uses compilation.getAsset() and compilation.updateAsset() for asset manipulation

https://claude.ai/code/session_01DhV789vGjbbRemZw1LZdN8

claude added 2 commits March 2, 2026 10:11
…o build output

Convert the CLI tool into reusable webpack/rspack plugins that inject ASCII art
comment headers (Buddha/Alpaca/Jesus) into bundled JS/CSS assets after minification.

- Add lib/BugfreePlugin.js as shared plugin core using processAssets hook
- Add webpack-plugin.js and rspack-plugin.js entry points
- Add exports field in package.json for `bugfreejs/webpack-plugin` and `bugfreejs/rspack-plugin`
- Add examples/webpack-example and examples/rspack-example demo projects
- Update .gitignore for dist and package-lock.json

https://claude.ai/code/session_01DhV789vGjbbRemZw1LZdN8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants