Repository navigation
fix(react, aspect): drop the @teambit/webpack dependency, source types elsewhere - #10620
Conversation
…ports react.env, react.main.runtime, and the app-build files only needed WebpackConfigTransformer/WebpackConfigMutator/Configuration types from @teambit/webpack; source them from webpack-bundler, webpack-dev-server, and modules.config-mutator instead (same for aspect.env). Those packages already ship the types and are what react/aspect actually bundle with - depending on @teambit/webpack too pulled in its own webpack instance (exact 5.97.1 + webpack-assets-manifest), which pnpm resolves separately from webpack-bundler's floating range, causing cross-instance "argument must be an instance of Compilation" failures when the plugin is applied to a compiler built by the other webpack copy.
PR Summary by QodoFix React/Aspect envs pulling @teambit/webpack via type-only imports
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can describe a rule in plain language on the Rules page and Qodo drafts it for you |
@teambit/node, react, aspect, env: 1.0.1102 -> 1.0.1105 @teambit/mdx, readme: 1.0.1103 -> 1.0.1106 react/aspect no longer depend on @teambit/webpack after #10620.
… the core aspect WebpackMain.createBundler/createDevServer, the WebpackBundler/WebpackDevServer classes, and their config factories duplicated what @teambit/webpack.webpack-bundler and @teambit/webpack.webpack-dev-server now do (react/aspect/node envs build through those packages directly, not this aspect - see #10620). Nothing in the codebase calls createBundler/createDevServer anymore. Also drops generateExposePeersTransformer (already marked dead code) and its only helpers (get-exposed-rules, resolve-peer). Kept: the type exports, WebpackConfigMutator/Configuration re-exports, the thin transformer/plugin/fallback re-exports, and the WebpackMain class itself (gutted, so the aspect still loads for backward compatibility).
…#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)
Summary
react.env,react.main.runtime, and the app-build files only ever neededWebpackConfigTransformer/WebpackConfigMutator/Configurationtypes from@teambit/webpack(the old core-aspect package). Same foraspect.env. Those type-only imports still made bit's dependency resolver add@teambit/webpackas a real runtime dependency of the published@teambit/react/@teambit/aspectpackages.@teambit/webpackcarries its own exact-pinned[email protected]+webpack-assets-manifest, separate from thewebpack-bundler/webpack-dev-serverpackages react/aspect actually bundle with (PR #10610). pnpm resolves these as two different webpack module instances, so theWebpackAssetsManifestplugin (built against@teambit/webpack's copy) gets applied to aCompilerbuilt bywebpack-bundler's copy - causingThe 'compilation' argument must be an instance of Compilationfailures 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-bundlerWebpackConfigWithDevServer→@teambit/webpack.webpack-dev-serverWebpackConfigMutator→@teambit/webpack.modules.config-mutatorConfiguration→webpackdirectly (matches the existing convention used elsewhere inscopes/react/react/webpack/*)No behavior change - type-only imports, just re-pointed.
@teambit/webpackno longer appears in either package's dependency policy.Test plan
bit tag --buildon a react-based custom env (the scenario frome2e/harmony/custom-env-operations.e2e.ts/custom-env-operations-2.e2e.ts) no longer throws the cross-instance webpack errornpm view @teambit/react dependencies/@teambit/aspect dependenciesno longer lists@teambit/webpackafter the next release