Skip to content

fix(web): simplify Helmet imports to use named ESM exports#1470

Merged
Tobbe merged 2 commits intocedarjs:mainfrom
mvanhorn:osc/373-simplify-helmet-imports
Mar 27, 2026
Merged

fix(web): simplify Helmet imports to use named ESM exports#1470
Tobbe merged 2 commits intocedarjs:mainfrom
mvanhorn:osc/373-simplify-helmet-imports

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

Replaced import * as helmetPkg + destructuring with direct named imports from @dr.pogodin/react-helmet.

Why this matters

The import * as pattern was needed when the package lacked ESM support. @dr.pogodin/react-helmet v2.0.4 ships with exports.import in its package.json, making named imports work correctly. The old pattern added unnecessary indirection.

Changes

  • packages/web/src/components/MetaTags.tsx: import { Helmet as HelmetHead }
  • packages/web/src/components/Metadata.tsx: import { Helmet as HelmetHead }
  • packages/web/src/components/RedwoodProvider.tsx: import { Helmet, HelmetProvider }
  • packages/web/src/index.ts: import { Helmet }

4 files, net -7 lines.

Testing

Verified @dr.pogodin/react-helmet@2.0.4 has exports.import and module fields in its npm registry entry. No behavioral change - same symbols imported, just cleaner syntax.

Closes #373

This contribution was developed with AI assistance (Claude Code).

`@dr.pogodin/react-helmet` v2.0.4 ships with proper ESM named exports
(exports.import in package.json). The `import * as helmetPkg` pattern
followed by destructuring was from before the package had ESM support.

Replaced all 4 occurrences with direct named imports.

Closes cedarjs#373
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

👷 Deploy request for cedarjs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 52acb94

@Tobbe Tobbe added this to the next-release-patch milestone Mar 27, 2026
@Tobbe Tobbe changed the title refactor: simplify Helmet imports to use named ESM exports fix(web): simplify Helmet imports to use named ESM exports Mar 27, 2026
@Tobbe Tobbe added the release:fix This PR is a fix label Mar 27, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR replaces the import * as helmetPkg + runtime destructuring pattern with standard ESM named imports from @dr.pogodin/react-helmet across all four files that consume the package, leveraging the exports.import field present in v2.0.4's package.json.\n\n- The substitution is semantically equivalent: both patterns ultimately bind the same symbols (Helmet, HelmetProvider); the named-import form is simply more idiomatic and removes the intermediate namespace object.\n- The package version (2.0.4) is pinned in packages/web/package.json, and the PR author confirmed it ships a proper exports.import entry, so named ESM imports resolve correctly at build time.\n- For the CJS compilation path (used when @cedarjs/web is consumed as CommonJS), TypeScript transforms import { X } from '…' to const { X } = require('…'), which is exactly what the old destructuring step was doing — no regression.\n- No logic, component API, or public export surface was changed; Head and Helmet continue to be re-exported identically from index.ts.

Confidence Score: 5/5

Safe to merge — pure import-syntax cleanup with no behavioral or API changes

All four changes are mechanically equivalent to the code they replace. The package version is pinned and verified to support named ESM exports. CJS compilation is unaffected. No new logic, no new dependencies, and the public export surface of @cedarjs/web is unchanged.

No files require special attention

Important Files Changed

Filename Overview
packages/web/src/components/MetaTags.tsx Replaces namespace import + destructure with a direct named import; no logic changes
packages/web/src/components/Metadata.tsx Same named-import simplification as MetaTags.tsx; no logic changes
packages/web/src/components/RedwoodProvider.tsx Imports both Helmet and HelmetProvider directly; single-line change with no behavioral impact
packages/web/src/index.ts Replaces namespace import + const destructure with named import; exported symbols (Head, Helmet) remain identical

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["@dr.pogodin/react-helmet v2.0.4\n(exports.import present)"]

    subgraph Before
        B1["import * as helmetPkg"]
        B2["const { Helmet } = helmetPkg"]
        B1 --> B2
    end

    subgraph After
        C1["import { Helmet } from '…'"]
    end

    A --> Before
    A --> After

    Before -- "same runtime binding" --> D["Helmet / HelmetProvider used in components"]
    After -- "same runtime binding" --> D

    D --> E1["MetaTags.tsx"]
    D --> E2["Metadata.tsx"]
    D --> E3["RedwoodProvider.tsx"]
    D --> E4["index.ts → exports Head, Helmet"]
Loading

Reviews (1): Last reviewed commit: "refactor: simplify Helmet imports to use..." | Re-trigger Greptile

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 27, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 52acb94

Command Status Duration Result
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 2s View ↗
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 4m 14s View ↗
nx run-many -t build ✅ Succeeded 3m 56s View ↗
nx run-many -t test:types ✅ Succeeded 12s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-27 16:38:28 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 27, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit c745fe8

Command Status Duration Result
nx run-many -t build ✅ Succeeded 1m 3s View ↗
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-27 07:45:50 UTC

@Tobbe
Copy link
Copy Markdown
Member

Tobbe commented Mar 27, 2026

@mvanhorn Thanks for submitting one more PR 🙏

Do you want to look at the lint issue, or should I take care of it?

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Fixed in 52acb94 - added the missing blank line between import groups in MetaTags.tsx.

@Tobbe Tobbe merged commit 3c7d578 into cedarjs:main Mar 27, 2026
39 checks passed
@Tobbe
Copy link
Copy Markdown
Member

Tobbe commented Mar 27, 2026

@mvanhorn Thanks for another good PR 🙏

@github-actions
Copy link
Copy Markdown

The changes in this PR are now available on npm.

Try them out by running yarn cedar upgrade -t 4.0.0-canary.13692

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

Labels

release:fix This PR is a fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TODO]: Simplify Helmet imports

2 participants