Skip to content

chore: Remove conflicting env option from swc-loader in storybook config#40144

Open
dougfabris wants to merge 1 commit intodevelopfrom
chore/storybook-conflict-jsc
Open

chore: Remove conflicting env option from swc-loader in storybook config#40144
dougfabris wants to merge 1 commit intodevelopfrom
chore/storybook-conflict-jsc

Conversation

@dougfabris
Copy link
Copy Markdown
Member

@dougfabris dougfabris commented Apr 13, 2026

Proposed changes (including videos or screenshots)

Summary

Fixes yarn storybook failing with \env\ and \jsc.target\ cannot be used togetheracross all.stories.tsx` files.

Context

The .swcrc added by #37614 (Meteor's Modern Build Stack) sets jsc.target: "es2022". The @storybook/addon-webpack5-compiler-swc addon injects env: { bugfixes: true } into the swc-loader options. SWC rejects configurations that set both env and jsc.target, so every story fails to compile.

Fix

In .storybook/main.ts, walk the swc-loader rules inside webpackFinal and delete the injected env option. This lets .swcrc's jsc.target drive transpilation and keeps Meteor's build untouched.

Alternative considered: move jsc.targetenv.targets in .swcrc. Rejected because it broke Meteor at runtime (React is not defined — the jsc.transform.react.runtime: "automatic" was no longer honored).

Test plan

  • yarn storybook starts and serves stories at http://localhost:6006
  • meteor build and runtime still work (no regression on Modern Build Stack)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Chores
    • Optimized Storybook's webpack build configuration to enhance loader settings resolution and improve build consistency during the compilation process.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Apr 13, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 13, 2026

⚠️ No Changeset found

Latest commit: 57c36a6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dougfabris dougfabris added this to the 8.4.0 milestone Apr 13, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

Walkthrough

A webpackFinal step was added to the Storybook configuration that iterates through webpack rules and removes the env option from SWC loader configurations when present during the webpack build process.

Changes

Cohort / File(s) Summary
Storybook Webpack Configuration
apps/meteor/.storybook/main.ts
Added webpackFinal step to filter webpack rules and remove use.options.env from SWC loader configurations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically summarizes the main change: removing the conflicting env option from swc-loader in the Storybook configuration. It accurately reflects the file being modified and the problem being solved.
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.


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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.22%. Comparing base (5cff1f4) to head (57c36a6).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 59.67% <ø> (+<0.01%) ⬆️
e2e-api 47.40% <ø> (+0.83%) ⬆️
unit 71.06% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dougfabris dougfabris marked this pull request as ready for review April 13, 2026 21:56
Copy link
Copy Markdown
Contributor

@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.

🧹 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.use is handled. Per webpack 5's RuleSetRule API, use can also be a single object or function, and rules can be nested via oneOf. 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

📥 Commits

Reviewing files that changed from the base of the PR and between c544b80 and 57c36a6.

📒 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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant