UNPKG

@nx/next

Version:

The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides: - Scaffolding for creating, building, serving, linting, and testing Next.js applications. - Integration wit

61 lines (60 loc) 4.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.COMPOSE_PLUGINS_DEPRECATION_MESSAGE = exports.WITHNX_DEPRECATION_MESSAGE = exports.NEXT_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.NEXT_BUILD_EXECUTOR_DEPRECATION_MESSAGE = void 0; exports.warnNextBuildExecutorDeprecation = warnNextBuildExecutorDeprecation; exports.warnNextServerExecutorDeprecation = warnNextServerExecutorDeprecation; exports.warnNextExecutorGenerating = warnNextExecutorGenerating; exports.warnWithNxDeprecation = warnWithNxDeprecation; exports.warnComposePluginsDeprecation = warnComposePluginsDeprecation; const devkit_1 = require("@nx/devkit"); // TODO(v24): Remove the @nx/next:build and @nx/next:server executors. The // inferred plugin (@nx/next/plugin) and the convert-to-inferred generator // stay supported. exports.NEXT_BUILD_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/next:build` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/next:convert-to-inferred` to migrate to the `@nx/next/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.'; exports.NEXT_SERVER_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/next:server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/next:convert-to-inferred` to migrate to the `@nx/next/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.'; function warnNextBuildExecutorDeprecation() { devkit_1.logger.warn(exports.NEXT_BUILD_EXECUTOR_DEPRECATION_MESSAGE); } function warnNextServerExecutorDeprecation() { devkit_1.logger.warn(exports.NEXT_SERVER_EXECUTOR_DEPRECATION_MESSAGE); } // Fired when the @nx/next:application generator is about to generate targets // that use the deprecated executors — i.e. when @nx/next/plugin isn't // registered in nx.json. Surfaces the deprecation at generation time rather // than only when the user later runs the generated targets. function warnNextExecutorGenerating() { devkit_1.logger.warn('Generating targets that use the deprecated `@nx/next:build` and `@nx/next:server` executors. These executors will be removed in Nx v24. Run `nx g @nx/next:convert-to-inferred` next to migrate these targets to the `@nx/next/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.'); } // TODO(v24): Remove the `withNx`/`composePlugins` config wrappers. Modern // workspaces resolve libraries via package manager workspaces and Next.js // transpiles workspace source automatically, so a plain `next.config.js` works. exports.WITHNX_DEPRECATION_MESSAGE = '[Nx] `withNx()` from `@nx/next` is deprecated and will be removed in Nx v24. ' + 'A plain `next.config.js` is now the recommended pattern; Next.js transpiles workspace libraries automatically. ' + 'See https://nx.dev/docs/technologies/react/next/Guides/next-config-setup for the migration recipe.'; exports.COMPOSE_PLUGINS_DEPRECATION_MESSAGE = '[Nx] `composePlugins()` from `@nx/next` is deprecated and will be removed in Nx v24. ' + 'Compose Next.js plugins directly in your `next.config.js` and remove the `@nx/next` import. ' + 'See https://nx.dev/docs/technologies/react/next/Guides/next-config-setup for the migration recipe.'; let warnedWithNx = false; function warnWithNxDeprecation() { if (warnedWithNx) return; warnedWithNx = true; devkit_1.logger.warn(exports.WITHNX_DEPRECATION_MESSAGE); } let warnedComposePlugins = false; // Only nudge during interactive Nx task execution: skip production server start // (PHASE_PRODUCTION_SERVER), internal graph-creation passes, and direct // (non-Nx) `next` invocations. `next/constants` is required lazily so the helper // stays loadable in contexts where Next is not present. function warnComposePluginsDeprecation(phase) { if (warnedComposePlugins) return; const { PHASE_PRODUCTION_SERVER } = require('next/constants'); if (phase === PHASE_PRODUCTION_SERVER || global.NX_GRAPH_CREATION || !process.env.NX_TASK_TARGET_TARGET) { return; } warnedComposePlugins = true; devkit_1.logger.warn(exports.COMPOSE_PLUGINS_DEPRECATION_MESSAGE); }