Repository: TanStack/router (ts)

Issue:
macro syntax is breaking dev/build
### Which project does this relate to?

Start

### Describe the bug

I'm using @parcel/macros to generate my CSS at build time.
This is leveraging the `import {...} from '....' with { type : 'macro' }` syntax (same as the bun macro one)

It looks like the chain of plugins is stripping the brackets around the type: 'macro' part. Is it possible to find a pointer on where to start looking for those issues?

code: 
```
import { createFileRoute } from '@tanstack/react-router'
import { css, v, q } from '../libs/boomer' with { type: 'macro' }
import { run } from '../css/theme'
```

Error
```
[vite] Internal server error: Transform failed with 1 error:
/home/arthur/git/tanstack/app/routes/index.tsx?tsr-split:1:48: ERROR: Expected "{" but found "type"
  Plugin: vite:esbuild
  File: /home/arthur/git/tanstack/app/routes/index.tsx?tsr-split:2:50
  
  Expected "{" but found "type"
  1  |  import { css, v, q } from '../libs/boomer' with type: 'macro';
     |                                                  ^
  2  |  import { run } from '../css/theme';
  3  |  run();
```

![Image](https://github.com/user-attachments/assets/4dad2a15-77a2-4dde-ba3a-196ca8b921b2)

### Your Example Website or App

https://stackblitz.com/edit/github-cshaakow-qd59rcrh?file=app%2Froutes%2Findex.tsx

### Steps to Reproduce the Bug or Issue

Follow the set up yourself guide on the documentation
get any import with the macro syntax (bun or parcel) 
`import { css, v, q } from '../libs/boomer' with { type: 'macro' }`
try to run the code in dev, with bun, npm or pnpm (didn't try others)

### Expected behavior

I would expect to be able to use those tools which are compatible as far as I know with vite itself (and bun)

### Screenshots or Videos

_No response_

### Platform

- OS: linux
- Browser: Chrome
- tanstack/start: 1.98.6
- runtime: bun 1.2.0


### Additional context

i'm the maintainer of boomerCSS (which leverage the parcel macros), trying to set the project up on as many framework possible and fixing compatibility issues

Pull request:
fix(router-plugin): fix handling of import attributes
fixes #3322

Patch:
diff --git a/examples/react/basic-ssr-file-based/package.json b/examples/react/basic-ssr-file-based/package.json
index 741165a62..70db11370 100644
--- a/examples/react/basic-ssr-file-based/package.json
+++ b/examples/react/basic-ssr-file-based/package.json
@@ -14,7 +14,7 @@
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
     "@tanstack/router-plugin": "^1.99.3",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "get-port": "^7.1.0",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
diff --git a/examples/react/basic-ssr-streaming-file-based/package.json b/examples/react/basic-ssr-streaming-file-based/package.json
index ef3fee311..1562d6b00 100644
--- a/examples/react/basic-ssr-streaming-file-based/package.json
+++ b/examples/react/basic-ssr-streaming-file-based/package.json
@@ -14,7 +14,7 @@
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
     "@tanstack/router-plugin": "^1.99.3",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "get-port": "^7.1.0",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
diff --git a/examples/react/start-basic-auth/package.json b/examples/react/start-basic-auth/package.json
index e6a3e23a0..00f37ac75 100644
--- a/examples/react/start-basic-auth/package.json
+++ b/examples/react/start-basic-auth/package.json
@@ -13,7 +13,7 @@
     "@prisma/client": "5.22.0",
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "prisma": "^5.22.0",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
diff --git a/examples/react/start-basic-react-query/package.json b/examples/react/start-basic-react-query/package.json
index 8ec5c167b..570ba4f9a 100644
--- a/examples/react/start-basic-react-query/package.json
+++ b/examples/react/start-basic-react-query/package.json
@@ -14,7 +14,7 @@
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/react-router-with-query": "^1.99.3",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "redaxios": "^0.5.1",
diff --git a/examples/react/start-basic-rsc/package.json b/examples/react/start-basic-rsc/package.json
index faab606bd..3546f1078 100644
--- a/examples/react/start-basic-rsc/package.json
+++ b/examples/react/start-basic-rsc/package.json
@@ -12,7 +12,7 @@
     "@babel/plugin-syntax-typescript": "^7.25.9",
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "redaxios": "^0.5.1",
diff --git a/examples/react/start-basic/package.json b/examples/react/start-basic/package.json
index 700f734d3..6645c45e7 100644
--- a/examples/react/start-basic/package.json
+++ b/examples/react/start-basic/package.json
@@ -11,7 +11,7 @@
   "dependencies": {
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "redaxios": "^0.5.1",
diff --git a/examples/react/start-clerk-basic/package.json b/examples/react/start-clerk-basic/package.json
index 9014c5aa8..2ed6f886a 100644
--- a/examples/react/start-clerk-basic/package.json
+++ b/examples/react/start-clerk-basic/package.json
@@ -12,7 +12,7 @@
     "@clerk/tanstack-start": "0.9.2",
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "redaxios": "^0.5.1",
diff --git a/examples/react/start-convex-trellaux/package.json b/examples/react/start-convex-trellaux/package.json
index ff72255d8..d25208759 100644
--- a/examples/react/start-convex-trellaux/package.json
+++ b/examples/react/start-convex-trellaux/package.json
@@ -17,7 +17,7 @@
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/react-router-with-query": "^1.99.3",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "concurrently": "^8.2.2",
     "convex": "^1.18.2",
     "ky": "^1.7.4",
diff --git a/examples/react/start-counter/package.json b/examples/react/start-counter/package.json
index 4b096006d..01ea74d36 100644
--- a/examples/react/start-counter/package.json
+++ b/examples/react/start-counter/package.json
@@ -10,7 +10,7 @@
   },
   "dependencies": {
     "@tanstack/react-router": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "vinxi": "0.5.1"
diff --git a/examples/react/start-large/package.json b/examples/react/start-large/package.json
index ac536cbd7..2def206aa 100644
--- a/examples/react/start-large/package.json
+++ b/examples/react/start-large/package.json
@@ -14,7 +14,7 @@
     "@tanstack/react-query": "^5.66.0",
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "redaxios": "^0.5.1",
diff --git a/examples/react/start-supabase-basic/package.json b/examples/react/start-supabase-basic/package.json
index 7ae36eedf..639a12767 100644
--- a/examples/react/start-supabase-basic/package.json
+++ b/examples/react/start-supabase-basic/package.json
@@ -17,7 +17,7 @@
     "@supabase/supabase-js": "^2.48.1",
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "vinxi": "0.5.1"
diff --git a/examples/react/start-trellaux/package.json b/examples/react/start-trellaux/package.json
index 188a806d4..32c6c6896 100644
--- a/examples/react/start-trellaux/package.json
+++ b/examples/react/start-trellaux/package.json
@@ -14,7 +14,7 @@
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/react-router-with-query": "^1.99.3",
     "@tanstack/router-devtools": "^1.99.0",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "ky": "^1.7.4",
     "msw": "^2.7.0",
     "react": "^19.0.0",
diff --git a/examples/react/with-trpc-react-query/package.json b/examples/react/with-trpc-react-query/package.json
index 926c576e8..ef1c42c5b 100644
--- a/examples/react/with-trpc-react-query/package.json
+++ b/examples/react/with-trpc-react-query/package.json
@@ -13,7 +13,7 @@
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
     "@tanstack/router-plugin": "^1.99.3",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "@trpc/client": "11.0.0-rc.730",
     "@trpc/react-query": "11.0.0-rc.730",
     "@trpc/server": "11.0.0-rc.730",
diff --git a/examples/react/with-trpc/package.json b/examples/react/with-trpc/package.json
index 57be78e19..d9ae92c16 100644
--- a/examples/react/with-trpc/package.json
+++ b/examples/react/with-trpc/package.json
@@ -11,7 +11,7 @@
     "@tanstack/react-router": "^1.99.0",
     "@tanstack/router-devtools": "^1.99.0",
     "@tanstack/router-plugin": "^1.99.3",
-    "@tanstack/start": "^1.99.3",
+    "@tanstack/start": "^1.99.4",
     "@trpc/client": "11.0.0-rc.730",
     "@trpc/server": "11.0.0-rc.730",
     "react": "^19.0.0",
diff --git a/packages/create-start/package.json b/packages/create-start/package.json
index 3858240a0..2cc213b62 100644
--- a/packages/create-start/package.json
+++ b/packages/create-start/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/create-start",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tim O'Connell",
   "license": "MIT",
diff --git a/packages/directive-functions-plugin/src/compilers.ts b/packages/directive-functions-plugin/src/compilers.ts
index 168d691bb..b359616a7 100644
--- a/packages/directive-functions-plugin/src/compilers.ts
+++ b/packages/directive-functions-plugin/src/compilers.ts
@@ -104,6 +104,7 @@ export function compileDirectives(opts: CompileDirectivesOpts): {
   const compiledResult = generateFromAst(ast, {
     sourceMaps: true,
     sourceFileName: opts.filename,
+    filename: opts.filename,
   })
 
   return {
diff --git a/packages/router-plugin/src/core/code-splitter/compilers.ts b/packages/router-plugin/src/core/code-splitter/compilers.ts
index 22eaf82d3..7885f49da 100644
--- a/packages/router-plugin/src/core/code-splitter/compilers.ts
+++ b/packages/router-plugin/src/core/code-splitter/compilers.ts
@@ -315,6 +315,7 @@ export function compileCodeSplitReferenceRoute(
   return generateFromAst(ast, {
     sourceMaps: true,
     sourceFileName: opts.filename,
+    filename: opts.filename,
   })
 }
 
@@ -589,6 +590,7 @@ export function compileCodeSplitVirtualRoute(
   return generateFromAst(ast, {
     sourceMaps: true,
     sourceFileName: opts.filename,
+    filename: opts.filename,
   })
 }
 
diff --git a/packages/router-utils/src/ast.ts b/packages/router-utils/src/ast.ts
index 795eff0f7..fbf6d970d 100644
--- a/packages/router-utils/src/ast.ts
+++ b/packages/router-utils/src/ast.ts
@@ -1,5 +1,6 @@
 import { parse } from '@babel/parser'
 import _generate from '@babel/generator'
+import type { GeneratorOptions, GeneratorResult } from '@babel/generator'
 import type { ParseResult } from '@babel/parser'
 import type * as _babel_types from '@babel/types'
 
@@ -29,6 +30,17 @@ let generate = _generate
 if ('default' in generate) {
   generate = generate.default as typeof generate
 }
-
-export { generate as generateFromAst }
+type GenerateFromAstOptions = GeneratorOptions &
+  Required<Pick<GeneratorOptions, 'sourceFileName' | 'filename'>>
+export function generateFromAst(
+  ast: _babel_types.Node,
+  opts?: GenerateFromAstOptions,
+): GeneratorResult {
+  return generate(
+    ast,
+    opts
+      ? { importAttributesKeyword: 'with', sourceMaps: true, ...opts }
+      : undefined,
+  )
+}
 export type { GeneratorResult } from '@babel/generator'
diff --git a/packages/start-api-routes/package.json b/packages/start-api-routes/package.json
index 6c130515a..9d68f939b 100644
--- a/packages/start-api-routes/package.json
+++ b/packages/start-api-routes/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-api-routes",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start-client/package.json b/packages/start-client/package.json
index 5d0f01d6d..e37c8d233 100644
--- a/packages/start-client/package.json
+++ b/packages/start-client/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-client",
-  "version": "1.99.0",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start-config/package.json b/packages/start-config/package.json
index 385b51db6..962ad960c 100644
--- a/packages/start-config/package.json
+++ b/packages/start-config/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-config",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start-server-functions-client/package.json b/packages/start-server-functions-client/package.json
index cf89f7f63..69609fbe9 100644
--- a/packages/start-server-functions-client/package.json
+++ b/packages/start-server-functions-client/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-server-functions-client",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start-server-functions-fetcher/package.json b/packages/start-server-functions-fetcher/package.json
index 71f988f12..c2c383ccb 100644
--- a/packages/start-server-functions-fetcher/package.json
+++ b/packages/start-server-functions-fetcher/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-server-functions-fetcher",
-  "version": "1.99.0",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start-server-functions-handler/package.json b/packages/start-server-functions-handler/package.json
index 63a050b80..79213c5ef 100644
--- a/packages/start-server-functions-handler/package.json
+++ b/packages/start-server-functions-handler/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-server-functions-handler",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start-server-functions-ssr/package.json b/packages/start-server-functions-ssr/package.json
index 2b8462fa6..282777217 100644
--- a/packages/start-server-functions-ssr/package.json
+++ b/packages/start-server-functions-ssr/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-server-functions-ssr",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start-server/package.json b/packages/start-server/package.json
index 75b413003..07c665f2d 100644
--- a/packages/start-server/package.json
+++ b/packages/start-server/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start-server",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",
diff --git a/packages/start/package.json b/packages/start/package.json
index 58671ad39..4f9361616 100644
--- a/packages/start/package.json
+++ b/packages/start/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@tanstack/start",
-  "version": "1.99.3",
+  "version": "1.99.4",
   "description": "Modern and scalable routing for React applications",
   "author": "Tanner Linsley",
   "license": "MIT",


Test patch:
diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute.tsx
new file mode 100644
index 000000000..643100983
--- /dev/null
+++ b/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute.tsx
@@ -0,0 +1,9 @@
+const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split');
+import { lazyRouteComponent } from '@tanstack/react-router';
+import { createFileRoute } from '@tanstack/react-router';
+export const Route = createFileRoute('/')({
+  component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr)
+});
+export function TSRDummyComponent() {
+  return null;
+}
\ No newline at end of file
diff --git a/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute@split.tsx
new file mode 100644
index 000000000..f34d3c640
--- /dev/null
+++ b/packages/router-plugin/tests/code-splitter/snapshots/development/importAttribute@split.tsx
@@ -0,0 +1,3 @@
+import { test } from './test' with { type: 'macro' };
+const SplitComponent = () => test;
+export { SplitComponent as component };
\ No newline at end of file
diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute.tsx
new file mode 100644
index 000000000..643100983
--- /dev/null
+++ b/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute.tsx
@@ -0,0 +1,9 @@
+const $$splitComponentImporter = () => import('importAttribute.tsx?tsr-split');
+import { lazyRouteComponent } from '@tanstack/react-router';
+import { createFileRoute } from '@tanstack/react-router';
+export const Route = createFileRoute('/')({
+  component: lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr)
+});
+export function TSRDummyComponent() {
+  return null;
+}
\ No newline at end of file
diff --git a/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute@split.tsx b/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute@split.tsx
new file mode 100644
index 000000000..f34d3c640
--- /dev/null
+++ b/packages/router-plugin/tests/code-splitter/snapshots/production/importAttribute@split.tsx
@@ -0,0 +1,3 @@
+import { test } from './test' with { type: 'macro' };
+const SplitComponent = () => test;
+export { SplitComponent as component };
\ No newline at end of file
diff --git a/packages/router-plugin/tests/code-splitter/test-files/importAttribute.tsx b/packages/router-plugin/tests/code-splitter/test-files/importAttribute.tsx
new file mode 100644
index 000000000..9d406d390
--- /dev/null
+++ b/packages/router-plugin/tests/code-splitter/test-files/importAttribute.tsx
@@ -0,0 +1,7 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+import { test } from './test' with { type: 'macro' }
+
+export const Route = createFileRoute('/')({
+  component: () => test,
+})