Skip to content

Supersede #913: bundler utility exports with lint unblock#922

Open
justin808 wants to merge 5 commits intomainfrom
codex/supersede-913-bundler-utils-lint
Open

Supersede #913: bundler utility exports with lint unblock#922
justin808 wants to merge 5 commits intomainfrom
codex/supersede-913-bundler-utils-lint

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Feb 15, 2026

Supersedes #913.

Includes:

Closes #875

Summary by CodeRabbit

  • New Features

    • Added bundler-agnostic utilities to detect the active bundler and retrieve common bundler plugins/loaders for Webpack and Rspack.
  • Tests

    • Added tests verifying bundler detection, plugin/loader accessors, and default return shapes.
  • Changed

    • Sass-loader now defaults to the modern Sass API (api: "modern").

Note

Low Risk
Low risk: adds new optional utility exports and TypeScript typings without changing existing bundling behavior; main risk is minor consumer impact if relying on undocumented internals or if required peer deps are missing when calling the new helpers.

Overview
Adds a new bundlerUtils public API to write Webpack/Rspack-agnostic config code, exposing isRspack/isWebpack plus helpers like getBundler(), getCssExtractPlugin()/getCssExtractPluginLoader(), and plugin constructors (getDefinePlugin(), getEnvironmentPlugin(), getProvidePlugin()).

Re-exports these utilities from both package/index.ts and package/rspack/index.ts, updates index.d.ts (and template) plus shakapacker/types to include the new types, and adds Jest coverage and a changelog entry; ESLint overrides are updated to account for the new util file.

Written by Cursor Bugbot for commit 363af2c. Configure here.

@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

Walkthrough

Adds a bundler-agnostic utilities module and exports to expose bundler detection and plugin accessors (isRspack, isWebpack, getBundler, getCssExtractPlugin, getCssExtractPluginLoader, getDefinePlugin, getEnvironmentPlugin, getProvidePlugin); updates types, re-exports from package and rspack entry points, adds tests, and documents the change in CHANGELOG.md.

Changes

Cohort / File(s) Summary
Bundler utilities implementation & tests
package/utils/bundlerUtils.ts, test/package/bundlerUtils.test.js
New module providing bundler detection constants, plugin interfaces/types, and helper functions to return appropriate bundler modules/plugins; accompanied by tests validating defaults and return shapes.
Public API & re-exports
package/index.ts, package/rspack/index.ts, package/index.d.ts, package/index.d.ts.template
Re-exports bundler utilities and adds type declarations to the public API surface for runtime accessors and plugin constructors.
Types
package/types/index.ts
Adds re-exports of bundler-related TypeScript types (PluginConstructor, CssExtractPluginOptions, CssExtractPluginConstructor, BundlerModule).
Docs & config
CHANGELOG.md, eslint.config.js
Documents the new bundler utilities in the changelog and adds the new utils file to the ESLint TypeScript override list.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble at code with joyful hop,
New helpers sprout where bundlers swap.
One call to fetch the plugin right,
Webpack or Rspack — both take flight.
A rabbit's cheer for seamless night.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: exporting bundler utility functions to supersede PR #913, with a mention of the lint unblock fix.
Linked Issues check ✅ Passed All coding requirements from issue #875 are met: bundler detection (isRspack, isWebpack), getBundler function, getCssExtractPlugin, and other plugin accessors are implemented, exported, and tested.
Out of Scope Changes check ✅ Passed The PR contains only in-scope changes: bundler utilities, exports, types, tests, and documentation. The .prettierignore update mentioned in PR objectives is the only tangential change but is appropriately minimal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/supersede-913-bundler-utils-lint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 15, 2026

Greptile Summary

This PR adds bundler utility functions (isRspack, isWebpack, getBundler, getCssExtractPlugin, getCssExtractPluginLoader, getDefinePlugin, getEnvironmentPlugin, getProvidePlugin) that abstract over Webpack/Rspack differences, allowing users to write bundler-agnostic configuration code. It also adds type definitions, a changelog entry, comprehensive tests for the webpack path, and a .prettierignore fix to unblock linting.

  • New package/utils/bundlerUtils.ts: Core utility module with well-documented functions using existing requireOrError infrastructure. The isRspack/isWebpack booleans are evaluated at module load time, consistent with how config.assets_bundler is used elsewhere in the codebase.
  • Exports from both entry points: Utilities are properly exported from both package/index.ts (CommonJS export =) and package/rspack/index.ts (named exports), maintaining consistency with existing export patterns.
  • Type definitions: Four new types (PluginConstructor, CssExtractPluginOptions, CssExtractPluginConstructor, BundlerModule) are re-exported through package/types/index.ts.
  • CHANGELOG: References PR Export bundler utility functions for Webpack/Rspack compatibility #880 rather than this PR (Supersede #913: bundler utility exports with lint unblock #922) — may need updating to point to the correct merged PR.
  • Tests: Cover all exported functions for the default webpack path. No Rspack path tests, which is expected given the test environment won't have @rspack/core installed.

Confidence Score: 4/5

Important Files Changed

Filename Overview
package/utils/bundlerUtils.ts New utility module providing bundler-agnostic functions (isRspack, isWebpack, getBundler, getCssExtractPlugin, etc.). Clean implementation with good documentation. Minor concern: getBundler() is called redundantly by each plugin getter function.
package/index.ts Imports and re-exports all bundler utility functions from bundlerUtils.ts. Clean integration with existing export pattern.
package/rspack/index.ts Imports and re-exports bundler utilities via require() for CommonJS compatibility, consistent with existing patterns in this file.
package/types/index.ts Re-exports four new bundler utility types (PluginConstructor, CssExtractPluginOptions, CssExtractPluginConstructor, BundlerModule) for consumer convenience.
test/package/bundlerUtils.test.js Tests cover all exported functions but only for the default webpack path. No Rspack path coverage, which is expected given test environment constraints.
CHANGELOG.md Adds changelog entry for bundler utility exports under "Added" section with a code example. References PR #880 (the original PR) rather than #922.
eslint.config.js Adds bundlerUtils.ts to the existing ESLint override block that relaxes type safety rules for utility files using dynamic requires.
.prettierignore Adds two workflow YAML files to prettierignore to unblock lint in PRs that can't modify workflow files due to GitHub validation.

Flowchart

flowchart TD
    A["User Config Code"] --> B["require('shakapacker')"]
    B --> C["package/index.ts"]
    B --> D["package/rspack/index.ts"]
    C --> E["bundlerUtils.ts"]
    D --> E
    E --> F{"config.assets_bundler"}
    F -->|"rspack"| G["requireOrError('@rspack/core')"]
    F -->|"webpack"| H["requireOrError('webpack')"]
    G --> I["isRspack = true\nisWebpack = false"]
    H --> J["isRspack = false\nisWebpack = true"]
    G --> K["CssExtractRspackPlugin"]
    H --> L["mini-css-extract-plugin"]
    G --> M["rspack.DefinePlugin\nrspack.EnvironmentPlugin\nrspack.ProvidePlugin"]
    H --> N["webpack.DefinePlugin\nwebpack.EnvironmentPlugin\nwebpack.ProvidePlugin"]
Loading

Last reviewed commit: 2012f6d

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +103 to +106
const getBundler = (): BundlerModule =>
(isRspack
? requireOrError("@rspack/core")
: requireOrError("webpack")) as BundlerModule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant requireOrError calls per plugin getter

Each call to getDefinePlugin(), getEnvironmentPlugin(), or getProvidePlugin() invokes getBundler(), which calls requireOrError() every time. While Node.js caches require() results so there's no real performance issue, consider caching the bundler module if these getters are called frequently in hot paths. This is a minor stylistic point — the current approach is functionally correct.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Node.js caches require() results so there's no real performance concern here. Leaving as-is for now since it's functionally correct and keeps each getter self-contained.

CHANGELOG.md Outdated

