@nx/next 0.0.0-pr-3-5e7ccde → 0.0.0-pr-29464-c4b160c
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 +7 -7
- package/src/generators/application/application.js +5 -0
- package/src/generators/custom-server/custom-server.js +15 -8
- package/src/generators/custom-server/files/server/main.ts__tmpl__ +1 -1
- package/src/utils/add-swc-to-custom-server.d.ts +1 -1
- package/src/utils/add-swc-to-custom-server.js +8 -12
- package/src/executors/build/lib/test-fixtures/ensure-exts/baz.json +0 -1
- package/src/executors/build/schema.json +0 -89
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/next",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29464-c4b160c",
|
|
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, Playwright, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"next": ">=14.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "0.0.0-pr-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-29464-c4b160c",
|
|
39
39
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
40
40
|
"@svgr/webpack": "^8.1.0",
|
|
41
41
|
"copy-webpack-plugin": "^10.2.4",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"semver": "^7.5.3",
|
|
45
45
|
"tslib": "^2.3.0",
|
|
46
46
|
"webpack-merge": "^5.8.0",
|
|
47
|
-
"@nx/js": "0.0.0-pr-
|
|
48
|
-
"@nx/eslint": "0.0.0-pr-
|
|
49
|
-
"@nx/react": "0.0.0-pr-
|
|
50
|
-
"@nx/web": "0.0.0-pr-
|
|
51
|
-
"@nx/webpack": "0.0.0-pr-
|
|
47
|
+
"@nx/js": "0.0.0-pr-29464-c4b160c",
|
|
48
|
+
"@nx/eslint": "0.0.0-pr-29464-c4b160c",
|
|
49
|
+
"@nx/react": "0.0.0-pr-29464-c4b160c",
|
|
50
|
+
"@nx/web": "0.0.0-pr-29464-c4b160c",
|
|
51
|
+
"@nx/webpack": "0.0.0-pr-29464-c4b160c",
|
|
52
52
|
"@phenomnomnominal/tsquery": "~5.0.1"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
@@ -24,6 +24,7 @@ const versions_2 = require("../../utils/versions");
|
|
|
24
24
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
25
25
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
26
26
|
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
27
|
+
const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server");
|
|
27
28
|
async function applicationGenerator(host, schema) {
|
|
28
29
|
return await applicationGeneratorInternal(host, {
|
|
29
30
|
addPlugin: false,
|
|
@@ -70,6 +71,10 @@ async function applicationGeneratorInternal(host, schema) {
|
|
|
70
71
|
(0, update_jest_config_1.updateJestConfig)(host, options);
|
|
71
72
|
(0, update_cypress_tsconfig_1.updateCypressTsConfig)(host, options);
|
|
72
73
|
(0, set_defaults_1.setDefaults)(host, options);
|
|
74
|
+
if (options.swc) {
|
|
75
|
+
const swcTask = (0, add_swc_to_custom_server_1.configureForSwc)(host, options.appProjectRoot);
|
|
76
|
+
tasks.push(swcTask);
|
|
77
|
+
}
|
|
73
78
|
if (options.customServer) {
|
|
74
79
|
await (0, custom_server_1.customServerGenerator)(host, {
|
|
75
80
|
project: options.projectName,
|
|
@@ -8,20 +8,17 @@ const add_swc_to_custom_server_1 = require("../../utils/add-swc-to-custom-server
|
|
|
8
8
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
9
9
|
async function customServerGenerator(host, options) {
|
|
10
10
|
const project = (0, devkit_2.readProjectConfiguration)(host, options.project);
|
|
11
|
+
const swcServerName = '.server.swcrc';
|
|
11
12
|
const nxJson = (0, devkit_2.readNxJson)(host);
|
|
12
13
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
13
14
|
? p === '@nx/next/plugin'
|
|
14
15
|
: p.plugin === '@nx/next/plugin');
|
|
15
|
-
if (project.targets?.build?.executor !== '@nx/next:build' &&
|
|
16
|
-
project.targets?.build?.executor !== '@nrwl/next:build' &&
|
|
17
|
-
!hasPlugin) {
|
|
16
|
+
if (project.targets?.build?.executor !== '@nx/next:build' && !hasPlugin) {
|
|
18
17
|
devkit_2.logger.error(`Project ${options.project} is not a Next.js project. Did you generate it with "nx g @nx/next:app"?`);
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
22
|
-
const outputPath =
|
|
23
|
-
? `dist/${project.root}`
|
|
24
|
-
: project.targets?.build?.options?.outputPath;
|
|
21
|
+
const outputPath = `dist/${project.root}-server`;
|
|
25
22
|
const root = project.root;
|
|
26
23
|
if ((!root ||
|
|
27
24
|
!outputPath ||
|
|
@@ -38,7 +35,9 @@ async function customServerGenerator(host, options) {
|
|
|
38
35
|
}
|
|
39
36
|
// In Nx 18 next artifacts are inside the project root .next/ & dist/ (for custom server)
|
|
40
37
|
// So we need ensure the mapping is correct from dist to the project root
|
|
41
|
-
const projectPathFromDist =
|
|
38
|
+
const projectPathFromDist = hasPlugin
|
|
39
|
+
? `../../${(0, devkit_2.offsetFromRoot)(project.root)}${project.root}`
|
|
40
|
+
: `${(0, devkit_2.offsetFromRoot)(`dist/${project.root}`)}${project.root}`;
|
|
42
41
|
const offset = (0, devkit_2.offsetFromRoot)(project.root);
|
|
43
42
|
const isTsSolution = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
44
43
|
(0, devkit_2.generateFiles)(host, (0, path_1.join)(__dirname, 'files'), project.root, {
|
|
@@ -72,6 +71,9 @@ async function customServerGenerator(host, options) {
|
|
|
72
71
|
tsConfig: `${root}/tsconfig.server.json`,
|
|
73
72
|
clean: false,
|
|
74
73
|
assets: [],
|
|
74
|
+
...(options.compiler === 'tsc'
|
|
75
|
+
? {}
|
|
76
|
+
: { swcrc: `${root}/${swcServerName}` }),
|
|
75
77
|
},
|
|
76
78
|
configurations: {
|
|
77
79
|
development: {},
|
|
@@ -105,6 +107,11 @@ async function customServerGenerator(host, options) {
|
|
|
105
107
|
return json;
|
|
106
108
|
});
|
|
107
109
|
if (options.compiler === 'swc') {
|
|
108
|
-
|
|
110
|
+
// Update app swc to exlude server files
|
|
111
|
+
(0, devkit_2.updateJson)(host, (0, path_1.join)(project.root, '.swcrc'), (json) => {
|
|
112
|
+
json.exclude = [...(json.exclude ?? []), 'server/**'];
|
|
113
|
+
return json;
|
|
114
|
+
});
|
|
115
|
+
return (0, add_swc_to_custom_server_1.configureForSwc)(host, project.root, swcServerName, ['src/**/*']);
|
|
109
116
|
}
|
|
110
117
|
}
|
|
@@ -15,8 +15,8 @@ import next from 'next';
|
|
|
15
15
|
// - The fallback `__dirname` is for production builds.
|
|
16
16
|
// - Feel free to change this to suit your needs.
|
|
17
17
|
|
|
18
|
-
const dir = process.env.NX_NEXT_DIR || <%- hasPlugin ? `path.join(__dirname, '${projectPathFromDist}')` : `path.join(__dirname, '..')`; %>
|
|
19
18
|
const dev = process.env.NODE_ENV === 'development';
|
|
19
|
+
const dir = process.env.NX_NEXT_DIR || <%- hasPlugin ? `path.join(__dirname, '${projectPathFromDist}')` : `path.join(__dirname, dev ? '..' : '', '${projectPathFromDist}')`; %>
|
|
20
20
|
|
|
21
21
|
// HTTP Server options:
|
|
22
22
|
// - Feel free to change this to suit your needs.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function configureForSwc(tree: Tree, projectRoot: string): () => void;
|
|
2
|
+
export declare function configureForSwc(tree: Tree, projectRoot: string, swcConfigName?: string, additonalExludes?: string[]): () => void;
|
|
@@ -4,28 +4,24 @@ exports.configureForSwc = configureForSwc;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("@nx/js/src/utils/versions");
|
|
6
6
|
const add_swc_config_1 = require("@nx/js/src/utils/swc/add-swc-config");
|
|
7
|
-
function configureForSwc(tree, projectRoot) {
|
|
8
|
-
const swcConfigPath = (0, devkit_1.joinPathFragments)(projectRoot,
|
|
7
|
+
function configureForSwc(tree, projectRoot, swcConfigName = '.swcrc', additonalExludes = []) {
|
|
8
|
+
const swcConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, swcConfigName);
|
|
9
9
|
const rootPackageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
10
10
|
const hasSwcDepedency = rootPackageJson.dependencies?.['@swc/core'] ||
|
|
11
11
|
rootPackageJson.devDependencies?.['@swc/core'];
|
|
12
12
|
const hasSwcCliDependency = rootPackageJson.dependencies?.['@swc/cli'] ||
|
|
13
13
|
rootPackageJson.devDependencies?.['@swc/cli'];
|
|
14
14
|
if (!tree.exists(swcConfigPath)) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
...json,
|
|
21
|
-
exclude: [...json.exclude, '.*.d.ts$'],
|
|
22
|
-
};
|
|
23
|
-
});
|
|
15
|
+
// We need to create a swc config file specific for custom server
|
|
16
|
+
(0, add_swc_config_1.addSwcConfig)(tree, projectRoot, 'commonjs', false, swcConfigName, [
|
|
17
|
+
...additonalExludes,
|
|
18
|
+
'.*.d.ts$',
|
|
19
|
+
]);
|
|
24
20
|
}
|
|
25
21
|
if (!hasSwcDepedency || !hasSwcCliDependency) {
|
|
26
22
|
addSwcDependencies(tree);
|
|
27
|
-
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
28
23
|
}
|
|
24
|
+
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
29
25
|
}
|
|
30
26
|
function addSwcDependencies(tree) {
|
|
31
27
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 2,
|
|
3
|
-
"outputCapture": "pipe",
|
|
4
|
-
"$schema": "https://json-schema.org/schema",
|
|
5
|
-
"cli": "nx",
|
|
6
|
-
"title": "Next Build",
|
|
7
|
-
"description": "Build a Next.js app.",
|
|
8
|
-
"type": "object",
|
|
9
|
-
"properties": {
|
|
10
|
-
"outputPath": {
|
|
11
|
-
"type": "string",
|
|
12
|
-
"description": "The output path of the generated files.",
|
|
13
|
-
"x-completion-type": "directory",
|
|
14
|
-
"x-priority": "important"
|
|
15
|
-
},
|
|
16
|
-
"fileReplacements": {
|
|
17
|
-
"description": "Replace files with other files in the build.",
|
|
18
|
-
"type": "array",
|
|
19
|
-
"items": {
|
|
20
|
-
"type": "object",
|
|
21
|
-
"properties": {
|
|
22
|
-
"replace": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "The file to be replaced.",
|
|
25
|
-
"x-completion-type": "file"
|
|
26
|
-
},
|
|
27
|
-
"with": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"description": "The file to replace with.",
|
|
30
|
-
"x-completion-type": "file"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"additionalProperties": false,
|
|
34
|
-
"required": ["replace", "with"]
|
|
35
|
-
},
|
|
36
|
-
"default": []
|
|
37
|
-
},
|
|
38
|
-
"nextConfig": {
|
|
39
|
-
"description": "Path (relative to workspace root) to a function which takes phase, config, and builder options, and returns the resulting config. This is an advanced option and should not be used with a normal Next.js config file (i.e. `next.config.js`).",
|
|
40
|
-
"type": "string",
|
|
41
|
-
"x-completion-type": "file",
|
|
42
|
-
"x-completion-glob": "next?(*).js",
|
|
43
|
-
"x-priority": "important"
|
|
44
|
-
},
|
|
45
|
-
"buildLibsFromSource": {
|
|
46
|
-
"type": "boolean",
|
|
47
|
-
"description": "Read buildable libraries from source instead of building them separately.",
|
|
48
|
-
"default": true
|
|
49
|
-
},
|
|
50
|
-
"includeDevDependenciesInPackageJson": {
|
|
51
|
-
"type": "boolean",
|
|
52
|
-
"description": "Include `devDependencies` in the generated package.json file. By default only production `dependencies` are included.",
|
|
53
|
-
"default": false
|
|
54
|
-
},
|
|
55
|
-
"generateLockfile": {
|
|
56
|
-
"type": "boolean",
|
|
57
|
-
"description": "Generate a lockfile (e.g. package-lock.json) that matches the workspace lockfile to ensure package versions match.",
|
|
58
|
-
"default": false,
|
|
59
|
-
"x-priority": "internal"
|
|
60
|
-
},
|
|
61
|
-
"skipOverrides": {
|
|
62
|
-
"type": "boolean",
|
|
63
|
-
"description": "Do not add a `overrides` and `resolutions` entries to the generated package.json file. Only works in conjunction with `generatePackageJson` option."
|
|
64
|
-
},
|
|
65
|
-
"skipPackageManager": {
|
|
66
|
-
"type": "boolean",
|
|
67
|
-
"description": "Do not add a `packageManager` entry to the generated package.json file."
|
|
68
|
-
},
|
|
69
|
-
"debug": {
|
|
70
|
-
"type": "boolean",
|
|
71
|
-
"description": "Enable Next.js debug build logging"
|
|
72
|
-
},
|
|
73
|
-
"profile": {
|
|
74
|
-
"type": "boolean",
|
|
75
|
-
"description": "Used to enable React Production Profiling"
|
|
76
|
-
},
|
|
77
|
-
"experimentalAppOnly": {
|
|
78
|
-
"type": "boolean",
|
|
79
|
-
"description": "Only build 'app' routes"
|
|
80
|
-
},
|
|
81
|
-
"experimentalBuildMode": {
|
|
82
|
-
"type": "string",
|
|
83
|
-
"description": "Change the build mode.",
|
|
84
|
-
"enum": ["compile", "generate"]
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"required": ["outputPath"],
|
|
88
|
-
"examplesFile": "../../../docs/build-next-executor-examples.md"
|
|
89
|
-
}
|