Skip to content

fix(loadable-components): skip transformation when ssr: false is specified#592

Merged
kdy1 merged 1 commit into
mainfrom
claude/issue-465-20260321-0028
Mar 21, 2026
Merged

fix(loadable-components): skip transformation when ssr: false is specified#592
kdy1 merged 1 commit into
mainfrom
claude/issue-465-20260321-0028

Conversation

@kdy1
Copy link
Copy Markdown
Member

@kdy1 kdy1 commented Mar 21, 2026

When loadable() is called with { ssr: false } in the options object, the plugin now skips the SSR transformation as required by the loadable-components API.

Fixes #465

Generated with Claude Code

…ified

When loadable() is called with { ssr: false } in the options object,
the plugin now skips the SSR transformation as required by the
loadable-components API.

Fixes #465

Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 21, 2026

⚠️ No Changeset found

Latest commit: af29599

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

@kdy1 kdy1 enabled auto-merge (squash) March 21, 2026 00:36
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@claude
Copy link
Copy Markdown

claude Bot commented Mar 21, 2026

Code Review

Overall this is a clean, correct fix for issue #465. The implementation is straightforward and well-targeted. A few observations:

Correctness

The logic in has_ssr_false correctly handles:

  • Missing second argument → skip (return false, don't skip transform)
  • Non-object second argument → don't skip
  • ssr key as both Ident and Str variants — good coverage
  • Spread properties are safely ignored (falls through to false)

One edge case worth considering: computed property keys like { ["ssr"]: false }. The current implementation only matches PropName::Ident and PropName::Str, so { ["ssr"]: false } would not be detected. This is likely fine in practice (uncommon pattern), but worth a comment or test if the reference Babel plugin handles it.

Missing changeset

The changeset-bot flagged that there's no changeset file. Since this is a bug fix that changes observable behavior, a .changeset file should be added so a patch version bump is issued for @swc/plugin-loadable-components.

Test coverage

The added test covers the basic case well. Consider adding tests for:

  1. { ssr: true } — should still transform (regression guard)
  2. { ssr: false } using a string key { "ssr": false } — exercises the PropName::Str branch
  3. loadable.lib(() => import("./Foo"), { ssr: false }) — verifies the skip also applies for the .lib call pattern if applicable

Minor style note

The intermediate is_ssr_key binding is clear and readable. Alternatively it could be folded directly into the matches! macro condition, but the current form is arguably more readable — no change needed.

Summary

The implementation is correct and the approach is appropriate. The main actionable items are:

  • Add a .changeset entry for the patch bump
  • Optionally add a { ssr: true } fixture to guard against regressions

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af29599f5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +141 to +145
obj.props.iter().any(|prop| match prop {
PropOrSpread::Prop(prop) => match prop.as_ref() {
Prop::KeyValue(kv) => {
let is_ssr_key = match &kv.key {
PropName::Ident(i) => &*i.sym == "ssr",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Respect later overrides when checking ssr: false

has_ssr_false() now returns true if any property in the options object is ssr: false, but JavaScript object literals are order-sensitive. Inputs like loadable(() => import('./Comp'), { ssr: false, ...opts }) or { ssr: false, ssr: true } end up with ssr !== false at runtime, yet this branch still skips the transform entirely. In those cases we silently drop the loadable SSR metadata even though SSR is effectively enabled.

Useful? React with 👍 / 👎.

@kdy1 kdy1 merged commit 4c82e78 into main Mar 21, 2026
12 of 13 checks passed
@kdy1 kdy1 deleted the claude/issue-465-20260321-0028 branch March 21, 2026 00:40
kdy1 added a commit that referenced this pull request Mar 21, 2026
## Summary
- Addressed `chatgpt-codex-connector[bot]` review follow-ups across
merged PRs: #585, #591, #592, #593, #594, #595, #597, #598, #599.
- Applied the fixes as 9 separate commits (one commit per original PR)
in a single follow-up branch.

## What Changed
- #585 / #592 (`loadable-components`)
- Fixed source-less default-import matching to honor the configured
local name.
- Updated `ssr: false` detection to respect final object-literal
override order.
  - Added/updated fixtures for both behaviors.
- #591 / #594 (`formatjs`)
- Added JSX member-expression message component support (e.g.
`ReactIntl.FormattedMessage`).
  - Updated #532 regression coverage to validate the `ast: true` path.
- #593 / #595 (`graphql-codegen-client-preset`)
  - Extended `namingConvention` parsing to accept string/object forms.
- Preserved names for `keep`/unknown conventions instead of forcing
PascalCase.
- Fixed Windows absolute `filename` path handling in WASM runtime path
resolution.
  - Added unit coverage for the new config/path behaviors.
- #597 / #599 (`emotion`)
- Ensured tagged-template labels are terminated before sourcemap
comments.
- Added css-prop rewrite support for namespace imports
(`emotionReact.css`).
  - Attached PURE comments to the generated call site span.
  - Updated emotion fixtures accordingly.
- #598 (docs)
- Corrected capability descriptions in `packages/jest/README.tmpl.md`
and `packages/swc-sdk/README.tmpl.md`.

## Validation
- `cargo test -p swc_plugin_loadable_components --test fixture --
--ignored`
- `cargo test -p swc_plugin_graphql_codegen_client_preset`
- `cargo test -p swc_emotion --test fixture -- --ignored`
- `pnpm -C /Users/kdy1/.codex/worktrees/17e6/plugins/packages/formatjs
test`

All passed (formatjs has an existing non-blocking Vitest warning about
an un-awaited rejects assertion).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

loadable-components plugin does not support ssr false

2 participants