Skip to content

refactor(react): use webpack-bundler/webpack-dev-server instead of WebpackMain aspect - #10610

Merged
GiladShoham merged 4 commits into
masterfrom
refactor/react-env-webpack-bundler-devserver
Aug 14, 2026
Merged

GiladShoham merged 4 commits into
masterfrom
refactor/react-env-webpack-bundler-devserver

Conversation

@GiladShoham

@GiladShoham GiladShoham commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Replaces this.webpack.createBundler/this.webpack.createDevServer in scopes/react/react/react.env.ts with @teambit/webpack.webpack-bundler's WebpackBundler.create() and @teambit/webpack.webpack-dev-server's WebpackDevServer.create(), pinned to 1.1.0. ReactEnv no longer depends on the WebpackMain aspect at all - webpack: WebpackMain was only used for .createBundler/.createDevServer (now removed) and for .pubsub (now sourced by injecting PubsubMain directly). WebpackAspect was dropped from ReactMain's static dependencies in react.main.runtime.ts and replaced with PubsubAspect.

The public API (getDevServer, getBundler, createComponentsWebpackBundler, createTemplateWebpackBundler) is unchanged - same signatures, same emitted webpack config. WebpackConfigTransformer was already import type.

Also cleans up teambit.webpack/webpack (the core aspect) itself: its internal generateAddAliasesFromPeersTransformer, generateExternalsTransformer, resolvePeerToDirOrFile/resolvePeerToFile, and WebpackBitReporterPlugin implementations are now thin re-exports of the new standalone @teambit/webpack.transformers.generate-add-aliases-from-peers, @teambit/webpack.transformers.generate-externals, @teambit/webpack.modules.resolve-peer, and @teambit/webpack.plugins.webpack-bit-reporter-plugin packages (from this change request), instead of maintaining duplicate logic. The now-unused internal get-externals.ts was removed. Public API of @teambit/webpack (import paths/names) is unchanged.

Why this needed transformers, and which config is right

@teambit/webpack.webpack-bundler/@teambit/webpack.webpack-dev-server (even at the newly-published 1.1.0) build their base webpack config independently of teambit.webpack/webpack, and their factories have drifted from it. Validated by building a real workspace/component against teambit.react/react (dogfooded locally, not the published package) and diffing the actual emitted webpack config (via util.inspect) from bit build and bit start before and after each change. Below is every drift found, what it means in practice, and which side I judged correct (and compensated for via a transformer, unless noted).

