next 16.2.11 → 16.2.12
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/dist/.build-commit +1 -1
- package/dist/bin/next +2 -2
- package/dist/build/index.js +3 -3
- package/dist/build/load-jsconfig.js +40 -20
- package/dist/build/load-jsconfig.js.map +1 -1
- package/dist/build/next-config-ts/transpile-config.js +3 -114
- package/dist/build/next-config-ts/transpile-config.js.map +1 -1
- package/dist/build/swc/index.js +1 -1
- package/dist/build/turbopack-analyze/index.js +1 -1
- package/dist/build/turbopack-build/impl.js +1 -1
- package/dist/build/type-check.js +20 -13
- package/dist/build/type-check.js.map +1 -1
- package/dist/build/webpack-config.js +3 -3
- package/dist/bundle-analyzer/404.html +2 -2
- package/dist/bundle-analyzer/__next.__PAGE__.txt +1 -1
- package/dist/bundle-analyzer/__next._full.txt +1 -1
- package/dist/bundle-analyzer/__next._head.txt +1 -1
- package/dist/bundle-analyzer/__next._index.txt +1 -1
- package/dist/bundle-analyzer/__next._tree.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._full.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._head.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._index.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._not-found.txt +1 -1
- package/dist/bundle-analyzer/_not-found/__next._tree.txt +1 -1
- package/dist/bundle-analyzer/_not-found.html +2 -2
- package/dist/bundle-analyzer/_not-found.txt +1 -1
- package/dist/bundle-analyzer/index.html +2 -2
- package/dist/bundle-analyzer/index.txt +1 -1
- package/dist/cli/next-test.js +2 -1
- package/dist/cli/next-test.js.map +1 -1
- package/dist/cli/next-typegen.js +2 -1
- package/dist/cli/next-typegen.js.map +1 -1
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
- package/dist/docs/01-app/01-getting-started/01-installation.md +33 -0
- package/dist/docs/01-app/01-getting-started/02-project-structure.md +1 -1
- package/dist/docs/01-app/01-getting-started/06-fetching-data.md +1 -1
- package/dist/docs/01-app/01-getting-started/09-revalidating.md +1 -1
- package/dist/docs/01-app/02-guides/authentication.md +18 -10
- package/dist/docs/01-app/02-guides/backend-for-frontend.md +1 -1
- package/dist/docs/01-app/02-guides/debugging.md +2 -2
- package/dist/docs/01-app/02-guides/migrating/app-router-migration.md +18 -14
- package/dist/docs/01-app/02-guides/single-page-applications.md +1 -1
- package/dist/docs/01-app/02-guides/static-exports.md +2 -0
- package/dist/docs/01-app/03-api-reference/02-components/form.md +1 -1
- package/dist/docs/01-app/03-api-reference/03-file-conventions/error.md +2 -0
- package/dist/docs/01-app/03-api-reference/03-file-conventions/not-found.md +3 -1
- package/dist/docs/01-app/03-api-reference/04-functions/redirect.md +1 -0
- package/dist/docs/01-app/03-api-reference/04-functions/refresh.md +4 -1
- package/dist/docs/01-app/03-api-reference/04-functions/revalidatePath.md +3 -0
- package/dist/docs/01-app/03-api-reference/04-functions/revalidateTag.md +3 -0
- package/dist/docs/01-app/03-api-reference/04-functions/unstable_cache.md +5 -5
- package/dist/docs/01-app/03-api-reference/04-functions/use-search-params.md +1 -1
- package/dist/docs/01-app/03-api-reference/05-config/01-next-config-js/headers.md +11 -11
- package/dist/docs/01-app/03-api-reference/05-config/01-next-config-js/redirects.md +10 -10
- package/dist/docs/01-app/03-api-reference/05-config/01-next-config-js/rewrites.md +16 -16
- package/dist/docs/01-app/03-api-reference/05-config/01-next-config-js/serverActions.md +4 -1
- package/dist/docs/01-app/03-api-reference/05-config/01-next-config-js/useTypeScriptCli.md +62 -0
- package/dist/docs/01-app/03-api-reference/05-config/02-typescript.md +55 -1
- package/dist/docs/01-app/03-api-reference/07-adapters/05-routing-with-next-routing.md +0 -3
- package/dist/docs/02-pages/02-guides/forms.md +6 -6
- package/dist/docs/02-pages/03-building-your-application/01-routing/08-custom-error.md +2 -0
- package/dist/docs/02-pages/04-api-reference/04-config/01-next-config-js/useTypeScriptCli.md +8 -0
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/load-jsconfig.js +40 -20
- package/dist/esm/build/load-jsconfig.js.map +1 -1
- package/dist/esm/build/next-config-ts/transpile-config.js +3 -73
- package/dist/esm/build/next-config-ts/transpile-config.js.map +1 -1
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/turbopack-analyze/index.js +1 -1
- package/dist/esm/build/turbopack-build/impl.js +1 -1
- package/dist/esm/build/type-check.js +20 -13
- package/dist/esm/build/type-check.js.map +1 -1
- package/dist/esm/build/webpack-config.js +3 -3
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/lib/has-necessary-dependencies.js.map +1 -1
- package/dist/esm/lib/install-dependencies.js +1 -1
- package/dist/esm/lib/install-dependencies.js.map +1 -1
- package/dist/esm/lib/patch-incorrect-lockfile.js +3 -3
- package/dist/esm/lib/typescript/loadTsConfig.js +129 -0
- package/dist/esm/lib/typescript/loadTsConfig.js.map +1 -0
- package/dist/esm/lib/typescript/missingDependencyError.js +1 -1
- package/dist/esm/lib/typescript/missingDependencyError.js.map +1 -1
- package/dist/esm/lib/typescript/runTypeCheck.js.map +1 -1
- package/dist/esm/lib/typescript/runTypeCheckCli.js +38 -0
- package/dist/esm/lib/typescript/runTypeCheckCli.js.map +1 -0
- package/dist/esm/lib/typescript/runTypeScriptCli.js +217 -0
- package/dist/esm/lib/typescript/runTypeScriptCli.js.map +1 -0
- package/dist/esm/lib/verify-typescript-setup.js +87 -52
- package/dist/esm/lib/verify-typescript-setup.js.map +1 -1
- package/dist/esm/server/config-schema.js +1 -0
- package/dist/esm/server/config-schema.js.map +1 -1
- package/dist/esm/server/config-shared.js +1 -0
- package/dist/esm/server/config-shared.js.map +1 -1
- package/dist/esm/server/config.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +2 -2
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/router-utils/setup-dev-bundler.js +2 -1
- package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/lib/has-necessary-dependencies.d.ts +2 -0
- package/dist/lib/has-necessary-dependencies.js.map +1 -1
- package/dist/lib/install-dependencies.js +1 -1
- package/dist/lib/install-dependencies.js.map +1 -1
- package/dist/lib/patch-incorrect-lockfile.js +3 -3
- package/dist/lib/typescript/loadTsConfig.d.ts +13 -0
- package/dist/lib/typescript/loadTsConfig.js +181 -0
- package/dist/lib/typescript/loadTsConfig.js.map +1 -0
- package/dist/lib/typescript/missingDependencyError.js +1 -1
- package/dist/lib/typescript/missingDependencyError.js.map +1 -1
- package/dist/lib/typescript/runTypeCheck.d.ts +2 -2
- package/dist/lib/typescript/runTypeCheck.js.map +1 -1
- package/dist/lib/typescript/runTypeCheckCli.d.ts +12 -0
- package/dist/lib/typescript/runTypeCheckCli.js +53 -0
- package/dist/lib/typescript/runTypeCheckCli.js.map +1 -0
- package/dist/lib/typescript/runTypeScriptCli.d.ts +38 -0
- package/dist/lib/typescript/runTypeScriptCli.js +256 -0
- package/dist/lib/typescript/runTypeScriptCli.js.map +1 -0
- package/dist/lib/verify-typescript-setup.d.ts +16 -1
- package/dist/lib/verify-typescript-setup.js +97 -56
- package/dist/lib/verify-typescript-setup.js.map +1 -1
- package/dist/server/config-schema.d.ts +1 -0
- package/dist/server/config-schema.js +1 -0
- package/dist/server/config-schema.js.map +1 -1
- package/dist/server/config-shared.d.ts +6 -0
- package/dist/server/config-shared.js +1 -0
- package/dist/server/config-shared.js.map +1 -1
- package/dist/server/config.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +2 -2
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/router-utils/setup-dev-bundler.js +2 -1
- package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/build.d.ts +1 -0
- package/dist/telemetry/events/build.js.map +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/swc-load-failure.js +1 -1
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +10 -10
- /package/dist/bundle-analyzer/_next/static/{yuLxudwpXbv0jKSL-s0ZM → xR78HbVQBty3GRl-Ydf7i}/_buildManifest.js +0 -0
- /package/dist/bundle-analyzer/_next/static/{yuLxudwpXbv0jKSL-s0ZM → xR78HbVQBty3GRl-Ydf7i}/_clientMiddlewareManifest.json +0 -0
- /package/dist/bundle-analyzer/_next/static/{yuLxudwpXbv0jKSL-s0ZM → xR78HbVQBty3GRl-Ydf7i}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "loadTsConfigOptions", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return loadTsConfigOptions;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodefs = require("node:fs");
|
|
12
|
+
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
13
|
+
const _commentjson = /*#__PURE__*/ _interop_require_wildcard(require("next/dist/compiled/comment-json"));
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
20
|
+
if (typeof WeakMap !== "function") return null;
|
|
21
|
+
var cacheBabelInterop = new WeakMap();
|
|
22
|
+
var cacheNodeInterop = new WeakMap();
|
|
23
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
24
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
25
|
+
})(nodeInterop);
|
|
26
|
+
}
|
|
27
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
28
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
32
|
+
return {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
37
|
+
if (cache && cache.has(obj)) {
|
|
38
|
+
return cache.get(obj);
|
|
39
|
+
}
|
|
40
|
+
var newObj = {
|
|
41
|
+
__proto__: null
|
|
42
|
+
};
|
|
43
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
|
+
for(var key in obj){
|
|
45
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
46
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
47
|
+
if (desc && (desc.get || desc.set)) {
|
|
48
|
+
Object.defineProperty(newObj, key, desc);
|
|
49
|
+
} else {
|
|
50
|
+
newObj[key] = obj[key];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
newObj.default = obj;
|
|
55
|
+
if (cache) {
|
|
56
|
+
cache.set(obj, newObj);
|
|
57
|
+
}
|
|
58
|
+
return newObj;
|
|
59
|
+
}
|
|
60
|
+
function resolveConfigDirValue(value, configDir, rootConfigDir) {
|
|
61
|
+
return _nodepath.default.resolve(configDir, value.replace(/\$\{configDir\}/g, rootConfigDir));
|
|
62
|
+
}
|
|
63
|
+
function resolveConfigFile(candidate) {
|
|
64
|
+
for (const configPath of [
|
|
65
|
+
candidate,
|
|
66
|
+
candidate.endsWith('.json') ? undefined : candidate + '.json'
|
|
67
|
+
]){
|
|
68
|
+
if (configPath && (0, _nodefs.existsSync)(configPath) && (0, _nodefs.statSync)(configPath).isFile()) {
|
|
69
|
+
return configPath;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function resolvePackageTsConfig(extendsPath, currentConfigDir) {
|
|
74
|
+
const parts = extendsPath.split('/');
|
|
75
|
+
const isPackageRoot = extendsPath.startsWith('@') ? parts.length === 2 : parts.length === 1;
|
|
76
|
+
if (!isPackageRoot) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const packageJsonPath = require.resolve(extendsPath + '/package.json', {
|
|
81
|
+
paths: [
|
|
82
|
+
currentConfigDir
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
const packageJson = JSON.parse((0, _nodefs.readFileSync)(packageJsonPath, 'utf8'));
|
|
86
|
+
if (packageJson.exports !== undefined) {
|
|
87
|
+
try {
|
|
88
|
+
const exportedConfig = require.resolve(extendsPath, {
|
|
89
|
+
paths: [
|
|
90
|
+
currentConfigDir
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
if (_nodepath.default.extname(exportedConfig) === '.json') {
|
|
94
|
+
return exportedConfig;
|
|
95
|
+
}
|
|
96
|
+
} catch {}
|
|
97
|
+
}
|
|
98
|
+
if (typeof packageJson.tsconfig === 'string') {
|
|
99
|
+
return resolveConfigFile(_nodepath.default.resolve(_nodepath.default.dirname(packageJsonPath), packageJson.tsconfig));
|
|
100
|
+
}
|
|
101
|
+
return resolveConfigFile(_nodepath.default.join(_nodepath.default.dirname(packageJsonPath), 'tsconfig'));
|
|
102
|
+
} catch {}
|
|
103
|
+
}
|
|
104
|
+
function resolveExtends(extendsPath, currentConfigDir) {
|
|
105
|
+
if (extendsPath.startsWith('./') || extendsPath.startsWith('../') || _nodepath.default.isAbsolute(extendsPath)) {
|
|
106
|
+
const resolved = _nodepath.default.resolve(currentConfigDir, extendsPath);
|
|
107
|
+
if ((0, _nodefs.existsSync)(resolved)) {
|
|
108
|
+
return resolved;
|
|
109
|
+
}
|
|
110
|
+
if (!resolved.endsWith('.json') && (0, _nodefs.existsSync)(resolved + '.json')) {
|
|
111
|
+
return resolved + '.json';
|
|
112
|
+
}
|
|
113
|
+
return resolved;
|
|
114
|
+
}
|
|
115
|
+
const packageConfigPath = resolvePackageTsConfig(extendsPath, currentConfigDir);
|
|
116
|
+
if (packageConfigPath) {
|
|
117
|
+
return packageConfigPath;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const resolved = require.resolve(extendsPath, {
|
|
121
|
+
paths: [
|
|
122
|
+
currentConfigDir
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
if (_nodepath.default.extname(resolved) === '.json') {
|
|
126
|
+
return resolved;
|
|
127
|
+
}
|
|
128
|
+
} catch {}
|
|
129
|
+
try {
|
|
130
|
+
return require.resolve(extendsPath + '/tsconfig.json', {
|
|
131
|
+
paths: [
|
|
132
|
+
currentConfigDir
|
|
133
|
+
]
|
|
134
|
+
});
|
|
135
|
+
} catch {
|
|
136
|
+
return _nodepath.default.resolve(currentConfigDir, extendsPath);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function loadTsConfigOptionsRecursive(configPath, visited, rootConfigDir) {
|
|
140
|
+
const resolvedPath = _nodepath.default.resolve(configPath);
|
|
141
|
+
if (visited.has(resolvedPath) || !(0, _nodefs.existsSync)(resolvedPath)) {
|
|
142
|
+
return {};
|
|
143
|
+
}
|
|
144
|
+
const nextVisited = new Set(visited);
|
|
145
|
+
nextVisited.add(resolvedPath);
|
|
146
|
+
const configContent = (0, _nodefs.readFileSync)(resolvedPath, 'utf8');
|
|
147
|
+
const config = _commentjson.parse(configContent);
|
|
148
|
+
const configDir = _nodepath.default.dirname(resolvedPath);
|
|
149
|
+
let mergedOptions = {};
|
|
150
|
+
if (config.extends) {
|
|
151
|
+
const extendsList = Array.isArray(config.extends) ? config.extends : [
|
|
152
|
+
config.extends
|
|
153
|
+
];
|
|
154
|
+
for (const extendsPath of extendsList){
|
|
155
|
+
const parentConfigPath = resolveExtends(extendsPath, configDir);
|
|
156
|
+
const parentOptions = loadTsConfigOptionsRecursive(parentConfigPath, nextVisited, rootConfigDir);
|
|
157
|
+
mergedOptions = {
|
|
158
|
+
...mergedOptions,
|
|
159
|
+
...parentOptions
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const currentOptions = config.compilerOptions ?? {};
|
|
164
|
+
if (Object.hasOwn(currentOptions, 'paths')) {
|
|
165
|
+
mergedOptions.paths = currentOptions.paths;
|
|
166
|
+
mergedOptions.pathsBasePath = configDir;
|
|
167
|
+
}
|
|
168
|
+
if (Object.hasOwn(currentOptions, 'baseUrl') && typeof currentOptions.baseUrl === 'string') {
|
|
169
|
+
mergedOptions.baseUrl = resolveConfigDirValue(currentOptions.baseUrl, configDir, rootConfigDir);
|
|
170
|
+
}
|
|
171
|
+
if (mergedOptions.baseUrl) {
|
|
172
|
+
mergedOptions.pathsBasePath = undefined;
|
|
173
|
+
}
|
|
174
|
+
return mergedOptions;
|
|
175
|
+
}
|
|
176
|
+
function loadTsConfigOptions(configPath) {
|
|
177
|
+
const resolvedPath = _nodepath.default.resolve(configPath);
|
|
178
|
+
return loadTsConfigOptionsRecursive(resolvedPath, new Set(), _nodepath.default.dirname(resolvedPath));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=loadTsConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/typescript/loadTsConfig.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs'\nimport path from 'node:path'\n\nimport * as CommentJson from 'next/dist/compiled/comment-json'\n\nexport type RelevantCompilerOptions = {\n paths?: Record<string, string[]>\n /** Absolute path for an explicitly configured baseUrl. */\n baseUrl?: string\n /** Absolute directory containing an inherited paths option without baseUrl. */\n pathsBasePath?: string\n}\n\nfunction resolveConfigDirValue(\n value: string,\n configDir: string,\n rootConfigDir: string\n): string {\n return path.resolve(\n configDir,\n value.replace(/\\$\\{configDir\\}/g, rootConfigDir)\n )\n}\n\nfunction resolveConfigFile(candidate: string): string | undefined {\n for (const configPath of [\n candidate,\n candidate.endsWith('.json') ? undefined : candidate + '.json',\n ]) {\n if (configPath && existsSync(configPath) && statSync(configPath).isFile()) {\n return configPath\n }\n }\n}\n\nfunction resolvePackageTsConfig(\n extendsPath: string,\n currentConfigDir: string\n): string | undefined {\n const parts = extendsPath.split('/')\n const isPackageRoot = extendsPath.startsWith('@')\n ? parts.length === 2\n : parts.length === 1\n\n if (!isPackageRoot) {\n return undefined\n }\n\n try {\n const packageJsonPath = require.resolve(extendsPath + '/package.json', {\n paths: [currentConfigDir],\n })\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))\n if (packageJson.exports !== undefined) {\n try {\n const exportedConfig = require.resolve(extendsPath, {\n paths: [currentConfigDir],\n })\n if (path.extname(exportedConfig) === '.json') {\n return exportedConfig\n }\n } catch {}\n }\n if (typeof packageJson.tsconfig === 'string') {\n return resolveConfigFile(\n path.resolve(path.dirname(packageJsonPath), packageJson.tsconfig)\n )\n }\n return resolveConfigFile(\n path.join(path.dirname(packageJsonPath), 'tsconfig')\n )\n } catch {}\n}\n\nfunction resolveExtends(extendsPath: string, currentConfigDir: string): string {\n if (\n extendsPath.startsWith('./') ||\n extendsPath.startsWith('../') ||\n path.isAbsolute(extendsPath)\n ) {\n const resolved = path.resolve(currentConfigDir, extendsPath)\n if (existsSync(resolved)) {\n return resolved\n }\n if (!resolved.endsWith('.json') && existsSync(resolved + '.json')) {\n return resolved + '.json'\n }\n return resolved\n }\n\n const packageConfigPath = resolvePackageTsConfig(\n extendsPath,\n currentConfigDir\n )\n if (packageConfigPath) {\n return packageConfigPath\n }\n\n try {\n const resolved = require.resolve(extendsPath, { paths: [currentConfigDir] })\n if (path.extname(resolved) === '.json') {\n return resolved\n }\n } catch {}\n\n try {\n return require.resolve(extendsPath + '/tsconfig.json', {\n paths: [currentConfigDir],\n })\n } catch {\n return path.resolve(currentConfigDir, extendsPath)\n }\n}\n\nfunction loadTsConfigOptionsRecursive(\n configPath: string,\n visited: Set<string>,\n rootConfigDir: string\n): RelevantCompilerOptions {\n const resolvedPath = path.resolve(configPath)\n\n if (visited.has(resolvedPath) || !existsSync(resolvedPath)) {\n return {}\n }\n\n const nextVisited = new Set(visited)\n nextVisited.add(resolvedPath)\n\n const configContent = readFileSync(resolvedPath, 'utf8')\n const config = CommentJson.parse(configContent)\n const configDir = path.dirname(resolvedPath)\n\n let mergedOptions: RelevantCompilerOptions = {}\n\n if (config.extends) {\n const extendsList = Array.isArray(config.extends)\n ? config.extends\n : [config.extends]\n\n for (const extendsPath of extendsList) {\n const parentConfigPath = resolveExtends(extendsPath, configDir)\n const parentOptions = loadTsConfigOptionsRecursive(\n parentConfigPath,\n nextVisited,\n rootConfigDir\n )\n mergedOptions = { ...mergedOptions, ...parentOptions }\n }\n }\n\n const currentOptions = config.compilerOptions ?? {}\n\n if (Object.hasOwn(currentOptions, 'paths')) {\n mergedOptions.paths = currentOptions.paths\n mergedOptions.pathsBasePath = configDir\n }\n\n if (\n Object.hasOwn(currentOptions, 'baseUrl') &&\n typeof currentOptions.baseUrl === 'string'\n ) {\n mergedOptions.baseUrl = resolveConfigDirValue(\n currentOptions.baseUrl,\n configDir,\n rootConfigDir\n )\n }\n\n if (mergedOptions.baseUrl) {\n mergedOptions.pathsBasePath = undefined\n }\n\n return mergedOptions\n}\n\n/**\n * Loads only the tsconfig options Next.js needs outside of the TypeScript API.\n * Paths and baseUrl keep the directory they were declared in while resolving\n * an extends chain, including arrays of extended configs.\n */\nexport function loadTsConfigOptions(\n configPath: string\n): RelevantCompilerOptions {\n const resolvedPath = path.resolve(configPath)\n return loadTsConfigOptionsRecursive(\n resolvedPath,\n new Set(),\n path.dirname(resolvedPath)\n )\n}\n"],"names":["loadTsConfigOptions","resolveConfigDirValue","value","configDir","rootConfigDir","path","resolve","replace","resolveConfigFile","candidate","configPath","endsWith","undefined","existsSync","statSync","isFile","resolvePackageTsConfig","extendsPath","currentConfigDir","parts","split","isPackageRoot","startsWith","length","packageJsonPath","require","paths","packageJson","JSON","parse","readFileSync","exports","exportedConfig","extname","tsconfig","dirname","join","resolveExtends","isAbsolute","resolved","packageConfigPath","loadTsConfigOptionsRecursive","visited","resolvedPath","has","nextVisited","Set","add","configContent","config","CommentJson","mergedOptions","extends","extendsList","Array","isArray","parentConfigPath","parentOptions","currentOptions","compilerOptions","Object","hasOwn","pathsBasePath","baseUrl"],"mappings":";;;;+BAoLgBA;;;eAAAA;;;wBApLmC;iEAClC;qEAEY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU7B,SAASC,sBACPC,KAAa,EACbC,SAAiB,EACjBC,aAAqB;IAErB,OAAOC,iBAAI,CAACC,OAAO,CACjBH,WACAD,MAAMK,OAAO,CAAC,oBAAoBH;AAEtC;AAEA,SAASI,kBAAkBC,SAAiB;IAC1C,KAAK,MAAMC,cAAc;QACvBD;QACAA,UAAUE,QAAQ,CAAC,WAAWC,YAAYH,YAAY;KACvD,CAAE;QACD,IAAIC,cAAcG,IAAAA,kBAAU,EAACH,eAAeI,IAAAA,gBAAQ,EAACJ,YAAYK,MAAM,IAAI;YACzE,OAAOL;QACT;IACF;AACF;AAEA,SAASM,uBACPC,WAAmB,EACnBC,gBAAwB;IAExB,MAAMC,QAAQF,YAAYG,KAA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IAAI,CAAC;IAElD,IAAIC,OAAOC,MAAM,CAACH,gBAAgB,UAAU;QAC1CP,cAAczB,KAAK,GAAGgC,eAAehC,KAAK;QAC1CyB,cAAcW,aAAa,GAAG3D;IAChC;IAEA,IACEyD,OAAOC,MAAM,CAACH,gBAAgB,cAC9B,OAAOA,eAAeK,OAAO,KAAK,UAClC;QACAZ,cAAcY,OAAO,GAAG9D,sBACtByD,eAAeK,OAAO,EACtB5D,WACAC;IAEJ;IAEA,IAAI+C,cAAcY,OAAO,EAAE;QACzBZ,cAAcW,aAAa,GAAGlD;IAChC;IAEA,OAAOuC;AACT;AAOO,SAASnD,oBACdU,UAAkB;IAElB,MAAMiC,eAAetC,iBAAI,CAACC,OAAO,CAACI;IAClC,OAAO+B,6BACLE,cACA,IAAIG,OACJzC,iBAAI,CAAC8B,OAAO,CAACQ;AAEjB","ignoreList":[0]}
|
|
@@ -14,7 +14,7 @@ const _fatalerror = require("../fatal-error");
|
|
|
14
14
|
const _getpkgmanager = require("../helpers/get-pkg-manager");
|
|
15
15
|
function missingDepsError(dir, missingPackages) {
|
|
16
16
|
const packagesHuman = (0, _oxfordcommalist.getOxfordCommaList)(missingPackages.map((p)=>p.pkg));
|
|
17
|
-
const packagesCli = missingPackages.map((p)=>p.pkg).join(' ');
|
|
17
|
+
const packagesCli = missingPackages.map((p)=>p.install ?? p.pkg).join(' ');
|
|
18
18
|
const packageManager = (0, _getpkgmanager.getPkgManager)(dir);
|
|
19
19
|
const removalMsg = '\n\n' + (0, _picocolors.bold)('If you are not trying to use TypeScript, please remove the ' + (0, _picocolors.cyan)('tsconfig.json') + ' file from your package root (and any TypeScript files in your app and pages directories).');
|
|
20
20
|
throw Object.defineProperty(new _fatalerror.FatalError((0, _picocolors.bold)((0, _picocolors.red)(`It looks like you're trying to use TypeScript but do not have the required package(s) installed.`)) + '\n\n' + (0, _picocolors.bold)(`Please install ${(0, _picocolors.bold)(packagesHuman)} by running:`) + '\n\n' + `\t${(0, _picocolors.bold)((0, _picocolors.cyan)((packageManager === 'yarn' ? 'yarn add --dev' : packageManager === 'pnpm' ? 'pnpm install --save-dev' : 'npm install --save-dev') + ' ' + packagesCli))}` + removalMsg + '\n'), "__NEXT_ERROR_CODE", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/typescript/missingDependencyError.ts"],"sourcesContent":["import { bold, cyan, red } from '../picocolors'\n\nimport { getOxfordCommaList } from '../oxford-comma-list'\nimport type { MissingDependency } from '../has-necessary-dependencies'\nimport { FatalError } from '../fatal-error'\nimport { getPkgManager } from '../helpers/get-pkg-manager'\n\nexport function missingDepsError(\n dir: string,\n missingPackages: MissingDependency[]\n): never {\n const packagesHuman = getOxfordCommaList(missingPackages.map((p) => p.pkg))\n const packagesCli = missingPackages.map((p) => p.pkg).join(' ')\n const packageManager = getPkgManager(dir)\n\n const removalMsg =\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n )\n\n throw new FatalError(\n bold(\n red(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n\\n' +\n bold(`Please install ${bold(packagesHuman)} by running:`) +\n '\\n\\n' +\n `\\t${bold(\n cyan(\n (packageManager === 'yarn'\n ? 'yarn add --dev'\n : packageManager === 'pnpm'\n ? 'pnpm install --save-dev'\n : 'npm install --save-dev') +\n ' ' +\n packagesCli\n )\n )}` +\n removalMsg +\n '\\n'\n )\n}\n"],"names":["missingDepsError","dir","missingPackages","packagesHuman","getOxfordCommaList","map","p","pkg","packagesCli","join","packageManager","getPkgManager","removalMsg","bold","cyan","FatalError","red"],"mappings":";;;;+BAOgBA;;;eAAAA;;;4BAPgB;iCAEG;4BAER;+BACG;AAEvB,SAASA,iBACdC,GAAW,EACXC,eAAoC;IAEpC,MAAMC,gBAAgBC,IAAAA,mCAAkB,EAACF,gBAAgBG,GAAG,CAAC,CAACC,IAAMA,EAAEC,GAAG;IACzE,MAAMC,cAAcN,gBAAgBG,GAAG,CAAC,CAACC,IAAMA,EAAEC,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/typescript/missingDependencyError.ts"],"sourcesContent":["import { bold, cyan, red } from '../picocolors'\n\nimport { getOxfordCommaList } from '../oxford-comma-list'\nimport type { MissingDependency } from '../has-necessary-dependencies'\nimport { FatalError } from '../fatal-error'\nimport { getPkgManager } from '../helpers/get-pkg-manager'\n\nexport function missingDepsError(\n dir: string,\n missingPackages: MissingDependency[]\n): never {\n const packagesHuman = getOxfordCommaList(missingPackages.map((p) => p.pkg))\n const packagesCli = missingPackages.map((p) => p.install ?? p.pkg).join(' ')\n const packageManager = getPkgManager(dir)\n\n const removalMsg =\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n )\n\n throw new FatalError(\n bold(\n red(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n\\n' +\n bold(`Please install ${bold(packagesHuman)} by running:`) +\n '\\n\\n' +\n `\\t${bold(\n cyan(\n (packageManager === 'yarn'\n ? 'yarn add --dev'\n : packageManager === 'pnpm'\n ? 'pnpm install --save-dev'\n : 'npm install --save-dev') +\n ' ' +\n packagesCli\n )\n )}` +\n removalMsg +\n '\\n'\n )\n}\n"],"names":["missingDepsError","dir","missingPackages","packagesHuman","getOxfordCommaList","map","p","pkg","packagesCli","install","join","packageManager","getPkgManager","removalMsg","bold","cyan","FatalError","red"],"mappings":";;;;+BAOgBA;;;eAAAA;;;4BAPgB;iCAEG;4BAER;+BACG;AAEvB,SAASA,iBACdC,GAAW,EACXC,eAAoC;IAEpC,MAAMC,gBAAgBC,IAAAA,mCAAkB,EAACF,gBAAgBG,GAAG,CAAC,CAACC,IAAMA,EAAEC,GAAG;IACzE,MAAMC,cAAcN,gBAAgBG,GAAG,CAAC,CAACC,IAAMA,EAAEG,OAAO,IAAIH,EAAEC,GAAG,EAAEG,IAAI,CAAC;IACxE,MAAMC,iBAAiBC,IAAAA,4BAAa,EAACX;IAErC,MAAMY,aACJ,SACAC,IAAAA,gBAAI,EACF,gEACEC,IAAAA,gBAAI,EAAC,mBACL;IAGN,MAAM,qBAsBL,CAtBK,IAAIC,sBAAU,CAClBF,IAAAA,gBAAI,EACFG,IAAAA,eAAG,EACD,CAAC,gGAAgG,CAAC,KAGpG,SACAH,IAAAA,gBAAI,EAAC,CAAC,eAAe,EAAEA,IAAAA,gBAAI,EAACX,eAAe,YAAY,CAAC,IACxD,SACA,CAAC,EAAE,EAAEW,IAAAA,gBAAI,EACPC,IAAAA,gBAAI,EACF,AAACJ,CAAAA,mBAAmB,SAChB,mBACAA,mBAAmB,SACjB,4BACA,wBAAuB,IAC3B,MACAH,eAEH,GACHK,aACA,OArBE,qBAAA;eAAA;oBAAA;sBAAA;IAsBN;AACF","ignoreList":[0]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/typescript/runTypeCheck.ts"],"sourcesContent":["import path from 'path'\nimport { getFormattedDiagnostic } from './diagnosticFormatter'\nimport { getTypeScriptConfiguration } from './getTypeScriptConfiguration'\nimport { getRequiredConfiguration } from './writeConfigurationDefaults'\nimport { getDevTypesPath } from './type-paths'\n\nimport { CompileError } from '../compile-error'\nimport { warn } from '../../build/output/log'\n\nexport interface TypeCheckResult {\n hasWarnings: boolean\n warnings?: string[]\n inputFilesCount: number\n totalFilesCount: number\n incremental: boolean\n}\n\nexport interface TypeCheckDirs {\n app?: string\n pages?: string\n}\n\nexport interface DebugBuildPaths {\n app?: string[]\n pages?: string[]\n}\n\n/**\n * Check if a file path matches any of the debug build paths.\n * Both filePath and debugPaths are resolved file paths from glob.\n */\nfunction fileMatchesDebugPaths(\n filePath: string,\n debugPaths: string[]\n): boolean {\n return debugPaths.includes(filePath)\n}\n\nexport async function runTypeCheck(\n typescript: typeof import('typescript'),\n baseDir: string,\n distDir: string,\n tsConfigPath: string,\n cacheDir?: string,\n isAppDirEnabled?: boolean,\n dirs?: TypeCheckDirs,\n debugBuildPaths?: DebugBuildPaths\n): Promise<TypeCheckResult> {\n const effectiveConfiguration = await getTypeScriptConfiguration(\n typescript,\n tsConfigPath\n )\n\n // tsconfig includes both .next/types and .next/dev/types to avoid config churn\n // between dev/build modes. During build, we filter out .next/dev/types files to\n // prevent stale dev types from causing errors when routes have been deleted since\n // the last dev session.\n let fileNames = effectiveConfiguration.fileNames\n\n // Get the dev types path to filter (null if not applicable)\n const devTypesDir = getDevTypesPath(baseDir, distDir)\n if (devTypesDir) {\n fileNames = fileNames.filter(\n (fileName) => !fileName.startsWith(devTypesDir)\n )\n }\n\n // Apply debug build paths filter if specified\n if (dirs && debugBuildPaths) {\n const { app: appDir, pages: pagesDir } = dirs\n const { app: debugAppPaths, pages: debugPagePaths } = debugBuildPaths\n\n fileNames = fileNames.filter((fileName) => {\n // Check if file is in app directory\n if (appDir && fileName.startsWith(appDir + path.sep)) {\n // If debugAppPaths is undefined, include all app files\n if (debugAppPaths === undefined) {\n return true\n }\n // If debugAppPaths is empty array, exclude all app files\n if (debugAppPaths.length === 0) {\n return false\n }\n // Check if file matches any of the debug paths\n const relativeToApp = fileName.slice(appDir.length)\n return fileMatchesDebugPaths(relativeToApp, debugAppPaths)\n }\n\n // Check if file is in pages directory\n if (pagesDir && fileName.startsWith(pagesDir + path.sep)) {\n // If debugPagePaths is undefined, include all pages files\n if (debugPagePaths === undefined) {\n return true\n }\n // If debugPagePaths is empty array, exclude all pages files\n if (debugPagePaths.length === 0) {\n return false\n }\n // Check if file matches any of the debug paths\n const relativeToPages = fileName.slice(pagesDir.length)\n return fileMatchesDebugPaths(relativeToPages, debugPagePaths)\n }\n\n // Keep files outside app/pages directories (shared code, etc.)\n return true\n })\n }\n\n if (fileNames.length < 1) {\n return {\n hasWarnings: false,\n inputFilesCount: 0,\n totalFilesCount: 0,\n incremental: false,\n }\n }\n const requiredConfig = getRequiredConfiguration(typescript)\n\n const options = {\n ...requiredConfig,\n ...effectiveConfiguration.options,\n declarationMap: false,\n emitDeclarationOnly: false,\n noEmit: true,\n }\n\n let program:\n | import('typescript').Program\n | import('typescript').BuilderProgram\n let incremental = false\n if ((options.incremental || options.composite) && cacheDir) {\n if (options.composite) {\n warn(\n 'TypeScript project references are not fully supported. Attempting to build in incremental mode.'\n )\n }\n incremental = true\n program = typescript.createIncrementalProgram({\n rootNames: fileNames,\n options: {\n ...options,\n composite: false,\n incremental: true,\n tsBuildInfoFile: path.join(cacheDir, '.tsbuildinfo'),\n },\n })\n } else {\n program = typescript.createProgram(fileNames, options)\n }\n\n const result = program.emit()\n\n const ignoreRegex = [\n // matches **/__(tests|mocks)__/**\n /[\\\\/]__(?:tests|mocks)__[\\\\/]/,\n // matches **/*.(spec|test).*\n /(?<=[\\\\/.])(?:spec|test)\\.[^\\\\/]+$/,\n ]\n const regexIgnoredFile = new RegExp(\n ignoreRegex.map((r) => r.source).join('|')\n )\n\n const allDiagnostics = typescript\n .getPreEmitDiagnostics(program as import('typescript').Program)\n .concat(result.diagnostics)\n .filter((d) => !(d.file && regexIgnoredFile.test(d.file.fileName)))\n\n const firstError =\n allDiagnostics.find(\n (d) =>\n d.category === typescript.DiagnosticCategory.Error && Boolean(d.file)\n ) ??\n allDiagnostics.find(\n (d) => d.category === typescript.DiagnosticCategory.Error\n )\n\n // In test mode, we want to check all diagnostics, not just the first one.\n if (process.env.__NEXT_TEST_MODE) {\n if (firstError) {\n const allErrors = allDiagnostics\n .filter((d) => d.category === typescript.DiagnosticCategory.Error)\n .map(\n (d) =>\n '[Test Mode] ' +\n getFormattedDiagnostic(\n typescript,\n baseDir,\n distDir,\n d,\n isAppDirEnabled\n )\n )\n\n console.error(\n '\\n\\n===== TS errors =====\\n\\n' +\n allErrors.join('\\n\\n') +\n '\\n\\n===== TS errors =====\\n\\n'\n )\n\n // Make sure all stdout is flushed before we exit.\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n }\n\n if (firstError) {\n throw new CompileError(\n getFormattedDiagnostic(\n typescript,\n baseDir,\n distDir,\n firstError,\n isAppDirEnabled\n )\n )\n }\n\n const warnings = allDiagnostics\n .filter((d) => d.category === typescript.DiagnosticCategory.Warning)\n .map((d) =>\n getFormattedDiagnostic(typescript, baseDir, distDir, d, isAppDirEnabled)\n )\n\n return {\n hasWarnings: true,\n warnings,\n inputFilesCount: fileNames.length,\n totalFilesCount: program.getSourceFiles().length,\n incremental,\n }\n}\n"],"names":["runTypeCheck","fileMatchesDebugPaths","filePath","debugPaths","includes","typescript","baseDir","distDir","tsConfigPath","cacheDir","isAppDirEnabled","dirs","debugBuildPaths","effectiveConfiguration","getTypeScriptConfiguration","fileNames","devTypesDir","getDevTypesPath","filter","fileName","startsWith","app","appDir","pages","pagesDir","debugAppPaths","debugPagePaths","path","sep","undefined","length","relativeToApp","slice","relativeToPages","hasWarnings","inputFilesCount","totalFilesCount","incremental","requiredConfig","getRequiredConfiguration","options","declarationMap","emitDeclarationOnly","noEmit","program","composite","warn","createIncrementalProgram","rootNames","tsBuildInfoFile","join","createProgram","result","emit","ignoreRegex","regexIgnoredFile","RegExp","map","r","source","allDiagnostics","getPreEmitDiagnostics","concat","diagnostics","d","file","test","firstError","find","category","DiagnosticCategory","Error","Boolean","process","env","__NEXT_TEST_MODE","allErrors","getFormattedDiagnostic","console","error","Promise","resolve","setTimeout","CompileError","warnings","Warning","getSourceFiles"],"mappings":";;;;+BAsCsBA;;;eAAAA;;;6DAtCL;qCACsB;4CACI;4CACF;2BACT;8BAEH;qBACR;;;;;;AAoBrB;;;CAGC,GACD,SAASC,sBACPC,QAAgB,EAChBC,UAAoB;IAEpB,OAAOA,WAAWC,QAAQ,CAACF;AAC7B;AAEO,eAAeF,aACpBK,UAAuC,EACvCC,OAAe,EACfC,OAAe,EACfC,YAAoB,EACpBC,QAAiB,EACjBC,eAAyB,EACzBC,IAAoB,EACpBC,eAAiC;IAEjC,MAAMC,y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IC,QAAQR,EAAEC,IAAI,MAExEL,eAAeQ,IAAI,CACjB,CAACJ,IAAMA,EAAEK,QAAQ,KAAKhE,WAAWiE,kBAAkB,CAACC,KAAK;IAG7D,0EAA0E;IAC1E,IAAIE,QAAQC,GAAG,CAACC,gBAAgB,EAAE;QAChC,IAAIR,YAAY;YACd,MAAMS,YAAYhB,eACf1C,MAAM,CAAC,CAAC8C,IAAMA,EAAEK,QAAQ,KAAKhE,WAAWiE,kBAAkB,CAACC,KAAK,EAChEd,GAAG,CACF,CAACO,IACC,iBACAa,IAAAA,2CAAsB,EACpBxE,YACAC,SACAC,SACAyD,GACAtD;YAIRoE,QAAQC,KAAK,CACX,kCACEH,UAAU1B,IAAI,CAAC,UACf;YAGJ,kDAAkD;YAClD,MAAM,IAAI8B,QAAQ,CAACC,UAAYC,WAAWD,SAAS;QACrD;IACF;IAEA,IAAId,YAAY;QACd,MAAM,qBAQL,CARK,IAAIgB,0BAAY,CACpBN,IAAAA,2CAAsB,EACpBxE,YACAC,SACAC,SACA4D,YACAzD,mBANE,qBAAA;mBAAA;wBAAA;0BAAA;QAQN;IACF;IAEA,MAAM0E,WAAWxB,eACd1C,MAAM,CAAC,CAAC8C,IAAMA,EAAEK,QAAQ,KAAKhE,WAAWiE,kBAAkB,CAACe,OAAO,EAClE5B,GAAG,CAAC,CAACO,IACJa,IAAAA,2CAAsB,EAACxE,YAAYC,SAASC,SAASyD,GAAGtD;IAG5D,OAAO;QACLwB,aAAa;QACbkD;QACAjD,iBAAiBpB,UAAUe,MAAM;QACjCM,iBAAiBQ,QAAQ0C,cAAc,GAAGxD,MAAM;QAChDO;IACF;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/typescript/runTypeCheck.ts"],"sourcesContent":["import path from 'path'\nimport { getFormattedDiagnostic } from './diagnosticFormatter'\nimport { getTypeScriptConfiguration } from './getTypeScriptConfiguration'\nimport { getRequiredConfiguration } from './writeConfigurationDefaults'\nimport { getDevTypesPath } from './type-paths'\n\nimport { CompileError } from '../compile-error'\nimport { warn } from '../../build/output/log'\n\nexport interface TypeCheckResult {\n hasWarnings: boolean\n warnings?: string[]\n inputFilesCount?: number\n totalFilesCount?: number\n incremental: boolean\n}\n\nexport interface TypeCheckDirs {\n app?: string\n pages?: string\n}\n\nexport interface DebugBuildPaths {\n app?: string[]\n pages?: string[]\n}\n\n/**\n * Check if a file path matches any of the debug build paths.\n * Both filePath and debugPaths are resolved file paths from glob.\n */\nfunction fileMatchesDebugPaths(\n filePath: string,\n debugPaths: string[]\n): boolean {\n return debugPaths.includes(filePath)\n}\n\nexport async function runTypeCheck(\n typescript: typeof import('typescript'),\n baseDir: string,\n distDir: string,\n tsConfigPath: string,\n cacheDir?: string,\n isAppDirEnabled?: boolean,\n dirs?: TypeCheckDirs,\n debugBuildPaths?: DebugBuildPaths\n): Promise<TypeCheckResult> {\n const effectiveConfiguration = await getTypeScriptConfiguration(\n typescript,\n tsConfigPath\n )\n\n // tsconfig includes both .next/types and .next/dev/types to avoid config churn\n // between dev/build modes. During build, we filter out .next/dev/types files to\n // prevent stale dev types from causing errors when routes have been deleted since\n // the last dev session.\n let fileNames = effectiveConfiguration.fileNames\n\n // Get the dev types path to filter (null if not applicable)\n const devTypesDir = getDevTypesPath(baseDir, distDir)\n if (devTypesDir) {\n fileNames = fileNames.filter(\n (fileName) => !fileName.startsWith(devTypesDir)\n )\n }\n\n // Apply debug build paths filter if specified\n if (dirs && debugBuildPaths) {\n const { app: appDir, pages: pagesDir } = dirs\n const { app: debugAppPaths, pages: debugPagePaths } = debugBuildPaths\n\n fileNames = fileNames.filter((fileName) => {\n // Check if file is in app directory\n if (appDir && fileName.startsWith(appDir + path.sep)) {\n // If debugAppPaths is undefined, include all app files\n if (debugAppPaths === undefined) {\n return true\n }\n // If debugAppPaths is empty array, exclude all app files\n if (debugAppPaths.length === 0) {\n return false\n }\n // Check if file matches any of the debug paths\n const relativeToApp = fileName.slice(appDir.length)\n return fileMatchesDebugPaths(relativeToApp, debugAppPaths)\n }\n\n // Check if file is in pages directory\n if (pagesDir && fileName.startsWith(pagesDir + path.sep)) {\n // If debugPagePaths is undefined, include all pages files\n if (debugPagePaths === undefined) {\n return true\n }\n // If debugPagePaths is empty array, exclude all pages files\n if (debugPagePaths.length === 0) {\n return false\n }\n // Check if file matches any of the debug paths\n const relativeToPages = fileName.slice(pagesDir.length)\n return fileMatchesDebugPaths(relativeToPages, debugPagePaths)\n }\n\n // Keep files outside app/pages directories (shared code, etc.)\n return true\n })\n }\n\n if (fileNames.length < 1) {\n return {\n hasWarnings: false,\n inputFilesCount: 0,\n totalFilesCount: 0,\n incremental: false,\n }\n }\n const requiredConfig = getRequiredConfiguration(typescript)\n\n const options = {\n ...requiredConfig,\n ...effectiveConfiguration.options,\n declarationMap: false,\n emitDeclarationOnly: false,\n noEmit: true,\n }\n\n let program:\n | import('typescript').Program\n | import('typescript').BuilderProgram\n let incremental = false\n if ((options.incremental || options.composite) && cacheDir) {\n if (options.composite) {\n warn(\n 'TypeScript project references are not fully supported. Attempting to build in incremental mode.'\n )\n }\n incremental = true\n program = typescript.createIncrementalProgram({\n rootNames: fileNames,\n options: {\n ...options,\n composite: false,\n incremental: true,\n tsBuildInfoFile: path.join(cacheDir, '.tsbuildinfo'),\n },\n })\n } else {\n program = typescript.createProgram(fileNames, options)\n }\n\n const result = program.emit()\n\n const ignoreRegex = [\n // matches **/__(tests|mocks)__/**\n /[\\\\/]__(?:tests|mocks)__[\\\\/]/,\n // matches **/*.(spec|test).*\n /(?<=[\\\\/.])(?:spec|test)\\.[^\\\\/]+$/,\n ]\n const regexIgnoredFile = new RegExp(\n ignoreRegex.map((r) => r.source).join('|')\n )\n\n const allDiagnostics = typescript\n .getPreEmitDiagnostics(program as import('typescript').Program)\n .concat(result.diagnostics)\n .filter((d) => !(d.file && regexIgnoredFile.test(d.file.fileName)))\n\n const firstError =\n allDiagnostics.find(\n (d) =>\n d.category === typescript.DiagnosticCategory.Error && Boolean(d.file)\n ) ??\n allDiagnostics.find(\n (d) => d.category === typescript.DiagnosticCategory.Error\n )\n\n // In test mode, we want to check all diagnostics, not just the first one.\n if (process.env.__NEXT_TEST_MODE) {\n if (firstError) {\n const allErrors = allDiagnostics\n .filter((d) => d.category === typescript.DiagnosticCategory.Error)\n .map(\n (d) =>\n '[Test Mode] ' +\n getFormattedDiagnostic(\n typescript,\n baseDir,\n distDir,\n d,\n isAppDirEnabled\n )\n )\n\n console.error(\n '\\n\\n===== TS errors =====\\n\\n' +\n allErrors.join('\\n\\n') +\n '\\n\\n===== TS errors =====\\n\\n'\n )\n\n // Make sure all stdout is flushed before we exit.\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n }\n\n if (firstError) {\n throw new CompileError(\n getFormattedDiagnostic(\n typescript,\n baseDir,\n distDir,\n firstError,\n isAppDirEnabled\n )\n )\n }\n\n const warnings = allDiagnostics\n .filter((d) => d.category === typescript.DiagnosticCategory.Warning)\n .map((d) =>\n getFormattedDiagnostic(typescript, baseDir, distDir, d, isAppDirEnabled)\n )\n\n return {\n hasWarnings: true,\n warnings,\n inputFilesCount: fileNames.length,\n totalFilesCount: program.getSourceFiles().length,\n incremental,\n }\n}\n"],"names":["runTypeCheck","fileMatchesDebugPaths","filePath","debugPaths","includes","typescript","baseDir","distDir","tsConfigPath","cacheDir","isAppDirEnabled","dirs","debugBuildPaths","effectiveConfiguration","getTypeScriptConfiguration","fileNames","devTypesDir","getDevTypesPath","filter","fileName","startsWith","app","appDir","pages","pagesDir","debugAppPaths","debugPagePaths","path","sep","undefined","length","relativeToApp","slice","relativeToPages","hasWarnings","inputFilesCount","totalFilesCount","incremental","requiredConfig","getRequiredConfiguration","options","declarationMap","emitDeclarationOnly","noEmit","program","composite","warn","createIncrementalProgram","rootNames","tsBuildInfoFile","join","createProgram","result","emit","ignoreRegex","regexIgnoredFile","RegExp","map","r","source","allDiagnostics","getPreEmitDiagnostics","concat","diagnostics","d","file","test","firstError","find","category","DiagnosticCategory","Error","Boolean","process","env","__NEXT_TEST_MODE","allErrors","getFormattedDiagnostic","console","error","Promise","resolve","setTimeout","CompileError","warnings","Warning","getSourceFiles"],"mappings":";;;;+BAsCsBA;;;eAAAA;;;6DAtCL;qCACsB;4CACI;4CACF;2BACT;8BAEH;qBACR;;;;;;AAoBrB;;;CAGC,GACD,SAASC,sBACPC,QAAgB,EAChBC,UAAoB;IAEpB,OAAOA,WAAWC,QAAQ,CAACF;AAC7B;AAEO,eAAeF,aACpBK,UAAuC,EACvCC,OAAe,EACfC,OAAe,EACfC,YAAoB,EACpBC,QAAiB,EACjBC,eAAyB,EACzBC,IAAoB,EACpBC,eAAiC;IAEjC,MAAMC,yBAAyB,MAAMC,IAAAA,sDAA0B,EAC7DT,YACAG;IAGF,+EAA+E;IAC/E,gFAAgF;IAChF,kFAAkF;IAClF,wBAAwB;IACxB,IAAIO,YAAYF,uBAAuBE,SAAS;IAEhD,4DAA4D;IAC5D,MAAMC,cAAcC,IAAAA,0BAAe,EAACX,SAASC;IAC7C,IAAIS,aAAa;QACfD,YAAYA,UAAUG,MAAM,CAC1B,CAACC,WAAa,CAACA,SAASC,UAAU,CAACJ;IAEvC;IAEA,8CAA8C;IAC9C,IAAIL,QAAQC,iBAAiB;QAC3B,MAAM,EAAES,KAAKC,MAAM,EAAEC,OAAOC,QAAQ,EAAE,GAAGb;QACzC,MAAM,EAAEU,KAAKI,aAAa,EAAEF,OAAOG,cAAc,EAAE,GAAGd;QAEtDG,YAAYA,UAAUG,MAAM,CAAC,CAACC;YAC5B,oCAAoC;YACpC,IAAIG,UAAUH,SAASC,UAAU,CAACE,SAASK,aAAI,CAACC,GAAG,GAAG;gBACpD,uDAAuD;gBACvD,IAAIH,kBAAkBI,WAAW;oBAC/B,OAAO;gBACT;gBACA,yDAAyD;gBACzD,IAAIJ,cAAcK,MAAM,KAAK,GAAG;oBAC9B,OAAO;gBACT;gBACA,+CAA+C;gBAC/C,MAAMC,gBAAgBZ,SAASa,KAAK,CAACV,OAAOQ,MAA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CAAC,CAACO,IACJa,IAAAA,2CAAsB,EAACxE,YAAYC,SAASC,SAASyD,GAAGtD;IAG5D,OAAO;QACLwB,aAAa;QACbkD;QACAjD,iBAAiBpB,UAAUe,MAAM;QACjCM,iBAAiBQ,QAAQ0C,cAAc,GAAGxD,MAAM;QAChDO;IACF;AACF","ignoreList":[0]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TypeCheckResult } from './runTypeCheck';
|
|
2
|
+
export declare function runTypeCheckCli({ baseDir, tsConfigPath, tscPath, cacheDir, onFirstOutput, }: {
|
|
3
|
+
baseDir: string;
|
|
4
|
+
tsConfigPath: string;
|
|
5
|
+
tscPath: string;
|
|
6
|
+
cacheDir?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Called once when `tsc` first produces output. Used to stop the build
|
|
9
|
+
* spinner so it does not sit above the diagnostics.
|
|
10
|
+
*/
|
|
11
|
+
onFirstOutput?: () => void;
|
|
12
|
+
}): Promise<TypeCheckResult>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "runTypeCheckCli", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return runTypeCheckCli;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
12
|
+
const _compileerror = require("../compile-error");
|
|
13
|
+
const _runTypeScriptCli = require("./runTypeScriptCli");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function runTypeCheckCli({ baseDir, tsConfigPath, tscPath, cacheDir, onFirstOutput }) {
|
|
20
|
+
const configuration = await (0, _runTypeScriptCli.getTypeScriptConfigurationCli)({
|
|
21
|
+
baseDir,
|
|
22
|
+
tsConfigPath,
|
|
23
|
+
tscPath
|
|
24
|
+
});
|
|
25
|
+
const incremental = Boolean(configuration.compilerOptions.incremental || configuration.compilerOptions.composite);
|
|
26
|
+
const args = [
|
|
27
|
+
'--project',
|
|
28
|
+
tsConfigPath,
|
|
29
|
+
'--noEmit',
|
|
30
|
+
'--declarationMap',
|
|
31
|
+
'false',
|
|
32
|
+
'--emitDeclarationOnly',
|
|
33
|
+
'false'
|
|
34
|
+
];
|
|
35
|
+
if (incremental && cacheDir) {
|
|
36
|
+
args.push('--tsBuildInfoFile', _nodepath.default.join(cacheDir, '.tsbuildinfo'));
|
|
37
|
+
}
|
|
38
|
+
const result = await (0, _runTypeScriptCli.runTypeScriptCli)({
|
|
39
|
+
cwd: baseDir,
|
|
40
|
+
tscPath,
|
|
41
|
+
args,
|
|
42
|
+
onFirstOutput
|
|
43
|
+
});
|
|
44
|
+
if (result.exitCode !== 0) {
|
|
45
|
+
throw new _compileerror.CompileError();
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
hasWarnings: false,
|
|
49
|
+
incremental
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=runTypeCheckCli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/typescript/runTypeCheckCli.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { CompileError } from '../compile-error'\nimport type { TypeCheckResult } from './runTypeCheck'\nimport {\n getTypeScriptConfigurationCli,\n runTypeScriptCli,\n} from './runTypeScriptCli'\n\nexport async function runTypeCheckCli({\n baseDir,\n tsConfigPath,\n tscPath,\n cacheDir,\n onFirstOutput,\n}: {\n baseDir: string\n tsConfigPath: string\n tscPath: string\n cacheDir?: string\n /**\n * Called once when `tsc` first produces output. Used to stop the build\n * spinner so it does not sit above the diagnostics.\n */\n onFirstOutput?: () => void\n}): Promise<TypeCheckResult> {\n const configuration = await getTypeScriptConfigurationCli({\n baseDir,\n tsConfigPath,\n tscPath,\n })\n const incremental = Boolean(\n configuration.compilerOptions.incremental ||\n configuration.compilerOptions.composite\n )\n const args = [\n '--project',\n tsConfigPath,\n '--noEmit',\n '--declarationMap',\n 'false',\n '--emitDeclarationOnly',\n 'false',\n ]\n\n if (incremental && cacheDir) {\n args.push('--tsBuildInfoFile', path.join(cacheDir, '.tsbuildinfo'))\n }\n\n const result = await runTypeScriptCli({\n cwd: baseDir,\n tscPath,\n args,\n onFirstOutput,\n })\n\n if (result.exitCode !== 0) {\n throw new CompileError()\n }\n\n return {\n hasWarnings: false,\n incremental,\n }\n}\n"],"names":["runTypeCheckCli","baseDir","tsConfigPath","tscPath","cacheDir","onFirstOutput","configuration","getTypeScriptConfigurationCli","incremental","Boolean","compilerOptions","composite","args","push","path","join","result","runTypeScriptCli","cwd","exitCode","CompileError","hasWarnings"],"mappings":";;;;+BASsBA;;;eAAAA;;;iEATL;8BAEY;kCAKtB;;;;;;AAEA,eAAeA,gBAAgB,EACpCC,OAAO,EACPC,YAAY,EACZC,OAAO,EACPC,QAAQ,EACRC,aAAa,EAWd;IACC,MAAMC,gBAAgB,MAAMC,IAAAA,+CAA6B,EAAC;QACxDN;QACAC;QACAC;IACF;IACA,MAAMK,cAAcC,QAClBH,cAAcI,eAAe,CAACF,WAAW,IACvCF,cAAcI,eAAe,CAACC,SAAS;IAE3C,MAAMC,OAAO;QACX;QACAV;QACA;QACA;QACA;QACA;QACA;KACD;IAED,IAAIM,eAAeJ,UAAU;QAC3BQ,KAAKC,IAAI,CAAC,qBAAqBC,iBAAI,CAACC,IAAI,CAACX,UAAU;IACrD;IAEA,MAAMY,SAAS,MAAMC,IAAAA,kCAAgB,EAAC;QACpCC,KAAKjB;QACLE;QACAS;QACAP;IACF;IAEA,IAAIW,OAAOG,QAAQ,KAAK,GAAG;QACzB,MAAM,IAAIC,0BAAY;IACxB;IAEA,OAAO;QACLC,aAAa;QACbb;IACF;AACF","ignoreList":[0]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface TypeScriptPackageInfo {
|
|
2
|
+
packageJsonPath: string;
|
|
3
|
+
packageDir: string;
|
|
4
|
+
version: string;
|
|
5
|
+
apiPath?: string;
|
|
6
|
+
tscPath?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getTypeScriptPackageInfo(baseDir: string): TypeScriptPackageInfo | null;
|
|
9
|
+
export declare function hasNativeTypeScriptPreview(baseDir: string): boolean;
|
|
10
|
+
export declare function getTypeScriptApiMissingError(version: string): Error;
|
|
11
|
+
export interface TypeScriptCliResult {
|
|
12
|
+
exitCode: number;
|
|
13
|
+
signal: NodeJS.Signals | null;
|
|
14
|
+
stdout: string;
|
|
15
|
+
stderr: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function runTypeScriptCli({ cwd, tscPath, args, captureOutput, onFirstOutput, }: {
|
|
18
|
+
cwd: string;
|
|
19
|
+
tscPath: string;
|
|
20
|
+
args: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Accumulate stdout/stderr into the resolved result instead of forwarding it
|
|
23
|
+
* to this process's stdout/stderr (for e.g. parsing `--showConfig` output).
|
|
24
|
+
*/
|
|
25
|
+
captureOutput?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Called once, on the first chunk of forwarded output. Used to stop the build
|
|
28
|
+
* spinner before `tsc`'s diagnostics appear. Not called when capturing.
|
|
29
|
+
*/
|
|
30
|
+
onFirstOutput?: () => void;
|
|
31
|
+
}): Promise<TypeScriptCliResult>;
|
|
32
|
+
export declare function getTypeScriptConfigurationCli({ baseDir, tsConfigPath, tscPath, }: {
|
|
33
|
+
baseDir: string;
|
|
34
|
+
tsConfigPath: string;
|
|
35
|
+
tscPath: string;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
compilerOptions: Record<string, any>;
|
|
38
|
+
}>;
|