chore: Remove conflicting env option from swc-loader in storybook config#40144
chore: Remove conflicting env option from swc-loader in storybook config#40144dougfabris wants to merge 1 commit intodevelopfrom
env option from swc-loader in storybook config#40144Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughA webpackFinal step was added to the Storybook configuration that iterates through webpack rules and removes the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #40144 +/- ##
===========================================
+ Coverage 70.18% 70.22% +0.04%
===========================================
Files 3279 3280 +1
Lines 116798 116814 +16
Branches 20714 20707 -7
===========================================
+ Hits 81977 82035 +58
+ Misses 31528 31485 -43
- Partials 3293 3294 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/meteor/.storybook/main.ts (1)
48-52: Make SWC option cleanup resilient to webpack rule shapes.On line 49, only array-form
rule.useis handled. Per webpack 5's RuleSetRule API,usecan also be a single object or function, and rules can be nested viaoneOf. While the current addon-webpack5-compiler-swc injects rules in standard array form, the implementation should account for these valid webpack patterns to remain robust against future addons or manual configuration.Proposed refactor
- for (const rule of (config.module?.rules ?? []) as any[]) { - for (const use of Array.isArray(rule?.use) ? rule.use : []) { - if (use?.loader?.includes?.('swc-loader') && use.options) delete use.options.env; - } - } + const stripSwcEnv = (rules: any[] = []): void => { + for (const rule of rules) { + const uses = Array.isArray(rule?.use) ? rule.use : rule?.use ? [rule.use] : []; + + for (const use of uses) { + if (typeof use === 'object' && use?.loader?.includes?.('swc-loader') && use.options) { + delete use.options.env; + } + } + + if (Array.isArray(rule?.oneOf)) { + stripSwcEnv(rule.oneOf); + } + } + }; + + stripSwcEnv((config.module?.rules ?? []) as any[]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/.storybook/main.ts` around lines 48 - 52, The current cleanup loop only handles array-form rule.use and misses single-object/function forms and nested rules (e.g., rule.oneOf), so update the logic that iterates config.module?.rules to recursively traverse rules and oneOf entries and normalize each rule.use into an array (wrap single object or call-result when it's a function) before processing; for each normalized use entry check loader as a string or use.loader?.includes('swc-loader') safely and, if use.options exists, delete use.options.env (or remove the env key) — refer to config.module?.rules, rule.use, rule.oneOf, and the swc-loader detection and use.options.env deletion to locate where to apply these changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/meteor/.storybook/main.ts`:
- Around line 48-52: The current cleanup loop only handles array-form rule.use
and misses single-object/function forms and nested rules (e.g., rule.oneOf), so
update the logic that iterates config.module?.rules to recursively traverse
rules and oneOf entries and normalize each rule.use into an array (wrap single
object or call-result when it's a function) before processing; for each
normalized use entry check loader as a string or
use.loader?.includes('swc-loader') safely and, if use.options exists, delete
use.options.env (or remove the env key) — refer to config.module?.rules,
rule.use, rule.oneOf, and the swc-loader detection and use.options.env deletion
to locate where to apply these changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f21c265f-4dd4-49d5-8ba5-1772021d06e9
📒 Files selected for processing (1)
apps/meteor/.storybook/main.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (5/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (1/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (2/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (4/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (3/5)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (4/4)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (2/4)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (1/4)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: In Rocket.Chat PRs, keep feature PRs free of unrelated lockfile-only dependency bumps; prefer reverting lockfile drift or isolating such bumps into a separate "chore" commit/PR, and always use yarn install --immutable with the Yarn version pinned in package.json via Corepack.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/elements/Timestamp/DateTimeFormats.spec.tsx:20-23
Timestamp: 2026-03-06T18:09:17.867Z
Learning: In the RocketChat/Rocket.Chat gazzodown package (`packages/gazzodown`), tests are intended to run under the UTC timezone, but as of PR `#39397` this is NOT yet explicitly enforced in `jest.config.ts` or the `package.json` test scripts (which just run `jest` without `TZ=UTC`). To make timezone-sensitive snapshot tests reliable across all environments, `TZ=UTC` should be added to the test scripts in `package.json` or to `jest.config.ts` via `testEnvironmentOptions.timezone`. Without explicit UTC enforcement, snapshot tests involving date-fns formatted output or `toLocaleString()` will fail for contributors in non-UTC timezones.
Proposed changes (including videos or screenshots)
Summary
Fixes
yarn storybookfailing with\env\and\jsc.target\cannot be used togetheracross all.stories.tsx` files.Context
The
.swcrcadded by #37614 (Meteor's Modern Build Stack) setsjsc.target: "es2022". The@storybook/addon-webpack5-compiler-swcaddon injectsenv: { bugfixes: true }into the swc-loader options. SWC rejects configurations that set bothenvandjsc.target, so every story fails to compile.Fix
In
.storybook/main.ts, walk the swc-loader rules insidewebpackFinaland delete the injectedenvoption. This lets.swcrc'sjsc.targetdrive transpilation and keeps Meteor's build untouched.Alternative considered: move
jsc.target→env.targetsin.swcrc. Rejected because it broke Meteor at runtime (React is not defined— thejsc.transform.react.runtime: "automatic"was no longer honored).Test plan
yarn storybookstarts and serves stories athttp://localhost:6006meteorbuild and runtime still work (no regression on Modern Build Stack)Issue(s)
Steps to test or reproduce
Further comments
Summary by CodeRabbit