Skip to content

fix(preview): move formatDate/formatDateTime into runtime subtree#3749

Open
daresTheDevil wants to merge 2 commits intonuxt:mainfrom
daresTheDevil:fix/cloudflare-import-path-3742
Open

fix(preview): move formatDate/formatDateTime into runtime subtree#3749
daresTheDevil wants to merge 2 commits intonuxt:mainfrom
daresTheDevil:fix/cloudflare-import-path-3742

Conversation

@daresTheDevil
Copy link

@daresTheDevil daresTheDevil commented Mar 21, 2026

🔗 Linked issue

Resolves #3742

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

src/runtime/internal/preview/collection.ts imported formatDate/formatDateTime from ../../../utils/content/transformers/utils. nuxt-module-build bundles src/utils/ into the main chunk but emits src/runtime/ files as separate modules — so that cross-tree import resolves to a path that doesn't exist in the published package.

Cloudflare Workers (strict module resolution) throws on the dangling import, breaking all v3.12 deploys on CF.

Fix: duplicate the two small functions into src/runtime/internal/preview/utils.ts and update the import in collection.ts. Added unit tests with a drift guard that asserts both copies produce identical output.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

The preview runtime imported these helpers from `src/utils/content/
transformers/utils`, which lives outside the `runtime/` subtree.
nuxt-module-build bundles `src/utils/` into the main chunk but emits
`src/runtime/` files as separate modules — so the cross-tree import
resolves to a path that doesn't exist in the published package.

This breaks Cloudflare Workers (strict module resolution) and any
other runtime that doesn't tolerate dangling imports.

Fix: duplicate the two small functions into `src/runtime/internal/
preview/utils.ts` and update the import in `collection.ts`.

Closes nuxt#3742
Covers the duplicated date formatters in the preview runtime subtree.
Includes a drift guard that asserts both copies (runtime and build-time)
produce identical output, so they can't silently diverge.
@vercel
Copy link

vercel bot commented Mar 21, 2026

@daresTheDevil is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 21, 2026

npm i https://pkg.pr.new/@nuxt/content@3749

commit: d7d65d9

@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

📝 Walkthrough

Walkthrough

This change resolves a broken import path reported in issue #3742 by consolidating date formatting utilities within the preview module. The functions formatDate and formatDateTime are implemented in the local src/runtime/internal/preview/utils.ts file instead of being imported from an unreachable cross-module path. The collection module is updated to import these formatting functions from the newly consolidated location. Comprehensive unit tests validate the formatting behavior, error handling, and consistency with any build-time transformer implementations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: moving formatDate/formatDateTime functions into the runtime subtree to fix module resolution issues.
Linked Issues check ✅ Passed The PR fully addresses issue #3742 by removing the broken cross-tree import and consolidating the functions into the runtime subtree, enabling strict module resolution environments like Cloudflare.
Out of Scope Changes check ✅ Passed All changes are directly in scope: moving formatDate/formatDateTime functions, updating imports in collection.ts, and adding unit tests to validate the changes and prevent drift.
Description check ✅ Passed The pull request description clearly relates to the changeset: it explains the cross-tree import issue, documents the fix (duplicating functions into runtime subtree), and references the corresponding issue #3742.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

Cloudflare build fails on 3.12

1 participant