@nx/next 16.8.0-beta.1 → 16.8.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/next",
3
- "version": "16.8.0-beta.1",
3
+ "version": "16.8.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Next.js plugin for Nx contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides:\n\n\n- Scaffolding for creating, building, serving, linting, and testing Next.js applications.\n\n- Integration with building, serving, and exporting a Next.js application.\n\n- Integration with React libraries within the workspace. \n\nWhen using Next.js in Nx, you get the out-of-the-box support for TypeScript, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
6
6
  "repository": {
@@ -35,17 +35,16 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/plugin-proposal-decorators": "^7.22.7",
38
- "@nrwl/next": "16.8.0-beta.1",
39
- "@nx/devkit": "16.8.0-beta.1",
40
- "@nx/js": "16.8.0-beta.1",
41
- "@nx/linter": "16.8.0-beta.1",
42
- "@nx/react": "16.8.0-beta.1",
43
- "@nx/web": "16.8.0-beta.1",
44
- "@nx/workspace": "16.8.0-beta.1",
38
+ "@nrwl/next": "16.8.0-beta.2",
39
+ "@nx/devkit": "16.8.0-beta.2",
40
+ "@nx/js": "16.8.0-beta.2",
41
+ "@nx/linter": "16.8.0-beta.2",
42
+ "@nx/react": "16.8.0-beta.2",
43
+ "@nx/web": "16.8.0-beta.2",
44
+ "@nx/workspace": "16.8.0-beta.2",
45
45
  "@svgr/webpack": "^8.0.1",
46
46
  "chalk": "^4.1.0",
47
47
  "copy-webpack-plugin": "^10.2.4",
48
- "dotenv": "~16.3.1",
49
48
  "fs-extra": "^11.1.0",
50
49
  "ignore": "^5.0.4",
51
50
  "semver": "7.5.3",
@@ -57,5 +56,5 @@
57
56
  "access": "public"
58
57
  },
59
58
  "type": "commonjs",
60
- "gitHead": "231a998e004c13e559c171ba6c164a9127886153"
59
+ "gitHead": "9bcc04742f9e1516d8c1ddbfb1907770c347876f"
61
60
  }
@@ -1,4 +1,3 @@
1
- import 'dotenv/config';
2
1
  import { ExecutorContext } from '@nx/devkit';
3
2
  import { NextBuildBuilderOptions } from '../../utils/types';
