Skip to content

add support for additional Next.js config file types#9871

Open
leoortizz wants to merge 4 commits intomainfrom
leoortizz_nextconfig
Open

add support for additional Next.js config file types#9871
leoortizz wants to merge 4 commits intomainfrom
leoortizz_nextconfig

Conversation

@leoortizz
Copy link
Member

Description

  • Updated CONFIG_FILES to include "next.config.ts" and "next.config.mts".
  • Modified logic in ɵcodegenFunctionsDirectory to handle new config file types.
  • Added unit tests for whichNextConfigFile to ensure correct file detection and prioritization.

Might fix #9854

Scenarios Tested

  • firebase deploy with Next.js projects using next.config.ts and next.config.mts

Sample Commands

firebase deploy

- Updated CONFIG_FILES to include "next.config.ts" and "next.config.mts".
- Modified logic in ɵcodegenFunctionsDirectory to handle new config file types.
- Added unit tests for whichNextConfigFile to ensure correct file detection and prioritization.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @leoortizz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Firebase CLI's compatibility with Next.js projects by introducing support for TypeScript-based configuration files. It ensures that projects using next.config.ts or next.config.mts can be correctly recognized and deployed, streamlining the development workflow for TypeScript users and improving the overall robustness of the Next.js integration.

Highlights

  • Expanded Next.js Config File Support: The CONFIG_FILES array has been updated to include next.config.ts and next.config.mts, allowing the Firebase CLI to recognize and process these TypeScript-based Next.js configuration files.
  • Improved Build Process for TypeScript Configs: The ɵcodegenFunctionsDirectory function now correctly handles next.config.mts files, ensuring that they are bundled as ES modules (.mjs) during the build process, aligning with the behavior for next.config.mjs.
  • Enhanced Test Coverage for Config File Detection: New unit tests have been added for the whichNextConfigFile utility function, verifying its ability to accurately detect and prioritize various Next.js configuration file types, including the newly supported TypeScript variants.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/frameworks/next/constants.ts
    • Added 'next.config.ts' and 'next.config.mts' to the CONFIG_FILES array to recognize new Next.js configuration file types.
  • src/frameworks/next/index.ts
    • Modified ɵcodegenFunctionsDirectory to treat next.config.mts similarly to next.config.mjs, ensuring the generated output file is an ES module (.mjs) and explicitly setting the outfile for esbuild.
    • Ensured esbuildArgs.outfile is explicitly set for both .mjs and .js outputs based on the detected config file type.
  • src/frameworks/next/utils.spec.ts
    • Imported whichNextConfigFile for testing.
    • Added a new test suite for whichNextConfigFile to verify its functionality across all supported Next.js config file types (.js, .mjs, .ts, .mts), including scenarios where no config file exists and ensuring correct prioritization (e.g., next.config.js takes precedence).
Activity
  • The pull request was opened by leoortizz with a description outlining the changes and scenarios tested. No further human activity (comments, reviews, etc.) has been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for TypeScript-based Next.js configuration files (next.config.ts and next.config.mts). The changes are well-implemented across the codebase. The CONFIG_FILES constant is updated, the function ɵcodegenFunctionsDirectory is modified to correctly transpile TypeScript config files for the Cloud Functions environment, and new unit tests have been added to verify the config file detection logic. The changes look solid and improve the framework's flexibility.

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.

"firebase deploy --only hosting" doesnt pick up next.config.ts anymore

1 participant