### Added

- **Export bundler utility functions for Webpack/Rspack compatibility**. [PR #880](https://github.com/shakacode/shakapacker/pull/880) by [justin808](https://github.com/justin808). New utility functions that make it easier to write bundler-agnostic configuration code: `isRspack`, `isWebpack`, `getBundler()`, `getCssExtractPlugin()`, `getCssExtractPluginLoader()`, `getDefinePlugin()`, `getEnvironmentPlugin()`, and `getProvidePlugin()`. Users no longer need to write conditional logic to handle differences between Webpack and Rspack.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOG references PR #880 instead of #922

The changelog entry links to PR #880, but this PR is #922 (superseding #913). If #880 was the original feature PR that was never merged, this link will point to a closed/unmerged PR. Consider updating to reference this PR (#922) so the link points to the actual merged change.

Suggested change
- **Export bundler utility functions for Webpack/Rspack compatibility**. [PR #880](https://github.com/shakacode/shakapacker/pull/880) by [justin808](https://github.com/justin808). New utility functions that make it easier to write bundler-agnostic configuration code: `isRspack`, `isWebpack`, `getBundler()`, `getCssExtractPlugin()`, `getCssExtractPluginLoader()`, `getDefinePlugin()`, `getEnvironmentPlugin()`, and `getProvidePlugin()`. Users no longer need to write conditional logic to handle differences between Webpack and Rspack.
- **Export bundler utility functions for Webpack/Rspack compatibility**. [PR #922](https://github.com/shakacode/shakapacker/pull/922) by [justin808](https://github.com/justin808). New utility functions that make it easier to write bundler-agnostic configuration code: `isRspack`, `isWebpack`, `getBundler()`, `getCssExtractPlugin()`, `getCssExtractPluginLoader()`, `getDefinePlugin()`, `getEnvironmentPlugin()`, and `getProvidePlugin()`. Users no longer need to write conditional logic to handle differences between Webpack and Rspack.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 363af2c — updated CHANGELOG to reference PR #922.

justin808 and others added 3 commits February 15, 2026 12:16
Add bundler utility functions that make it easier to write bundler-agnostic
configuration code. Users no longer need to write conditional logic to handle
differences between Webpack and Rspack.

New exports from shakapacker:
- isRspack: Boolean indicating if current bundler is Rspack
- isWebpack: Boolean indicating if current bundler is Webpack
- getBundler(): Returns the bundler module (webpack or @rspack/core)
- getCssExtractPlugin(): Returns MiniCssExtractPlugin or CssExtractRspackPlugin
- getCssExtractPluginLoader(): Returns the CSS extraction loader string
- getDefinePlugin(): Returns the DefinePlugin for the current bundler
- getEnvironmentPlugin(): Returns the EnvironmentPlugin for the current bundler
- getProvidePlugin(): Returns the ProvidePlugin for the current bundler

Usage example:
  const { getCssExtractPlugin, isRspack } = require('shakapacker')
  const CssPlugin = getCssExtractPlugin()
  new CssPlugin({ filename: 'styles.css' })

Closes #875

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Improves developer experience by providing proper TypeScript types:
- BundlerModule: Interface describing the bundler module
- PluginConstructor: Common interface for plugin constructors
- CssExtractPluginConstructor: Typed CSS extraction plugin
- CssExtractPluginOptions: Options for CSS extraction plugins

Users now get autocompletion when using these utilities.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@justin808 justin808 force-pushed the codex/supersede-913-bundler-utils-lint branch from 2012f6d to 92247d5 Compare February 15, 2026 22:16
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Line 16: Update the CHANGELOG entry to reference the actual merging PR:
replace the `[PR `#880`](https://github.com/shakacode/shakapacker/pull/880)`
fragment with `[PR `#922`](https://github.com/shakacode/shakapacker/pull/922)` and
ensure the author attribution remains `by
[justin808](https://github.com/justin808)` so the entry reads: `[PR
`#922`](https://github.com/shakacode/shakapacker/pull/922) by
[justin808](https://github.com/justin808)` while leaving the rest of the text
(function list: `isRspack`, `isWebpack`, `getBundler()`,
`getCssExtractPlugin()`, `getCssExtractPluginLoader()`, `getDefinePlugin()`,
`getEnvironmentPlugin()`, `getProvidePlugin()`) unchanged.
🧹 Nitpick comments (3)
package/utils/bundlerUtils.ts (1)

161-168: getCssExtractPluginLoader lacks the type assertions used in getCssExtractPlugin.

getCssExtractPlugin (Line 129) explicitly casts the requireOrError return value, but getCssExtractPluginLoader accesses .CssExtractRspackPlugin.loader and .loader on untyped results without assertions. While this works at runtime (and the ESLint overrides suppress warnings), adding consistent type narrowing would improve readability and make the code more resilient if lint suppressions are ever removed.

Suggested fix
 const getCssExtractPluginLoader = (): string => {
   if (isRspack) {
-    const rspack = requireOrError("@rspack/core")
+    const rspack = requireOrError("@rspack/core") as {
+      CssExtractRspackPlugin: CssExtractPluginConstructor
+    }
     return rspack.CssExtractRspackPlugin.loader
   }
-  const MiniCssExtractPlugin = requireOrError("mini-css-extract-plugin")
+  const MiniCssExtractPlugin = requireOrError(
+    "mini-css-extract-plugin"
+  ) as CssExtractPluginConstructor
   return MiniCssExtractPlugin.loader
 }
test/package/bundlerUtils.test.js (2)

1-97: Missing test coverage for the Rspack bundler path.

All tests verify only the default webpack behavior. The rspack code path (e.g., loading @rspack/core, returning CssExtractRspackPlugin) is not tested at all. Consider adding a parallel test suite that mocks config.assets_bundler as "rspack" (via jest.mock) to validate the rspack branch of each utility.

Based on learnings: "Test changes with both webpack and rspack configurations when modifying core functionality."


29-35: Consider verifying plugin identity, not just existence.

The getBundler test checks that DefinePlugin, EnvironmentPlugin, and ProvidePlugin are toBeDefined(), but doesn't verify they are the expected constructor (e.g., expect(bundler.DefinePlugin).toBe(require('webpack').DefinePlugin)). This would catch subtle regressions where the wrong module is loaded.

@justin808 justin808 added codex Created by Codex next-release Targeting next release p2 Medium: enhancements, docs, quality improvements and removed p2 Medium: enhancements, docs, quality improvements labels Feb 27, 2026
- Update CHANGELOG entry to reference PR #922 instead of #880
- Add bundler utility exports (isRspack, isWebpack, getBundler,
  getCssExtractPlugin, etc.) to ShakapackerExports interface in
  index.d.ts and index.d.ts.template so TypeScript consumers
  get proper type checking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Feb 27, 2026

Review: Bundler Utility Exports

Overall this is clean, well-documented work. The API design is sensible and the JSDoc examples are genuinely helpful. A few things worth addressing before merging:

Issues

1. getCssExtractPluginLoader duplicates the @rspack/core require from getCssExtractPlugin

Both functions load @rspack/core independently when rspack is active. getCssExtractPluginLoader could simply delegate to getCssExtractPlugin().loader, removing the duplication and guaranteeing both functions stay in sync if the rspack plugin structure changes.

2. Tests only cover the webpack code path

Every test relies on the default webpack bundler. The rspack branches in getCssExtractPlugin, getCssExtractPluginLoader, and getBundler are never exercised. Tests that temporarily set config.assets_bundler = 'rspack' (or mock the module) and assert the correct rspack plugins are returned would close this gap.

3. isWebpack is defined as !== 'rspack' rather than === 'webpack'

Any unrecognized assets_bundler value (a future bundler, a typo) would silently make isWebpack === true and potentially load the wrong plugins. The config already defaults unset values to 'webpack', so === 'webpack' should be safe and would make the symmetry explicit. Low-priority, but worth considering.

4. CssExtractPluginOptions includes webpack-only options in the shared type

experimentalUseImportModule is webpack-only and doesn't exist in Rspack's CssExtractRspackPlugin. Passing it when using rspack is silently ignored, which could confuse users. A comment or separate per-bundler option types would clarify intent.

5. Internal duplication opportunity (optional)

getStyleRule.ts lines 27-30 contain an inline copy of the CSS loader detection logic. Now that getCssExtractPluginLoader is public API, it could be used there too. Not blocking — worth a follow-up.

Minor

  • The // Bundler utilities grouping comment in package/rspack/index.ts is the only such group comment in that file's export list.
  • BundlerModule lists HotModuleReplacementPlugin and ProgressPlugin but no helpers are provided for them. Fine for now, but the interface may need updates as bundler surface area grows.

Comment on lines +161 to +168
const getCssExtractPluginLoader = (): string => {
if (isRspack) {
const rspack = requireOrError("@rspack/core")
return rspack.CssExtractRspackPlugin.loader
}
const MiniCssExtractPlugin = requireOrError("mini-css-extract-plugin")
return MiniCssExtractPlugin.loader
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates the @rspack/core require already performed inside getCssExtractPlugin. Consider delegating:

Suggested change
const getCssExtractPluginLoader = (): string => {
if (isRspack) {
const rspack = requireOrError("@rspack/core")
return rspack.CssExtractRspackPlugin.loader
}
const MiniCssExtractPlugin = requireOrError("mini-css-extract-plugin")
return MiniCssExtractPlugin.loader
}
const getCssExtractPluginLoader = (): string => getCssExtractPlugin().loader

This keeps both functions in sync automatically and avoids loading @rspack/core twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — Node.js caches require() results so the redundant call has no real cost. Leaving as-is for simplicity.

* // Webpack-specific configuration
* }
*/
const isWebpack: boolean = config.assets_bundler !== "rspack"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using !== "rspack" means any future or mistyped assets_bundler value (e.g. "vite", "webpack5") silently resolves to isWebpack === true, which could cause the wrong plugins to be loaded. Since config.ts already normalises missing values to "webpack", using === "webpack" here would be symmetric with isRspack and safer:

Suggested change
const isWebpack: boolean = config.assets_bundler !== "rspack"
const isWebpack: boolean = config.assets_bundler === "webpack"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. The \!== "rspack" pattern is intentional — webpack is the default/fallback bundler, and this is consistent with how config.assets_bundler is used elsewhere in the codebase (e.g., isRspack checks for === "rspack" throughout). Adding explicit validation for unknown bundler values would be a separate concern.

attributes?: Record<string, string>
linkType?: string | false
runtime?: boolean
experimentalUseImportModule?: boolean
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

experimentalUseImportModule is a webpack-only mini-css-extract-plugin option — it doesn't exist in Rspack's CssExtractRspackPlugin. Placing it in the shared interface risks silently confusing rspack users who pass it and get no effect. A brief comment noting it is webpack-only, or splitting into separate WebpackCssExtractPluginOptions / RspackCssExtractPluginOptions, would clarify intent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation. The interface is intentionally a union of common options that work across both bundlers. The property will simply be ignored by rspack if passed, and having it in the type helps webpack users get autocomplete. That said, this is a minor point — could be revisited if it causes confusion.

Comment on lines +1 to +97
const index = require("../../package/index")

describe("bundlerUtils", () => {
describe("isRspack and isWebpack", () => {
test("exports isRspack as a boolean", () => {
expect(typeof index.isRspack).toBe("boolean")
})

test("exports isWebpack as a boolean", () => {
expect(typeof index.isWebpack).toBe("boolean")
})

test("isRspack and isWebpack are mutually exclusive", () => {
expect(index.isRspack).not.toBe(index.isWebpack)
})

test("defaults to webpack (isWebpack is true, isRspack is false)", () => {
// Default bundler is webpack
expect(index.isWebpack).toBe(true)
expect(index.isRspack).toBe(false)
})
})

describe("getBundler", () => {
test("exports getBundler as a function", () => {
expect(index.getBundler).toBeInstanceOf(Function)
})

test("returns webpack module by default", () => {
const bundler = index.getBundler()
expect(bundler).toBeDefined()
expect(bundler.DefinePlugin).toBeDefined()
expect(bundler.EnvironmentPlugin).toBeDefined()
expect(bundler.ProvidePlugin).toBeDefined()
})
})

describe("getCssExtractPlugin", () => {
test("exports getCssExtractPlugin as a function", () => {
expect(index.getCssExtractPlugin).toBeInstanceOf(Function)
})

test("returns MiniCssExtractPlugin by default", () => {
const CssPlugin = index.getCssExtractPlugin()
expect(CssPlugin).toBeDefined()
// MiniCssExtractPlugin has a loader property
expect(CssPlugin.loader).toBeDefined()
})
})

describe("getCssExtractPluginLoader", () => {
test("exports getCssExtractPluginLoader as a function", () => {
expect(index.getCssExtractPluginLoader).toBeInstanceOf(Function)
})

test("returns a string loader path", () => {
const loader = index.getCssExtractPluginLoader()
expect(typeof loader).toBe("string")
})
})

describe("getDefinePlugin", () => {
test("exports getDefinePlugin as a function", () => {
expect(index.getDefinePlugin).toBeInstanceOf(Function)
})

test("returns webpack.DefinePlugin by default", () => {
const DefinePlugin = index.getDefinePlugin()
expect(DefinePlugin).toBeDefined()
expect(DefinePlugin).toBeInstanceOf(Function)
})
})

describe("getEnvironmentPlugin", () => {
test("exports getEnvironmentPlugin as a function", () => {
expect(index.getEnvironmentPlugin).toBeInstanceOf(Function)
})

test("returns webpack.EnvironmentPlugin by default", () => {
const EnvironmentPlugin = index.getEnvironmentPlugin()
expect(EnvironmentPlugin).toBeDefined()
expect(EnvironmentPlugin).toBeInstanceOf(Function)
})
})

describe("getProvidePlugin", () => {
test("exports getProvidePlugin as a function", () => {
expect(index.getProvidePlugin).toBeInstanceOf(Function)
})

test("returns webpack.ProvidePlugin by default", () => {
const ProvidePlugin = index.getProvidePlugin()
expect(ProvidePlugin).toBeDefined()
expect(ProvidePlugin).toBeInstanceOf(Function)
})
})
})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests run against the default webpack bundler. The rspack branches of getCssExtractPlugin, getCssExtractPluginLoader, and getBundler are never exercised.

Consider adding a describe block like:

describe("rspack bundler path", () => {
  let originalBundler
  beforeEach(() => {
    const config = require("../../package/config")
    originalBundler = config.default.assets_bundler
    config.default.assets_bundler = "rspack"
    jest.resetModules()
  })
  afterEach(() => {
    const config = require("../../package/config")
    config.default.assets_bundler = originalBundler
    jest.resetModules()
  })
  // ...assert @rspack/core plugins are returned
})

Without this, the core branching logic (the main value of this PR) has no test coverage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct — rspack path testing is not feasible in this test environment since @rspack/core is not installed. The webpack path tests provide adequate coverage for the utility logic. Rspack-specific behavior is validated in integration tests that have rspack available.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package/index.d.ts.template`:
- Around line 13-17: The file is missing a trailing newline at EOF which
violates formatting rules; open the file containing the import of
PluginConstructor, CssExtractPluginConstructor, and BundlerModule from
"./utils/bundlerUtils" and add a single newline character at the end of the file
so the file ends with a newline.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92247d5 and 363af2c.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • package/index.d.ts
  • package/index.d.ts.template
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

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

Labels

codex Created by Codex next-release Targeting next release p2 Medium: enhancements, docs, quality improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Export bundler utility functions for Webpack/Rspack compatibility

1 participant