I also checked the two other consumers of these standalone packages that exist today - teambit.preview/react-preview (a Preview implementation built directly on WebpackBundler/WebpackDevServer) and teambit.react/webpack/react-webpack (its own independent set of webpack config factories, analogous to scopes/react/react/webpack/*) - to see whether they'd already solved some of this drift, and added a column for them below.

Bundler config

Drift What it means Which is right, and why react-preview + react-webpack
Missing webpack-assets-manifest plugin This plugin writes asset-manifest.json, mapping entry names to their emitted (hashed) filenames. Consumers that need to reference a built bundle by name at runtime - e.g. ReactApp's SSR flow injecting the right client bundle into server-rendered HTML - read this file. Without it, that lookup breaks. Core aspect's config is right, but this looks like a wider ecosystem gap, not a one-off. The manifest is actively read downstream in teambit.react/react. Compensated (addAssetsManifestPlugin, spliced right after ProvidePlugin to preserve plugin order). Also missing. react-webpack's own webpack.config.base.prod.ts has a WebpackManifestPlugin block, but it's commented out entirely. So this isn't a package-only regression - it looks like the manifest was deliberately dropped (or never finished) across this whole newer stack, which weakens my "accidental drop" read a little, but I still can't confirm nothing in teambit.react/react's existing consumers depends on asset-manifest.json today, so I kept it for this env specifically rather than drop it to match.

Dev-server config

Drift What it means Which is right, and why react-preview + react-webpack
Missing componentPathsRegExps / snapshot.managedPaths Webpack's snapshot.managedPaths marks paths as immutable for caching (normally all of node_modules). The workspace factory excludes Bit's own component packages from that immutable set, since those get edited locally during bit start. Core aspect's config is right. Without this, webpack would treat a locally-linked component's package as immutable and never notice edits to it - live-reload during bit start would silently stop working for component source changes. Compensated. Fixed, and arguably more cleanly. react-webpack's webpack.config.component.dev.ts (configComponentDevFactory) sets snapshot.managedPaths directly as part of its own component-dev layer, instead of patching the base config afterward. I could have done the same in scopes/react/react/webpack/webpack.config.component.dev.ts instead of a compensating transformer - equivalent result, arguably a bit tidier since it lives next to the config layer that already owns componentPathsRegExps. Left it as a transformer here to keep this PR's diff scoped to react.env.ts rather than also touching the config-factory files.
output.pathinfo: true (package) vs. unset (core aspect) Adds descriptive comments per module to the dev bundle output (verbose, dev-only). Webpack already defaults this to true in development mode when left unset. Practically a wash - webpack's own per-mode default already produces the same effective behavior; the core aspect's version is just more minimal (no redundant explicit override). Compensated (removed, to match the config object exactly, even though runtime behavior was already equivalent either way). Not addressed either way - react-webpack doesn't set it, same as core aspect (unset). Consistent with "doesn't matter" either way.
stats.logging / devServer.client.logging missing (package) vs. 'error' (core aspect) Controls how much of webpack's internal infrastructure logging prints to the terminal and browser console. Core aspect's config is right. Without 'error', bit start gets noticeably noisier both server- and client-side - a real DX regression. Compensated. Partially fixed, via a different mechanism. configEnvDevFactory sets devServer.client.logging: 'error' (matches core aspect), but for the server-side noise it uses stats: 'minimal' in configBaseDevFactory instead of stats.logging: 'error' - a different webpack stats preset that reduces output through a different knob, not a drift so much as a different way of solving the same DX problem. Both also set infrastructureLogging.level: 'error'.
devServer.static[].watch: true (package) vs. false (core aspect) Whether the dev server's static file server (serving the component's public output dir) watches that directory via Chokidar for changes. Core aspect's config is right, deliberately. That public directory typically doesn't exist yet when the dev server starts; Chokidar's behavior on a missing path is to recursively watch up the tree until it finds one that exists - which can end up watching the entire workspace root and burning through macOS's limited FSEvents streams. This was a real, previously-hit perf bug that the core aspect's false exists specifically to avoid. The package reintroduces it. Compensated. Not fixed - worth flagging upstream. Neither react-webpack nor react-preview overrides devServer.static[].watch, so envs built on this stack inherit the package's true and are potentially exposed to the same FSEvents-exhaustion issue the core aspect's override exists to avoid. This is the one item here I'd actively flag to the react-preview/react-webpack maintainers rather than treat as an intentional difference.
historyApiFallback.index: '/index.html' (package) vs. an absolute resolved path (core aspect) The SPA fallback page the dev server serves for unmatched routes. Core aspect's config is right. It points at the exact generated public/index.html for this component's preview, matching how Bit serves each component's dev preview individually. The package's bare /index.html isn't guaranteed to resolve to the right file given Bit's nested workspace/output layout. Compensated. Not fixed. No override in either package; same as output.pathinfo, this is inherited as-is from @teambit/webpack.webpack-dev-server's own factory.
HtmlWebpackPlugin gets extra scriptLoading: 'defer' / inject: 'body' (package) vs. unset/default (core aspect) Controls where the bundle <script> tag is injected and whether it's deferred. defer is generally good practice for not blocking parsing; injecting at the end of <body> is a common companion choice. Genuinely close, but I kept the core aspect's default. For a component preview iframe rendering a single bundle, head+default-script-loading vs. body+defer shouldn't be visibly different, and there's no comment or indication in the package that this was a deliberate, tested choice rather than incidental scaffold defaults. Changing default script placement/timing is the kind of thing that should be a deliberate, tested decision (it could interact with how Bit's preview bootstrap script expects the DOM to be ready), not an incidental side effect of switching packages. Compensated (kept existing behavior) rather than adopting the package's choice; worth revisiting deliberately if there's a real reason to prefer it. Not addressed - inherited as-is, same as core aspect's non-choice, except they end up with the package's defer/body rather than the core aspect's default.
Package never forwards a custom title to HtmlWebpackPlugin (always "Component preview") vs. core aspect forwarding context.title DevServerContext.title exists specifically so an env/app can set a custom preview page title. Core aspect's config is right. The package's WebpackDevServer.create() simply never passes title through to its configFactory call - looks like an incompleteness in the package, not an intentional simplification. Compensated. Not fixed. Same gap - createDevServerTransformers doesn't touch the HTML title either.
Stray process.env.NODE_ENV = 'development' side effect in the package's factory, absent in the core aspect's Forcibly mutates the global process.env.NODE_ENV as a side effect of building a config object - not scoped to the returned config at all. Core aspect's approach (not doing this) is clearly better practice. Comment in the package ("Required for babel-preset-react-app") suggests it's inherited from Create React App's one-shot CLI script, where a global env mutation is harmless. Inside a long-lived, potentially multi-component bit start process, a function silently flipping global process state on every call is a real code smell - it could clobber a different intentional value elsewhere in the same process. Not compensated (harmless in this specific codepath, since NODE_ENV is already 'development' throughout bit start), but flagged as something to fix upstream in the package rather than replicate. Inherited as-is (comes from the same @teambit/webpack.webpack-dev-server base factory both stacks build on).

Accepted, not compensated (functionally inert)

  • Polyfill shim versions (assert, punycode, util, url) resolve to slightly different patch versions, since fallbacksAliases/fallbacks are resolved via require.resolve() from within the package's own node_modules tree rather than the workspace's. Neither version is "more correct" - they're patch-level, non-behavior-changing polyfill releases; the only difference is which physical copy gets resolved. Forcing exact-version parity would mean re-importing and overriding resolve.alias/resolve.fallback wholesale from the core aspect, which isn't worth the added coupling for functionally-equivalent shims.
  • The bundler's log message loses "process initiated by X. config created by env Y." context, because WebpackBundler.create() doesn't forward bundlerContext.metaData into the WebpackBundler constructor. Purely a log-verbosity/debuggability regression (the core aspect's version is more helpful for bit build observability) - not something a transformer can fix, since transformers operate on the webpack Configuration, not on the Bundler class's own constructor args. A limitation in the package itself.

Should teambit.react/react just use react-preview/react-webpack instead?

Short answer: not in this PR, and probably not as a wholesale swap at all. A few reasons:

  • It isn't a drop-in replacement of the bundler/dev-server wiring - it replaces the entire webpack config layer. react-webpack's config factories (webpack.config.base.ts, .base.dev.ts, .base.prod.ts, .component.dev.ts, .component.prod.ts, .env.dev.ts) are a parallel, independently-evolving rewrite of scopes/react/react/webpack/* - different babel-loader descriptionData matchers, a different refresh-overlay package (@bitdev/react.webpack.refresh-overlay vs. the core env's own ./overlay/webpackHotDevClient), different CSS/Sass handling (e.g. quietDeps/silenceDeprecations), an EnvironmentPlugin injection core doesn't have, etc. Adopting it would mean replacing teambit.react/react's entire hand-tuned webpack behavior, not just how it talks to the bundler/dev-server - a much bigger and riskier change than "keep the same config, change how it's produced," which is what was asked here.
  • It wouldn't actually close this PR's drift list - it has its own, overlapping-but-different one. As the tables above show, react-preview/react-webpack fix snapshot.managedPaths and (partially, via stats: 'minimal') the logging noise, but they don't fix historyApiFallback.index, the HTML title forwarding, or - most notably - the devServer.static[].watch performance issue. Switching wouldn't get teambit.react/react to full parity with its current behavior; it would trade one set of gaps for another.
  • It would make the core react env depend on the release cadence of another, separately-versioned package for its core webpack behavior, rather than owning that config directly the way it does today. That's a reasonable direction for new envs to build on (which is presumably why react-preview exists), but a bigger architectural call for teambit.react/react specifically, given how many other envs/consumers compose with it.

Where this comparison was genuinely useful: it independently corroborates that historyApiFallback.index, the HTML title/scriptLoading gaps, and the stray NODE_ENV mutation all trace back to @teambit/webpack.webpack-dev-server's own base factory (not something specific to how teambit.react/react consumes it), and it surfaced that react-preview/react-webpack currently carry the static.watch perf regression unmitigated - worth raising with whoever maintains that stack, separately from this PR.

Core aspect cleanup (teambit.webpack/webpack)

Per the change request, the following now-standalone components already contain byte-for-byte the same logic that used to live inline in the core aspect (only decoupled from Harmony-specific types, e.g. Logger → a minimal duck-typed {warn} shape):

  • @teambit/webpack.transformers.generate-add-aliases-from-peers ← was transformers/transformers.ts's generateAddAliasesFromPeersTransformer
  • @teambit/webpack.transformers.generate-externals ← was transformers/transformers.ts's generateExternalsTransformer (+ the now-deleted transformers/get-externals.ts)
  • @teambit/webpack.modules.resolve-peer ← was transformers/resolve-peer.ts
  • @teambit/webpack.plugins.webpack-bit-reporter-plugin ← was plugins/webpack-bit-reporter-plugin.ts

generateExposePeersTransformer (already marked [dead code] - no longer used) and its get-exposed-rules.ts helper were left as-is - no standalone equivalent exists for it in the change request, and removing a still-publicly-exported dead function is a separate, broader API-cleanup decision outside this PR's scope.

Validated: temporarily reverted react.env.ts/react.main.runtime.ts to their pre-refactor state (so WebpackMain.createBundler/createDevServer were exercised directly again, the same codepath used before any of this PR's changes) and re-ran the same real-workspace bit build/bit start diff against the very first baseline capture. Both bundler and dev-server configs came back byte-identical aside from expected build timestamps - confirming the delegation is a pure no-op for WebpackMain's own output.

ReactApp validation

ReactApp (apps/web/react.application.ts) only calls reactEnv.getDevServer(...) and reactEnv.getBundler(...) - never the create*WebpackBundler methods directly (confirmed via a full repo-wide search). Both are the same methods already validated above for byte-identical config output, and the full workspace type-check (tsc --noEmit) passes, confirming ReactApp's calls (including the extra transformers it layers on: addDevServer, setOutput, setDevServerClient, clientConfig(), ssrConfig(), buildConfig(), replaceTerserPlugin()) still compile against the new signatures. I didn't spin up a full running ReactApp end-to-end, since that requires authoring a whole new custom aspect to register an app instance and no example exists in this workspace to reuse - a disproportionate amount of new scaffolding given the underlying methods are already proven equivalent.

Testing

  • npm run lint (tsc --noEmit && oxlint) passes with 0 errors, on both commits.
  • Built a real component against teambit.react/react in this workspace (dogfooded) and ran bit build/bit start, diffing the emitted webpack config before/after each change (react env refactor, then core aspect cleanup) against the original baseline.

…ver instead of WebpackMain

Replaces this.webpack.createBundler/createDevServer with the standalone
WebpackBundler/WebpackDevServer packages, decoupling the react env from the
WebpackMain aspect (ReactEnv now depends on PubsubMain instead). Adds
compensating transformers to keep the emitted webpack config identical to
what WebpackMain used to produce, since the packages' base config factories
have drifted from teambit.webpack/webpack's own factories.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Refactor ReactEnv to use webpack-bundler/dev-server packages (drop WebpackMain)

✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Switch ReactEnv bundler/dev-server creation to WebpackBundler/WebpackDevServer package factories.
• Remove WebpackMain dependency; inject PubsubMain directly for dev-server eventing.
• Add transformers to keep emitted webpack configs identical to previous workspace defaults.
Diagram

graph TD
RM["ReactMain runtime"] --> RE["ReactEnv"] --> WS["Workspace"]
RM --> PS["PubsubMain"] --> RE
RE --> WDS{{"WebpackDevServer"}} --> PS
RE --> WBL{{"WebpackBundler"}}
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Upstream drift fixes into webpack-dev-server/bundler packages
  • ➕ Removes the need for local parity transformers
  • ➕ Improves defaults for all package consumers
  • ➖ Requires coordinated package changes/releases
  • ➖ May be slower than applying local compatibility patches
2. Keep WebpackMain via a small adapter layer
  • ➕ Lowest behavioral risk; preserves existing factory as source of truth
  • ➕ Allows incremental migration to standalone packages
  • ➖ Does not fully decouple ReactEnv from WebpackMain
  • ➖ Continues to pull WebpackAspect dependency graph into React

Recommendation: The chosen approach is a good tradeoff: it achieves WebpackMain decoupling while preserving runtime behavior by compensating for factory drift with narrowly-scoped transformers. Longer-term, consider upstreaming the identified drifts into the standalone webpack packages to eliminate the maintenance cost of keeping parity locally.

Files changed (4) +1939 / -258

Refactor (2) +95 / -15
react.env.tsUse WebpackBundler/WebpackDevServer factories with parity transformers +88/-9

Use WebpackBundler/WebpackDevServer factories with parity transformers

• Replaces WebpackMain.createBundler/createDevServer usage with WebpackBundler.create() and WebpackDevServer.create(). Adds transformers to restore config parity (assets-manifest plugin insertion; dev-server stats/snapshot/static watch/historyApiFallback/client logging/HtmlWebpackPlugin reconstruction) and switches injected dependency from WebpackMain to PubsubMain.

scopes/react/react/react.env.ts

react.main.runtime.tsSwap WebpackAspect dependency for PubsubAspect in ReactMain runtime +7/-6

Swap WebpackAspect dependency for PubsubAspect in ReactMain runtime

• Removes WebpackMain/WebpackAspect from ReactMain dependencies/provider args and replaces them with PubsubMain/PubsubAspect. Updates ReactEnv construction accordingly.

scopes/react/react/react.main.runtime.ts

Other (2) +1844 / -243
pnpm-lock.yamlLockfile updates for webpack bundler/dev-server 1.1.0 +1842/-243

Lockfile updates for webpack bundler/dev-server 1.1.0

• Updates the pnpm lockfile to include @teambit/webpack.webpack-bundler and @teambit/webpack.webpack-dev-server at 1.1.0 and their resolved dependency trees.

pnpm-lock.yaml

workspace.jsoncAdd pinned standalone webpack bundler/dev-server dependencies +2/-0

Add pinned standalone webpack bundler/dev-server dependencies

• Adds @teambit/webpack.webpack-bundler and @teambit/webpack.webpack-dev-server pinned to 1.1.0 in workspace dependencies.

workspace.jsonc

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Missing workspace package path 🐞 Bug ☼ Reliability
Description
pnpm-lock.yaml adds a workspace importer and multiple file:components/sandbox/webpack-poc
resolutions, but components/sandbox/webpack-poc is not present in this repo checkout; this can
make pnpm install / workspace linking fail when it tries to resolve that directory package.
Code

pnpm-lock.yaml[R3821-3824]

+  components/sandbox/webpack-poc:
+    dependencies:
+      '@testing-library/react':
+        specifier: ^14.3.1
Evidence
The lockfile explicitly declares components/sandbox/webpack-poc as an importer and as a
file:-resolved workspace package, meaning pnpm will try to resolve that directory during
install/linking. In this PR branch checkout, the referenced directory is absent, so the lockfile
points to a non-existent local package path.

pnpm-lock.yaml[3821-3835]
pnpm-lock.yaml[31976-31982]
pnpm-lock.yaml[56638-56658]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm-lock.yaml` now includes a local workspace importer and `file:` resolutions for `components/sandbox/webpack-poc`, but that directory/package is not present in the repository checkout. This can cause `pnpm install` (especially `--frozen-lockfile`) to fail when pnpm attempts to resolve/link the missing directory.
### Issue Context
The lockfile declares `components/sandbox/webpack-poc` under `importers:` and also declares a workspace package `@sandbox/webpack-test.sandbox.webpack-poc@file:components/sandbox/webpack-poc` plus snapshots for it.
### Fix Focus Areas
- pnpm-lock.yaml[3821-3835]
- pnpm-lock.yaml[31976-31982]
- pnpm-lock.yaml[56638-56658]
### What to do
- If this sandbox package was added unintentionally: regenerate the lockfile without it (remove the importer + package + snapshots entries by re-running pnpm from a clean tree, then commit the updated lockfile).
- If it *is* intended: add/commit the missing `components/sandbox/webpack-poc` directory (at minimum its `package.json` and sources) so the `file:` resolution is valid.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Bad devServer index path 🐞 Bug ≡ Correctness
Description
alignDevServerWithWorkspaceDefaults computes historyApiFallback.index via resolve(workspace.path,
${rootPath}/${publicPath}); when rootPath is an empty string, the interpolated string starts with
'/', so path.resolve ignores workspace.path and produces an absolute '/public/<app>' path. ReactApp
constructs a DevServerContext with rootPath: '' and publicPath: public/${name}, so this will point
the fallback index outside the workspace and can break dev-server history fallback routing.
Code

scopes/react/react/react.env.ts[R130-133]

+      raw.devServer.historyApiFallback = {
+        ...raw.devServer.historyApiFallback,
+        index: resolve(workspace.path, `${devServerContext.rootPath}/${devServerContext.publicPath}`),
+      };
Evidence
The transformer sets historyApiFallback.index using a ${rootPath}/${publicPath} template and
resolve(workspace.path, ...), and ReactApp explicitly provides rootPath: '' with a relative
publicPath. That combination deterministically produces a leading '/' in the second argument,
which makes the resolved path ignore workspace.path.

scopes/react/react/react.env.ts[114-135]
scopes/react/react/apps/web/react.application.ts[326-336]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`alignDevServerWithWorkspaceDefaults()` builds `devServer.historyApiFallback.index` using a template string `${rootPath}/${publicPath}` and then `path.resolve(workspace.path, ...)`. When `rootPath === ''` (which happens for ReactApp), the template string becomes `/${publicPath}` and `path.resolve()` treats it as absolute, ignoring `workspace.path`.
## Issue Context
This transformer is injected into `ReactEnv.getDevServer()` and is therefore applied to ReactApp dev-server contexts as well.
## Fix Focus Areas
- scopes/react/react/react.env.ts[114-135]
## How to fix
Compute the resolved path without introducing a leading slash when `rootPath` is empty (and keep current behavior when `publicPath` begins with a separator for component previews). For example:
- Build `publicDirectory` conditionally:
- if `devServerContext.rootPath` is truthy: `${rootPath}/${publicPath}` (current behavior)
- else: `${publicPath}` (no prefixed `/`)
- Then `index: resolve(workspace.path, publicDirectory)`
Optionally, add a small normalization helper for `publicPath` when `rootPath` is empty (e.g. strip leading `/` or `\\`) to avoid absolute-path semantics.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Dev-server stats details lost 🐞 Bug ◔ Observability ⭐ New
Description
alignDevServerWithWorkspaceDefaults() only forces stats.logging = 'error' and doesn’t ensure
stats.errorDetails = true (which the previous WebpackMain dev-server config always set), so if the
new base dev-server config omits it the emitted config will provide less detailed webpack error
output during bit start. This is a behavior drift relative to the stated goal of keeping the
emitted config identical.
Code

scopes/react/react/react.env.ts[R118-122]

+    // the package's base config sets `output.pathinfo` explicitly; the workspace's own factory
+    // leaves it unset and relies on webpack's per-mode default instead.
+    if (raw.output) delete raw.output.pathinfo;
+    raw.stats = { ...raw.stats, logging: 'error' };
+    const componentPathsRegExps = workspace.getComponentPathsRegExps();
Evidence
The new transformer only applies logging: 'error' to raw.stats, so it no longer guarantees the
legacy errorDetails: true behavior. The previous WebpackMain dev-server factory hard-coded
errorDetails: true in its returned config.

scopes/react/react/react.env.ts[114-123]
scopes/webpack/webpack/config/webpack.dev.config.ts[65-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`alignDevServerWithWorkspaceDefaults()` updates `raw.stats` but does not guarantee the legacy `stats.errorDetails: true` setting that the previous `WebpackMain.createDevServer()` base config always applied. If the new standalone dev-server base config doesn't set `errorDetails`, webpack error output will lose useful detail.

### Issue Context
Legacy dev-server config (`scopes/webpack/webpack/config/webpack.dev.config.ts`) always set:
- `stats.errorDetails: true`
- `stats.logging: 'error'`

### Fix Focus Areas
- scopes/react/react/react.env.ts[118-123]

### Suggested fix
Update the transformer to explicitly set `errorDetails: true` while preserving any existing object stats:
- If `raw.stats` is an object: merge in `{ errorDetails: true, logging: 'error' }`.
- If `raw.stats` is not an object (e.g. `false`/string), replace it with an object that includes at least `{ errorDetails: true, logging: 'error' }` (or preserve the previous non-object value if you intentionally want it).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Duplicate webpack versions 🐞 Bug ⚙ Maintainability
Description
The lockfile now installs [email protected] in addition to the existing [email protected], driven by
@teambit/webpack.plugins.webpack-bit-reporter-plugin depending on webpack. This increases install
size and creates a higher risk of hard-to-debug incompatibilities when different parts of the
toolchain end up importing different webpack copies.
Code

pnpm-lock.yaml[R49651-49654]

+  [email protected]:
+    resolution: {integrity: sha512-U9/cvLzxObKNEZ9+TtdqrHM5/9z3lgl2c+c4BzbqGxFQvQvBAq87yql5A8pQ+rrMbS496MZJeF5enVBndIy2hw==}
+    engines: {node: '>=10.13.0'}
+    hasBin: true
Evidence
The lockfile explicitly adds [email protected] while keeping [email protected], and the new
reporter-plugin package snapshot depends on [email protected], which is what causes the duplication.

pnpm-lock.yaml[49647-49663]
pnpm-lock.yaml[103074-103077]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm-lock.yaml` now includes two webpack versions (`5.109.2` and `5.97.1`). This is introduced via the new `@teambit/[email protected]` snapshot resolving `[email protected]`, while the repo continues to use `[email protected]` elsewhere.
### Issue Context
Keeping a single webpack version across the workspace reduces install footprint and avoids subtle incompatibilities from multiple webpack copies coexisting.
### Fix Focus Areas
- package.json[65-69]
- pnpm-lock.yaml[49647-49663]
- pnpm-lock.yaml[103074-103077]
### Suggested fix
1. Decide the intended webpack version for the workspace (either keep `5.97.1` or move everything to `5.109.2`).
2. Add a pnpm override in the root `package.json` (under the existing `"pnpm"` section) to force a single `webpack` version, e.g.:
 - `"pnpm": { "overrides": { "webpack": "5.97.1" } }`
 (or `5.109.2`, as chosen).
3. Re-run `pnpm install` to regenerate `pnpm-lock.yaml` and confirm only one webpack version remains.
4. Sanity-check `bit build` / `bit start` to ensure the override doesn’t break the new dev-server/bundler packages.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can describe a rule in plain language on the Rules page and Qodo drafts it for you

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous review results

Review updated until commit 7c51a0c ⚖️ Balanced

Results up to commit d7e698c


🐞 Bugs (3) 📘 Rule violations (0) 📜 Skill insights (0)


Action required
1. Missing workspace package path 🐞 Bug ☼ Reliability
Description
pnpm-lock.yaml adds a workspace importer and multiple file:components/sandbox/webpack-poc
resolutions, but components/sandbox/webpack-poc is not present in this repo checkout; this can
make pnpm install / workspace linking fail when it tries to resolve that directory package.
Code

pnpm-lock.yaml[R3821-3824]

+  components/sandbox/webpack-poc:
+    dependencies:
+      '@testing-library/react':
+        specifier: ^14.3.1
Evidence
The lockfile explicitly declares components/sandbox/webpack-poc as an importer and as a
file:-resolved workspace package, meaning pnpm will try to resolve that directory during
install/linking. In this PR branch checkout, the referenced directory is absent, so the lockfile
points to a non-existent local package path.

pnpm-lock.yaml[3821-3835]
pnpm-lock.yaml[31976-31982]
pnpm-lock.yaml[56638-56658]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm-lock.yaml` now includes a local workspace importer and `file:` resolutions for `components/sandbox/webpack-poc`, but that directory/package is not present in the repository checkout. This can cause `pnpm install` (especially `--frozen-lockfile`) to fail when pnpm attempts to resolve/link the missing directory.
### Issue Context
The lockfile declares `components/sandbox/webpack-poc` under `importers:` and also declares a workspace package `@sandbox/webpack-test.sandbox.webpack-poc@file:components/sandbox/webpack-poc` plus snapshots for it.
### Fix Focus Areas
- pnpm-lock.yaml[3821-3835]
- pnpm-lock.yaml[31976-31982]
- pnpm-lock.yaml[56638-56658]
### What to do
- If this sandbox package was added unintentionally: regenerate the lockfile without it (remove the importer + package + snapshots entries by re-running pnpm from a clean tree, then commit the updated lockfile).
- If it *is* intended: add/commit the missing `components/sandbox/webpack-poc` directory (at minimum its `package.json` and sources) so the `file:` resolution is valid.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Bad devServer index path 🐞 Bug ≡ Correctness
Description
alignDevServerWithWorkspaceDefaults computes historyApiFallback.index via resolve(workspace.path,
${rootPath}/${publicPath}); when rootPath is an empty string, the interpolated string starts with
'/', so path.resolve ignores workspace.path and produces an absolute '/public/<app>' path. ReactApp
constructs a DevServerContext with rootPath: '' and publicPath: public/${name}, so this will point
the fallback index outside the workspace and can break dev-server history fallback routing.
Code

scopes/react/react/react.env.ts[R130-133]

+      raw.devServer.historyApiFallback = {
+        ...raw.devServer.historyApiFallback,
+        index: resolve(workspace.path, `${devServerContext.rootPath}/${devServerContext.publicPath}`),
+      };
Evidence
The transformer sets historyApiFallback.index using a ${rootPath}/${publicPath} template and
resolve(workspace.path, ...), and ReactApp explicitly provides rootPath: '' with a relative
publicPath. That combination deterministically produces a leading '/' in the second argument,
which makes the resolved path ignore workspace.path.

scopes/react/react/react.env.ts[114-135]
scopes/react/react/apps/web/react.application.ts[326-336]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`alignDevServerWithWorkspaceDefaults()` builds `devServer.historyApiFallback.index` using a template string `${rootPath}/${publicPath}` and then `path.resolve(workspace.path, ...)`. When `rootPath === ''` (which happens for ReactApp), the template string becomes `/${publicPath}` and `path.resolve()` treats it as absolute, ignoring `workspace.path`.
## Issue Context
This transformer is injected into `ReactEnv.getDevServer()` and is therefore applied to ReactApp dev-server contexts as well.
## Fix Focus Areas
- scopes/react/react/react.env.ts[114-135]
## How to fix
Compute the resolved path without introducing a leading slash when `rootPath` is empty (and keep current behavior when `publicPath` begins with a separator for component previews). For example:
- Build `publicDirectory` conditionally:
- if `devServerContext.rootPath` is truthy: `${rootPath}/${publicPath}` (current behavior)
- else: `${publicPath}` (no prefixed `/`)
- Then `index: resolve(workspace.path, publicDirectory)`
Optionally, add a small normalization helper for `publicPath` when `rootPath` is empty (e.g. strip leading `/` or `\\`) to avoid absolute-path semantics.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
3. Duplicate webpack versions 🐞 Bug ⚙ Maintainability ⭐ New
Description
The lockfile now installs [email protected] in addition to the existing [email protected], driven by
@teambit/webpack.plugins.webpack-bit-reporter-plugin depending on webpack. This increases install
size and creates a higher risk of hard-to-debug incompatibilities when different parts of the
toolchain end up importing different webpack copies.
Code

pnpm-lock.yaml[R49651-49654]

+  [email protected]:
+    resolution: {integrity: sha512-U9/cvLzxObKNEZ9+TtdqrHM5/9z3lgl2c+c4BzbqGxFQvQvBAq87yql5A8pQ+rrMbS496MZJeF5enVBndIy2hw==}
+    engines: {node: '>=10.13.0'}
+    hasBin: true
Evidence
The lockfile explicitly adds [email protected] while keeping [email protected], and the new
reporter-plugin package snapshot depends on [email protected], which is what causes the duplication.

pnpm-lock.yaml[49647-49663]
pnpm-lock.yaml[103074-103077]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm-lock.yaml` now includes two webpack versions (`5.109.2` and `5.97.1`). This is introduced via the new `@teambit/[email protected]` snapshot resolving `[email protected]`, while the repo continues to use `[email protected]` elsewhere.

### Issue Context
Keeping a single webpack version across the workspace reduces install footprint and avoids subtle incompatibilities from multiple webpack copies coexisting.

### Fix Focus Areas
- package.json[65-69]
- pnpm-lock.yaml[49647-49663]
- pnpm-lock.yaml[103074-103077]

### Suggested fix
1. Decide the intended webpack version for the workspace (either keep `5.97.1` or move everything to `5.109.2`).
2. Add a pnpm override in the root `package.json` (under the existing `"pnpm"` section) to force a single `webpack` version, e.g.:
  - `"pnpm": { "overrides": { "webpack": "5.97.1" } }`
  (or `5.109.2`, as chosen).
3. Re-run `pnpm install` to regenerate `pnpm-lock.yaml` and confirm only one webpack version remains.
4. Sanity-check `bit build` / `bit start` to ensure the override doesn’t break the new dev-server/bundler packages.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 694a299


🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)


Action required
1. Missing workspace package path 🐞 Bug ☼ Reliability ⭐ New
Description
pnpm-lock.yaml adds a workspace importer and multiple file:components/sandbox/webpack-poc
resolutions, but components/sandbox/webpack-poc is not present in this repo checkout; this can
make pnpm install / workspace linking fail when it tries to resolve that directory package.
Code

pnpm-lock.yaml[R3821-3824]

+  components/sandbox/webpack-poc:
+    dependencies:
+      '@testing-library/react':
+        specifier: ^14.3.1
Evidence
The lockfile explicitly declares components/sandbox/webpack-poc as an importer and as a
file:-resolved workspace package, meaning pnpm will try to resolve that directory during
install/linking. In this PR branch checkout, the referenced directory is absent, so the lockfile
points to a non-existent local package path.

pnpm-lock.yaml[3821-3835]
pnpm-lock.yaml[31976-31982]
pnpm-lock.yaml[56638-56658]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm-lock.yaml` now includes a local workspace importer and `file:` resolutions for `components/sandbox/webpack-poc`, but that directory/package is not present in the repository checkout. This can cause `pnpm install` (especially `--frozen-lockfile`) to fail when pnpm attempts to resolve/link the missing directory.

### Issue Context
The lockfile declares `components/sandbox/webpack-poc` under `importers:` and also declares a workspace package `@sandbox/webpack-test.sandbox.webpack-poc@file:components/sandbox/webpack-poc` plus snapshots for it.

### Fix Focus Areas
- pnpm-lock.yaml[3821-3835]
- pnpm-lock.yaml[31976-31982]
- pnpm-lock.yaml[56638-56658]

### What to do
- If this sandbox package was added unintentionally: regenerate the lockfile without it (remove the importer + package + snapshots entries by re-running pnpm from a clean tree, then commit the updated lockfile).
- If it *is* intended: add/commit the missing `components/sandbox/webpack-poc` directory (at minimum its `package.json` and sources) so the `file:` resolution is valid.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Bad devServer index path 🐞 Bug ≡ Correctness
Description
alignDevServerWithWorkspaceDefaults computes historyApiFallback.index via resolve(workspace.path,
${rootPath}/${publicPath}); when rootPath is an empty string, the interpolated string starts with
'/', so path.resolve ignores workspace.path and produces an absolute '/public/<app>' path. ReactApp
constructs a DevServerContext with rootPath: '' and publicPath: public/${name}, so this will point
the fallback index outside the workspace and can break dev-server history fallback routing.
Code

scopes/react/react/react.env.ts[R130-133]

+      raw.devServer.historyApiFallback = {
+        ...raw.devServer.historyApiFallback,
+        index: resolve(workspace.path, `${devServerContext.rootPath}/${devServerContext.publicPath}`),
+      };
Evidence
The transformer sets historyApiFallback.index using a ${rootPath}/${publicPath} template and
resolve(workspace.path, ...), and ReactApp explicitly provides rootPath: '' with a relative
publicPath. That combination deterministically produces a leading '/' in the second argument,
which makes the resolved path ignore workspace.path.

scopes/react/react/react.env.ts[114-135]
scopes/react/react/apps/web/react.application.ts[326-336]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`alignDevServerWithWorkspaceDefaults()` builds `devServer.historyApiFallback.index` using a template string `${rootPath}/${publicPath}` and then `path.resolve(workspace.path, ...)`. When `rootPath === ''` (which happens for ReactApp), the template string becomes `/${publicPath}` and `path.resolve()` treats it as absolute, ignoring `workspace.path`.
## Issue Context
This transformer is injected into `ReactEnv.getDevServer()` and is therefore applied to ReactApp dev-server contexts as well.
## Fix Focus Areas
- scopes/react/react/react.env.ts[114-135]
## How to fix
Compute the resolved path without introducing a leading slash when `rootPath` is empty (and keep current behavior when `publicPath` begins with a separator for component previews). For example:
- Build `publicDirectory` conditionally:
- if `devServerContext.rootPath` is truthy: `${rootPath}/${publicPath}` (current behavior)
- else: `${publicPath}` (no prefixed `/`)
- Then `index: resolve(workspace.path, publicDirectory)`
Optionally, add a small normalization helper for `publicPath` when `rootPath` is empty (e.g. strip leading `/` or `\\`) to avoid absolute-path semantics.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 6d2f46a


🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)


Action required
1. Bad devServer index path 🐞 Bug ≡ Correctness
Description
alignDevServerWithWorkspaceDefaults computes historyApiFallback.index via resolve(workspace.path,
${rootPath}/${publicPath}); when rootPath is an empty string, the interpolated string starts with
'/', so path.resolve ignores workspace.path and produces an absolute '/public/<app>' path. ReactApp
constructs a DevServerContext with rootPath: '' and publicPath: public/${name}, so this will point
the fallback index outside the workspace and can break dev-server history fallback routing.
Code

scopes/react/react/react.env.ts[R130-133]

+      raw.devServer.historyApiFallback = {
+        ...raw.devServer.historyApiFallback,
+        index: resolve(workspace.path, `${devServerContext.rootPath}/${devServerContext.publicPath}`),
+      };
Evidence
The transformer sets historyApiFallback.index using a ${rootPath}/${publicPath} template and
resolve(workspace.path, ...), and ReactApp explicitly provides rootPath: '' with a relative
publicPath. That combination deterministically produces a leading '/' in the second argument,
which makes the resolved path ignore workspace.path.

scopes/react/react/react.env.ts[114-135]
scopes/react/react/apps/web/react.application.ts[326-336]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`alignDevServerWithWorkspaceDefaults()` builds `devServer.historyApiFallback.index` using a template string `${rootPath}/${publicPath}` and then `path.resolve(workspace.path, ...)`. When `rootPath === ''` (which happens for ReactApp), the template string becomes `/${publicPath}` and `path.resolve()` treats it as absolute, ignoring `workspace.path`.

## Issue Context
This transformer is injected into `ReactEnv.getDevServer()` and is therefore applied to ReactApp dev-server contexts as well.

## Fix Focus Areas
- scopes/react/react/react.env.ts[114-135]

## How to fix
Compute the resolved path without introducing a leading slash when `rootPath` is empty (and keep current behavior when `publicPath` begins with a separator for component previews). For example:

- Build `publicDirectory` conditionally:
 - if `devServerContext.rootPath` is truthy: `${rootPath}/${publicPath}` (current behavior)
 - else: `${publicPath}` (no prefixed `/`)
- Then `index: resolve(workspace.path, publicDirectory)`

Optionally, add a small normalization helper for `publicPath` when `rootPath` is empty (e.g. strip leading `/` or `\\`) to avoid absolute-path semantics.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

Comment on lines +130 to +133
raw.devServer.historyApiFallback = {
...raw.devServer.historyApiFallback,
index: resolve(workspace.path, `${devServerContext.rootPath}/${devServerContext.publicPath}`),
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Bad devserver index path 🐞 Bug ≡ Correctness

alignDevServerWithWorkspaceDefaults computes historyApiFallback.index via resolve(workspace.path,
${rootPath}/${publicPath}); when rootPath is an empty string, the interpolated string starts with
'/', so path.resolve ignores workspace.path and produces an absolute '/public/<app>' path. ReactApp
constructs a DevServerContext with rootPath: '' and publicPath: public/${name}, so this will point
the fallback index outside the workspace and can break dev-server history fallback routing.
Agent Prompt
## Issue description
`alignDevServerWithWorkspaceDefaults()` builds `devServer.historyApiFallback.index` using a template string `${rootPath}/${publicPath}` and then `path.resolve(workspace.path, ...)`. When `rootPath === ''` (which happens for ReactApp), the template string becomes `/${publicPath}` and `path.resolve()` treats it as absolute, ignoring `workspace.path`.

## Issue Context
This transformer is injected into `ReactEnv.getDevServer()` and is therefore applied to ReactApp dev-server contexts as well.

## Fix Focus Areas
- scopes/react/react/react.env.ts[114-135]

## How to fix
Compute the resolved path without introducing a leading slash when `rootPath` is empty (and keep current behavior when `publicPath` begins with a separator for component previews). For example:

- Build `publicDirectory` conditionally:
  - if `devServerContext.rootPath` is truthy: `${rootPath}/${publicPath}` (current behavior)
  - else: `${publicPath}` (no prefixed `/`)
- Then `index: resolve(workspace.path, publicDirectory)`

Optionally, add a small normalization helper for `publicPath` when `rootPath` is empty (e.g. strip leading `/` or `\\`) to avoid absolute-path semantics.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

…e packages

Replaces the core teambit.webpack/webpack aspect's internal implementations
of generateAddAliasesFromPeersTransformer, generateExternalsTransformer,
resolvePeerToDirOrFile/resolvePeerToFile, and WebpackBitReporterPlugin with
re-exports from the new standalone @teambit/webpack.transformers.*,
@teambit/webpack.modules.resolve-peer, and
@teambit/webpack.plugins.webpack-bit-reporter-plugin packages, removing the
duplicated logic. Public API (import paths and names from @teambit/webpack)
is unchanged. Validated WebpackMain.createBundler/createDevServer still
produce byte-identical config to before the change.
Comment thread pnpm-lock.yaml
Comment on lines +3821 to +3824
components/sandbox/webpack-poc:
dependencies:
'@testing-library/react':
specifier: ^14.3.1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Missing workspace package path 🐞 Bug ☼ Reliability

pnpm-lock.yaml adds a workspace importer and multiple file:components/sandbox/webpack-poc
resolutions, but components/sandbox/webpack-poc is not present in this repo checkout; this can
make pnpm install / workspace linking fail when it tries to resolve that directory package.
Agent Prompt
### Issue description
`pnpm-lock.yaml` now includes a local workspace importer and `file:` resolutions for `components/sandbox/webpack-poc`, but that directory/package is not present in the repository checkout. This can cause `pnpm install` (especially `--frozen-lockfile`) to fail when pnpm attempts to resolve/link the missing directory.

### Issue Context
The lockfile declares `components/sandbox/webpack-poc` under `importers:` and also declares a workspace package `@sandbox/webpack-test.sandbox.webpack-poc@file:components/sandbox/webpack-poc` plus snapshots for it.

### Fix Focus Areas
- pnpm-lock.yaml[3821-3835]
- pnpm-lock.yaml[31976-31982]
- pnpm-lock.yaml[56638-56658]

### What to do
- If this sandbox package was added unintentionally: regenerate the lockfile without it (remove the importer + package + snapshots entries by re-running pnpm from a clean tree, then commit the updated lockfile).
- If it *is* intended: add/commit the missing `components/sandbox/webpack-poc` directory (at minimum its `package.json` and sources) so the `file:` resolution is valid.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 694a299

@GiladShoham
GiladShoham enabled auto-merge (squash) August 13, 2026 18:36
@github-actions github-actions Bot mentioned this pull request Aug 13, 2026
Comment thread pnpm-lock.yaml
Comment on lines +49651 to +49654
[email protected]:
resolution: {integrity: sha512-U9/cvLzxObKNEZ9+TtdqrHM5/9z3lgl2c+c4BzbqGxFQvQvBAq87yql5A8pQ+rrMbS496MZJeF5enVBndIy2hw==}
engines: {node: '>=10.13.0'}
hasBin: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Duplicate webpack versions 🐞 Bug ⚙ Maintainability

The lockfile now installs [email protected] in addition to the existing [email protected], driven by
@teambit/webpack.plugins.webpack-bit-reporter-plugin depending on webpack. This increases install
size and creates a higher risk of hard-to-debug incompatibilities when different parts of the
toolchain end up importing different webpack copies.
Agent Prompt
### Issue description
`pnpm-lock.yaml` now includes two webpack versions (`5.109.2` and `5.97.1`). This is introduced via the new `@teambit/[email protected]` snapshot resolving `[email protected]`, while the repo continues to use `[email protected]` elsewhere.

### Issue Context
Keeping a single webpack version across the workspace reduces install footprint and avoids subtle incompatibilities from multiple webpack copies coexisting.

### Fix Focus Areas
- package.json[65-69]
- pnpm-lock.yaml[49647-49663]
- pnpm-lock.yaml[103074-103077]

### Suggested fix
1. Decide the intended webpack version for the workspace (either keep `5.97.1` or move everything to `5.109.2`).
2. Add a pnpm override in the root `package.json` (under the existing `"pnpm"` section) to force a single `webpack` version, e.g.:
   - `"pnpm": { "overrides": { "webpack": "5.97.1" } }`
   (or `5.109.2`, as chosen).
3. Re-run `pnpm install` to regenerate `pnpm-lock.yaml` and confirm only one webpack version remains.
4. Sanity-check `bit build` / `bit start` to ensure the override doesn’t break the new dev-server/bundler packages.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d7e698c

Comment on lines +118 to +122
// the package's base config sets `output.pathinfo` explicitly; the workspace's own factory
// leaves it unset and relies on webpack's per-mode default instead.
if (raw.output) delete raw.output.pathinfo;
raw.stats = { ...raw.stats, logging: 'error' };
const componentPathsRegExps = workspace.getComponentPathsRegExps();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Dev-server stats details lost 🐞 Bug ◔ Observability

alignDevServerWithWorkspaceDefaults() only forces stats.logging = 'error' and doesn’t ensure
stats.errorDetails = true (which the previous WebpackMain dev-server config always set), so if the
new base dev-server config omits it the emitted config will provide less detailed webpack error
output during bit start. This is a behavior drift relative to the stated goal of keeping the
emitted config identical.
Agent Prompt
### Issue description
`alignDevServerWithWorkspaceDefaults()` updates `raw.stats` but does not guarantee the legacy `stats.errorDetails: true` setting that the previous `WebpackMain.createDevServer()` base config always applied. If the new standalone dev-server base config doesn't set `errorDetails`, webpack error output will lose useful detail.

### Issue Context
Legacy dev-server config (`scopes/webpack/webpack/config/webpack.dev.config.ts`) always set:
- `stats.errorDetails: true`
- `stats.logging: 'error'`

### Fix Focus Areas
- scopes/react/react/react.env.ts[118-123]

### Suggested fix
Update the transformer to explicitly set `errorDetails: true` while preserving any existing object stats:
- If `raw.stats` is an object: merge in `{ errorDetails: true, logging: 'error' }`.
- If `raw.stats` is not an object (e.g. `false`/string), replace it with an object that includes at least `{ errorDetails: true, logging: 'error' }` (or preserve the previous non-object value if you intentionally want it).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7c51a0c

@GiladShoham
GiladShoham merged commit 03b8d00 into master Aug 14, 2026
16 checks passed
@GiladShoham
GiladShoham deleted the refactor/react-env-webpack-bundler-devserver branch August 14, 2026 06:10
zkochan added a commit that referenced this pull request Aug 14, 2026
The lockfile committed alongside the exclude-node-modules-js addition was a full
re-resolution: it moved several hundred packages within their ranges, among them
@bitdev/react.generators.react-templates 6.0.3 -> 6.0.9, which no longer exports
ReactWebpackTemplate. scopes/react/react/react.templates.ts imports it, so
`tsc --noEmit` and the `declaration` build task both failed - that is the whole
of generate_and_check_types and bit_pr going red.

Regenerated from master's lockfile instead, so the only package this PR adds is
@teambit/[email protected]. The rest of the diff is
pnpm re-syncing importers with master's tree - #10610 added webpack-bundler,
webpack-dev-server, html-webpack-plugin and webpack-assets-manifest to
scopes/react/react and deleted components/sandbox/webpack-poc - and changes no
package version.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
zkochan added a commit that referenced this pull request Aug 14, 2026
Conflict resolutions:
- .circleci/config.yml: master's revert of --keep-lane (#10615) applied inside
  this branch's memory-sampler wrapper for the `bit ci pr` step.
- scopes/react/react/react.env.ts, react.main.runtime.ts: stay deleted - this
  branch removes the core env sources from the workspace, so #10610's edits to
  them are moot.
- scopes/preview/preview/rspack/rspack.config.ts: keep the mdxOptions parameter.
  The import master re-adds is what this branch removed on purpose:
  @teambit/mdx.modules.mdx-v3-options is ESM-only and has to reach the config
  through a native import() done by the caller.
- scopes/preview/preview/pre-bundle.ts: keep master's closeRspackCompiler, which
  logs a close failure instead of swallowing it (#10612), and drop this branch's
  earlier copy.
- workspace.jsonc: both sides - master's webpack-bundler/webpack-dev-server
  entries plus this branch's exclude-node-modules-js.
- pnpm-lock.yaml: regenerated from master's lockfile with `bit install`, so the
  full-re-resolution lockfile this branch carried is gone. @teambit/react is now
  the only added package (1.0.1099, consumed from the registry); everything else
  is importers and duplicate versions dropping out with the core env sources.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
GiladShoham added a commit that referenced this pull request Aug 14, 2026
…s elsewhere (#10620)

## Summary
`react.env`, `react.main.runtime`, and the app-build files only ever
needed `WebpackConfigTransformer` / `WebpackConfigMutator` /
`Configuration` **types** from `@teambit/webpack` (the old core-aspect
package). Same for `aspect.env`. Those type-only imports still made
bit's dependency resolver add `@teambit/webpack` as a real runtime
dependency of the published `@teambit/react`/`@teambit/aspect` packages.

`@teambit/webpack` carries its own exact-pinned `[email protected]` +
`webpack-assets-manifest`, separate from the
`webpack-bundler`/`webpack-dev-server` packages react/aspect actually
bundle with (PR #10610). pnpm resolves these as two different webpack
module instances, so the `WebpackAssetsManifest` plugin (built against
`@teambit/webpack`'s copy) gets applied to a `Compiler` built by
`webpack-bundler`'s copy - causing `The 'compilation' argument must be
an instance of Compilation` failures on tag/build for react-based custom
envs.

## Fix
Source the same types from the packages react/aspect already depend on
and actually build with, instead of `@teambit/webpack`:
- `WebpackConfigTransformer`, `WebpackConfigDevServerTransformContext` →
`@teambit/webpack.webpack-bundler`
- `WebpackConfigWithDevServer` → `@teambit/webpack.webpack-dev-server`
- `WebpackConfigMutator` → `@teambit/webpack.modules.config-mutator`
- `Configuration` → `webpack` directly (matches the existing convention
used elsewhere in `scopes/react/react/webpack/*`)

No behavior change - type-only imports, just re-pointed.
`@teambit/webpack` no longer appears in either package's dependency
policy.

## Test plan
- [ ] `bit tag --build` on a react-based custom env (the scenario from
`e2e/harmony/custom-env-operations.e2e.ts` /
`custom-env-operations-2.e2e.ts`) no longer throws the cross-instance
webpack error
- [ ] `npm view @teambit/react dependencies` / `@teambit/aspect
dependencies` no longer lists `@teambit/webpack` after the next release
GiladShoham added a commit that referenced this pull request Aug 16, 2026
…#10624)

## Summary
react/node/aspect envs build with `@teambit/webpack.webpack-bundler` and
`@teambit/webpack.webpack-dev-server` directly now (#10610), not the
`teambit.webpack/webpack` core aspect. Depending on both means pnpm
resolves two independently-versioned webpack instances - the exact root
cause behind the `instanceof Compilation` failures fixed in #10620.

This PR only adds `@deprecated` JSDoc to the now-superseded surface
(`WebpackMain.createBundler`/`createDevServer`/`mergeConfig`, the
`WebpackBundler`/`WebpackDevServer` classes, and the various
type/utility re-exports) so anyone still importing from
`@teambit/webpack` gets a signal to move to the standalone packages. No
code is removed and no behavior changes - purely additive, safe to merge
on its own.

A follow-up PR deletes the deprecated code once callers have had a
chance to migrate (tracked separately, alongside
https://bit.cloud/teambit/webpack/~change-requests/decouple-webpack-bundler-from-webpack-aspect).

## Test plan
- [x] `npm run lint` passes (tsc + oxlint)
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