Commit 53e9524
fix(router-plugin): respect directive prologues when inserting imports
Add insertAfterDirectives() helper to ensure imports are inserted after
directive prologues ('use client', 'use server', etc.) rather than before
them. This is critical for React Server Components and other frameworks
that require directives to be the first statements in a module.
Previously, unshiftContainer() would insert imports at the start of the
program body, potentially before directives, which would cause them to be
ignored or throw errors.
All 5 usages of unshiftContainer() have been replaced with the new helper:
- LazyRouteComponent imports
- Dynamic import importer functions
- lazyFn imports
- Shared variable imports (with correct index tracking)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 7295859 commit 53e9524
1 file changed
+37
-7
lines changedLines changed: 37 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
149 | 177 | | |
150 | 178 | | |
151 | 179 | | |
| |||
411 | 439 | | |
412 | 440 | | |
413 | 441 | | |
414 | | - | |
| 442 | + | |
415 | 443 | | |
416 | 444 | | |
417 | 445 | | |
| |||
425 | 453 | | |
426 | 454 | | |
427 | 455 | | |
428 | | - | |
| 456 | + | |
429 | 457 | | |
430 | 458 | | |
431 | 459 | | |
| |||
479 | 507 | | |
480 | 508 | | |
481 | 509 | | |
482 | | - | |
483 | | - | |
| 510 | + | |
| 511 | + | |
484 | 512 | | |
485 | 513 | | |
486 | 514 | | |
| |||
494 | 522 | | |
495 | 523 | | |
496 | 524 | | |
497 | | - | |
| 525 | + | |
498 | 526 | | |
499 | 527 | | |
500 | 528 | | |
| |||
1100 | 1128 | | |
1101 | 1129 | | |
1102 | 1130 | | |
1103 | | - | |
| 1131 | + | |
1104 | 1132 | | |
1105 | 1133 | | |
1106 | | - | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
1107 | 1137 | | |
1108 | 1138 | | |
1109 | 1139 | | |
| |||
0 commit comments