diff --git a/docs/generated/packages/next/executors/build.json b/docs/generated/packages/next/executors/build.json index d55195b462..881fccb0c7 100644 --- a/docs/generated/packages/next/executors/build.json +++ b/docs/generated/packages/next/executors/build.json @@ -53,6 +53,11 @@ "type": "boolean", "description": "Include `devDependencies` in the generated package.json file. By default only production `dependencies` are included.", "default": false + }, + "generateLockfile": { + "type": "boolean", + "description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.", + "default": false } }, "required": ["root", "outputPath"], diff --git a/e2e/next/src/next.test.ts b/e2e/next/src/next.test.ts index ef5edd9a68..db4e18ca0c 100644 --- a/e2e/next/src/next.test.ts +++ b/e2e/next/src/next.test.ts @@ -12,9 +12,9 @@ import { updateFile, updateProjectConfig, } from '@nrwl/e2e/utils'; -import { checkApp } from './utils'; import { stringUtils } from '@nrwl/workspace'; import * as http from 'http'; +import { checkApp } from './utils'; describe('Next.js Applications', () => { let proj: string; diff --git a/e2e/next/src/utils.ts b/e2e/next/src/utils.ts index 0cfe480fae..2a419b95de 100644 --- a/e2e/next/src/utils.ts +++ b/e2e/next/src/utils.ts @@ -1,14 +1,11 @@ import { checkFilesExist, - detectPackageManager, killPorts, readJson, runCLI, runCLIAsync, runCypressTests, - tmpProjPath, } from '../../utils'; -import { getLockFileName } from '../../../packages/nx/src/lock-file/lock-file'; export async function checkApp( appName: string, @@ -28,12 +25,6 @@ export async function checkApp( expect(packageJson.dependencies['react-dom']).toBeDefined(); expect(packageJson.dependencies.next).toBeDefined(); - checkFilesExist( - `dist/apps/${appName}/${getLockFileName( - detectPackageManager(tmpProjPath()) - )}` - ); - if (opts.checkLint) { const lintResults = runCLI(`lint ${appName}`); expect(lintResults).toContain('All files pass linting.'); diff --git a/packages/next/src/executors/build/build.impl.ts b/packages/next/src/executors/build/build.impl.ts index 39534f8d45..0126696eb0 100644 --- a/packages/next/src/executors/build/build.impl.ts +++ b/packages/next/src/executors/build/build.impl.ts @@ -90,11 +90,14 @@ export default async function buildExecutor( } ); updatePackageJson(builtPackageJson, context); - const lockFile = createLockFile(builtPackageJson); writeJsonFile(`${options.outputPath}/package.json`, builtPackageJson); - writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, { - encoding: 'utf-8', - }); + + if (options.generateLockfile) { + const lockFile = createLockFile(builtPackageJson); + writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, { + encoding: 'utf-8', + }); + } createNextConfigFile(options, context); diff --git a/packages/next/src/executors/build/schema.json b/packages/next/src/executors/build/schema.json index 765b4ea1a7..6d615af155 100644 --- a/packages/next/src/executors/build/schema.json +++ b/packages/next/src/executors/build/schema.json @@ -53,6 +53,11 @@ "type": "boolean", "description": "Include `devDependencies` in the generated package.json file. By default only production `dependencies` are included.", "default": false + }, + "generateLockfile": { + "type": "boolean", + "description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.", + "default": false } }, "required": ["root", "outputPath"] diff --git a/packages/next/src/utils/types.ts b/packages/next/src/utils/types.ts index dd574df6a8..350fd620ca 100644 --- a/packages/next/src/utils/types.ts +++ b/packages/next/src/utils/types.ts @@ -37,6 +37,7 @@ export interface NextBuildBuilderOptions { nextConfig?: string; buildLibsFromSource?: boolean; includeDevDependenciesInPackageJson?: boolean; + generateLockfile?: boolean; watch?: boolean; }