Skip to content

Commit

Permalink
fix(nextjs): fix issues with migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Jun 27, 2024
1 parent 55ab7eb commit 820eae4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import {
addProjectConfiguration,
joinPathFragments,
readNxJson,
readProjectConfiguration,
updateNxJson,
updateProjectConfiguration,
writeJson,
type ExpandedPluginConfiguration,
joinPathFragments,
type ProjectConfiguration,
type ProjectGraph,
readNxJson,
readProjectConfiguration,
type Tree,
writeJson,
} from '@nx/devkit';
import { TempFs } from '@nx/devkit/internal-testing-utils';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { join } from 'node:path';
import { getRelativeProjectJsonSchemaPath } from 'nx/src/generators/utils/project-configuration';
import type { NextPluginOptions } from '../../plugins/plugin';
import { convertToInferred } from './convert-to-inferred';

let fs: TempFs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function convertToInferred(tree: Tree, options: Schema) {
executors: ['@nx/next:server'],
postTargetTransformer: servePosTargetTransformer(migrationLogs),
targetPluginOptionMapper: (targetName) => ({
startTargetName: targetName,
devTargetName: targetName,
}),
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@ function handlePropertiesFromTargetOptions(
delete options.watch;
}

if ('experimentalAppOnly' in options) {
options['experimental-app-only'] = options['experimentalAppOnly'];
if ('experimentalAppOnly' in options && options['experimentalAppOnly']) {
options['args'] ??= [];
options['args'].push('--experimental-app-only');
delete options.experimentalAppOnly;
}

if ('experimentalBuildMode' in options) {
options['experimental-build-mode'] = options['experimentalBuildMode'];
options['args'] ??= [];
options['args'].push('--experimental-build-mode');
delete options.experimentalBuildMode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ describe('UpdateNextConfig', () => {
with: "./environments/environment.prod.ts"
}
],
assets: [
{
input: "./assets",
output: "./public/assets",
glob: "**/*"
}
],
},
assets: [
{
input: "./assets",
output: "./public/assets",
glob: "**/*"
}
],
};
const plugins = [
// Add more Next.js plugins to this list if needed.
Expand Down Expand Up @@ -233,14 +233,14 @@ describe('UpdateNextConfig', () => {
// Set this to true if you would like to use SVGR
// See: https://github.com/gregberge/svgr
svgr: false,
assets: [
{
input: "./assets",
output: "./public/assets",
glob: "**/*"
}
],
},
assets: [
{
input: "./assets",
output: "./public/assets",
glob: "**/*"
}
],
};
const plugins = [
// Add more Next.js plugins to this list if needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function updateNextConfig(
};
});

nextConfigObject['properties'].push(
nxConfigObject['properties'].push(
createPropertyAssignment(
'assets',
createArrayLiteralExpression(assetsProperty)
Expand Down

0 comments on commit 820eae4

Please sign in to comment.