feat(nextjs): add support for typescript Next.js config file (#28709)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28572
This commit is contained in:
Nicholas Cunningham 2024-10-30 14:15:48 -06:00 committed by GitHub
parent 63b745e8c3
commit 51bed0e456
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 4 deletions

View File

@ -60,6 +60,7 @@ The `@nx/next` plugin will create tasks for any project that has a Next.js confi
- `next.config.js`
- `next.config.cjs`
- `next.config.mjs`
- `next.config.ts`
### View Inferred Tasks

View File

@ -60,6 +60,7 @@ The `@nx/next` plugin will create tasks for any project that has a Next.js confi
- `next.config.js`
- `next.config.cjs`
- `next.config.mjs`
- `next.config.ts`
### View Inferred Tasks

View File

@ -54,7 +54,7 @@ describe('addPlugin', () => {
},
};
createNodes = [
'**/next.config.{js,cjs,mjs}',
'**/next.config.{ts,js,cjs,mjs}',
(_, { targetName }) => [
[
'app1/next.config.js',
@ -300,7 +300,7 @@ describe('addPlugin', () => {
});
createNodes = [
'**/next.config.{js,cjs,mjs}',
'**/next.config.{ts,js,cjs,mjs}',
() => [
[
'app1/next.config.js',

View File

@ -155,7 +155,12 @@ export function findNextConfigPath(
);
}
const candidates = ['next.config.js', 'next.config.cjs', 'next.config.mjs'];
const candidates = [
'next.config.js',
'next.config.cjs',
'next.config.mjs',
'next.config.ts',
];
for (const candidate of candidates) {
if (existsSync(join(dirname, candidate))) return candidate;
}

View File

@ -29,7 +29,7 @@ export interface NextPluginOptions {
serveStaticTargetName?: string;
}
const nextConfigBlob = '**/next.config.{js,cjs,mjs}';
const nextConfigBlob = '**/next.config.{ts,js,cjs,mjs}';
function readTargetsCache(
cachePath: string