Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

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

fixes #5525

Summary by CodeRabbit

  • Improvements
    • Enhanced file path matching to correctly handle query parameters in asset references, enabling broader compatibility with various file reference formats.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 25, 2025

Walkthrough

Updated the TRANSFORM_ID_REGEX pattern in the start plugin core constants to support optional query parameters after file extensions. The regex now matches TypeScript and JavaScript files that may include query strings, preventing transforms from incorrectly processing unrelated content.

Changes

Cohort / File(s) Change Summary
Regex pattern enhancement
packages/start-plugin-core/src/constants.ts
Updated TRANSFORM_ID_REGEX from /\.[cm]?[tj]sx?/ to `/.[cm]?[tj]sx?($

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Verify the regex pattern correctly handles query strings and boundary cases
  • Confirm the change resolves the reported issue with JSON string transforms

Possibly related PRs

Suggested labels

package: start-plugin-core

Suggested reviewers

  • lachlancollins

Poem

🐰 A query string sneaks through the gate,
Our regex now matches its fate,
No more stray JSON in the fold,
The pattern's tightened, strong and bold! ✨

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 title "fix: fix transform id regex" accurately describes the core change in the pull request. The changeset updates the TRANSFORM_ID_REGEX pattern in packages/start-plugin-core/src/constants.ts to add support for query parameters after file extensions, making the regex more specific and preventing incorrect matching. The title is clear, concise, and directly reflects the main modification without unnecessary noise or vague terminology.
Linked Issues Check ✅ Passed The TRANSFORM_ID_REGEX modification directly addresses the core requirement in issue #5525 by making the file extension matching more precise and boundary-aware. The updated regex pattern /\\.[cm]?[tj]sx?($|\\?)/ ensures that file extensions are matched only at end-of-string or before query parameters, which helps prevent incorrect file type identification that could cause JSON content to be misinterpreted as source code during AST parsing. This change reduces the likelihood of JSON strings like "createMiddleware" triggering Babel parsing errors by ensuring proper file type detection.
Out of Scope Changes Check ✅ Passed The change is narrowly scoped and directly related to the linked issue. The modification is limited to updating a single constant (TRANSFORM_ID_REGEX) in packages/start-plugin-core/src/constants.ts, which is the specific component identified as problematic in issue #5525. No extraneous modifications, refactoring, or unrelated changes are present in the changeset, maintaining focus on resolving the JSON file parsing error through improved file extension matching.
✨ 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-2

📜 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 54e0be8 and 81c6218.

📒 Files selected for processing (1)
  • packages/start-plugin-core/src/constants.ts (1 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/constants.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/constants.ts
🔇 Additional comments (2)
packages/start-plugin-core/src/constants.ts (2)

22-25: Clear documentation of regex behavior.

The comments accurately document which extensions are matched and clarify that JSON files are excluded, which directly addresses the bug context.


26-26: Regex fix correctly prevents false matches.

The addition of ($|\?) ensures the extension pattern is matched only at proper boundaries (end-of-string or before query parameters). This prevents transforming files like .ts.map, .tsx-backup, or other non-source files that contain the extension pattern within their paths, directly addressing the bug where JSON files were incorrectly being processed.

The regex still correctly matches:

  • All TypeScript/JavaScript source files with the documented extensions
  • Files with Vite query parameters (e.g., .ts?raw, .tsx?url)

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

@nx-cloud
Copy link

nx-cloud bot commented Oct 25, 2025

View your CI Pipeline Execution ↗ for commit 81c6218

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

☁️ Nx Cloud last updated this comment at 2025-10-25 22:46:31 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 25, 2025

More templates

@tanstack/arktype-adapter

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

@tanstack/directive-functions-plugin

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

@tanstack/eslint-plugin-router

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/server-functions-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/zod-adapter

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

commit: 81c6218

@schiller-manuel schiller-manuel merged commit eed6a79 into main Oct 25, 2025
6 checks passed
@schiller-manuel schiller-manuel deleted the fix-5525-2 branch October 25, 2025 22:49
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

2 participants