Skip to content

fix: Slug component import path to use absolute package reference#426

Merged
ainsleyclark merged 1 commit intomainfrom
claude/fix-slug-import-error-TJ8NP
Mar 13, 2026
Merged

fix: Slug component import path to use absolute package reference#426
ainsleyclark merged 1 commit intomainfrom
claude/fix-slug-import-error-TJ8NP

Conversation

@ainsleyclark
Copy link
Contributor

Summary

Fixed the slug field component import path to use an absolute package reference instead of a relative path, ensuring proper resolution in consumer applications.

Key Changes

  • Updated the slug component import path from a relative path (/fields/Slug/Component#Component) to an absolute package reference (@ainsleydev/payload-helper/fields/Slug/Component#Component)
  • Added explicit export configuration in package.json for the slug component to support the new import path with proper type definitions and entry points

Implementation Details

The issue was that the relative path would resolve incorrectly in the consumer's import map. By using the absolute package reference and adding the corresponding export configuration, the component can now be properly resolved regardless of where it's imported from. This ensures consistent behavior across different consumer applications and build configurations.

https://claude.ai/code/session_01WVA6tqvspfT8wQrJG8Zivn

Fixes the slug field component path from a relative `/fields/Slug/Component`
to the fully-qualified `@ainsleydev/payload-helper/fields/Slug/Component`,
preventing PayloadCMS from resolving it as a relative path in the
consumer's importMap. Also adds the corresponding package.json export.

https://claude.ai/code/session_01WVA6tqvspfT8wQrJG8Zivn
@ainsleyclark ainsleyclark changed the title Fix slug component import path to use absolute package reference fix: Slug component import path to use absolute package reference Mar 13, 2026
@claude
Copy link

claude bot commented Mar 13, 2026

Review summary

  • Overall score: 8/10
  • Critical issues: 0
  • Warnings: 2
  • Suggestions: 1
  • Recommendation: ⚠️ Approve with comments

A small, well-scoped fix for a real PayloadCMS import resolution bug. The root cause is clear, the changeset is present, and the approach (absolute package reference + matching export entry) is correct. Two minor consistency issues worth noting.

Critical issues 🔴

None.

Warnings 🟡

1. Inconsistent export conditions

The new export adds a "default" condition, but the majority of existing exports (./collections, ./globals, ./util, ./common, ./endpoints, ./fields) only declare "types" and "import":

"./fields/Slug/Component": {
    "types": "./dist/fields/Slug/Component.d.ts",
    "import": "./dist/fields/Slug/Component.js",
    "default": "./dist/fields/Slug/Component.js"   // ← inconsistent
}

Since the package declares "type": "module", the "default" condition is redundant for ESM consumers. Either remove it to match the pattern of other named exports, or add it consistently to all exports. As-is, it creates a subtle inconsistency that could cause confusion for future contributors.

2. No test coverage for the path fix

There is no test (unit or integration) verifying that the slug field component path resolves correctly to the absolute package reference. If this regresses — for example, if someone changes the path property back — there is nothing to catch it. A simple unit test asserting the Field.components.Field.path value equals @ainsleydev/payload-helper/fields/Slug/Component#Component would suffice.

Suggestions 🟢

Commit message scope

The commit uses fix(payload-helper): ... but AGENTS.md convention shows fix: ... without a scope segment. Minor deviation — worth aligning for consistency with the rest of the commit history.

@ainsleyclark ainsleyclark marked this pull request as ready for review March 13, 2026 16:03
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@ainsleyclark ainsleyclark merged commit d57ed1b into main Mar 13, 2026
4 checks passed
@ainsleyclark ainsleyclark deleted the claude/fix-slug-import-error-TJ8NP branch March 13, 2026 16:04
@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.26%. Comparing base (7f6b060) to head (fccebf5).
⚠️ Report is 511 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #426      +/-   ##
==========================================
+ Coverage   64.59%   70.26%   +5.67%     
==========================================
  Files         154      187      +33     
  Lines        6064     7439    +1375     
==========================================
+ Hits         3917     5227    +1310     
+ Misses       2064     2012      -52     
- Partials       83      200     +117     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants