Skip to content

Commit 4c1fb37

Browse files
committed
fix(nx-dev): build nx-dev in-place to fix ai package resolution
## Current Behavior The default `@nx/next:build` for nx-dev outputs to `dist/nx-dev/nx-dev`, which breaks Node.js package resolution for the `ai` package at runtime since `node_modules` is at the workspace root. ## Expected Behavior Build in-place to `nx-dev/nx-dev` (matching the Netlify config) so `.next` stays close to `node_modules` and package resolution works. Also fixes missing `@nx/nx-dev-ui-icons` dependency in `ui-video-courses` introduced by #34669. ## Related Issue(s) Fixes DOC-418
1 parent b316ec1 commit 4c1fb37

File tree

10 files changed

+68
-58
lines changed

10 files changed

+68
-58
lines changed

nx-dev/nx-dev/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Generated by next-sitemap during build
2+
public/robots.txt
3+
public/sitemap*.xml

nx-dev/nx-dev/next-sitemap.config.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@ const path = require('path');
33
const siteUrl = process.env.NX_DEV_URL || 'https://nx.dev';
44
const noIndex = process.env.NEXT_PUBLIC_NO_INDEX === 'true';
55

6-
// On Netlify, the build output is in nx-dev/nx-dev/.next instead of dist/nx-dev/nx-dev/.next
7-
const isNetlify = process.env.NETLIFY === 'true';
8-
const buildOutputDir = isNetlify
9-
? path.resolve(__dirname, '.next')
10-
: path.resolve(__dirname, '../../dist/nx-dev/nx-dev/.next');
11-
const publicOutputDir = isNetlify
12-
? path.resolve(__dirname, 'public')
13-
: path.resolve(__dirname, '../../dist/nx-dev/nx-dev/public');
6+
const buildOutputDir = path.resolve(__dirname, '.next');
7+
const publicOutputDir = path.resolve(__dirname, 'public');
148

