Conversation
|
👋 @marcospassos
☝️ Lastly, the title for the commit will come from the pull request title. So please provide a descriptive title that summarizes the changes in 50 characters or less using the imperative mood. |
commit: |
There was a problem hiding this comment.
Pull Request Overview
This PR updates the Next.js middleware codemod to stop re-exporting matcher configurations and instead inject literal matcher strings, and adjusts the related transformation tests.
- Remove detection of re-exported configs and always inline a
configexport with a literal matcher pattern. - Introduce
addConfigExporthelper to append aconfigdeclaration. - Update existing fixtures by deleting re-export statements and simplify test inputs.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/application/project/code/transformation/fixtures/nextjs-middleware/existingMiddlewareAndConfigReexport.ts | Removed middleware and config re-export fixture content |
| test/application/project/code/transformation/fixtures/nextjs-middleware/existingLocalConfigAndMiddlewareReexport.ts | Cleared local config and middleware re-export fixture |
| test/application/project/code/transformation/fixtures/nextjs-middleware/existingConfigReexport.ts | Deleted config re-export fixture |
| src/application/project/code/transformation/javascript/nextJsMiddlewareCodemod.ts | Dropped config re-export logic, added inline config export helper, and adjusted matcher property handling |
Comments suppressed due to low confidence (3)
src/application/project/code/transformation/javascript/nextJsMiddlewareCodemod.ts:129
- [nitpick] This comment indicates only a middleware re-export is added, but the code also appends a
configexport. Consider updating the comment to reflect both actions for clarity.
// just add middleware re-export
src/application/project/code/transformation/javascript/nextJsMiddlewareCodemod.ts:54
- Removing the check for re-exported configs may cause the codemod to always inject a new
configexport even when one is re-exported. Consider reintroducing anisConfigReexportedcheck to skip addingconfigif it already exists.
const localConfig = NextJsMiddlewareCodemod.findConfig(input);
Summary
This PR fixes a wrong assumption: Next.js doesn't support reexporting middleware matchers. Matchers are now defined using literal strings instead.
Checklist