Skip to content

Conversation

schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Oct 18, 2025

fixes #5525

Summary by CodeRabbit

Release Notes

  • Chores
    • Enhanced file pattern matching for plugin transformations to improve consistency and file type handling across the build process.

Copy link
Contributor

coderabbitai bot commented Oct 18, 2025

Walkthrough

Added a new TRANSFORM_ID_REGEX constant defining regex patterns for TS/TSX and JS/JSX files. Updated two plugin files to use this constant in their transform ID filters, ensuring transformations apply only to these specific file types.

Changes

Cohort / File(s) Summary
New constant definition
packages/start-plugin-core/src/constants.ts
Exported new TRANSFORM_ID_REGEX constant containing regex patterns to match TypeScript and JavaScript file extensions (TS/TSX, JS/JSX).
Plugin filter updates
packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts,
packages/start-plugin-core/src/start-compiler-plugin/plugin.ts
Imported TRANSFORM_ID_REGEX and applied it to the transform.id.include filter in both plugins to restrict transformations to targeted file types only.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

The changes are straightforward and repetitive: a single constant definition followed by identical imports and applications in two plugin files. No complex logic, minimal scope, and easy to validate.

Possibly related PRs

Poem

🐰 A regex hopper skips with glee,
Through .ts and .jsx, wild and free!
JSON files? We'll skip those by,
Transform filters make bugs say goodbye!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix: only transform TS/JS files" is concise, clear, and directly summarizes the primary change in the changeset. It accurately describes the solution to the issue—restricting transformations to TypeScript/JavaScript files only—which is the core objective. The title is specific enough for a teammate reviewing history to understand the main change without ambiguity.
Linked Issues Check ✅ Passed The changes directly address the linked issue #5525, which reports that JSON files are incorrectly parsed as JavaScript, causing BABEL_PARSER_SYNTAX_ERROR when a JSON file contains the string "createMiddleware". The solution implemented adds TRANSFORM_ID_REGEX to filter transformations to only TS/TSX and JS/JSX files, and updates both the server-fn-plugin and start-compiler-plugin to use this filter. This prevents JSON files from being processed through the AST parser, resolving the root cause of the reported bug.
Out of Scope Changes Check ✅ Passed All changes in the pull request are directly scoped to fixing issue #5525. The addition of TRANSFORM_ID_REGEX in constants.ts serves to define the file extension patterns, and its integration into both the server-fn-plugin and start-compiler-plugin directly implements the filtering mechanism. No unrelated refactoring, cleanup, or other modifications are present in the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-5525

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57bb795 and d542046.

📒 Files selected for processing (3)
  • packages/start-plugin-core/src/constants.ts (1 hunks)
  • packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts (2 hunks)
  • packages/start-plugin-core/src/start-compiler-plugin/plugin.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with extensive type safety across the codebase

Files:

  • packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts
  • packages/start-plugin-core/src/constants.ts
  • packages/start-plugin-core/src/start-compiler-plugin/plugin.ts
packages/{*-start,start-*}/**

📄 CodeRabbit inference engine (AGENTS.md)

Name and place Start framework packages under packages/-start/ or packages/start-/

Files:

  • packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts
  • packages/start-plugin-core/src/constants.ts
  • packages/start-plugin-core/src/start-compiler-plugin/plugin.ts
🧬 Code graph analysis (2)
packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts (1)
packages/start-plugin-core/src/constants.ts (1)
  • TRANSFORM_ID_REGEX (22-22)
packages/start-plugin-core/src/start-compiler-plugin/plugin.ts (1)
packages/start-plugin-core/src/constants.ts (1)
  • TRANSFORM_ID_REGEX (22-22)
⏰ 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). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (5)
packages/start-plugin-core/src/constants.ts (1)

21-22: LGTM! Regex patterns correctly identify TS/JS files.

The regex patterns comprehensively match all standard TypeScript and JavaScript file extensions, including CommonJS (.cjs, .cts) and ES Module (.mjs, .mts) variants. This will effectively prevent JSON and other non-source files from being parsed, fixing issue #5525.

packages/start-plugin-core/src/start-compiler-plugin/plugin.ts (2)

9-9: LGTM! Import correctly added.

The import statement properly brings in the new TRANSFORM_ID_REGEX constant alongside the existing import.


57-57: Perfect! This fixes the JSON parsing issue.

Adding TRANSFORM_ID_REGEX to id.include ensures only TypeScript and JavaScript files reach the transform handler. This prevents JSON files (even those containing strings like "createMiddleware") from being parsed by Babel, which was the root cause of issue #5525.

packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts (2)

1-1: LGTM! Import statement is correct.

The import properly adds TRANSFORM_ID_REGEX to the existing imports, consistent with the approach in the start-compiler-plugin.


84-84: Excellent! Consistent fix applied to server-fn plugin.

This change mirrors the fix in the start-compiler-plugin, ensuring the server-fn plugin also only transforms TS/JS files. Without this filter, JSON files containing strings matching the code patterns (.handler( or .createMiddleware()) would incorrectly be transformed, causing the same Babel parsing errors.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

nx-cloud bot commented Oct 18, 2025

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit d542046

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ❌ Failed 28m 17s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 24s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-18 15:21:27 UTC

Copy link

pkg-pr-new bot commented Oct 18, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5526

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5526

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5526

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5526

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5526

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5526

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5526

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5526

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5526

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5526

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5526

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5526

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5526

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5526

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5526

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5526

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5526

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5526

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5526

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5526

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5526

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5526

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5526

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5526

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5526

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5526

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5526

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5526

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5526

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5526

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5526

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5526

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5526

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5526

commit: d542046

@schiller-manuel schiller-manuel merged commit 2824bf7 into main Oct 18, 2025
5 of 6 checks passed
@schiller-manuel schiller-manuel deleted the fix-5525 branch October 18, 2025 15:08
@coderabbitai coderabbitai bot mentioned this pull request Oct 19, 2025
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.

Json file with createMiddleware string throws error

1 participant