159
/**
1610
* @type {import('next-sitemap').IConfig}

nx-dev/nx-dev/package.json

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,63 @@
44
"type": "commonjs",
55
"private": true,
66
"dependencies": {
7-
"ai": "3.0.19",
8-
"@nx/nx-dev-data-access-documents": "workspace:*",
7+
"@docsearch/react": "3.9.0",
8+
"@grafana/faro-web-sdk": "1.19.0",
9+
"@headlessui/react": "2.2.4",
10+
"@heroicons/react": "2.2.0",
11+
"@markdoc/markdoc": "0.2.2",
12+
"@nx/graph": "1.0.4",
913
"@nx/nx-dev-data-access-courses": "workspace:*",
14+
"@nx/nx-dev-data-access-documents": "workspace:*",
15+
"@nx/nx-dev-feature-ai": "workspace:*",
16+
"@nx/nx-dev-feature-analytics": "workspace:*",
17+
"@nx/nx-dev-feature-feedback": "workspace:*",
18+
"@nx/nx-dev-feature-search": "workspace:*",
19+
"@nx/nx-dev-ui-animations": "workspace:*",
20+
"@nx/nx-dev-ui-blog": "workspace:*",
1021
"@nx/nx-dev-ui-common": "workspace:*",
1122
"@nx/nx-dev-ui-courses": "workspace:*",
23+
"@nx/nx-dev-ui-fence": "workspace:*",
1224
"@nx/nx-dev-ui-icons": "workspace:*",
13-
"@nx/nx-dev-util-ai": "workspace:*",
1425
"@nx/nx-dev-ui-markdoc": "workspace:*",
15-
"@nx/nx-dev-feature-analytics": "workspace:*",
26+
"@nx/nx-dev-ui-podcast": "workspace:*",
27+
"@nx/nx-dev-ui-pricing": "workspace:*",
1628
"@nx/nx-dev-ui-primitives": "workspace:*",
17-
"@nx/nx-dev-feature-feedback": "workspace:*",
18-
"@nx/nx-dev-ui-theme": "workspace:*",
19-
"@nx/nx-dev-feature-ai": "workspace:*",
20-
"@nx/nx-dev-ui-animations": "workspace:*",
21-
"@nx/nx-dev-feature-search": "workspace:*",
2229
"@nx/nx-dev-ui-references": "workspace:*",
23-
"@nx/nx-dev-ui-fence": "workspace:*",
24-
"@nx/nx-dev-ui-blog": "workspace:*",
2530
"@nx/nx-dev-ui-resources": "workspace:*",
26-
"@nx/nx-dev-ui-podcast": "workspace:*",
27-
"@nx/nx-dev-ui-pricing": "workspace:*",
28-
"@nx/nx-dev-ui-video-courses": "workspace:*"
31+
"@nx/nx-dev-ui-theme": "workspace:*",
32+
"@nx/nx-dev-ui-video-courses": "workspace:*",
33+
"@nx/nx-dev-util-ai": "workspace:*",
34+
"@tailwindcss/aspect-ratio": "0.4.2",
35+
"@tailwindcss/forms": "0.5.10",
36+
"@tailwindcss/typography": "0.5.13",
37+
"@yarnpkg/lockfile": "1.1.0",
38+
"@yarnpkg/parsers": "3.0.2",
39+
"ai": "3.0.19",
40+
"axios": "1.12.0",
41+
"classnames": "2.5.1",
42+
"cliui": "8.0.1",
43+
"enquirer": "2.3.6",
44+
"framer-motion": "11.18.2",
45+
"front-matter": "4.0.2",
46+
"ignore": "7.0.5",
47+
"next": "14.2.35",
48+
"next-seo": "5.15.0",
49+
"node-machine-id": "1.1.12",
50+
"npm-run-path": "4.0.1",
51+
"react": "18.3.1",
52+
"react-copy-to-clipboard": "5.1.0",
53+
"react-dom": "18.3.1",
54+
"react-syntax-highlighter": "15.6.1",
55+
"sharp": "0.33.5",
56+
"string-width": "4.2.3",
57+
"tailwind-merge": "2.6.0",
58+
"tailwindcss": "3.4.4",
59+
"tslib": "2.8.1",
60+
"typescript": "5.9.2"
61+
},
62+
"packageManager": "pnpm@10.28.2",
63+
"scripts": {
64+
"start": "next start"
2965
}
3066
}

nx-dev/nx-dev/project.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020
"^production",
2121
{ "env": "NEXT_PUBLIC_ASTRO_URL" }
2222
],
23-
"outputs": ["{workspaceRoot}/dist/nx-dev/nx-dev"],
24-
"configurations": {
25-
"netlify": {
26-
"outputs": ["{workspaceRoot}/nx-dev/nx-dev/.next"]
27-
}
28-
}
23+
"outputs": ["{workspaceRoot}/nx-dev/nx-dev/.next"]
2924
},
3025
"check-links": {
3126
"cache": true,
@@ -36,7 +31,7 @@
3631
},
3732
"inputs": [
3833
"{workspaceRoot}/docs/**/*",
39-
"{workspaceRoot}/dist/nx-dev/nx-dev/public/sitemap*.xml",
34+
"{workspaceRoot}/nx-dev/nx-dev/public/sitemap*.xml",
4035
"{workspaceRoot}/astro-docs/dist/sitemap*.xml",
4136
"{workspaceRoot}/scripts/tsconfig.scripts.json",
4237
"{workspaceRoot}/scripts/documentation/internal-link-checker.ts"
@@ -54,7 +49,7 @@
5449
{ "env": "NX_DEV_URL" },
5550
{ "env": "NEXT_PUBLIC_NO_INDEX" }
5651
],
57-
"outputs": ["{workspaceRoot}/dist/nx-dev/nx-dev/public"],
52+
"outputs": ["{workspaceRoot}/nx-dev/nx-dev/public"],
5853
"options": {
5954
"command": "pnpm next-sitemap --config ./nx-dev/nx-dev/next-sitemap.config.js && node ./nx-dev/nx-dev/scripts/patch-sitemap-index.mjs"
6055
}
@@ -79,16 +74,10 @@
7974
"outputs": ["{options.outputPath}"],
8075
"options": {
8176
"root": "nx-dev/nx-dev",
82-
"outputPath": "dist/nx-dev/nx-dev"
77+
"outputPath": "nx-dev/nx-dev"
8378
},
8479
"configurations": {
85-
"development": {
86-
"outputPath": "nx-dev/nx-dev"
87-
},
88-
"production": {},
89-
"netlify": {
90-
"outputPath": "nx-dev/nx-dev"
91-
}
80+
"production": {}
9281
}
9382
},
9483
"copy-docs": {
@@ -124,13 +113,8 @@
124113
"production": {
125114
"buildTarget": "nx-dev:build-base:production",
126115
"dev": false
127-
},
128-
"development": {
129-
"buildTarget": "nx-dev:build-base:development",
130-
"dev": true
131116
}
132-
},
133-
"defaultConfiguration": "development"
117+
}
134118
},
135119
"deploy-build": {
136120
"executor": "nx:run-commands",
@@ -152,7 +136,7 @@
152136
"netlify": {
153137
"commands": [
154138
{
155-
"command": "nx run nx-dev:build-base:netlify && cp nx-dev/nx-dev/_redirects nx-dev/nx-dev/.next/_redirects && nx run nx-dev:sitemap",
139+
"command": "nx run nx-dev:build-base && cp nx-dev/nx-dev/_redirects nx-dev/nx-dev/.next/_redirects && nx run nx-dev:sitemap",
156140
"description": "NextJs build for Netlify"
157141
}
158142
]

nx-dev/nx-dev/scripts/patch-sitemap-index.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import { readFileSync, writeFileSync } from 'fs';
66
import { resolve } from 'path';
77

88
const siteUrl = process.env.NX_DEV_URL || 'https://nx.dev';
9-
const isNetlify = process.env.NETLIFY === 'true';
10-
const outDir = isNetlify
11-
? resolve(import.meta.dirname, '../public')
12-
: resolve(import.meta.dirname, '../../../dist/nx-dev/nx-dev/public');
9+
const outDir = resolve(import.meta.dirname, '../public');
1310

1411
const sitemapPath = resolve(outDir, 'sitemap.xml');
1512

nx-dev/nx-dev/tsconfig.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"lib": ["dom", "dom.iterable", "es2021", "esnext"],
5-
"outDir": "../../dist/nx-dev/nx-dev",
6-
"tsBuildInfoFile": "../../dist/nx-dev/nx-dev/tsconfig.tsbuildinfo",
5+
"outDir": "./dist",
6+
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo",
77
"jsx": "preserve",
88
"allowJs": true,
99
"esModuleInterop": true,
@@ -34,9 +34,8 @@
3434
"**/*.tsx",
3535
"next-env.d.ts",
3636
".next/types/**/*.ts",
37-
"../../dist/nx-dev/nx-dev/.next/types/**/*.ts",
3837
"public/documentation/**/*.json",
39-
"dist/nx-dev/nx-dev/.next/types/**/*.ts"
38+
"../../nx-dev/nx-dev/.next/types/**/*.ts"
4039
],
4140
"references": [
4241
{

nx-dev/ui-video-courses/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"types": "./src/index.ts",
88
"dependencies": {
99
"@nx/nx-dev-data-access-courses": "workspace:*",
10+
"@nx/nx-dev-ui-icons": "workspace:*",
1011
"@nx/nx-dev-ui-primitives": "workspace:*",
1112
"@nx/nx-dev-ui-common": "workspace:*"
1213
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
"@xstate/inspect": "0.7.0",
173173
"@xstate/react": "3.0.1",
174174
"@zkochan/js-yaml": "catalog:",
175-
"ai": "3.0.19",
176175
"ajv": "^8.12.0",
177176
"angular-eslint": "catalog:eslint",
178177
"autoprefixer": "10.4.13",

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/documentation/internal-link-checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const documentLinks = extractAllLinks(join(workspaceRoot, 'docs'));
145145

146146
// Read Next.js sitemap URLs
147147
const nextjsSitemapUrls = readSiteMapIndex(
148-
join(workspaceRoot, 'dist/nx-dev/nx-dev/public/'),
148+
join(workspaceRoot, 'nx-dev/nx-dev/public/'),
149149
'sitemap.xml'
150150
).flatMap((path) => readSiteMapLinks(path));
151151
console.log(nextjsSitemapUrls.length + ' URLs found in Next.js sitemap');

0 commit comments

Comments
 (0)