4
3
  export default function buildExecutor(options: NextBuildBuilderOptions, context: ExecutorContext): Promise<{
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- require("dotenv/config");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const js_1 = require("@nx/js");
7
6
  const path_1 = require("path");
@@ -1,4 +1,3 @@
1
- import 'dotenv/config';
2
1
  import { ExecutorContext } from '@nx/devkit';
3
2
  import { NextExportBuilderOptions } from '../../utils/types';
4
3
  /**
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- require("dotenv/config");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const export_1 = require("next/dist/export");
7
6
  const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
@@ -1,4 +1,3 @@
1
- import 'dotenv/config';
2
1
  import { ExecutorContext } from '@nx/devkit';
3
2
  import { NextServeBuilderOptions } from '../../utils/types';
4
3
  export default function serveExecutor(options: NextServeBuilderOptions, context: ExecutorContext): AsyncGenerator<{
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- require("dotenv/config");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const path_1 = require("path");
7
6
  function serveExecutor(options, context) {
@@ -1,4 +1,3 @@
1
- import 'dotenv/config';
2
1
  import { ExecutorContext } from '@nx/devkit';
3
2
  import { NextServeBuilderOptions } from '../../utils/types';
4
3
  export default function serveExecutor(options: NextServeBuilderOptions, context: ExecutorContext): AsyncGenerator<{
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- require("dotenv/config");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const path_1 = require("path");
7
6
  const child_process_1 = require("child_process");
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const linter_1 = require("@nx/linter");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const lint_1 = require("@nx/react/src/utils/lint");
8
+ const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
8
9
  function addLinting(host, options) {
9
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
11
  const lintTask = yield (0, linter_1.lintProjectGenerator)(host, {
@@ -18,46 +19,38 @@ function addLinting(host, options) {
18
19
  skipFormat: true,
19
20
  rootProject: options.rootProject,
20
21
  });
21
- if (options.linter === linter_1.Linter.EsLint) {
22
- (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.eslintrc.json'), (json) => {
23
- var _a, _b, _c;
24
- json = (0, lint_1.extendReactEslintJson)(json);
25
- // Turn off @next/next/no-html-link-for-pages since there is an issue with nextjs throwing linting errors
26
- // TODO(nicholas): remove after Vercel updates nextjs linter to only lint ["*.ts", "*.tsx", "*.js", "*.jsx"]
27
- json.ignorePatterns = [...json.ignorePatterns, '.next/**/*'];
28
- json.rules = Object.assign({ '@next/next/no-html-link-for-pages': 'off' }, json.rules);
29
- // Find the override that handles both TS and JS files.
30
- const commonOverride = (_a = json.overrides) === null || _a === void 0 ? void 0 : _a.find((o) => ['*.ts', '*.tsx', '*.js', '*.jsx'].every((ext) => o.files.includes(ext)));
31
- if (commonOverride) {
32
- // Only set parserOptions.project if it already exists (defined by options.setParserOptionsProject)
33
- if ((_b = commonOverride.parserOptions) === null || _b === void 0 ? void 0 : _b.project) {
34
- commonOverride.parserOptions.project = [
35
- `${options.appProjectRoot}/tsconfig(.*)?.json`,
36
- ];
37
- }
38
- // Configure custom pages directory for next rule
39
- if (commonOverride.rules) {
40
- commonOverride.rules = Object.assign(Object.assign({}, commonOverride.rules), { '@next/next/no-html-link-for-pages': [
41
- 'error',
42
- `${options.appProjectRoot}/pages`,
43
- ] });
44
- }
45
- }
46
- (_c = json.extends) !== null && _c !== void 0 ? _c : (json.extends = []);
47
- if (typeof json.extends === 'string') {
48
- json.extends = [json.extends];
49
- }
50
- // add next.js configuration
51
- json.extends.unshift(...['next', 'next/core-web-vitals']);
52
- // remove nx/react plugin, as it conflicts with the next.js one
53
- json.extends = json.extends.filter((name) => name !== 'plugin:@nx/react' && name !== 'plugin:@nrwl/nx/react');
54
- json.extends.unshift('plugin:@nx/react-typescript');
55
- if (!json.env) {
56
- json.env = {};
57
- }
58
- json.env.jest = true;
59
- return json;
60
- });
22
+ if (options.linter === linter_1.Linter.EsLint && (0, eslint_file_1.isEslintConfigSupported)(host)) {
23
+ (0, eslint_file_1.addExtendsToLintConfig)(host, options.appProjectRoot, [
24
+ 'plugin:@nx/react-typescript',
25
+ 'next',
26
+ 'next/core-web-vitals',
27
+ ]);
28
+ // Turn off @next/next/no-html-link-for-pages since there is an issue with nextjs throwing linting errors
29
+ // TODO(nicholas): remove after Vercel updates nextjs linter to only lint ["*.ts", "*.tsx", "*.js", "*.jsx"]
30
+ (0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
31
+ files: ['*.*'],
32
+ rules: {
33
+ '@next/next/no-html-link-for-pages': 'off',
34
+ },
35
+ }, { insertAtTheEnd: false });
36
+ (0, eslint_file_1.updateOverrideInLintConfig)(host, options.appProjectRoot, (o) => Array.isArray(o.files) &&
37
+ o.files.some((f) => f.match(/\*\.ts$/)) &&
38
+ o.files.some((f) => f.match(/\*\.tsx$/)) &&
39
+ o.files.some((f) => f.match(/\*\.js$/)) &&
40
+ o.files.some((f) => f.match(/\*\.jsx$/)), (o) => (Object.assign(Object.assign({}, o), { rules: Object.assign(Object.assign({}, o.rules), { '@next/next/no-html-link-for-pages': [
41
+ 'error',
42
+ `${options.appProjectRoot}/pages`,
43
+ ] }) })));
44
+ // add jest specific config
45
+ if (options.unitTestRunner === 'jest') {
46
+ (0, eslint_file_1.addOverrideToLintConfig)(host, options.appProjectRoot, {
47
+ files: ['*.spec.ts', '*.spec.tsx', '*.spec.js', '*.spec.jsx'],
48
+ env: {
49
+ jest: true,
50
+ },
51
+ });
52
+ }
53
+ (0, eslint_file_1.addIgnoresToLintConfig)(host, options.appProjectRoot, ['.next/**/*']);
61
54
  }
62
55
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
63
56
  return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
@@ -19,20 +19,8 @@ function normalizeOptions(host, options) {
19
19
  });
20
20
  options.rootProject = appProjectRoot === '.';
21
21
  options.projectNameAndRootFormat = projectNameAndRootFormat;
22
- let e2eProjectName = 'e2e';
23
- let e2eProjectRoot = 'e2e';
24
- if (!options.rootProject) {
25
- const projectNameAndRoot = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
26
- name: `${options.name}-e2e`,
27
- projectType: 'application',
28
- directory: options.directory,
29
- projectNameAndRootFormat: options.projectNameAndRootFormat,
30
- rootProject: options.rootProject,
31
- callingGenerator: '@nx/next:application',
32
- });
33
- e2eProjectName = projectNameAndRoot.projectName;
34
- e2eProjectRoot = projectNameAndRoot.projectRoot;
35
- }
22
+ const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
23
+ const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
36
24
  const name = (0, devkit_1.names)(options.name).fileName;
37
25
  const outputPath = (0, devkit_1.joinPathFragments)('dist', appProjectRoot, ...(options.rootProject ? [name] : []));
38
26
  const parsedTags = options.tags