next 16.1.0-canary.3 → 16.1.0-canary.4
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/bin/next +2 -2
- package/dist/build/index.js +3 -3
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +2 -2
- 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._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._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/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/pages-api.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages-api.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.prod.js +1 -1
- package/dist/compiled/next-server/pages.runtime.prod.js.map +1 -1
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/lib/typescript/runTypeCheck.js +18 -5
- package/dist/esm/lib/typescript/runTypeCheck.js.map +1 -1
- package/dist/esm/lib/typescript/type-paths.js +37 -0
- package/dist/esm/lib/typescript/type-paths.js.map +1 -0
- package/dist/esm/lib/typescript/writeConfigurationDefaults.js +6 -17
- package/dist/esm/lib/typescript/writeConfigurationDefaults.js.map +1 -1
- package/dist/esm/lib/verify-typescript-setup.js +1 -1
- package/dist/esm/lib/verify-typescript-setup.js.map +1 -1
- package/dist/esm/server/config.js +2 -2
- package/dist/esm/server/config.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- 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/start-server.js +1 -1
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/lib/typescript/runTypeCheck.d.ts +1 -1
- package/dist/lib/typescript/runTypeCheck.js +18 -5
- package/dist/lib/typescript/runTypeCheck.js.map +1 -1
- package/dist/lib/typescript/type-paths.d.ts +12 -0
- package/dist/lib/typescript/type-paths.js +56 -0
- package/dist/lib/typescript/type-paths.js.map +1 -0
- package/dist/lib/typescript/writeConfigurationDefaults.js +6 -17
- package/dist/lib/typescript/writeConfigurationDefaults.js.map +1 -1
- package/dist/lib/verify-typescript-setup.js +1 -1
- package/dist/lib/verify-typescript-setup.js.map +1 -1
- package/dist/server/config.js +2 -2
- package/dist/server/config.js.map +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +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/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
- /package/dist/bundle-analyzer/_next/static/{TnRZ8nGbopg18HtVsbM43 → Aod3729un5YGDrF2l8UjT}/_buildManifest.js +0 -0
- /package/dist/bundle-analyzer/_next/static/{TnRZ8nGbopg18HtVsbM43 → Aod3729un5YGDrF2l8UjT}/_clientMiddlewareManifest.json +0 -0
- /package/dist/bundle-analyzer/_next/static/{TnRZ8nGbopg18HtVsbM43 → Aod3729un5YGDrF2l8UjT}/_ssgManifest.js +0 -0
|
@@ -12,16 +12,29 @@ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
|
12
12
|
const _diagnosticFormatter = require("./diagnosticFormatter");
|
|
13
13
|
const _getTypeScriptConfiguration = require("./getTypeScriptConfiguration");
|
|
14
14
|
const _writeConfigurationDefaults = require("./writeConfigurationDefaults");
|
|
15
|
+
const _typepaths = require("./type-paths");
|
|
15
16
|
const _compileerror = require("../compile-error");
|
|
16
17
|
const _log = require("../../build/output/log");
|
|
18
|
+
const _configshared = require("../../server/config-shared");
|
|
17
19
|
function _interop_require_default(obj) {
|
|
18
20
|
return obj && obj.__esModule ? obj : {
|
|
19
21
|
default: obj
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
|
-
async function runTypeCheck(typescript, baseDir, distDir, tsConfigPath, cacheDir, isAppDirEnabled) {
|
|
24
|
+
async function runTypeCheck(typescript, baseDir, distDir, tsConfigPath, cacheDir, isAppDirEnabled, isolatedDevBuild) {
|
|
23
25
|
const effectiveConfiguration = await (0, _getTypeScriptConfiguration.getTypeScriptConfiguration)(typescript, tsConfigPath);
|
|
24
|
-
|
|
26
|
+
// When isolatedDevBuild is enabled, tsconfig includes both .next/types and
|
|
27
|
+
// .next/dev/types to avoid config churn between dev/build modes. During build,
|
|
28
|
+
// we filter out .next/dev/types files to prevent stale dev types from causing
|
|
29
|
+
// errors when routes have been deleted since the last dev session.
|
|
30
|
+
let fileNames = effectiveConfiguration.fileNames;
|
|
31
|
+
const resolvedIsolatedDevBuild = isolatedDevBuild === undefined ? _configshared.defaultConfig.experimental.isolatedDevBuild : isolatedDevBuild;
|
|
32
|
+
// Get the dev types path to filter (null if not applicable)
|
|
33
|
+
const devTypesDir = (0, _typepaths.getDevTypesPath)(baseDir, distDir, resolvedIsolatedDevBuild);
|
|
34
|
+
if (devTypesDir) {
|
|
35
|
+
fileNames = fileNames.filter((fileName)=>!fileName.startsWith(devTypesDir));
|
|
36
|
+
}
|
|
37
|
+
if (fileNames.length < 1) {
|
|
25
38
|
return {
|
|
26
39
|
hasWarnings: false,
|
|
27
40
|
inputFilesCount: 0,
|
|
@@ -45,7 +58,7 @@ async function runTypeCheck(typescript, baseDir, distDir, tsConfigPath, cacheDir
|
|
|
45
58
|
}
|
|
46
59
|
incremental = true;
|
|
47
60
|
program = typescript.createIncrementalProgram({
|
|
48
|
-
rootNames:
|
|
61
|
+
rootNames: fileNames,
|
|
49
62
|
options: {
|
|
50
63
|
...options,
|
|
51
64
|
composite: false,
|
|
@@ -54,7 +67,7 @@ async function runTypeCheck(typescript, baseDir, distDir, tsConfigPath, cacheDir
|
|
|
54
67
|
}
|
|
55
68
|
});
|
|
56
69
|
} else {
|
|
57
|
-
program = typescript.createProgram(
|
|
70
|
+
program = typescript.createProgram(fileNames, options);
|
|
58
71
|
}
|
|
59
72
|
const result = program.emit();
|
|
60
73
|
const ignoreRegex = [
|
|
@@ -86,7 +99,7 @@ async function runTypeCheck(typescript, baseDir, distDir, tsConfigPath, cacheDir
|
|
|
86
99
|
return {
|
|
87
100
|
hasWarnings: true,
|
|
88
101
|
warnings,
|
|
89
|
-
inputFilesCount:
|
|
102
|
+
inputFilesCount: fileNames.length,
|
|
90
103
|
totalFilesCount: program.getSourceFiles().length,
|
|
91
104
|
incremental
|
|
92
105
|
};
|
|
@@ -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'\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 async function runTypeCheck(\n typescript: typeof import('typescript'),\n baseDir: string,\n distDir: string,\n tsConfigPath: string,\n cacheDir?: string,\n isAppDirEnabled?: boolean\n): Promise<TypeCheckResult> {\n const effectiveConfiguration = await getTypeScriptConfiguration(\n typescript,\n tsConfigPath\n )\n\n if (
|
|
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'\nimport { defaultConfig } from '../../server/config-shared'\n\nexport interface TypeCheckResult {\n hasWarnings: boolean\n warnings?: string[]\n inputFilesCount: number\n totalFilesCount: number\n incremental: boolean\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 isolatedDevBuild?: boolean\n): Promise<TypeCheckResult> {\n const effectiveConfiguration = await getTypeScriptConfiguration(\n typescript,\n tsConfigPath\n )\n\n // When isolatedDevBuild is enabled, tsconfig includes both .next/types and\n // .next/dev/types to avoid config churn between dev/build modes. During build,\n // we filter out .next/dev/types files to prevent stale dev types from causing\n // errors when routes have been deleted since the last dev session.\n let fileNames = effectiveConfiguration.fileNames\n const resolvedIsolatedDevBuild =\n isolatedDevBuild === undefined\n ? defaultConfig.experimental.isolatedDevBuild\n : isolatedDevBuild\n\n // Get the dev types path to filter (null if not applicable)\n const devTypesDir = getDevTypesPath(\n baseDir,\n distDir,\n resolvedIsolatedDevBuild\n )\n if (devTypesDir) {\n fileNames = fileNames.filter(\n (fileName) => !fileName.startsWith(devTypesDir)\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","typescript","baseDir","distDir","tsConfigPath","cacheDir","isAppDirEnabled","isolatedDevBuild","effectiveConfiguration","getTypeScriptConfiguration","fileNames","resolvedIsolatedDevBuild","undefined","defaultConfig","experimental","devTypesDir","getDevTypesPath","filter","fileName","startsWith","length","hasWarnings","inputFilesCount","totalFilesCount","incremental","requiredConfig","getRequiredConfiguration","options","declarationMap","emitDeclarationOnly","noEmit","program","composite","warn","createIncrementalProgram","rootNames","tsBuildInfoFile","path","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":";;;;+BAkBsBA;;;eAAAA;;;6DAlBL;qCACsB;4CACI;4CACF;2BACT;8BAEH;qBACR;8BACS;;;;;;AAUvB,eAAeA,aACpBC,UAAuC,EACvCC,OAAe,EACfC,OAAe,EACfC,YAAoB,EACpBC,QAAiB,EACjBC,eAAyB,EACzBC,gBAA0B;IAE1B,MAAMC,yBAAyB,MAAMC,IAAAA,sDAA0B,EAC7DR,YACAG;IAGF,2EAA2E;IAC3E,+EAA+E;IAC/E,8EAA8E;IAC9E,mEAAmE;IACnE,IAAIM,YAAYF,uBAAuBE,SAAS;IAChD,MAAMC,2BACJJ,qBAAqBK,YACjBC,2BAAa,C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0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the glob patterns for type definition directories in tsconfig.
|
|
3
|
+
* When isolatedDevBuild is enabled, Next.js uses different distDir paths:
|
|
4
|
+
* - Development: "{distDir}/dev"
|
|
5
|
+
* - Production: "{distDir}"
|
|
6
|
+
*/
|
|
7
|
+
export declare function getTypeDefinitionGlobPatterns(distDir: string, isolatedDevBuild: boolean): string[];
|
|
8
|
+
/**
|
|
9
|
+
* Gets the absolute path to the dev types directory for filtering during type-checking.
|
|
10
|
+
* Returns null if isolatedDevBuild is disabled or in dev mode (where dev types are the main types).
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDevTypesPath(baseDir: string, distDir: string, isolatedDevBuild: boolean): string | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
getDevTypesPath: null,
|
|
7
|
+
getTypeDefinitionGlobPatterns: null
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: all[name]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
getDevTypesPath: function() {
|
|
17
|
+
return getDevTypesPath;
|
|
18
|
+
},
|
|
19
|
+
getTypeDefinitionGlobPatterns: function() {
|
|
20
|
+
return getTypeDefinitionGlobPatterns;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
24
|
+
function _interop_require_default(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function getTypeDefinitionGlobPatterns(distDir, isolatedDevBuild) {
|
|
30
|
+
const distDirPosix = _path.default.win32.sep === _path.default.sep ? distDir.replaceAll(_path.default.win32.sep, _path.default.posix.sep) : distDir;
|
|
31
|
+
const typeGlobPatterns = [
|
|
32
|
+
`${distDirPosix}/types/**/*.ts`
|
|
33
|
+
];
|
|
34
|
+
// When isolatedDevBuild is enabled, include both .next/types and .next/dev/types
|
|
35
|
+
// to avoid tsconfig churn when switching between dev/build modes
|
|
36
|
+
if (isolatedDevBuild) {
|
|
37
|
+
typeGlobPatterns.push(process.env.NODE_ENV === 'development' ? `${distDirPosix.replace(/\/dev$/, '')}/types/**/*.ts` : `${distDirPosix}/dev/types/**/*.ts`);
|
|
38
|
+
// Sort for consistent order
|
|
39
|
+
typeGlobPatterns.sort((a, b)=>a.length - b.length);
|
|
40
|
+
}
|
|
41
|
+
return typeGlobPatterns;
|
|
42
|
+
}
|
|
43
|
+
function getDevTypesPath(baseDir, distDir, isolatedDevBuild) {
|
|
44
|
+
if (!isolatedDevBuild) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
48
|
+
if (isDev) {
|
|
49
|
+
// In dev mode, dev types are the main types, so no need to filter
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
// In build mode, dev types are at "{baseDir}/{distDir}/dev/types" and should be filtered
|
|
53
|
+
return _path.default.join(baseDir, distDir, 'dev', 'types');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=type-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/typescript/type-paths.ts"],"sourcesContent":["import path from 'path'\n\n/**\n * Gets the glob patterns for type definition directories in tsconfig.\n * When isolatedDevBuild is enabled, Next.js uses different distDir paths:\n * - Development: \"{distDir}/dev\"\n * - Production: \"{distDir}\"\n */\nexport function getTypeDefinitionGlobPatterns(\n distDir: string,\n isolatedDevBuild: boolean\n): string[] {\n const distDirPosix =\n path.win32.sep === path.sep\n ? distDir.replaceAll(path.win32.sep, path.posix.sep)\n : distDir\n\n const typeGlobPatterns: string[] = [`${distDirPosix}/types/**/*.ts`]\n\n // When isolatedDevBuild is enabled, include both .next/types and .next/dev/types\n // to avoid tsconfig churn when switching between dev/build modes\n if (isolatedDevBuild) {\n typeGlobPatterns.push(\n process.env.NODE_ENV === 'development'\n ? // In dev, distDir is \"{distDir}/dev\", so also include \"{distDir}/types\"\n `${distDirPosix.replace(/\\/dev$/, '')}/types/**/*.ts`\n : // In build, distDir is \"{distDir}\", so also include \"{distDir}/dev/types\"\n `${distDirPosix}/dev/types/**/*.ts`\n )\n // Sort for consistent order\n typeGlobPatterns.sort((a, b) => a.length - b.length)\n }\n\n return typeGlobPatterns\n}\n\n/**\n * Gets the absolute path to the dev types directory for filtering during type-checking.\n * Returns null if isolatedDevBuild is disabled or in dev mode (where dev types are the main types).\n */\nexport function getDevTypesPath(\n baseDir: string,\n distDir: string,\n isolatedDevBuild: boolean\n): string | null {\n if (!isolatedDevBuild) {\n return null\n }\n\n const isDev = process.env.NODE_ENV === 'development'\n if (isDev) {\n // In dev mode, dev types are the main types, so no need to filter\n return null\n }\n\n // In build mode, dev types are at \"{baseDir}/{distDir}/dev/types\" and should be filtered\n return path.join(baseDir, distDir, 'dev', 'types')\n}\n"],"names":["getDevTypesPath","getTypeDefinitionGlobPatterns","distDir","isolatedDevBuild","distDirPosix","path","win32","sep","replaceAll","posix","typeGlobPatterns","push","process","env","NODE_ENV","replace","sort","a","b","length","baseDir","isDev","join"],"mappings":";;;;;;;;;;;;;;;IAwCgBA,eAAe;eAAfA;;IAhCAC,6BAA6B;eAA7BA;;;6DARC;;;;;;AAQV,SAASA,8BACdC,OAAe,EACfC,gBAAyB;IAEzB,MAAMC,eACJC,aAAI,CAACC,KAAK,CAACC,GAAG,KAAKF,aAAI,CAACE,GAAG,GACvBL,QAAQM,UAAU,CAACH,aAAI,CAACC,KAAK,CAACC,GAAG,EAAEF,aAAI,CAACI,KAAK,CAACF,GAAG,IACjDL;IAEN,MAAMQ,mBAA6B;QAAC,GAAGN,aAAa,cAAc,CAAC;KAAC;IAEpE,iFAAiF;IACjF,iEAAiE;IACjE,IAAID,kBAAkB;QACpBO,iBAAiBC,IAAI,CACnBC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBAErB,GAAGV,aAAaW,OAAO,CAAC,UAAU,IAAI,cAAc,CAAC,GAErD,GAAGX,aAAa,kBAAkB,CAAC;QAEzC,4BAA4B;QAC5BM,iBAAiBM,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEE,MAAM,GAAGD,EAAEC,MAAM;IACrD;IAEA,OAAOT;AACT;AAMO,SAASV,gBACdoB,OAAe,EACflB,OAAe,EACfC,gBAAyB;IAEzB,IAAI,CAACA,kBAAkB;QACrB,OAAO;IACT;IAEA,MAAMkB,QAAQT,QAAQC,GAAG,CAACC,QAAQ,KAAK;IACvC,IAAIO,OAAO;QACT,kEAAkE;QAClE,OAAO;IACT;IAEA,yFAAyF;IACzF,OAAOhB,aAAI,CAACiB,IAAI,CAACF,SAASlB,SAAS,OAAO;AAC5C","ignoreList":[0]}
|
|
@@ -21,12 +21,13 @@ _export(exports, {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _fs = require("fs");
|
|
24
|
-
const _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
|
25
24
|
const _picocolors = require("../picocolors");
|
|
26
25
|
const _commentjson = /*#__PURE__*/ _interop_require_wildcard(require("next/dist/compiled/comment-json"));
|
|
27
26
|
const _semver = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/semver"));
|
|
28
27
|
const _os = /*#__PURE__*/ _interop_require_default(require("os"));
|
|
28
|
+
const _typepaths = require("./type-paths");
|
|
29
29
|
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../build/output/log"));
|
|
30
|
+
const _configshared = require("../../server/config-shared");
|
|
30
31
|
function _interop_require_default(obj) {
|
|
31
32
|
return obj && obj.__esModule ? obj : {
|
|
32
33
|
default: obj
|
|
@@ -279,22 +280,10 @@ async function writeConfigurationDefaults(typescriptVersion, tsConfigPath, isFir
|
|
|
279
280
|
const _ = check;
|
|
280
281
|
}
|
|
281
282
|
}
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
// When isolatedDevBuild is enabled, Next.js uses different distDir paths:
|
|
287
|
-
// - Development: "{distDir}/dev"
|
|
288
|
-
// - Production: "{distDir}"
|
|
289
|
-
// To prevent tsconfig updates when switching between dev/build modes,
|
|
290
|
-
// we proactively include both type paths regardless of current environment.
|
|
291
|
-
if (isolatedDevBuild !== false) {
|
|
292
|
-
nextAppTypes.push(process.env.NODE_ENV === 'development' ? // Here we remove "/dev" at the end of distDir for consistency.
|
|
293
|
-
`${distDirPosix.replace(/\/dev$/, '')}/types/**/*.ts` : // Here we add "/dev" at the end of distDir for consistency.
|
|
294
|
-
`${distDirPosix}/dev/types/**/*.ts`);
|
|
295
|
-
// Sort the array to ensure consistent order.
|
|
296
|
-
nextAppTypes.sort((a, b)=>a.length - b.length);
|
|
297
|
-
}
|
|
283
|
+
const resolvedIsolatedDevBuild = isolatedDevBuild === undefined ? _configshared.defaultConfig.experimental.isolatedDevBuild : isolatedDevBuild;
|
|
284
|
+
// Get type definition glob patterns using shared utility to ensure consistency
|
|
285
|
+
// with other TypeScript infrastructure (e.g., runTypeCheck.ts)
|
|
286
|
+
const nextAppTypes = (0, _typepaths.getTypeDefinitionGlobPatterns)(distDir, resolvedIsolatedDevBuild);
|
|
298
287
|
if (!('include' in userTsConfig)) {
|
|
299
288
|
userTsConfig.include = hasAppDir ? [
|
|
300
289
|
'next-env.d.ts',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/typescript/writeConfigurationDefaults.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'fs'\nimport * as path from 'path'\nimport { bold, cyan, white } from '../picocolors'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\nimport semver from 'next/dist/compiled/semver'\nimport os from 'os'\nimport type { CompilerOptions } from 'typescript'\nimport * as Log from '../../build/output/log'\n\ntype DesiredCompilerOptionsShape = {\n [K in keyof CompilerOptions]:\n | { suggested: any; reason?: string }\n | {\n parsedValue?: any\n parsedValues?: Array<any>\n value: any\n reason: string\n }\n}\n\nfunction getDesiredCompilerOptions(\n typescriptVersion: string,\n userTsConfig?: Record<string, any>\n): DesiredCompilerOptionsShape {\n // ModuleKind\n const moduleKindESNext = 'esnext'\n const moduleKindES2020 = 'es2020'\n const moduleKindPreserve = 'preserve'\n const moduleKindNodeNext = 'nodenext'\n const moduleKindNode16 = 'node16'\n const moduleKindCommonJS = 'commonjs'\n const moduleKindAMD = 'amd'\n\n // ModuleResolutionKind\n const moduleResolutionKindBundler = 'bundler'\n const moduleResolutionKindNode10 = 'node10'\n const moduleResolutionKindNode12 = 'node12'\n const moduleResolutionKindNodeJs = 'node'\n\n // Jsx\n const jsxEmitReactJSX = 'react-jsx'\n\n return {\n target: {\n suggested: 'ES2017',\n reason:\n 'For top-level `await`. Note: Next.js only polyfills for the esmodules target.',\n },\n // These are suggested values and will be set when not present in the\n // tsconfig.json\n lib: { suggested: ['dom', 'dom.iterable', 'esnext'] },\n allowJs: { suggested: true },\n skipLibCheck: { suggested: true },\n strict: { suggested: false },\n noEmit: { suggested: true },\n incremental: { suggested: true },\n\n // These values are required and cannot be changed by the user\n // Keep this in sync with the webpack config\n // 'parsedValue' matches the output value from ts.parseJsonConfigFileContent()\n module: {\n parsedValue: moduleKindESNext,\n // All of these values work:\n parsedValues: [\n semver.gte(typescriptVersion, '5.4.0') && moduleKindPreserve,\n moduleKindES2020,\n moduleKindESNext,\n moduleKindCommonJS,\n moduleKindAMD,\n moduleKindNodeNext,\n moduleKindNode16,\n ],\n value: 'esnext',\n reason: 'for dynamic import() support',\n },\n // TODO: Semver check not needed once Next.js repo uses 5.4.\n ...(semver.gte(typescriptVersion, '5.4.0') &&\n userTsConfig?.compilerOptions?.module?.toLowerCase() === moduleKindPreserve\n ? {\n // TypeScript 5.4 introduced `Preserve`. Using `Preserve` implies\n // - `moduleResolution` is `Bundler`\n // - `esModuleInterop` is `true`\n // - `resolveJsonModule` is `true`\n // This means that if the user is using Preserve, they don't need these options\n }\n : {\n esModuleInterop: {\n value: true,\n reason: 'requirement for SWC / babel',\n },\n moduleResolution: {\n // In TypeScript 5.0, `NodeJs` has renamed to `Node10`\n parsedValue: moduleResolutionKindBundler,\n // All of these values work:\n parsedValues: [\n moduleResolutionKindNode10,\n moduleResolutionKindNodeJs,\n // only newer TypeScript versions have this field, it\n // will be filtered for new versions of TypeScript\n moduleResolutionKindNode12,\n moduleKindNode16,\n moduleKindNodeNext,\n moduleResolutionKindBundler,\n ].filter((val) => typeof val !== 'undefined'),\n value: 'node',\n reason: 'to match webpack resolution',\n },\n resolveJsonModule: {\n value: true,\n reason: 'to match webpack resolution',\n },\n }),\n ...(userTsConfig?.compilerOptions?.verbatimModuleSyntax === true\n ? undefined\n : {\n isolatedModules: {\n value: true,\n reason: 'requirement for SWC / Babel',\n },\n }),\n jsx: {\n parsedValue: jsxEmitReactJSX,\n value: 'react-jsx',\n reason: 'next.js uses the React automatic runtime',\n },\n } satisfies DesiredCompilerOptionsShape\n}\n\nexport function getRequiredConfiguration(\n typescript: typeof import('typescript')\n): Partial<import('typescript').CompilerOptions> {\n const res: Partial<import('typescript').CompilerOptions> = {}\n const typescriptVersion = typescript.version\n\n const desiredCompilerOptions = getDesiredCompilerOptions(typescriptVersion)\n for (const optionKey of Object.keys(desiredCompilerOptions)) {\n const ev = desiredCompilerOptions[optionKey]\n if (!('value' in ev)) {\n continue\n }\n\n const value = ev.parsedValue ?? ev.value\n\n // Convert string values back to TypeScript enum values\n if (optionKey === 'module' && typeof value === 'string') {\n const moduleMap: Record<string, import('typescript').ModuleKind> = {\n esnext: typescript.ModuleKind.ESNext,\n es2020: typescript.ModuleKind.ES2020,\n ...(typescript.ModuleKind.Preserve !== undefined\n ? { preserve: typescript.ModuleKind.Preserve }\n : {}),\n nodenext: typescript.ModuleKind.NodeNext,\n node16: typescript.ModuleKind.Node16,\n commonjs: typescript.ModuleKind.CommonJS,\n amd: typescript.ModuleKind.AMD,\n }\n res[optionKey] = moduleMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'moduleResolution' && typeof value === 'string') {\n const moduleResolutionMap: Record<\n string,\n import('typescript').ModuleResolutionKind\n > = {\n bundler: typescript.ModuleResolutionKind.Bundler,\n node10: typescript.ModuleResolutionKind.Node10,\n node12: (typescript.ModuleResolutionKind as any).Node12,\n node: typescript.ModuleResolutionKind.NodeJs,\n }\n res[optionKey] = moduleResolutionMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'jsx' && typeof value === 'string') {\n const jsxMap: Record<string, import('typescript').JsxEmit> = {\n 'react-jsx': typescript.JsxEmit.ReactJSX,\n }\n res[optionKey] = jsxMap[value.toLowerCase()] ?? value\n } else {\n res[optionKey] = value\n }\n }\n\n return res\n}\n\nconst localDevTestFilesExcludeAction =\n 'NEXT_PRIVATE_LOCAL_DEV_TEST_FILES_EXCLUDE'\n\nexport async function writeConfigurationDefaults(\n typescriptVersion: string,\n tsConfigPath: string,\n isFirstTimeSetup: boolean,\n hasAppDir: boolean,\n distDir: string,\n hasPagesDir: boolean,\n isolatedDevBuild: boolean | undefined\n): Promise<void> {\n if (isFirstTimeSetup) {\n writeFileSync(tsConfigPath, '{}' + os.EOL)\n }\n\n const userTsConfigContent = readFileSync(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = CommentJson.parse(userTsConfigContent)\n\n // Bail automatic setup when the user has extended or referenced another config\n if ('extends' in userTsConfig || 'references' in userTsConfig) {\n return\n }\n\n if (userTsConfig?.compilerOptions == null) {\n userTsConfig.compilerOptions = {}\n isFirstTimeSetup = true\n }\n\n const desiredCompilerOptions = getDesiredCompilerOptions(\n typescriptVersion,\n userTsConfig\n )\n\n const suggestedActions: string[] = []\n const requiredActions: string[] = []\n for (const optionKey in desiredCompilerOptions) {\n const check = desiredCompilerOptions[optionKey]\n if ('suggested' in check) {\n if (!(optionKey in userTsConfig?.compilerOptions)) {\n userTsConfig.compilerOptions[optionKey] = check.suggested\n suggestedActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.suggested) +\n (check.reason ? ` (${check.reason})` : '')\n )\n }\n } else if ('value' in check) {\n let existingValue = userTsConfig?.compilerOptions?.[optionKey]\n\n if (typeof existingValue === 'string') {\n existingValue = existingValue.toLowerCase()\n }\n\n const shouldWriteRequiredValue = () => {\n // Check if the option has multiple allowed values\n if (check.parsedValues) {\n return !check.parsedValues.includes(existingValue)\n }\n\n // Check if the option has a single parsed value\n if (check.parsedValue) {\n return check.parsedValue !== existingValue\n }\n\n // Fall back to direct value comparison\n return check.value !== existingValue\n }\n\n if (shouldWriteRequiredValue()) {\n if (!userTsConfig.compilerOptions) {\n userTsConfig.compilerOptions = {}\n }\n userTsConfig.compilerOptions[optionKey] = check.value\n requiredActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.value) +\n ` (${check.reason})`\n )\n }\n } else {\n const _: never = check\n }\n }\n\n const distDirPosix =\n path.win32.sep === path.sep\n ? distDir.replaceAll(path.win32.sep, path.posix.sep)\n : distDir\n const nextAppTypes: string[] = [`${distDirPosix}/types/**/*.ts`]\n\n // When isolatedDevBuild is enabled, Next.js uses different distDir paths:\n // - Development: \"{distDir}/dev\"\n // - Production: \"{distDir}\"\n // To prevent tsconfig updates when switching between dev/build modes,\n // we proactively include both type paths regardless of current environment.\n if (isolatedDevBuild !== false) {\n nextAppTypes.push(\n process.env.NODE_ENV === 'development'\n ? // In dev, distDir is \"{distDir}/dev\", which is already in the array above, but we also need \"{distDir}/types\".\n // Here we remove \"/dev\" at the end of distDir for consistency.\n `${distDirPosix.replace(/\\/dev$/, '')}/types/**/*.ts`\n : // In build, distDir is \"{distDir}\", which is already in the array above, but we also need \"{distDir}/dev/types\".\n // Here we add \"/dev\" at the end of distDir for consistency.\n `${distDirPosix}/dev/types/**/*.ts`\n )\n // Sort the array to ensure consistent order.\n nextAppTypes.sort((a, b) => a.length - b.length)\n }\n\n if (!('include' in userTsConfig)) {\n userTsConfig.include = hasAppDir\n ? ['next-env.d.ts', ...nextAppTypes, '**/*.mts', '**/*.ts', '**/*.tsx']\n : ['next-env.d.ts', '**/*.mts', '**/*.ts', '**/*.tsx']\n suggestedActions.push(\n cyan('include') +\n ' was set to ' +\n bold(\n hasAppDir\n ? `['next-env.d.ts', ${nextAppTypes.map((type) => `'${type}'`).join(', ')}, '**/*.mts', '**/*.ts', '**/*.tsx']`\n : `['next-env.d.ts', '**/*.mts', '**/*.ts', '**/*.tsx']`\n )\n )\n } else if (hasAppDir) {\n const missingFromResolved = []\n for (const type of nextAppTypes) {\n if (!userTsConfig.include.includes(type)) {\n missingFromResolved.push(type)\n }\n }\n\n if (missingFromResolved.length > 0) {\n if (!Array.isArray(userTsConfig.include)) {\n userTsConfig.include = []\n }\n\n missingFromResolved.forEach((item) => {\n userTsConfig.include.push(item)\n suggestedActions.push(\n cyan('include') + ' was updated to add ' + bold(`'${item}'`)\n )\n })\n }\n }\n\n // Enable the Next.js typescript plugin.\n if (hasAppDir) {\n // Check if the config or the resolved config has the plugin already.\n const plugins = [\n ...(Array.isArray(userTsConfig?.plugins) ? userTsConfig.plugins : []),\n ...(userTsConfig.compilerOptions &&\n Array.isArray(userTsConfig.compilerOptions.plugins)\n ? userTsConfig.compilerOptions.plugins\n : []),\n ]\n const hasNextPlugin = plugins.some(\n ({ name }: { name: string }) => name === 'next'\n )\n\n // If the TS config extends on another config, we can't add the `plugin` field\n // because that will override the parent config's plugins.\n // Instead we have to show a message to the user to add the plugin manually.\n if (\n !userTsConfig.compilerOptions ||\n (plugins.length &&\n !hasNextPlugin &&\n 'extends' in userTsConfig &&\n (!userTsConfig.compilerOptions ||\n !userTsConfig.compilerOptions.plugins))\n ) {\n Log.info(\n `\\nYour ${bold(\n 'tsconfig.json'\n )} extends another configuration, which means we cannot add the Next.js TypeScript plugin automatically. To improve your development experience, we recommend adding the Next.js plugin (\\`${cyan(\n '\"plugins\": [{ \"name\": \"next\" }]'\n )}\\`) manually to your TypeScript configuration. Learn more: https://nextjs.org/docs/app/api-reference/config/typescript#the-typescript-plugin\\n`\n )\n } else if (!hasNextPlugin) {\n if (!('plugins' in userTsConfig.compilerOptions)) {\n userTsConfig.compilerOptions.plugins = []\n }\n userTsConfig.compilerOptions.plugins.push({ name: 'next' })\n suggestedActions.push(\n cyan('plugins') + ' was updated to add ' + bold(`{ name: 'next' }`)\n )\n }\n\n // If `strict` is set to `false` and `strictNullChecks` is set to `false`,\n // then set `strictNullChecks` to `true`.\n if (\n hasPagesDir &&\n hasAppDir &&\n !userTsConfig?.compilerOptions?.strict &&\n !('strictNullChecks' in userTsConfig?.compilerOptions)\n ) {\n userTsConfig.compilerOptions.strictNullChecks = true\n suggestedActions.push(\n cyan('strictNullChecks') + ' was set to ' + bold(`true`)\n )\n }\n }\n\n if (!('exclude' in userTsConfig)) {\n userTsConfig.exclude = ['node_modules']\n suggestedActions.push(\n cyan('exclude') + ' was set to ' + bold(`['node_modules']`)\n )\n }\n\n // During local development inside Next.js repo, exclude the test files coverage by the local tsconfig\n if (process.env.NEXT_PRIVATE_LOCAL_DEV && userTsConfig.exclude) {\n const tsGlob = '**/*.test.ts'\n const tsxGlob = '**/*.test.tsx'\n let hasUpdates = false\n if (!userTsConfig.exclude.includes(tsGlob)) {\n userTsConfig.exclude.push(tsGlob)\n hasUpdates = true\n }\n if (!userTsConfig.exclude.includes(tsxGlob)) {\n userTsConfig.exclude.push(tsxGlob)\n hasUpdates = true\n }\n\n if (hasUpdates) {\n requiredActions.push(localDevTestFilesExcludeAction)\n }\n }\n\n if (suggestedActions.length < 1 && requiredActions.length < 1) {\n return\n }\n\n writeFileSync(\n tsConfigPath,\n CommentJson.stringify(userTsConfig, null, 2) + os.EOL\n )\n\n Log.info('')\n if (isFirstTimeSetup) {\n Log.info(\n `We detected TypeScript in your project and created a ${cyan(\n 'tsconfig.json'\n )} file for you.`\n )\n return\n }\n\n Log.info(\n `We detected TypeScript in your project and reconfigured your ${cyan(\n 'tsconfig.json'\n )} file for you.${\n userTsConfig.compilerOptions?.strict\n ? ''\n : ` Strict-mode is set to ${cyan('false')} by default.`\n }`\n )\n\n if (suggestedActions.length) {\n Log.info(\n `The following suggested values were added to your ${cyan(\n 'tsconfig.json'\n )}. These values ${cyan('can be changed')} to fit your project's needs:\\n`\n )\n\n suggestedActions.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n\n const requiredActionsToBeLogged = process.env.NEXT_PRIVATE_LOCAL_DEV\n ? requiredActions.filter(\n (action) => action !== localDevTestFilesExcludeAction\n )\n : requiredActions\n\n if (requiredActionsToBeLogged.length) {\n Log.info(\n `The following ${white('mandatory changes')} were made to your ${cyan(\n 'tsconfig.json'\n )}:\\n`\n )\n\n requiredActionsToBeLogged.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n}\n"],"names":["getRequiredConfiguration","writeConfigurationDefaults","getDesiredCompilerOptions","typescriptVersion","userTsConfig","moduleKindESNext","moduleKindES2020","moduleKindPreserve","moduleKindNodeNext","moduleKindNode16","moduleKindCommonJS","moduleKindAMD","moduleResolutionKindBundler","moduleResolutionKindNode10","moduleResolutionKindNode12","moduleResolutionKindNodeJs","jsxEmitReactJSX","target","suggested","reason","lib","allowJs","skipLibCheck","strict","noEmit","incremental","module","parsedValue","parsedValues","semver","gte","value","compilerOptions","toLowerCase","esModuleInterop","moduleResolution","filter","val","resolveJsonModule","verbatimModuleSyntax","undefined","isolatedModules","jsx","typescript","res","version","desiredCompilerOptions","optionKey","Object","keys","ev","moduleMap","esnext","ModuleKind","ESNext","es2020","ES2020","Preserve","preserve","nodenext","NodeNext","node16","Node16","commonjs","CommonJS","amd","AMD","moduleResolutionMap","bundler","ModuleResolutionKind","Bundler","node10","Node10","node12","Node12","node","NodeJs","jsxMap","JsxEmit","ReactJSX","localDevTestFilesExcludeAction","tsConfigPath","isFirstTimeSetup","hasAppDir","distDir","hasPagesDir","isolatedDevBuild","writeFileSync","os","EOL","userTsConfigContent","readFileSync","encoding","CommentJson","parse","suggestedActions","requiredActions","check","push","cyan","bold","existingValue","shouldWriteRequiredValue","includes","_","distDirPosix","path","win32","sep","replaceAll","posix","nextAppTypes","process","env","NODE_ENV","replace","sort","a","b","length","include","map","type","join","missingFromResolved","Array","isArray","forEach","item","plugins","hasNextPlugin","some","name","Log","info","strictNullChecks","exclude","NEXT_PRIVATE_LOCAL_DEV","tsGlob","tsxGlob","hasUpdates","stringify","action","requiredActionsToBeLogged","white"],"mappings":";;;;;;;;;;;;;;;IAgIgBA,wBAAwB;eAAxBA;;IAwDMC,0BAA0B;eAA1BA;;;oBAxLsB;8DACtB;4BACY;qEACL;+DACV;2DACJ;6DAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAarB,SAASC,0BACPC,iBAAyB,EACzBC,YAAkC;QAuDhCA,sCAAAA,+BAmCIA;IAxFN,aAAa;IACb,MAAMC,mBAAmB;IACzB,MAAMC,mBAAmB;IACzB,MAAMC,qBAAqB;IAC3B,MAAMC,qBAAqB;IAC3B,MAAMC,mBAAmB;IACzB,MAAMC,qBAAqB;IAC3B,MAAMC,gBAAgB;IAEtB,uBAAuB;IACvB,MAAMC,8BAA8B;IACpC,MAAMC,6BAA6B;IACnC,MAAMC,6BAA6B;IACnC,MAAMC,6BAA6B;IAEnC,MAAM;IACN,MAAMC,kBAAkB;IAExB,OAAO;QACLC,QAAQ;YACNC,WAAW;YACXC,QACE;QACJ;QACA,qEAAqE;QACrE,gBAAgB;QAChBC,KAAK;YAAEF,WAAW;gBAAC;gBAAO;gBAAgB;aAAS;QAAC;QACpDG,SAAS;YAAEH,WAAW;QAAK;QAC3BI,cAAc;YAAEJ,WAAW;QAAK;QAChCK,QAAQ;YAAEL,WAAW;QAAM;QAC3BM,QAAQ;YAAEN,WAAW;QAAK;QAC1BO,aAA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,MAAM,IAChC,KACA,CAAC,uBAAuB,EAAE4E,IAAAA,gBAAI,EAAC,SAAS,YAAY,CAAC,EACzD;IAGJ,IAAIJ,iBAAiBwB,MAAM,EAAE;QAC3Bc,KAAIC,IAAI,CACN,CAAC,kDAAkD,EAAEnC,IAAAA,gBAAI,EACvD,iBACA,eAAe,EAAEA,IAAAA,gBAAI,EAAC,kBAAkB,+BAA+B,CAAC;QAG5EJ,iBAAiBgC,OAAO,CAAC,CAACe,SAAWT,KAAIC,IAAI,CAAC,CAAC,IAAI,EAAEQ,QAAQ;QAE7DT,KAAIC,IAAI,CAAC;IACX;IAEA,MAAMS,4BAA4B/B,QAAQC,GAAG,CAACwB,sBAAsB,GAChEzC,gBAAgB5D,MAAM,CACpB,CAAC0G,SAAWA,WAAW9D,kCAEzBgB;IAEJ,IAAI+C,0BAA0BxB,MAAM,EAAE;QACpCc,KAAIC,IAAI,CACN,CAAC,cAAc,EAAEU,IAAAA,iBAAK,EAAC,qBAAqB,mBAAmB,EAAE7C,IAAAA,gBAAI,EACnE,iBACA,GAAG,CAAC;QAGR4C,0BAA0BhB,OAAO,CAAC,CAACe,SAAWT,KAAIC,IAAI,CAAC,CAAC,IAAI,EAAEQ,QAAQ;QAEtET,KAAIC,IAAI,CAAC;IACX;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/typescript/writeConfigurationDefaults.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'fs'\nimport { bold, cyan, white } from '../picocolors'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\nimport semver from 'next/dist/compiled/semver'\nimport os from 'os'\nimport type { CompilerOptions } from 'typescript'\nimport { getTypeDefinitionGlobPatterns } from './type-paths'\nimport * as Log from '../../build/output/log'\nimport { defaultConfig } from '../../server/config-shared'\n\ntype DesiredCompilerOptionsShape = {\n [K in keyof CompilerOptions]:\n | { suggested: any; reason?: string }\n | {\n parsedValue?: any\n parsedValues?: Array<any>\n value: any\n reason: string\n }\n}\n\nfunction getDesiredCompilerOptions(\n typescriptVersion: string,\n userTsConfig?: Record<string, any>\n): DesiredCompilerOptionsShape {\n // ModuleKind\n const moduleKindESNext = 'esnext'\n const moduleKindES2020 = 'es2020'\n const moduleKindPreserve = 'preserve'\n const moduleKindNodeNext = 'nodenext'\n const moduleKindNode16 = 'node16'\n const moduleKindCommonJS = 'commonjs'\n const moduleKindAMD = 'amd'\n\n // ModuleResolutionKind\n const moduleResolutionKindBundler = 'bundler'\n const moduleResolutionKindNode10 = 'node10'\n const moduleResolutionKindNode12 = 'node12'\n const moduleResolutionKindNodeJs = 'node'\n\n // Jsx\n const jsxEmitReactJSX = 'react-jsx'\n\n return {\n target: {\n suggested: 'ES2017',\n reason:\n 'For top-level `await`. Note: Next.js only polyfills for the esmodules target.',\n },\n // These are suggested values and will be set when not present in the\n // tsconfig.json\n lib: { suggested: ['dom', 'dom.iterable', 'esnext'] },\n allowJs: { suggested: true },\n skipLibCheck: { suggested: true },\n strict: { suggested: false },\n noEmit: { suggested: true },\n incremental: { suggested: true },\n\n // These values are required and cannot be changed by the user\n // Keep this in sync with the webpack config\n // 'parsedValue' matches the output value from ts.parseJsonConfigFileContent()\n module: {\n parsedValue: moduleKindESNext,\n // All of these values work:\n parsedValues: [\n semver.gte(typescriptVersion, '5.4.0') && moduleKindPreserve,\n moduleKindES2020,\n moduleKindESNext,\n moduleKindCommonJS,\n moduleKindAMD,\n moduleKindNodeNext,\n moduleKindNode16,\n ],\n value: 'esnext',\n reason: 'for dynamic import() support',\n },\n // TODO: Semver check not needed once Next.js repo uses 5.4.\n ...(semver.gte(typescriptVersion, '5.4.0') &&\n userTsConfig?.compilerOptions?.module?.toLowerCase() === moduleKindPreserve\n ? {\n // TypeScript 5.4 introduced `Preserve`. Using `Preserve` implies\n // - `moduleResolution` is `Bundler`\n // - `esModuleInterop` is `true`\n // - `resolveJsonModule` is `true`\n // This means that if the user is using Preserve, they don't need these options\n }\n : {\n esModuleInterop: {\n value: true,\n reason: 'requirement for SWC / babel',\n },\n moduleResolution: {\n // In TypeScript 5.0, `NodeJs` has renamed to `Node10`\n parsedValue: moduleResolutionKindBundler,\n // All of these values work:\n parsedValues: [\n moduleResolutionKindNode10,\n moduleResolutionKindNodeJs,\n // only newer TypeScript versions have this field, it\n // will be filtered for new versions of TypeScript\n moduleResolutionKindNode12,\n moduleKindNode16,\n moduleKindNodeNext,\n moduleResolutionKindBundler,\n ].filter((val) => typeof val !== 'undefined'),\n value: 'node',\n reason: 'to match webpack resolution',\n },\n resolveJsonModule: {\n value: true,\n reason: 'to match webpack resolution',\n },\n }),\n ...(userTsConfig?.compilerOptions?.verbatimModuleSyntax === true\n ? undefined\n : {\n isolatedModules: {\n value: true,\n reason: 'requirement for SWC / Babel',\n },\n }),\n jsx: {\n parsedValue: jsxEmitReactJSX,\n value: 'react-jsx',\n reason: 'next.js uses the React automatic runtime',\n },\n } satisfies DesiredCompilerOptionsShape\n}\n\nexport function getRequiredConfiguration(\n typescript: typeof import('typescript')\n): Partial<import('typescript').CompilerOptions> {\n const res: Partial<import('typescript').CompilerOptions> = {}\n const typescriptVersion = typescript.version\n\n const desiredCompilerOptions = getDesiredCompilerOptions(typescriptVersion)\n for (const optionKey of Object.keys(desiredCompilerOptions)) {\n const ev = desiredCompilerOptions[optionKey]\n if (!('value' in ev)) {\n continue\n }\n\n const value = ev.parsedValue ?? ev.value\n\n // Convert string values back to TypeScript enum values\n if (optionKey === 'module' && typeof value === 'string') {\n const moduleMap: Record<string, import('typescript').ModuleKind> = {\n esnext: typescript.ModuleKind.ESNext,\n es2020: typescript.ModuleKind.ES2020,\n ...(typescript.ModuleKind.Preserve !== undefined\n ? { preserve: typescript.ModuleKind.Preserve }\n : {}),\n nodenext: typescript.ModuleKind.NodeNext,\n node16: typescript.ModuleKind.Node16,\n commonjs: typescript.ModuleKind.CommonJS,\n amd: typescript.ModuleKind.AMD,\n }\n res[optionKey] = moduleMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'moduleResolution' && typeof value === 'string') {\n const moduleResolutionMap: Record<\n string,\n import('typescript').ModuleResolutionKind\n > = {\n bundler: typescript.ModuleResolutionKind.Bundler,\n node10: typescript.ModuleResolutionKind.Node10,\n node12: (typescript.ModuleResolutionKind as any).Node12,\n node: typescript.ModuleResolutionKind.NodeJs,\n }\n res[optionKey] = moduleResolutionMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'jsx' && typeof value === 'string') {\n const jsxMap: Record<string, import('typescript').JsxEmit> = {\n 'react-jsx': typescript.JsxEmit.ReactJSX,\n }\n res[optionKey] = jsxMap[value.toLowerCase()] ?? value\n } else {\n res[optionKey] = value\n }\n }\n\n return res\n}\n\nconst localDevTestFilesExcludeAction =\n 'NEXT_PRIVATE_LOCAL_DEV_TEST_FILES_EXCLUDE'\n\nexport async function writeConfigurationDefaults(\n typescriptVersion: string,\n tsConfigPath: string,\n isFirstTimeSetup: boolean,\n hasAppDir: boolean,\n distDir: string,\n hasPagesDir: boolean,\n isolatedDevBuild: boolean | undefined\n): Promise<void> {\n if (isFirstTimeSetup) {\n writeFileSync(tsConfigPath, '{}' + os.EOL)\n }\n\n const userTsConfigContent = readFileSync(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = CommentJson.parse(userTsConfigContent)\n\n // Bail automatic setup when the user has extended or referenced another config\n if ('extends' in userTsConfig || 'references' in userTsConfig) {\n return\n }\n\n if (userTsConfig?.compilerOptions == null) {\n userTsConfig.compilerOptions = {}\n isFirstTimeSetup = true\n }\n\n const desiredCompilerOptions = getDesiredCompilerOptions(\n typescriptVersion,\n userTsConfig\n )\n\n const suggestedActions: string[] = []\n const requiredActions: string[] = []\n for (const optionKey in desiredCompilerOptions) {\n const check = desiredCompilerOptions[optionKey]\n if ('suggested' in check) {\n if (!(optionKey in userTsConfig?.compilerOptions)) {\n userTsConfig.compilerOptions[optionKey] = check.suggested\n suggestedActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.suggested) +\n (check.reason ? ` (${check.reason})` : '')\n )\n }\n } else if ('value' in check) {\n let existingValue = userTsConfig?.compilerOptions?.[optionKey]\n\n if (typeof existingValue === 'string') {\n existingValue = existingValue.toLowerCase()\n }\n\n const shouldWriteRequiredValue = () => {\n // Check if the option has multiple allowed values\n if (check.parsedValues) {\n return !check.parsedValues.includes(existingValue)\n }\n\n // Check if the option has a single parsed value\n if (check.parsedValue) {\n return check.parsedValue !== existingValue\n }\n\n // Fall back to direct value comparison\n return check.value !== existingValue\n }\n\n if (shouldWriteRequiredValue()) {\n if (!userTsConfig.compilerOptions) {\n userTsConfig.compilerOptions = {}\n }\n userTsConfig.compilerOptions[optionKey] = check.value\n requiredActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.value) +\n ` (${check.reason})`\n )\n }\n } else {\n const _: never = check\n }\n }\n\n const resolvedIsolatedDevBuild =\n isolatedDevBuild === undefined\n ? defaultConfig.experimental.isolatedDevBuild\n : isolatedDevBuild\n\n // Get type definition glob patterns using shared utility to ensure consistency\n // with other TypeScript infrastructure (e.g., runTypeCheck.ts)\n const nextAppTypes = getTypeDefinitionGlobPatterns(\n distDir,\n resolvedIsolatedDevBuild\n )\n\n if (!('include' in userTsConfig)) {\n userTsConfig.include = hasAppDir\n ? ['next-env.d.ts', ...nextAppTypes, '**/*.mts', '**/*.ts', '**/*.tsx']\n : ['next-env.d.ts', '**/*.mts', '**/*.ts', '**/*.tsx']\n suggestedActions.push(\n cyan('include') +\n ' was set to ' +\n bold(\n hasAppDir\n ? `['next-env.d.ts', ${nextAppTypes.map((type) => `'${type}'`).join(', ')}, '**/*.mts', '**/*.ts', '**/*.tsx']`\n : `['next-env.d.ts', '**/*.mts', '**/*.ts', '**/*.tsx']`\n )\n )\n } else if (hasAppDir) {\n const missingFromResolved = []\n for (const type of nextAppTypes) {\n if (!userTsConfig.include.includes(type)) {\n missingFromResolved.push(type)\n }\n }\n\n if (missingFromResolved.length > 0) {\n if (!Array.isArray(userTsConfig.include)) {\n userTsConfig.include = []\n }\n\n missingFromResolved.forEach((item) => {\n userTsConfig.include.push(item)\n suggestedActions.push(\n cyan('include') + ' was updated to add ' + bold(`'${item}'`)\n )\n })\n }\n }\n\n // Enable the Next.js typescript plugin.\n if (hasAppDir) {\n // Check if the config or the resolved config has the plugin already.\n const plugins = [\n ...(Array.isArray(userTsConfig?.plugins) ? userTsConfig.plugins : []),\n ...(userTsConfig.compilerOptions &&\n Array.isArray(userTsConfig.compilerOptions.plugins)\n ? userTsConfig.compilerOptions.plugins\n : []),\n ]\n const hasNextPlugin = plugins.some(\n ({ name }: { name: string }) => name === 'next'\n )\n\n // If the TS config extends on another config, we can't add the `plugin` field\n // because that will override the parent config's plugins.\n // Instead we have to show a message to the user to add the plugin manually.\n if (\n !userTsConfig.compilerOptions ||\n (plugins.length &&\n !hasNextPlugin &&\n 'extends' in userTsConfig &&\n (!userTsConfig.compilerOptions ||\n !userTsConfig.compilerOptions.plugins))\n ) {\n Log.info(\n `\\nYour ${bold(\n 'tsconfig.json'\n )} extends another configuration, which means we cannot add the Next.js TypeScript plugin automatically. To improve your development experience, we recommend adding the Next.js plugin (\\`${cyan(\n '\"plugins\": [{ \"name\": \"next\" }]'\n )}\\`) manually to your TypeScript configuration. Learn more: https://nextjs.org/docs/app/api-reference/config/typescript#the-typescript-plugin\\n`\n )\n } else if (!hasNextPlugin) {\n if (!('plugins' in userTsConfig.compilerOptions)) {\n userTsConfig.compilerOptions.plugins = []\n }\n userTsConfig.compilerOptions.plugins.push({ name: 'next' })\n suggestedActions.push(\n cyan('plugins') + ' was updated to add ' + bold(`{ name: 'next' }`)\n )\n }\n\n // If `strict` is set to `false` and `strictNullChecks` is set to `false`,\n // then set `strictNullChecks` to `true`.\n if (\n hasPagesDir &&\n hasAppDir &&\n !userTsConfig?.compilerOptions?.strict &&\n !('strictNullChecks' in userTsConfig?.compilerOptions)\n ) {\n userTsConfig.compilerOptions.strictNullChecks = true\n suggestedActions.push(\n cyan('strictNullChecks') + ' was set to ' + bold(`true`)\n )\n }\n }\n\n if (!('exclude' in userTsConfig)) {\n userTsConfig.exclude = ['node_modules']\n suggestedActions.push(\n cyan('exclude') + ' was set to ' + bold(`['node_modules']`)\n )\n }\n\n // During local development inside Next.js repo, exclude the test files coverage by the local tsconfig\n if (process.env.NEXT_PRIVATE_LOCAL_DEV && userTsConfig.exclude) {\n const tsGlob = '**/*.test.ts'\n const tsxGlob = '**/*.test.tsx'\n let hasUpdates = false\n if (!userTsConfig.exclude.includes(tsGlob)) {\n userTsConfig.exclude.push(tsGlob)\n hasUpdates = true\n }\n if (!userTsConfig.exclude.includes(tsxGlob)) {\n userTsConfig.exclude.push(tsxGlob)\n hasUpdates = true\n }\n\n if (hasUpdates) {\n requiredActions.push(localDevTestFilesExcludeAction)\n }\n }\n\n if (suggestedActions.length < 1 && requiredActions.length < 1) {\n return\n }\n\n writeFileSync(\n tsConfigPath,\n CommentJson.stringify(userTsConfig, null, 2) + os.EOL\n )\n\n Log.info('')\n if (isFirstTimeSetup) {\n Log.info(\n `We detected TypeScript in your project and created a ${cyan(\n 'tsconfig.json'\n )} file for you.`\n )\n return\n }\n\n Log.info(\n `We detected TypeScript in your project and reconfigured your ${cyan(\n 'tsconfig.json'\n )} file for you.${\n userTsConfig.compilerOptions?.strict\n ? ''\n : ` Strict-mode is set to ${cyan('false')} by default.`\n }`\n )\n\n if (suggestedActions.length) {\n Log.info(\n `The following suggested values were added to your ${cyan(\n 'tsconfig.json'\n )}. These values ${cyan('can be changed')} to fit your project's needs:\\n`\n )\n\n suggestedActions.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n\n const requiredActionsToBeLogged = process.env.NEXT_PRIVATE_LOCAL_DEV\n ? requiredActions.filter(\n (action) => action !== localDevTestFilesExcludeAction\n )\n : requiredActions\n\n if (requiredActionsToBeLogged.length) {\n Log.info(\n `The following ${white('mandatory changes')} were made to your ${cyan(\n 'tsconfig.json'\n )}:\\n`\n )\n\n requiredActionsToBeLogged.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n}\n"],"names":["getRequiredConfiguration","writeConfigurationDefaults","getDesiredCompilerOptions","typescriptVersion","userTsConfig","moduleKindESNext","moduleKindES2020","moduleKindPreserve","moduleKindNodeNext","moduleKindNode16","moduleKindCommonJS","moduleKindAMD","moduleResolutionKindBundler","moduleResolutionKindNode10","moduleResolutionKindNode12","moduleResolutionKindNodeJs","jsxEmitReactJSX","target","suggested","reason","lib","allowJs","skipLibCheck","strict","noEmit","incremental","module","parsedValue","parsedValues","semver","gte","value","compilerOptions","toLowerCase","esModuleInterop","moduleResolution","filter","val","resolveJsonModule","verbatimModuleSyntax","undefined","isolatedModules","jsx","typescript","res","version","desiredCompilerOptions","optionKey","Object","keys","ev","moduleMap","esnext","ModuleKind","ESNext","es2020","ES2020","Preserve","preserve","nodenext","NodeNext","node16","Node16","commonjs","CommonJS","amd","AMD","moduleResolutionMap","bundler","ModuleResolutionKind","Bundler","node10","Node10","node12","Node12","node","NodeJs","jsxMap","JsxEmit","ReactJSX","localDevTestFilesExcludeAction","tsConfigPath","isFirstTimeSetup","hasAppDir","distDir","hasPagesDir","isolatedDevBuild","writeFileSync","os","EOL","userTsConfigContent","readFileSync","encoding","CommentJson","parse","suggestedActions","requiredActions","check","push","cyan","bold","existingValue","shouldWriteRequiredValue","includes","_","resolvedIsolatedDevBuild","defaultConfig","experimental","nextAppTypes","getTypeDefinitionGlobPatterns","include","map","type","join","missingFromResolved","length","Array","isArray","forEach","item","plugins","hasNextPlugin","some","name","Log","info","strictNullChecks","exclude","process","env","NEXT_PRIVATE_LOCAL_DEV","tsGlob","tsxGlob","hasUpdates","stringify","action","requiredActionsToBeLogged","white"],"mappings":";;;;;;;;;;;;;;;IAiIgBA,wBAAwB;eAAxBA;;IAwDMC,0BAA0B;eAA1BA;;;oBAzLsB;4BACV;qEACL;+DACV;2DACJ;2BAE+B;6DACzB;8BACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAa9B,SAAS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AqD,EAAE1B,IAAAA,gBAAI,EAC1D,iBACA,cAAc,CAAC;QAEnB;IACF;IAEAyB,KAAIC,IAAI,CACN,CAAC,6DAA6D,EAAE1B,IAAAA,gBAAI,EAClE,iBACA,cAAc,EACd/F,EAAAA,gCAAAA,aAAa4B,eAAe,qBAA5B5B,8BAA8BmB,MAAM,IAChC,KACA,CAAC,uBAAuB,EAAE4E,IAAAA,gBAAI,EAAC,SAAS,YAAY,CAAC,EACzD;IAGJ,IAAIJ,iBAAiBoB,MAAM,EAAE;QAC3BS,KAAIC,IAAI,CACN,CAAC,kDAAkD,EAAE1B,IAAAA,gBAAI,EACvD,iBACA,eAAe,EAAEA,IAAAA,gBAAI,EAAC,kBAAkB,+BAA+B,CAAC;QAG5EJ,iBAAiBuB,OAAO,CAAC,CAACiB,SAAWX,KAAIC,IAAI,CAAC,CAAC,IAAI,EAAEU,QAAQ;QAE7DX,KAAIC,IAAI,CAAC;IACX;IAEA,MAAMW,4BAA4BR,QAAQC,GAAG,CAACC,sBAAsB,GAChElC,gBAAgB5D,MAAM,CACpB,CAACmG,SAAWA,WAAWvD,kCAEzBgB;IAEJ,IAAIwC,0BAA0BrB,MAAM,EAAE;QACpCS,KAAIC,IAAI,CACN,CAAC,cAAc,EAAEY,IAAAA,iBAAK,EAAC,qBAAqB,mBAAmB,EAAEtC,IAAAA,gBAAI,EACnE,iBACA,GAAG,CAAC;QAGRqC,0BAA0BlB,OAAO,CAAC,CAACiB,SAAWX,KAAIC,IAAI,CAAC,CAAC,IAAI,EAAEU,QAAQ;QAEtEX,KAAIC,IAAI,CAAC;IACX;AACF","ignoreList":[0]}
|
|
@@ -136,7 +136,7 @@ async function verifyTypeScriptSetup({ dir, distDir, cacheDir, intentDirs, tscon
|
|
|
136
136
|
const tsPath = deps.resolved.get('typescript');
|
|
137
137
|
const typescript = await Promise.resolve(require(tsPath));
|
|
138
138
|
// Verify the project passes type-checking before we go to webpack phase:
|
|
139
|
-
result = await runTypeCheck(typescript, dir, distDir, resolvedTsConfigPath, cacheDir, hasAppDir);
|
|
139
|
+
result = await runTypeCheck(typescript, dir, distDir, resolvedTsConfigPath, cacheDir, hasAppDir, isolatedDevBuild);
|
|
140
140
|
}
|
|
141
141
|
return {
|
|
142
142
|
result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path, { join } from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type { NecessaryDependencies } from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\n\nconst requiredPackages = [\n {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n exportsRestrict: true,\n },\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyTypeScriptSetup({\n dir,\n distDir,\n cacheDir,\n intentDirs,\n tsconfigPath,\n typeCheckPreflight,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n isolatedDevBuild,\n}: {\n dir: string\n distDir: string\n cacheDir?: string\n tsconfigPath: string | undefined\n intentDirs: string[]\n typeCheckPreflight: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n isolatedDevBuild: boolean | undefined\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\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'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n // Load TypeScript after we're sure it exists:\n const tsPackageJsonPath = deps.resolved.get(\n join('typescript', 'package.json')\n )!\n const typescriptPackageJson = require(tsPackageJsonPath)\n\n const typescriptVersion = typescriptPackageJson.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n isolatedDevBuild\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n\n const tsPath = deps.resolved.get('typescript')!\n const typescript = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir\n )\n }\n return { result, version: typescriptVersion }\n } catch (err) {\n // These are special errors that should not show a stack trace:\n if (err instanceof CompileError) {\n console.error(red('Failed to compile.\\n'))\n console.error(err.message)\n process.exit(1)\n }\n\n /**\n * verifyTypeScriptSetup can be either invoked directly in the main thread (during next dev / next lint)\n * or run in a worker (during next build). In the latter case, we need to print the error message, as the\n * parent process will only receive an `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\n\n // we are in a worker, print the error message and exit the process\n if (process.env.IS_NEXT_WORKER) {\n if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n process.exit(1)\n }\n // we are in the main thread, throw the error and it will be handled by the caller\n throw err\n }\n}\n"],"names":["verifyTypeScriptSetup","requiredPackages","file","pkg","exportsRestrict","dir","distDir","cacheDir","intentDirs","tsconfigPath","typeCheckPreflight","disableStaticImages","hasAppDir","hasPagesDir","isolatedDevBuild","tsConfigFileName","resolvedTsConfigPath","path","join","deps","intent","getTypeScriptIntent","version","hasNecessaryDependencies","missing","length","isCI","missingDepsError","console","log","bold","yellow","cyan","installDependencies","catch","err","error","command","tsPackageJsonPath","resolved","get","typescriptPackageJson","require","typescriptVersion","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","writeAppTypeDeclarations","baseDir","imageImportsEnabled","result","runTypeCheck","tsPath","typescript","Promise","resolve","CompileError","red","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":";;;;+BAmCsBA;;;eAAAA;;;4BAnCkB;8DACb;0CAEc;+DAEtB;8BACU;6DACR;qCAEe;0CAEK;4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aAAaA,KAAK;oBACtDP,QAAQQ,KAAK,CACX,CAAC,+FAA+F,CAAC,GAC/F,AAACD,IAAYE,OAAO,GACpB;gBAEN;gBACA,MAAMF;YACR;YACAhB,OAAOI,IAAAA,kDAAwB,EAAClB,KAAKJ;QACvC;QAEA,8CAA8C;QAC9C,MAAMqC,oBAAoBnB,KAAKoB,QAAQ,CAACC,GAAG,CACzCtB,IAAAA,UAAI,EAAC,cAAc;QAErB,MAAMuB,wBAAwBC,QAAQJ;QAEtC,MAAMK,oBAAoBF,sBAAsBnB,OAAO;QAEvD,IAAIsB,eAAM,CAACC,EAAE,CAACF,mBAAmB,UAAU;YACzCd,KAAIiB,IAAI,CACN,CAAC,yHAAyH,EAAEH,mBAAmB;QAEnJ;QAEA,+DAA+D;QAC/D,MAAMI,IAAAA,sDAA0B,EAC9BJ,mBACA3B,sBACAI,OAAO4B,cAAc,EACrBpC,WACAN,SACAO,aACAC;QAEF,qEAAqE;QACrE,kBAAkB;QAClB,MAAMmC,IAAAA,kDAAwB,EAAC;YAC7BC,SAAS7C;YACTC;YACA6C,qBAAqB,CAACxC;YACtBE;YACAD;QACF;QAEA,IAAIwC;QACJ,IAAI1C,oBAAoB;YACtB,MAAM,EAAE2C,YAAY,EAAE,GACpBX,QAAQ;YAEV,MAAMY,SAASnC,KAAKoB,QAAQ,CAACC,GAAG,CAAC;YACjC,MAAMe,aAAc,MAAMC,QAAQC,OAAO,CACvCf,QAAQY;YAGV,yEAAyE;YACzEF,SAAS,MAAMC,aACbE,YACAlD,KACAC,SACAU,sBACAT,UACAK;QAEJ;QACA,OAAO;
|
|
1
|
+
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path, { join } from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type { NecessaryDependencies } from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\n\nconst requiredPackages = [\n {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n exportsRestrict: true,\n },\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyTypeScriptSetup({\n dir,\n distDir,\n cacheDir,\n intentDirs,\n tsconfigPath,\n typeCheckPreflight,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n isolatedDevBuild,\n}: {\n dir: string\n distDir: string\n cacheDir?: string\n tsconfigPath: string | undefined\n intentDirs: string[]\n typeCheckPreflight: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n isolatedDevBuild: boolean | undefined\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\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'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n // Load TypeScript after we're sure it exists:\n const tsPackageJsonPath = deps.resolved.get(\n join('typescript', 'package.json')\n )!\n const typescriptPackageJson = require(tsPackageJsonPath)\n\n const typescriptVersion = typescriptPackageJson.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n isolatedDevBuild\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n\n const tsPath = deps.resolved.get('typescript')!\n const typescript = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir,\n isolatedDevBuild\n )\n }\n return { result, version: typescriptVersion }\n } catch (err) {\n // These are special errors that should not show a stack trace:\n if (err instanceof CompileError) {\n console.error(red('Failed to compile.\\n'))\n console.error(err.message)\n process.exit(1)\n }\n\n /**\n * verifyTypeScriptSetup can be either invoked directly in the main thread (during next dev / next lint)\n * or run in a worker (during next build). In the latter case, we need to print the error message, as the\n * parent process will only receive an `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\n\n // we are in a worker, print the error message and exit the process\n if (process.env.IS_NEXT_WORKER) {\n if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n process.exit(1)\n }\n // we are in the main thread, throw the error and it will be handled by the caller\n throw err\n }\n}\n"],"names":["verifyTypeScriptSetup","requiredPackages","file","pkg","exportsRestrict","dir","distDir","cacheDir","intentDirs","tsconfigPath","typeCheckPreflight","disableStaticImages","hasAppDir","hasPagesDir","isolatedDevBuild","tsConfigFileName","resolvedTsConfigPath","path","join","deps","intent","getTypeScriptIntent","version","hasNecessaryDependencies","missing","length","isCI","missingDepsError","console","log","bold","yellow","cyan","installDependencies","catch","err","error","command","tsPackageJsonPath","resolved","get","typescriptPackageJson","require","typescriptVersion","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","writeAppTypeDeclarations","baseDir","imageImportsEnabled","result","runTypeCheck","tsPath","typescript","Promise","resolve","CompileError","red","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":";;;;+BAmCsBA;;;eAAAA;;;4BAnCkB;8DACb;0CAEc;+DAEtB;8BACU;6DACR;qCAEe;0CAEK;4CACE;qCACP;wBACf;wCACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,MAAMC,mBAAmB;IACvB;QACEC,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;CACD;AAEM,eAAeJ,sBAAsB,EAC1CK,GAAG,EACHC,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,YAAY,EACZC,kBAAkB,EAClBC,mBAAmB,EACnBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,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IiB,IAAI,CACN,CAAC,yHAAyH,EAAEH,mBAAmB;QAEnJ;QAEA,+DAA+D;QAC/D,MAAMI,IAAAA,sDAA0B,EAC9BJ,mBACA3B,sBACAI,OAAO4B,cAAc,EACrBpC,WACAN,SACAO,aACAC;QAEF,qEAAqE;QACrE,kBAAkB;QAClB,MAAMmC,IAAAA,kDAAwB,EAAC;YAC7BC,SAAS7C;YACTC;YACA6C,qBAAqB,CAACxC;YACtBE;YACAD;QACF;QAEA,IAAIwC;QACJ,IAAI1C,oBAAoB;YACtB,MAAM,EAAE2C,YAAY,EAAE,GACpBX,QAAQ;YAEV,MAAMY,SAASnC,KAAKoB,QAAQ,CAACC,GAAG,CAAC;YACjC,MAAMe,aAAc,MAAMC,QAAQC,OAAO,CACvCf,QAAQY;YAGV,yEAAyE;YACzEF,SAAS,MAAMC,aACbE,YACAlD,KACAC,SACAU,sBACAT,UACAK,WACAE;QAEJ;QACA,OAAO;YAAEsC;YAAQ9B,SAASqB;QAAkB;IAC9C,EAAE,OAAOR,KAAK;QACZ,+DAA+D;QAC/D,IAAIA,eAAeuB,0BAAY,EAAE;YAC/B9B,QAAQQ,KAAK,CAACuB,IAAAA,eAAG,EAAC;YAClB/B,QAAQQ,KAAK,CAACD,IAAIyB,OAAO;YACzBC,QAAQC,IAAI,CAAC;QACf;QAEA;;;;KAIC,GAED,mEAAmE;QACnE,IAAID,QAAQE,GAAG,CAACC,cAAc,EAAE;YAC9B,IAAI7B,eAAe8B,OAAO;gBACxBrC,QAAQQ,KAAK,CAACD,IAAIyB,OAAO;YAC3B,OAAO;gBACLhC,QAAQQ,KAAK,CAACD;YAChB;YACA0B,QAAQC,IAAI,CAAC;QACf;QACA,kFAAkF;QAClF,MAAM3B;IACR;AACF","ignoreList":[0]}
|
package/dist/server/config.js
CHANGED
|
@@ -215,7 +215,7 @@ function warnCustomizedOption(config, key, defaultValue, customMessage, configFi
|
|
|
215
215
|
* @param silent - Whether to suppress warnings.
|
|
216
216
|
* @returns The complete config.
|
|
217
217
|
*/ function assignDefaultsAndValidate(dir, userConfig, silent, phase) {
|
|
218
|
-
var _result_experimental, _result_experimental1, _result_experimental_serverActions, _result_experimental2, _userConfig_experimental, _userConfig_experimental1, _userConfig_experimental2, _userConfig_experimental3, _userConfig_experimental4, _userConfig_experimental5, _userConfig_experimental6, _userConfig_experimental7, _userConfig_experimental8, _userConfig_experimental9, _userConfig_experimental10, _userConfig_experimental11, _userConfig_experimental12, _userConfig_experimental13, _userConfig_experimental14, _userConfig_experimental15, _result_experimental3, _result_turbopack, _result_turbopack1, _result_devIndicators, _result_experimental4
|
|
218
|
+
var _result_experimental, _result_experimental1, _result_experimental_serverActions, _result_experimental2, _userConfig_experimental, _userConfig_experimental1, _userConfig_experimental2, _userConfig_experimental3, _userConfig_experimental4, _userConfig_experimental5, _userConfig_experimental6, _userConfig_experimental7, _userConfig_experimental8, _userConfig_experimental9, _userConfig_experimental10, _userConfig_experimental11, _userConfig_experimental12, _userConfig_experimental13, _userConfig_experimental14, _userConfig_experimental15, _result_experimental3, _result_turbopack, _result_turbopack1, _result_devIndicators, _result_experimental4;
|
|
219
219
|
const configFileName = userConfig.configFileName;
|
|
220
220
|
if (typeof userConfig.exportTrailingSlash !== 'undefined') {
|
|
221
221
|
if (!silent) {
|
|
@@ -1036,7 +1036,7 @@ function warnCustomizedOption(config, key, defaultValue, customMessage, configFi
|
|
|
1036
1036
|
// Store the distDirRoot in the config before it is modified by the isolatedDevBuild flag
|
|
1037
1037
|
;
|
|
1038
1038
|
result.distDirRoot = result.distDir;
|
|
1039
|
-
if (phase === _constants.PHASE_DEVELOPMENT_SERVER &&
|
|
1039
|
+
if (phase === _constants.PHASE_DEVELOPMENT_SERVER && result.experimental.isolatedDevBuild) {
|
|
1040
1040
|
result.distDir = (0, _path.join)(result.distDir, 'dev');
|
|
1041
1041
|
}
|
|
1042
1042
|
return result;
|