@openuiai/next 15.6.0-bun.16 → 15.6.0-bun.17
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 +1 -1
- 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/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/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/eslint/runLintCheck.js +1 -0
- package/dist/esm/lib/eslint/runLintCheck.js.map +1 -1
- package/dist/esm/lib/verify-typescript-setup.js +1 -0
- package/dist/esm/lib/verify-typescript-setup.js.map +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/canary-only.js +1 -1
- package/dist/lib/eslint/runLintCheck.d.ts +1 -0
- package/dist/lib/eslint/runLintCheck.js +1 -0
- package/dist/lib/eslint/runLintCheck.js.map +1 -1
- package/dist/lib/verify-typescript-setup.d.ts +1 -0
- package/dist/lib/verify-typescript-setup.js +1 -0
- package/dist/lib/verify-typescript-setup.js.map +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/canary-only.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 +1 -1
package/dist/esm/build/index.js
CHANGED
|
@@ -301,7 +301,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
|
301
301
|
const nextBuildSpan = trace('next-build', undefined, {
|
|
302
302
|
buildMode: experimentalBuildMode,
|
|
303
303
|
isTurboBuild: String(isTurbopack),
|
|
304
|
-
version: "15.6.0-bun.
|
|
304
|
+
version: "15.6.0-bun.17"
|
|
305
305
|
});
|
|
306
306
|
NextBuildContext.nextBuildSpan = nextBuildSpan;
|
|
307
307
|
NextBuildContext.dir = dir;
|
|
@@ -780,7 +780,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
|
780
780
|
// Files outside of the distDir can be "type": "module"
|
|
781
781
|
await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
|
782
782
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
|
783
|
-
await recordFrameworkVersion("15.6.0-bun.
|
|
783
|
+
await recordFrameworkVersion("15.6.0-bun.17");
|
|
784
784
|
await updateBuildDiagnostics({
|
|
785
785
|
buildStage: 'start'
|
|
786
786
|
});
|
|
@@ -2425,7 +2425,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
|
2425
2425
|
distDir,
|
|
2426
2426
|
config,
|
|
2427
2427
|
staticPages,
|
|
2428
|
-
nextVersion: "15.6.0-bun.
|
|
2428
|
+
nextVersion: "15.6.0-bun.17",
|
|
2429
2429
|
tracingRoot: outputFileTracingRoot,
|
|
2430
2430
|
hasNodeMiddleware,
|
|
2431
2431
|
hasInstrumentationHook,
|
|
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
|
|
|
11
11
|
import { getDefineEnv } from '../define-env';
|
|
12
12
|
import { getReactCompilerLoader } from '../get-babel-loader-config';
|
|
13
13
|
import { throwTurbopackInternalError } from '../../shared/lib/turbopack/internal-error';
|
|
14
|
-
const nextVersion = "15.6.0-bun.
|
|
14
|
+
const nextVersion = "15.6.0-bun.17";
|
|
15
15
|
const ArchName = arch();
|
|
16
16
|
const PlatformName = platform();
|
|
17
17
|
function infoLog(...args) {
|
|
@@ -1575,7 +1575,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1575
1575
|
isClient && new CopyFilePlugin({
|
|
1576
1576
|
// file path to build output of `@next/polyfill-nomodule`
|
|
1577
1577
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
|
1578
|
-
cacheKey: "15.6.0-bun.
|
|
1578
|
+
cacheKey: "15.6.0-bun.17",
|
|
1579
1579
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
|
1580
1580
|
minimize: false,
|
|
1581
1581
|
info: {
|
|
@@ -1756,7 +1756,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1756
1756
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
|
1757
1757
|
// - Next.js version
|
|
1758
1758
|
// - next.config.js keys that affect compilation
|
|
1759
|
-
version: `${__dirname}|${"15.6.0-bun.
|
|
1759
|
+
version: `${__dirname}|${"15.6.0-bun.17"}|${configVars}`,
|
|
1760
1760
|
cacheDirectory: path.join(distDir, 'cache', 'webpack'),
|
|
1761
1761
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
|
1762
1762
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - next/script with `beforeInteractive` strategy
|
|
6
6
|
*/ import { getAssetPrefix } from './asset-prefix';
|
|
7
7
|
import { setAttributesFromProps } from './set-attributes-from-props';
|
|
8
|
-
const version = "15.6.0-bun.
|
|
8
|
+
const version = "15.6.0-bun.17";
|
|
9
9
|
window.next = {
|
|
10
10
|
version,
|
|
11
11
|
appDir: true
|
package/dist/esm/client/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
|
|
|
26
26
|
import { onRecoverableError } from './react-client-callbacks/on-recoverable-error';
|
|
27
27
|
import tracer from './tracing/tracer';
|
|
28
28
|
import { isNextRouterError } from './components/is-next-router-error';
|
|
29
|
-
export const version = "15.6.0-bun.
|
|
29
|
+
export const version = "15.6.0-bun.17";
|
|
30
30
|
export let router;
|
|
31
31
|
export const emitter = mitt();
|
|
32
32
|
const looseToArray = (input)=>[].slice.call(input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/eslint/runLintCheck.ts"],"sourcesContent":["import { promises as fs, existsSync } from 'fs'\nimport { bold, cyan, red, underline, yellow } from '../picocolors'\nimport path from 'path'\n\nimport findUp from 'next/dist/compiled/find-up'\nimport semver from 'next/dist/compiled/semver'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\n\nimport { formatResults } from './customFormatter'\nimport type { LintResult } from './customFormatter'\nimport { writeDefaultConfig } from './writeDefaultConfig'\nimport { hasEslintConfiguration } from './hasEslintConfiguration'\nimport { writeOutputFile } from './writeOutputFile'\n\nimport { findPagesDir } from '../find-pages-dir'\nimport { installDependencies } from '../install-dependencies'\nimport { hasNecessaryDependencies } from '../has-necessary-dependencies'\n\nimport * as Log from '../../build/output/log'\nimport type { EventLintCheckCompleted } from '../../telemetry/events/build'\nimport isError, { getProperError } from '../is-error'\nimport { getPkgManager } from '../helpers/get-pkg-manager'\nimport {\n getESLintStrictValue,\n getESLintPromptValues,\n} from './getESLintPromptValues'\n\ntype Config = {\n plugins: string[]\n rules: { [key: string]: Array<number | string> }\n}\n\n// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules\nconst VALID_SEVERITY = ['off', 'warn', 'error'] as const\ntype Severity = (typeof VALID_SEVERITY)[number]\n\nfunction isValidSeverity(severity: string): severity is Severity {\n return VALID_SEVERITY.includes(severity as Severity)\n}\n\nconst requiredPackages = [\n { file: 'eslint', pkg: 'eslint', exportsRestrict: false },\n {\n file: 'eslint-config-next',\n pkg: 'eslint-config-next',\n exportsRestrict: false,\n },\n]\n\nasync function cliPrompt(cwd: string): Promise<{ config?: any }> {\n console.log(\n bold(\n `${cyan(\n '?'\n )} How would you like to configure ESLint? https://nextjs.org/docs/app/api-reference/config/eslint`\n )\n )\n\n try {\n const cliSelect = (\n await Promise.resolve(\n (require('next/dist/compiled/cli-select') as typeof import('next/dist/compiled/cli-select'))\n )\n ).default\n const { value } = await cliSelect({\n values: await getESLintPromptValues(cwd),\n valueRenderer: (\n {\n title,\n recommended,\n }: { title: string; recommended?: boolean; config: any },\n selected: boolean\n ) => {\n const name = selected ? bold(underline(cyan(title))) : title\n return name + (recommended ? bold(yellow(' (recommended)')) : '')\n },\n selected: cyan('❯ '),\n unselected: ' ',\n })\n\n return { config: value?.config ?? null }\n } catch {\n return { config: null }\n }\n}\n\nasync function lint(\n baseDir: string,\n lintDirs: string[],\n eslintrcFile: string | null,\n pkgJsonPath: string | null,\n {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n }: {\n lintDuringBuild: boolean\n eslintOptions: any\n reportErrorsOnly: boolean\n maxWarnings: number\n formatter: string | null\n outputFile: string | null\n }\n): Promise<\n | string\n | null\n | {\n output: string | null\n isError: boolean\n eventInfo: EventLintCheckCompleted\n }\n> {\n try {\n // Load ESLint after we're sure it exists:\n const deps = hasNecessaryDependencies(baseDir, requiredPackages)\n const packageManager = getPkgManager(baseDir)\n\n if (deps.missing.some((dep) => dep.pkg === 'eslint')) {\n Log.error(\n `ESLint must be installed${\n lintDuringBuild ? ' in order to run during builds:' : ':'\n } ${bold(\n cyan(\n (packageManager === 'yarn'\n ? 'yarn add --dev'\n : packageManager === 'pnpm'\n ? 'pnpm install --save-dev'\n : 'npm install --save-dev') + ' eslint'\n )\n )}`\n )\n return null\n }\n\n const mod = await Promise.resolve(require(deps.resolved.get('eslint')!))\n\n // If V9 config was found, use flat config, or else use legacy.\n const useFlatConfig = eslintrcFile\n ? // eslintrcFile is absolute path\n path.basename(eslintrcFile).startsWith('eslint.config.')\n : false\n\n let ESLint\n // loadESLint is >= 8.57.0\n // PR https://github.com/eslint/eslint/pull/18098\n // Release https://github.com/eslint/eslint/releases/tag/v8.57.0\n if ('loadESLint' in mod) {\n // By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.\n // https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613\n ESLint = await mod.loadESLint({\n useFlatConfig,\n })\n } else {\n // eslint < 8.57.0, use legacy ESLint\n ESLint = mod.ESLint\n }\n\n let eslintVersion = ESLint?.version ?? mod.CLIEngine?.version\n\n if (!eslintVersion || semver.lt(eslintVersion, '7.0.0')) {\n return `${red(\n 'error'\n )} - Your project has an older version of ESLint installed${\n eslintVersion ? ' (' + eslintVersion + ')' : ''\n }. Please upgrade to ESLint version 7 or above`\n }\n\n let options: any = {\n useEslintrc: true,\n baseConfig: {},\n errorOnUnmatchedPattern: false,\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n cache: true,\n ...eslintOptions,\n }\n\n if (semver.gte(eslintVersion, '9.0.0') && useFlatConfig) {\n for (const option of [\n 'useEslintrc',\n 'extensions',\n 'ignorePath',\n 'reportUnusedDisableDirectives',\n 'resolvePluginsRelativeTo',\n 'rulePaths',\n 'inlineConfig',\n 'maxWarnings',\n ]) {\n if (option in options) {\n delete options[option]\n }\n }\n }\n\n let eslint = new ESLint(options)\n\n let nextEslintPluginIsEnabled = false\n const nextRulesEnabled = new Map<string, Severity>()\n\n for (const configFile of [eslintrcFile, pkgJsonPath]) {\n if (!configFile) continue\n\n const completeConfig: Config | undefined =\n await eslint.calculateConfigForFile(configFile)\n if (!completeConfig) continue\n\n const plugins = completeConfig.plugins\n\n const hasNextPlugin =\n // in ESLint < 9, `plugins` value is string[]\n Array.isArray(plugins)\n ? plugins.includes('@next/next')\n : // in ESLint >= 9, `plugins` value is Record<string, unknown>\n '@next/next' in plugins\n\n if (hasNextPlugin) {\n nextEslintPluginIsEnabled = true\n for (const [name, [severity]] of Object.entries(completeConfig.rules)) {\n if (!name.startsWith('@next/next/')) {\n continue\n }\n if (\n typeof severity === 'number' &&\n severity >= 0 &&\n severity < VALID_SEVERITY.length\n ) {\n nextRulesEnabled.set(name, VALID_SEVERITY[severity])\n } else if (\n typeof severity === 'string' &&\n isValidSeverity(severity)\n ) {\n nextRulesEnabled.set(name, severity)\n }\n }\n break\n }\n }\n\n const pagesDir = findPagesDir(baseDir).pagesDir\n const pagesDirRules = pagesDir ? ['@next/next/no-html-link-for-pages'] : []\n\n if (nextEslintPluginIsEnabled) {\n let updatedPagesDir = false\n\n for (const rule of pagesDirRules) {\n if (\n !options.baseConfig!.rules?.[rule] &&\n !options.baseConfig!.rules?.[\n rule.replace('@next/next', '@next/babel-plugin-next')\n ]\n ) {\n if (!options.baseConfig!.rules) {\n options.baseConfig!.rules = {}\n }\n options.baseConfig!.rules[rule] = [1, pagesDir]\n updatedPagesDir = true\n }\n }\n\n if (updatedPagesDir) {\n eslint = new ESLint(options)\n }\n } else {\n Log.warn('')\n Log.warn(\n 'The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n }\n\n const lintStart = process.hrtime()\n\n let results = await eslint.lintFiles(lintDirs)\n let selectedFormatter = null\n\n if (options.fix) await ESLint.outputFixes(results)\n if (reportErrorsOnly) results = await ESLint.getErrorResults(results) // Only return errors if --quiet flag is used\n\n if (formatter) selectedFormatter = await eslint.loadFormatter(formatter)\n const formattedResult = await formatResults(\n baseDir,\n results,\n selectedFormatter?.format\n )\n const lintEnd = process.hrtime(lintStart)\n const totalWarnings = results.reduce(\n (sum: number, file: LintResult) => sum + file.warningCount,\n 0\n )\n\n if (outputFile) await writeOutputFile(outputFile, formattedResult.output)\n\n return {\n output: formattedResult.outputWithMessages,\n isError:\n ESLint.getErrorResults(results)?.length > 0 ||\n (maxWarnings >= 0 && totalWarnings > maxWarnings),\n eventInfo: {\n durationInSeconds: lintEnd[0],\n eslintVersion: eslintVersion,\n lintedFilesCount: results.length,\n lintFix: !!options.fix,\n nextEslintPluginVersion:\n nextEslintPluginIsEnabled && deps.resolved.has('eslint-config-next')\n ? require(\n path.join(\n path.dirname(deps.resolved.get('eslint-config-next')!),\n 'package.json'\n )\n ).version\n : null,\n nextEslintPluginErrorsCount: formattedResult.totalNextPluginErrorCount,\n nextEslintPluginWarningsCount:\n formattedResult.totalNextPluginWarningCount,\n nextRulesEnabled: Object.fromEntries(nextRulesEnabled),\n },\n }\n } catch (err) {\n if (lintDuringBuild) {\n Log.error(\n `ESLint: ${\n isError(err) && err.message ? err.message.replace(/\\n/g, ' ') : err\n }`\n )\n return null\n } else {\n throw getProperError(err)\n }\n }\n}\n\nexport async function runLintCheck(\n baseDir: string,\n lintDirs: string[],\n opts: {\n lintDuringBuild?: boolean\n eslintOptions?: any\n reportErrorsOnly?: boolean\n maxWarnings?: number\n formatter?: string | null\n outputFile?: string | null\n strict?: boolean\n }\n): ReturnType<typeof lint> {\n const {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n strict = false,\n } = opts\n try {\n // Find user's .eslintrc file\n // See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats\n const eslintrcFile =\n (await findUp(\n [\n // eslint v9\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n // TS extensions require to install a separate package `jiti`.\n // https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files\n 'eslint.config.ts',\n 'eslint.config.mts',\n 'eslint.config.cts',\n // eslint <= v8\n '.eslintrc.js',\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n '.eslintrc',\n ],\n {\n cwd: baseDir,\n }\n )) ?? null\n\n const pkgJsonPath = (await findUp('package.json', { cwd: baseDir })) ?? null\n let packageJsonConfig = null\n if (pkgJsonPath) {\n const pkgJsonContent = await fs.readFile(pkgJsonPath, {\n encoding: 'utf8',\n })\n packageJsonConfig = CommentJson.parse(pkgJsonContent)\n }\n\n const config = await hasEslintConfiguration(eslintrcFile, packageJsonConfig)\n let deps\n\n if (config.exists) {\n // Run if ESLint config exists\n return await lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, {\n lintDuringBuild,\n eslintOptions,\n reportErrorsOnly,\n maxWarnings,\n formatter,\n outputFile,\n })\n } else {\n // Display warning if no ESLint configuration is present inside\n // config file during \"next build\", no warning is shown when\n // no eslintrc file is present\n if (lintDuringBuild) {\n if (config.emptyPkgJsonConfig || config.emptyEslintrc) {\n Log.warn(\n `No ESLint configuration detected. Run ${bold(\n cyan('next lint')\n )} to begin setup`\n )\n }\n return null\n } else {\n // Ask user what config they would like to start with for first time \"next lint\" setup\n const { config: selectedConfig } = strict\n ? await getESLintStrictValue(baseDir)\n : await cliPrompt(baseDir)\n\n if (selectedConfig == null) {\n // Show a warning if no option is selected in prompt\n Log.warn(\n 'If you set up ESLint yourself, we recommend adding the Next.js ESLint plugin. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n return null\n } else {\n // Check if necessary deps installed, and install any that are missing\n deps = await hasNecessaryDependencies(baseDir, requiredPackages)\n if (deps.missing.length > 0) {\n deps.missing.forEach((dep) => {\n if (dep.pkg === 'eslint') {\n // pin to v9 to avoid breaking changes\n dep.pkg = 'eslint@^9'\n }\n })\n\n await installDependencies(baseDir, deps.missing, true)\n }\n\n // Write default ESLint config.\n // Check for /pages and src/pages is to make sure this happens in Next.js folder\n if (\n ['app', 'src/app', 'pages', 'src/pages'].some((dir) =>\n existsSync(path.join(baseDir, dir))\n )\n ) {\n await writeDefaultConfig(\n baseDir,\n config,\n selectedConfig,\n eslintrcFile,\n pkgJsonPath,\n packageJsonConfig\n )\n }\n }\n\n Log.ready(\n `ESLint has successfully been configured. Run ${bold(\n cyan('next lint')\n )} again to view warnings and errors.`\n )\n\n return null\n }\n }\n } catch (err) {\n throw err\n }\n}\n"],"names":["promises","fs","existsSync","bold","cyan","red","underline","yellow","path","findUp","semver","CommentJson","formatResults","writeDefaultConfig","hasEslintConfiguration","writeOutputFile","findPagesDir","installDependencies","hasNecessaryDependencies","Log","isError","getProperError","getPkgManager","getESLintStrictValue","getESLintPromptValues","VALID_SEVERITY","isValidSeverity","severity","includes","requiredPackages","file","pkg","exportsRestrict","cliPrompt","cwd","console","log","cliSelect","Promise","resolve","require","default","value","values","valueRenderer","title","recommended","selected","name","unselected","config","lint","baseDir","lintDirs","eslintrcFile","pkgJsonPath","lintDuringBuild","eslintOptions","reportErrorsOnly","maxWarnings","formatter","outputFile","mod","ESLint","deps","packageManager","missing","some","dep","error","resolved","get","useFlatConfig","basename","startsWith","loadESLint","eslintVersion","version","CLIEngine","lt","options","useEslintrc","baseConfig","errorOnUnmatchedPattern","extensions","cache","gte","option","eslint","nextEslintPluginIsEnabled","nextRulesEnabled","Map","configFile","completeConfig","calculateConfigForFile","plugins","hasNextPlugin","Array","isArray","Object","entries","rules","length","set","pagesDir","pagesDirRules","updatedPagesDir","rule","replace","warn","lintStart","process","hrtime","results","lintFiles","selectedFormatter","fix","outputFixes","getErrorResults","loadFormatter","formattedResult","format","lintEnd","totalWarnings","reduce","sum","warningCount","output","outputWithMessages","eventInfo","durationInSeconds","lintedFilesCount","lintFix","nextEslintPluginVersion","has","join","dirname","nextEslintPluginErrorsCount","totalNextPluginErrorCount","nextEslintPluginWarningsCount","totalNextPluginWarningCount","fromEntries","err","message","runLintCheck","opts","strict","packageJsonConfig","pkgJsonContent","readFile","encoding","parse","exists","emptyPkgJsonConfig","emptyEslintrc","selectedConfig","forEach","dir","ready"],"mappings":"AAAA,SAASA,YAAYC,EAAE,EAAEC,UAAU,QAAQ,KAAI;AAC/C,SAASC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAM,QAAQ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B,WAC3B,MAAMnB,UAAUmB;gBAEpB,IAAIuG,kBAAkB,MAAM;oBAC1B,oDAAoD;oBACpDxI,IAAI0F,IAAI,CACN;oBAEF,OAAO;gBACT,OAAO;oBACL,sEAAsE;oBACtE7C,OAAO,MAAM9C,yBAAyBkC,SAASvB;oBAC/C,IAAImC,KAAKE,OAAO,CAACoC,MAAM,GAAG,GAAG;wBAC3BtC,KAAKE,OAAO,CAAC0F,OAAO,CAAC,CAACxF;4BACpB,IAAIA,IAAIrC,GAAG,KAAK,UAAU;gCACxB,sCAAsC;gCACtCqC,IAAIrC,GAAG,GAAG;4BACZ;wBACF;wBAEA,MAAMd,oBAAoBmC,SAASY,KAAKE,OAAO,EAAE;oBACnD;oBAEA,+BAA+B;oBAC/B,gFAAgF;oBAChF,IACE;wBAAC;wBAAO;wBAAW;wBAAS;qBAAY,CAACC,IAAI,CAAC,CAAC0F,MAC7C3J,WAAWM,KAAK+H,IAAI,CAACnF,SAASyG,QAEhC;wBACA,MAAMhJ,mBACJuC,SACAF,QACAyG,gBACArG,cACAC,aACA4F;oBAEJ;gBACF;gBAEAhI,IAAI2I,KAAK,CACP,CAAC,6CAA6C,EAAE3J,KAC9CC,KAAK,cACL,mCAAmC,CAAC;gBAGxC,OAAO;YACT;QACF;IACF,EAAE,OAAO0I,KAAK;QACZ,MAAMA;IACR;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/eslint/runLintCheck.ts"],"sourcesContent":["import '../../server/require-hook'\nimport { promises as fs, existsSync } from 'fs'\nimport { bold, cyan, red, underline, yellow } from '../picocolors'\nimport path from 'path'\n\nimport findUp from 'next/dist/compiled/find-up'\nimport semver from 'next/dist/compiled/semver'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\n\nimport { formatResults } from './customFormatter'\nimport type { LintResult } from './customFormatter'\nimport { writeDefaultConfig } from './writeDefaultConfig'\nimport { hasEslintConfiguration } from './hasEslintConfiguration'\nimport { writeOutputFile } from './writeOutputFile'\n\nimport { findPagesDir } from '../find-pages-dir'\nimport { installDependencies } from '../install-dependencies'\nimport { hasNecessaryDependencies } from '../has-necessary-dependencies'\n\nimport * as Log from '../../build/output/log'\nimport type { EventLintCheckCompleted } from '../../telemetry/events/build'\nimport isError, { getProperError } from '../is-error'\nimport { getPkgManager } from '../helpers/get-pkg-manager'\nimport {\n getESLintStrictValue,\n getESLintPromptValues,\n} from './getESLintPromptValues'\n\ntype Config = {\n plugins: string[]\n rules: { [key: string]: Array<number | string> }\n}\n\n// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules\nconst VALID_SEVERITY = ['off', 'warn', 'error'] as const\ntype Severity = (typeof VALID_SEVERITY)[number]\n\nfunction isValidSeverity(severity: string): severity is Severity {\n return VALID_SEVERITY.includes(severity as Severity)\n}\n\nconst requiredPackages = [\n { file: 'eslint', pkg: 'eslint', exportsRestrict: false },\n {\n file: 'eslint-config-next',\n pkg: 'eslint-config-next',\n exportsRestrict: false,\n },\n]\n\nasync function cliPrompt(cwd: string): Promise<{ config?: any }> {\n console.log(\n bold(\n `${cyan(\n '?'\n )} How would you like to configure ESLint? https://nextjs.org/docs/app/api-reference/config/eslint`\n )\n )\n\n try {\n const cliSelect = (\n await Promise.resolve(\n (require('next/dist/compiled/cli-select') as typeof import('next/dist/compiled/cli-select'))\n )\n ).default\n const { value } = await cliSelect({\n values: await getESLintPromptValues(cwd),\n valueRenderer: (\n {\n title,\n recommended,\n }: { title: string; recommended?: boolean; config: any },\n selected: boolean\n ) => {\n const name = selected ? bold(underline(cyan(title))) : title\n return name + (recommended ? bold(yellow(' (recommended)')) : '')\n },\n selected: cyan('❯ '),\n unselected: ' ',\n })\n\n return { config: value?.config ?? null }\n } catch {\n return { config: null }\n }\n}\n\nasync function lint(\n baseDir: string,\n lintDirs: string[],\n eslintrcFile: string | null,\n pkgJsonPath: string | null,\n {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n }: {\n lintDuringBuild: boolean\n eslintOptions: any\n reportErrorsOnly: boolean\n maxWarnings: number\n formatter: string | null\n outputFile: string | null\n }\n): Promise<\n | string\n | null\n | {\n output: string | null\n isError: boolean\n eventInfo: EventLintCheckCompleted\n }\n> {\n try {\n // Load ESLint after we're sure it exists:\n const deps = hasNecessaryDependencies(baseDir, requiredPackages)\n const packageManager = getPkgManager(baseDir)\n\n if (deps.missing.some((dep) => dep.pkg === 'eslint')) {\n Log.error(\n `ESLint must be installed${\n lintDuringBuild ? ' in order to run during builds:' : ':'\n } ${bold(\n cyan(\n (packageManager === 'yarn'\n ? 'yarn add --dev'\n : packageManager === 'pnpm'\n ? 'pnpm install --save-dev'\n : 'npm install --save-dev') + ' eslint'\n )\n )}`\n )\n return null\n }\n\n const mod = await Promise.resolve(require(deps.resolved.get('eslint')!))\n\n // If V9 config was found, use flat config, or else use legacy.\n const useFlatConfig = eslintrcFile\n ? // eslintrcFile is absolute path\n path.basename(eslintrcFile).startsWith('eslint.config.')\n : false\n\n let ESLint\n // loadESLint is >= 8.57.0\n // PR https://github.com/eslint/eslint/pull/18098\n // Release https://github.com/eslint/eslint/releases/tag/v8.57.0\n if ('loadESLint' in mod) {\n // By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.\n // https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613\n ESLint = await mod.loadESLint({\n useFlatConfig,\n })\n } else {\n // eslint < 8.57.0, use legacy ESLint\n ESLint = mod.ESLint\n }\n\n let eslintVersion = ESLint?.version ?? mod.CLIEngine?.version\n\n if (!eslintVersion || semver.lt(eslintVersion, '7.0.0')) {\n return `${red(\n 'error'\n )} - Your project has an older version of ESLint installed${\n eslintVersion ? ' (' + eslintVersion + ')' : ''\n }. Please upgrade to ESLint version 7 or above`\n }\n\n let options: any = {\n useEslintrc: true,\n baseConfig: {},\n errorOnUnmatchedPattern: false,\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n cache: true,\n ...eslintOptions,\n }\n\n if (semver.gte(eslintVersion, '9.0.0') && useFlatConfig) {\n for (const option of [\n 'useEslintrc',\n 'extensions',\n 'ignorePath',\n 'reportUnusedDisableDirectives',\n 'resolvePluginsRelativeTo',\n 'rulePaths',\n 'inlineConfig',\n 'maxWarnings',\n ]) {\n if (option in options) {\n delete options[option]\n }\n }\n }\n\n let eslint = new ESLint(options)\n\n let nextEslintPluginIsEnabled = false\n const nextRulesEnabled = new Map<string, Severity>()\n\n for (const configFile of [eslintrcFile, pkgJsonPath]) {\n if (!configFile) continue\n\n const completeConfig: Config | undefined =\n await eslint.calculateConfigForFile(configFile)\n if (!completeConfig) continue\n\n const plugins = completeConfig.plugins\n\n const hasNextPlugin =\n // in ESLint < 9, `plugins` value is string[]\n Array.isArray(plugins)\n ? plugins.includes('@next/next')\n : // in ESLint >= 9, `plugins` value is Record<string, unknown>\n '@next/next' in plugins\n\n if (hasNextPlugin) {\n nextEslintPluginIsEnabled = true\n for (const [name, [severity]] of Object.entries(completeConfig.rules)) {\n if (!name.startsWith('@next/next/')) {\n continue\n }\n if (\n typeof severity === 'number' &&\n severity >= 0 &&\n severity < VALID_SEVERITY.length\n ) {\n nextRulesEnabled.set(name, VALID_SEVERITY[severity])\n } else if (\n typeof severity === 'string' &&\n isValidSeverity(severity)\n ) {\n nextRulesEnabled.set(name, severity)\n }\n }\n break\n }\n }\n\n const pagesDir = findPagesDir(baseDir).pagesDir\n const pagesDirRules = pagesDir ? ['@next/next/no-html-link-for-pages'] : []\n\n if (nextEslintPluginIsEnabled) {\n let updatedPagesDir = false\n\n for (const rule of pagesDirRules) {\n if (\n !options.baseConfig!.rules?.[rule] &&\n !options.baseConfig!.rules?.[\n rule.replace('@next/next', '@next/babel-plugin-next')\n ]\n ) {\n if (!options.baseConfig!.rules) {\n options.baseConfig!.rules = {}\n }\n options.baseConfig!.rules[rule] = [1, pagesDir]\n updatedPagesDir = true\n }\n }\n\n if (updatedPagesDir) {\n eslint = new ESLint(options)\n }\n } else {\n Log.warn('')\n Log.warn(\n 'The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n }\n\n const lintStart = process.hrtime()\n\n let results = await eslint.lintFiles(lintDirs)\n let selectedFormatter = null\n\n if (options.fix) await ESLint.outputFixes(results)\n if (reportErrorsOnly) results = await ESLint.getErrorResults(results) // Only return errors if --quiet flag is used\n\n if (formatter) selectedFormatter = await eslint.loadFormatter(formatter)\n const formattedResult = await formatResults(\n baseDir,\n results,\n selectedFormatter?.format\n )\n const lintEnd = process.hrtime(lintStart)\n const totalWarnings = results.reduce(\n (sum: number, file: LintResult) => sum + file.warningCount,\n 0\n )\n\n if (outputFile) await writeOutputFile(outputFile, formattedResult.output)\n\n return {\n output: formattedResult.outputWithMessages,\n isError:\n ESLint.getErrorResults(results)?.length > 0 ||\n (maxWarnings >= 0 && totalWarnings > maxWarnings),\n eventInfo: {\n durationInSeconds: lintEnd[0],\n eslintVersion: eslintVersion,\n lintedFilesCount: results.length,\n lintFix: !!options.fix,\n nextEslintPluginVersion:\n nextEslintPluginIsEnabled && deps.resolved.has('eslint-config-next')\n ? require(\n path.join(\n path.dirname(deps.resolved.get('eslint-config-next')!),\n 'package.json'\n )\n ).version\n : null,\n nextEslintPluginErrorsCount: formattedResult.totalNextPluginErrorCount,\n nextEslintPluginWarningsCount:\n formattedResult.totalNextPluginWarningCount,\n nextRulesEnabled: Object.fromEntries(nextRulesEnabled),\n },\n }\n } catch (err) {\n if (lintDuringBuild) {\n Log.error(\n `ESLint: ${\n isError(err) && err.message ? err.message.replace(/\\n/g, ' ') : err\n }`\n )\n return null\n } else {\n throw getProperError(err)\n }\n }\n}\n\nexport async function runLintCheck(\n baseDir: string,\n lintDirs: string[],\n opts: {\n lintDuringBuild?: boolean\n eslintOptions?: any\n reportErrorsOnly?: boolean\n maxWarnings?: number\n formatter?: string | null\n outputFile?: string | null\n strict?: boolean\n }\n): ReturnType<typeof lint> {\n const {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n strict = false,\n } = opts\n try {\n // Find user's .eslintrc file\n // See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats\n const eslintrcFile =\n (await findUp(\n [\n // eslint v9\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n // TS extensions require to install a separate package `jiti`.\n // https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files\n 'eslint.config.ts',\n 'eslint.config.mts',\n 'eslint.config.cts',\n // eslint <= v8\n '.eslintrc.js',\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n '.eslintrc',\n ],\n {\n cwd: baseDir,\n }\n )) ?? null\n\n const pkgJsonPath = (await findUp('package.json', { cwd: baseDir })) ?? null\n let packageJsonConfig = null\n if (pkgJsonPath) {\n const pkgJsonContent = await fs.readFile(pkgJsonPath, {\n encoding: 'utf8',\n })\n packageJsonConfig = CommentJson.parse(pkgJsonContent)\n }\n\n const config = await hasEslintConfiguration(eslintrcFile, packageJsonConfig)\n let deps\n\n if (config.exists) {\n // Run if ESLint config exists\n return await lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, {\n lintDuringBuild,\n eslintOptions,\n reportErrorsOnly,\n maxWarnings,\n formatter,\n outputFile,\n })\n } else {\n // Display warning if no ESLint configuration is present inside\n // config file during \"next build\", no warning is shown when\n // no eslintrc file is present\n if (lintDuringBuild) {\n if (config.emptyPkgJsonConfig || config.emptyEslintrc) {\n Log.warn(\n `No ESLint configuration detected. Run ${bold(\n cyan('next lint')\n )} to begin setup`\n )\n }\n return null\n } else {\n // Ask user what config they would like to start with for first time \"next lint\" setup\n const { config: selectedConfig } = strict\n ? await getESLintStrictValue(baseDir)\n : await cliPrompt(baseDir)\n\n if (selectedConfig == null) {\n // Show a warning if no option is selected in prompt\n Log.warn(\n 'If you set up ESLint yourself, we recommend adding the Next.js ESLint plugin. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n return null\n } else {\n // Check if necessary deps installed, and install any that are missing\n deps = await hasNecessaryDependencies(baseDir, requiredPackages)\n if (deps.missing.length > 0) {\n deps.missing.forEach((dep) => {\n if (dep.pkg === 'eslint') {\n // pin to v9 to avoid breaking changes\n dep.pkg = 'eslint@^9'\n }\n })\n\n await installDependencies(baseDir, deps.missing, true)\n }\n\n // Write default ESLint config.\n // Check for /pages and src/pages is to make sure this happens in Next.js folder\n if (\n ['app', 'src/app', 'pages', 'src/pages'].some((dir) =>\n existsSync(path.join(baseDir, dir))\n )\n ) {\n await writeDefaultConfig(\n baseDir,\n config,\n selectedConfig,\n eslintrcFile,\n pkgJsonPath,\n packageJsonConfig\n )\n }\n }\n\n Log.ready(\n `ESLint has successfully been configured. Run ${bold(\n cyan('next lint')\n )} again to view warnings and errors.`\n )\n\n return null\n }\n }\n } catch (err) {\n throw err\n }\n}\n"],"names":["promises","fs","existsSync","bold","cyan","red","underline","yellow","path","findUp","semver","CommentJson","formatResults","writeDefaultConfig","hasEslintConfiguration","writeOutputFile","findPagesDir","installDependencies","hasNecessaryDependencies","Log","isError","getProperError","getPkgManager","getESLintStrictValue","getESLintPromptValues","VALID_SEVERITY","isValidSeverity","severity","includes","requiredPackages","file","pkg","exportsRestrict","cliPrompt","cwd","console","log","cliSelect","Promise","resolve","require","default","value","values","valueRenderer","title","recommended","selected","name","unselected","config","lint","baseDir","lintDirs","eslintrcFile","pkgJsonPath","lintDuringBuild","eslintOptions","reportErrorsOnly","maxWarnings","formatter","outputFile","mod","ESLint","deps","packageManager","missing","some","dep","error","resolved","get","useFlatConfig","basename","startsWith","loadESLint","eslintVersion","version","CLIEngine","lt","options","useEslintrc","baseConfig","errorOnUnmatchedPattern","extensions","cache","gte","option","eslint","nextEslintPluginIsEnabled","nextRulesEnabled","Map","configFile","completeConfig","calculateConfigForFile","plugins","hasNextPlugin","Array","isArray","Object","entries","rules","length","set","pagesDir","pagesDirRules","updatedPagesDir","rule","replace","warn","lintStart","process","hrtime","results","lintFiles","selectedFormatter","fix","outputFixes","getErrorResults","loadFormatter","formattedResult","format","lintEnd","totalWarnings","reduce","sum","warningCount","output","outputWithMessages","eventInfo","durationInSeconds","lintedFilesCount","lintFix","nextEslintPluginVersion","has","join","dirname","nextEslintPluginErrorsCount","totalNextPluginErrorCount","nextEslintPluginWarningsCount","totalNextPluginWarningCount","fromEntries","err","message","runLintCheck","opts","strict","packageJsonConfig","pkgJsonContent","readFile","encoding","parse","exists","emptyPkgJsonConfig","emptyEslintrc","selectedConfig","forEach","dir","ready"],"mappings":"AAAA,OAAO,4BAA2B;AAClC,SAASA,YAAYC,EAAE,EAAEC,UAAU,QAAQ,KAAI;AAC/C,SAASC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAM,QAAQ,gBAAe;AAClE,OAAOC,UAAU,OAAM;AAEvB,OAAOC,YAAY,6BAA4B;AAC/C,OAAOC,YAAY,4BAA2B;AAC9C,YAAYC,iBAAiB,kCAAiC;AAE9D,SAASC,aAAa,QAAQ,oBAAmB;AAEjD,SAASC,kBAAkB,QAAQ,uBAAsB;AACzD,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,eAAe,QAAQ,oBAAmB;AAEnD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,0BAAyB;AAC7D,SAASC,wBAAwB,QAAQ,gCAA+B;AAExE,YAAYC,SAAS,yBAAwB;AAE7C,OAAOC,WAAWC,cAAc,QAAQ,cAAa;AACrD,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SACEC,oBAAoB,EACpBC,qBAAqB,QAChB,0BAAyB;AAOhC,8GAA8G;AAC9G,MAAMC,iBAAiB;IAAC;IAAO;IAAQ;CAAQ;AAG/C,SAASC,gBAAgBC,QAAgB;IAC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mBACJuC,SACAF,QACAyG,gBACArG,cACAC,aACA4F;oBAEJ;gBACF;gBAEAhI,IAAI2I,KAAK,CACP,CAAC,6CAA6C,EAAE3J,KAC9CC,KAAK,cACL,mCAAmC,CAAC;gBAGxC,OAAO;YACT;QACF;IACF,EAAE,OAAO0I,KAAK;QACZ,MAAMA;IACR;AACF","ignoreList":[0]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path 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}: {\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}): 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 tsPath = deps.resolved.get('typescript')!\n const ts = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n if (semver.lt(ts.version, '4.5.2')) {\n log.warn(\n `Minimum recommended TypeScript version is v4.5.2, older versions can potentially be incompatible with Next.js. Detected: ${ts.version}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n ts,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir\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 // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n ts,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir\n )\n }\n return { result, version: ts.version }\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":["bold","cyan","red","yellow","path","hasNecessaryDependencies","semver","CompileError","log","getTypeScriptIntent","writeAppTypeDeclarations","writeConfigurationDefaults","installDependencies","isCI","missingDepsError","requiredPackages","file","pkg","exportsRestrict","verifyTypeScriptSetup","dir","distDir","cacheDir","intentDirs","tsconfigPath","typeCheckPreflight","disableStaticImages","hasAppDir","hasPagesDir","tsConfigFileName","resolvedTsConfigPath","join","deps","intent","version","missing","length","console","catch","err","error","command","tsPath","resolved","get","ts","Promise","resolve","require","lt","warn","firstTimeSetup","baseDir","imageImportsEnabled","result","runTypeCheck","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":"AAAA,SAASA,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,QAAQ,eAAc;AACtD,OAAOC,UAAU,OAAM;AAEvB,SAASC,wBAAwB,QAAQ,+BAA8B;AAEvE,OAAOC,YAAY,4BAA2B;AAC9C,SAASC,YAAY,QAAQ,kBAAiB;AAC9C,YAAYC,SAAS,sBAAqB;AAE1C,SAASC,mBAAmB,QAAQ,m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AClF,MAAMnB;IACR;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import '../server/require-hook'\nimport { bold, cyan, red, yellow } from './picocolors'\nimport path 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}: {\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}): 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 tsPath = deps.resolved.get('typescript')!\n const ts = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n if (semver.lt(ts.version, '4.5.2')) {\n log.warn(\n `Minimum recommended TypeScript version is v4.5.2, older versions can potentially be incompatible with Next.js. Detected: ${ts.version}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n ts,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir\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 // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n ts,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir\n )\n }\n return { result, version: ts.version }\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":["bold","cyan","red","yellow","path","hasNecessaryDependencies","semver","CompileError","log","getTypeScriptIntent","writeAppTypeDeclarations","writeConfigurationDefaults","installDependencies","isCI","missingDepsError","requiredPackages","file","pkg","exportsRestrict","verifyTypeScriptSetup","dir","distDir","cacheDir","intentDirs","tsconfigPath","typeCheckPreflight","disableStaticImages","hasAppDir","hasPagesDir","tsConfigFileName","resolvedTsConfigPath","join","deps","intent","version","missing","length","console","catch","err","error","command","tsPath","resolved","get","ts","Promise","resolve","require","lt","warn","firstTimeSetup","baseDir","imageImportsEnabled","result","runTypeCheck","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":"AAAA,OAAO,yBAAwB;AAC/B,SAASA,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,QAAQ,eAAc;AACtD,OAAOC,UAAU,OAAM;AAEvB,SAASC,wBAAwB,QAAQ,+BAA8B;AAEvE,OAAOC,YAAY,4BAA2B;AAC9C,SAASC,YAAY,QAAQ,kBAAiB;AAC9C,YAAYC,SAAS,sBAAqB;AAE1C,SAASC,mBAAmB,QAAQ,mCAAkC;AAEtE,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,0BAA0B,QAAQ,0CAAyC;AACpF,SAASC,mBAAmB,QAAQ,yBAAwB;AAC5D,SAASC,IAAI,QAAQ,oBAAmB;AACxC,SAASC,gBAAgB,QAA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KW,QAAQ,CAACC,GAAG,CAAC;QACjC,MAAMC,KAAM,MAAMC,QAAQC,OAAO,CAC/BC,QAAQN;QAGV,IAAIpC,OAAO2C,EAAE,CAACJ,GAAGX,OAAO,EAAE,UAAU;YAClC1B,IAAI0C,IAAI,CACN,CAAC,yHAAyH,EAAEL,GAAGX,OAAO,EAAE;QAE5I;QAEA,+DAA+D;QAC/D,MAAMvB,2BACJkC,IACAf,sBACAG,OAAOkB,cAAc,EACrBxB,WACAN,SACAO;QAEF,qEAAqE;QACrE,kBAAkB;QAClB,MAAMlB,yBAAyB;YAC7B0C,SAAShC;YACTC;YACAgC,qBAAqB,CAAC3B;YACtBE;YACAD;QACF;QAEA,IAAI2B;QACJ,IAAI7B,oBAAoB;YACtB,MAAM,EAAE8B,YAAY,EAAE,GACpBP,QAAQ;YAEV,yEAAyE;YACzEM,SAAS,MAAMC,aACbV,IACAzB,KACAC,SACAS,sBACAR,UACAK;QAEJ;QACA,OAAO;YAAE2B;YAAQpB,SAASW,GAAGX,OAAO;QAAC;IACvC,EAAE,OAAOK,KAAK;QACZ,+DAA+D;QAC/D,IAAIA,eAAehC,cAAc;YAC/B8B,QAAQG,KAAK,CAACtC,IAAI;YAClBmC,QAAQG,KAAK,CAACD,IAAIiB,OAAO;YACzBC,QAAQC,IAAI,CAAC;QACf;QAEA;;;;KAIC,GAED,mEAAmE;QACnE,IAAID,QAAQE,GAAG,CAACC,cAAc,EAAE;YAC9B,IAAIrB,eAAesB,OAAO;gBACxBxB,QAAQG,KAAK,CAACD,IAAIiB,OAAO;YAC3B,OAAO;gBACLnB,QAAQG,KAAK,CAACD;YAChB;YACAkB,QAAQC,IAAI,CAAC;QACf;QACA,kFAAkF;QAClF,MAAMnB;IACR;AACF","ignoreList":[0]}
|
|
@@ -158,7 +158,7 @@ export default class HotReloaderWebpack {
|
|
|
158
158
|
this.previewProps = previewProps;
|
|
159
159
|
this.rewrites = rewrites;
|
|
160
160
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
|
161
|
-
version: "15.6.0-bun.
|
|
161
|
+
version: "15.6.0-bun.17"
|
|
162
162
|
});
|
|
163
163
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
164
164
|
// of the current `next dev` invocation.
|
|
@@ -14,7 +14,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
|
|
|
14
14
|
bundlerSuffix = ' (webpack)';
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.6.0-bun.
|
|
17
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.6.0-bun.17"}`))}${bundlerSuffix}`);
|
|
18
18
|
if (appUrl) {
|
|
19
19
|
Log.bootstrap(`- Local: ${appUrl}`);
|
|
20
20
|
}
|
|
@@ -87,7 +87,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
|
|
|
87
87
|
export async function startServer(serverOptions) {
|
|
88
88
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
89
89
|
let { port } = serverOptions;
|
|
90
|
-
process.title = `next-server (v${"15.6.0-bun.
|
|
90
|
+
process.title = `next-server (v${"15.6.0-bun.17"})`;
|
|
91
91
|
let handlersReady = ()=>{};
|
|
92
92
|
let handlersError = ()=>{};
|
|
93
93
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function isStableBuild() {
|
|
2
2
|
var _process_env___NEXT_VERSION;
|
|
3
|
-
return !((_process_env___NEXT_VERSION = "15.6.0-bun.
|
|
3
|
+
return !((_process_env___NEXT_VERSION = "15.6.0-bun.17") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
|
4
4
|
}
|
|
5
5
|
export class CanaryOnlyError extends Error {
|
|
6
6
|
constructor(arg){
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../../server/require-hook';
|
|
1
2
|
import type { EventLintCheckCompleted } from '../../telemetry/events/build';
|
|
2
3
|
declare function lint(baseDir: string, lintDirs: string[], eslintrcFile: string | null, pkgJsonPath: string | null, { lintDuringBuild, eslintOptions, reportErrorsOnly, maxWarnings, formatter, outputFile, }: {
|
|
3
4
|
lintDuringBuild: boolean;
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "runLintCheck", {
|
|
|
8
8
|
return runLintCheck;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
require("../../server/require-hook");
|
|
11
12
|
const _fs = require("fs");
|
|
12
13
|
const _picocolors = require("../picocolors");
|
|
13
14
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/eslint/runLintCheck.ts"],"sourcesContent":["import { promises as fs, existsSync } from 'fs'\nimport { bold, cyan, red, underline, yellow } from '../picocolors'\nimport path from 'path'\n\nimport findUp from 'next/dist/compiled/find-up'\nimport semver from 'next/dist/compiled/semver'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\n\nimport { formatResults } from './customFormatter'\nimport type { LintResult } from './customFormatter'\nimport { writeDefaultConfig } from './writeDefaultConfig'\nimport { hasEslintConfiguration } from './hasEslintConfiguration'\nimport { writeOutputFile } from './writeOutputFile'\n\nimport { findPagesDir } from '../find-pages-dir'\nimport { installDependencies } from '../install-dependencies'\nimport { hasNecessaryDependencies } from '../has-necessary-dependencies'\n\nimport * as Log from '../../build/output/log'\nimport type { EventLintCheckCompleted } from '../../telemetry/events/build'\nimport isError, { getProperError } from '../is-error'\nimport { getPkgManager } from '../helpers/get-pkg-manager'\nimport {\n getESLintStrictValue,\n getESLintPromptValues,\n} from './getESLintPromptValues'\n\ntype Config = {\n plugins: string[]\n rules: { [key: string]: Array<number | string> }\n}\n\n// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules\nconst VALID_SEVERITY = ['off', 'warn', 'error'] as const\ntype Severity = (typeof VALID_SEVERITY)[number]\n\nfunction isValidSeverity(severity: string): severity is Severity {\n return VALID_SEVERITY.includes(severity as Severity)\n}\n\nconst requiredPackages = [\n { file: 'eslint', pkg: 'eslint', exportsRestrict: false },\n {\n file: 'eslint-config-next',\n pkg: 'eslint-config-next',\n exportsRestrict: false,\n },\n]\n\nasync function cliPrompt(cwd: string): Promise<{ config?: any }> {\n console.log(\n bold(\n `${cyan(\n '?'\n )} How would you like to configure ESLint? https://nextjs.org/docs/app/api-reference/config/eslint`\n )\n )\n\n try {\n const cliSelect = (\n await Promise.resolve(\n (require('next/dist/compiled/cli-select') as typeof import('next/dist/compiled/cli-select'))\n )\n ).default\n const { value } = await cliSelect({\n values: await getESLintPromptValues(cwd),\n valueRenderer: (\n {\n title,\n recommended,\n }: { title: string; recommended?: boolean; config: any },\n selected: boolean\n ) => {\n const name = selected ? bold(underline(cyan(title))) : title\n return name + (recommended ? bold(yellow(' (recommended)')) : '')\n },\n selected: cyan('❯ '),\n unselected: ' ',\n })\n\n return { config: value?.config ?? null }\n } catch {\n return { config: null }\n }\n}\n\nasync function lint(\n baseDir: string,\n lintDirs: string[],\n eslintrcFile: string | null,\n pkgJsonPath: string | null,\n {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n }: {\n lintDuringBuild: boolean\n eslintOptions: any\n reportErrorsOnly: boolean\n maxWarnings: number\n formatter: string | null\n outputFile: string | null\n }\n): Promise<\n | string\n | null\n | {\n output: string | null\n isError: boolean\n eventInfo: EventLintCheckCompleted\n }\n> {\n try {\n // Load ESLint after we're sure it exists:\n const deps = hasNecessaryDependencies(baseDir, requiredPackages)\n const packageManager = getPkgManager(baseDir)\n\n if (deps.missing.some((dep) => dep.pkg === 'eslint')) {\n Log.error(\n `ESLint must be installed${\n lintDuringBuild ? ' in order to run during builds:' : ':'\n } ${bold(\n cyan(\n (packageManager === 'yarn'\n ? 'yarn add --dev'\n : packageManager === 'pnpm'\n ? 'pnpm install --save-dev'\n : 'npm install --save-dev') + ' eslint'\n )\n )}`\n )\n return null\n }\n\n const mod = await Promise.resolve(require(deps.resolved.get('eslint')!))\n\n // If V9 config was found, use flat config, or else use legacy.\n const useFlatConfig = eslintrcFile\n ? // eslintrcFile is absolute path\n path.basename(eslintrcFile).startsWith('eslint.config.')\n : false\n\n let ESLint\n // loadESLint is >= 8.57.0\n // PR https://github.com/eslint/eslint/pull/18098\n // Release https://github.com/eslint/eslint/releases/tag/v8.57.0\n if ('loadESLint' in mod) {\n // By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.\n // https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613\n ESLint = await mod.loadESLint({\n useFlatConfig,\n })\n } else {\n // eslint < 8.57.0, use legacy ESLint\n ESLint = mod.ESLint\n }\n\n let eslintVersion = ESLint?.version ?? mod.CLIEngine?.version\n\n if (!eslintVersion || semver.lt(eslintVersion, '7.0.0')) {\n return `${red(\n 'error'\n )} - Your project has an older version of ESLint installed${\n eslintVersion ? ' (' + eslintVersion + ')' : ''\n }. Please upgrade to ESLint version 7 or above`\n }\n\n let options: any = {\n useEslintrc: true,\n baseConfig: {},\n errorOnUnmatchedPattern: false,\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n cache: true,\n ...eslintOptions,\n }\n\n if (semver.gte(eslintVersion, '9.0.0') && useFlatConfig) {\n for (const option of [\n 'useEslintrc',\n 'extensions',\n 'ignorePath',\n 'reportUnusedDisableDirectives',\n 'resolvePluginsRelativeTo',\n 'rulePaths',\n 'inlineConfig',\n 'maxWarnings',\n ]) {\n if (option in options) {\n delete options[option]\n }\n }\n }\n\n let eslint = new ESLint(options)\n\n let nextEslintPluginIsEnabled = false\n const nextRulesEnabled = new Map<string, Severity>()\n\n for (const configFile of [eslintrcFile, pkgJsonPath]) {\n if (!configFile) continue\n\n const completeConfig: Config | undefined =\n await eslint.calculateConfigForFile(configFile)\n if (!completeConfig) continue\n\n const plugins = completeConfig.plugins\n\n const hasNextPlugin =\n // in ESLint < 9, `plugins` value is string[]\n Array.isArray(plugins)\n ? plugins.includes('@next/next')\n : // in ESLint >= 9, `plugins` value is Record<string, unknown>\n '@next/next' in plugins\n\n if (hasNextPlugin) {\n nextEslintPluginIsEnabled = true\n for (const [name, [severity]] of Object.entries(completeConfig.rules)) {\n if (!name.startsWith('@next/next/')) {\n continue\n }\n if (\n typeof severity === 'number' &&\n severity >= 0 &&\n severity < VALID_SEVERITY.length\n ) {\n nextRulesEnabled.set(name, VALID_SEVERITY[severity])\n } else if (\n typeof severity === 'string' &&\n isValidSeverity(severity)\n ) {\n nextRulesEnabled.set(name, severity)\n }\n }\n break\n }\n }\n\n const pagesDir = findPagesDir(baseDir).pagesDir\n const pagesDirRules = pagesDir ? ['@next/next/no-html-link-for-pages'] : []\n\n if (nextEslintPluginIsEnabled) {\n let updatedPagesDir = false\n\n for (const rule of pagesDirRules) {\n if (\n !options.baseConfig!.rules?.[rule] &&\n !options.baseConfig!.rules?.[\n rule.replace('@next/next', '@next/babel-plugin-next')\n ]\n ) {\n if (!options.baseConfig!.rules) {\n options.baseConfig!.rules = {}\n }\n options.baseConfig!.rules[rule] = [1, pagesDir]\n updatedPagesDir = true\n }\n }\n\n if (updatedPagesDir) {\n eslint = new ESLint(options)\n }\n } else {\n Log.warn('')\n Log.warn(\n 'The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n }\n\n const lintStart = process.hrtime()\n\n let results = await eslint.lintFiles(lintDirs)\n let selectedFormatter = null\n\n if (options.fix) await ESLint.outputFixes(results)\n if (reportErrorsOnly) results = await ESLint.getErrorResults(results) // Only return errors if --quiet flag is used\n\n if (formatter) selectedFormatter = await eslint.loadFormatter(formatter)\n const formattedResult = await formatResults(\n baseDir,\n results,\n selectedFormatter?.format\n )\n const lintEnd = process.hrtime(lintStart)\n const totalWarnings = results.reduce(\n (sum: number, file: LintResult) => sum + file.warningCount,\n 0\n )\n\n if (outputFile) await writeOutputFile(outputFile, formattedResult.output)\n\n return {\n output: formattedResult.outputWithMessages,\n isError:\n ESLint.getErrorResults(results)?.length > 0 ||\n (maxWarnings >= 0 && totalWarnings > maxWarnings),\n eventInfo: {\n durationInSeconds: lintEnd[0],\n eslintVersion: eslintVersion,\n lintedFilesCount: results.length,\n lintFix: !!options.fix,\n nextEslintPluginVersion:\n nextEslintPluginIsEnabled && deps.resolved.has('eslint-config-next')\n ? require(\n path.join(\n path.dirname(deps.resolved.get('eslint-config-next')!),\n 'package.json'\n )\n ).version\n : null,\n nextEslintPluginErrorsCount: formattedResult.totalNextPluginErrorCount,\n nextEslintPluginWarningsCount:\n formattedResult.totalNextPluginWarningCount,\n nextRulesEnabled: Object.fromEntries(nextRulesEnabled),\n },\n }\n } catch (err) {\n if (lintDuringBuild) {\n Log.error(\n `ESLint: ${\n isError(err) && err.message ? err.message.replace(/\\n/g, ' ') : err\n }`\n )\n return null\n } else {\n throw getProperError(err)\n }\n }\n}\n\nexport async function runLintCheck(\n baseDir: string,\n lintDirs: string[],\n opts: {\n lintDuringBuild?: boolean\n eslintOptions?: any\n reportErrorsOnly?: boolean\n maxWarnings?: number\n formatter?: string | null\n outputFile?: string | null\n strict?: boolean\n }\n): ReturnType<typeof lint> {\n const {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n strict = false,\n } = opts\n try {\n // Find user's .eslintrc file\n // See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats\n const eslintrcFile =\n (await findUp(\n [\n // eslint v9\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n // TS extensions require to install a separate package `jiti`.\n // https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files\n 'eslint.config.ts',\n 'eslint.config.mts',\n 'eslint.config.cts',\n // eslint <= v8\n '.eslintrc.js',\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n '.eslintrc',\n ],\n {\n cwd: baseDir,\n }\n )) ?? null\n\n const pkgJsonPath = (await findUp('package.json', { cwd: baseDir })) ?? null\n let packageJsonConfig = null\n if (pkgJsonPath) {\n const pkgJsonContent = await fs.readFile(pkgJsonPath, {\n encoding: 'utf8',\n })\n packageJsonConfig = CommentJson.parse(pkgJsonContent)\n }\n\n const config = await hasEslintConfiguration(eslintrcFile, packageJsonConfig)\n let deps\n\n if (config.exists) {\n // Run if ESLint config exists\n return await lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, {\n lintDuringBuild,\n eslintOptions,\n reportErrorsOnly,\n maxWarnings,\n formatter,\n outputFile,\n })\n } else {\n // Display warning if no ESLint configuration is present inside\n // config file during \"next build\", no warning is shown when\n // no eslintrc file is present\n if (lintDuringBuild) {\n if (config.emptyPkgJsonConfig || config.emptyEslintrc) {\n Log.warn(\n `No ESLint configuration detected. Run ${bold(\n cyan('next lint')\n )} to begin setup`\n )\n }\n return null\n } else {\n // Ask user what config they would like to start with for first time \"next lint\" setup\n const { config: selectedConfig } = strict\n ? await getESLintStrictValue(baseDir)\n : await cliPrompt(baseDir)\n\n if (selectedConfig == null) {\n // Show a warning if no option is selected in prompt\n Log.warn(\n 'If you set up ESLint yourself, we recommend adding the Next.js ESLint plugin. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n return null\n } else {\n // Check if necessary deps installed, and install any that are missing\n deps = await hasNecessaryDependencies(baseDir, requiredPackages)\n if (deps.missing.length > 0) {\n deps.missing.forEach((dep) => {\n if (dep.pkg === 'eslint') {\n // pin to v9 to avoid breaking changes\n dep.pkg = 'eslint@^9'\n }\n })\n\n await installDependencies(baseDir, deps.missing, true)\n }\n\n // Write default ESLint config.\n // Check for /pages and src/pages is to make sure this happens in Next.js folder\n if (\n ['app', 'src/app', 'pages', 'src/pages'].some((dir) =>\n existsSync(path.join(baseDir, dir))\n )\n ) {\n await writeDefaultConfig(\n baseDir,\n config,\n selectedConfig,\n eslintrcFile,\n pkgJsonPath,\n packageJsonConfig\n )\n }\n }\n\n Log.ready(\n `ESLint has successfully been configured. Run ${bold(\n cyan('next lint')\n )} again to view warnings and errors.`\n )\n\n return null\n }\n }\n } catch (err) {\n throw err\n }\n}\n"],"names":["runLintCheck","VALID_SEVERITY","isValidSeverity","severity","includes","requiredPackages","file","pkg","exportsRestrict","cliPrompt","cwd","console","log","bold","cyan","cliSelect","Promise","resolve","require","default","value","values","getESLintPromptValues","valueRenderer","title","recommended","selected","name","underline","yellow","unselected","config","lint","baseDir","lintDirs","eslintrcFile","pkgJsonPath","lintDuringBuild","eslintOptions","reportErrorsOnly","maxWarnings","formatter","outputFile","mod","ESLint","deps","hasNecessaryDependencies","packageManager","getPkgManager","missing","some","dep","Log","error","resolved","get","useFlatConfig","path","basename","startsWith","loadESLint","eslintVersion","version","CLIEngine","semver","lt","red","options","useEslintrc","baseConfig","errorOnUnmatchedPattern","extensions","cache","gte","option","eslint","nextEslintPluginIsEnabled","nextRulesEnabled","Map","configFile","completeConfig","calculateConfigForFile","plugins","hasNextPlugin","Array","isArray","Object","entries","rules","length","set","pagesDir","findPagesDir","pagesDirRules","updatedPagesDir","rule","replace","warn","lintStart","process","hrtime","results","lintFiles","selectedFormatter","fix","outputFixes","getErrorResults","loadFormatter","formattedResult","formatResults","format","lintEnd","totalWarnings","reduce","sum","warningCount","writeOutputFile","output","outputWithMessages","isError","eventInfo","durationInSeconds","lintedFilesCount","lintFix","nextEslintPluginVersion","has","join","dirname","nextEslintPluginErrorsCount","totalNextPluginErrorCount","nextEslintPluginWarningsCount","totalNextPluginWarningCount","fromEntries","err","message","getProperError","opts","strict","findUp","packageJsonConfig","pkgJsonContent","fs","readFile","encoding","CommentJson","parse","hasEslintConfiguration","exists","emptyPkgJsonConfig","emptyEslintrc","selectedConfig","getESLintStrictValue","forEach","installDependencies","dir","existsSync","writeDefaultConfig","ready"],"mappings":";;;;+BA4UsBA;;;eAAAA;;;oBA5UqB;4BACQ;6DAClC;+DAEE;+DACA;qEACU;iCAEC;oCAEK;wCACI;iCACP;8BAEH;qCACO;0CACK;6DAEpB;iEAEmB;+BACV;uCAIvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOP,8GAA8G;AAC9G,MAAMC,iBAAiB;IAAC;IAAO;IAAQ;CAAQ;AAG/C,SAASC,gBAAgBC,QAAgB;IACvC,OAAOF,eAAeG,QAAQ,CAACD;AACjC;AAEA,MAAME,mBAAmB;IACvB;QAAEC,MAAM;QAAUC,KAAK;QAAUC,iBAAiB;IAAM;IACxD;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;CACD;AAED,eAAeC,UAAUC,GAAW;IAClCC,QAAQC,GAAG,CACTC,IAAAA,gBAAI,EACF,GAAGC,IAAAA,gBAAI,EACL,KACA,gGAAgG,CAAC;IAIvG,IAAI;QACF,MAAMC,YAAY,AAChB,CAAA,MAAMC,QAAQC,OAAO,CAClBC,QAAQ,iCACX,EACAC,OAAO;QACT,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAML,UAAU;YAChCM,QAAQ,MAAMC,IAAAA,4CAAqB,EAACZ;YACpCa,eAAe,CACb,EACEC,KAAK,EACLC,WAAW,EAC2C,EACxDC;gBAEA,MAAMC,OAAOD,WAAWb,IAAAA,gBAAI,EAACe,IAAAA,qBAAS,EAACd,IAAAA,gBAAI,EAACU,WAAWA;gBACvD,OAAOG,OAAQF,CAAAA,cAAcZ,IAAAA,gBAAI,EAACgB,IAAAA,kBAAM,EAAC,qBAAqB,EAAC;YACjE;YACAH,UAAUZ,IAAAA,gBAAI,EAAC;YACfgB,YAAY;QACd;QAEA,OAAO;YAAEC,QAAQX,CAAAA,yBAA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AAC;gBAEtB;gBACA,OAAO;YACT,OAAO;gBACL,sFAAsF;gBACtF,MAAM,EAAEiB,QAAQuH,cAAc,EAAE,GAAGb,SAC/B,MAAMc,IAAAA,2CAAoB,EAACtH,WAC3B,MAAMxB,UAAUwB;gBAEpB,IAAIqH,kBAAkB,MAAM;oBAC1B,oDAAoD;oBACpDlG,KAAI6C,IAAI,CACN;oBAEF,OAAO;gBACT,OAAO;oBACL,sEAAsE;oBACtEpD,OAAO,MAAMC,IAAAA,kDAAwB,EAACb,SAAS5B;oBAC/C,IAAIwC,KAAKI,OAAO,CAACwC,MAAM,GAAG,GAAG;wBAC3B5C,KAAKI,OAAO,CAACuG,OAAO,CAAC,CAACrG;4BACpB,IAAIA,IAAI5C,GAAG,KAAK,UAAU;gCACxB,sCAAsC;gCACtC4C,IAAI5C,GAAG,GAAG;4BACZ;wBACF;wBAEA,MAAMkJ,IAAAA,wCAAmB,EAACxH,SAASY,KAAKI,OAAO,EAAE;oBACnD;oBAEA,+BAA+B;oBAC/B,gFAAgF;oBAChF,IACE;wBAAC;wBAAO;wBAAW;wBAAS;qBAAY,CAACC,IAAI,CAAC,CAACwG,MAC7CC,IAAAA,cAAU,EAAClG,aAAI,CAACqE,IAAI,CAAC7F,SAASyH,QAEhC;wBACA,MAAME,IAAAA,sCAAkB,EACtB3H,SACAF,QACAuH,gBACAnH,cACAC,aACAuG;oBAEJ;gBACF;gBAEAvF,KAAIyG,KAAK,CACP,CAAC,6CAA6C,EAAEhJ,IAAAA,gBAAI,EAClDC,IAAAA,gBAAI,EAAC,cACL,mCAAmC,CAAC;gBAGxC,OAAO;YACT;QACF;IACF,EAAE,OAAOuH,KAAK;QACZ,MAAMA;IACR;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/eslint/runLintCheck.ts"],"sourcesContent":["import '../../server/require-hook'\nimport { promises as fs, existsSync } from 'fs'\nimport { bold, cyan, red, underline, yellow } from '../picocolors'\nimport path from 'path'\n\nimport findUp from 'next/dist/compiled/find-up'\nimport semver from 'next/dist/compiled/semver'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\n\nimport { formatResults } from './customFormatter'\nimport type { LintResult } from './customFormatter'\nimport { writeDefaultConfig } from './writeDefaultConfig'\nimport { hasEslintConfiguration } from './hasEslintConfiguration'\nimport { writeOutputFile } from './writeOutputFile'\n\nimport { findPagesDir } from '../find-pages-dir'\nimport { installDependencies } from '../install-dependencies'\nimport { hasNecessaryDependencies } from '../has-necessary-dependencies'\n\nimport * as Log from '../../build/output/log'\nimport type { EventLintCheckCompleted } from '../../telemetry/events/build'\nimport isError, { getProperError } from '../is-error'\nimport { getPkgManager } from '../helpers/get-pkg-manager'\nimport {\n getESLintStrictValue,\n getESLintPromptValues,\n} from './getESLintPromptValues'\n\ntype Config = {\n plugins: string[]\n rules: { [key: string]: Array<number | string> }\n}\n\n// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules\nconst VALID_SEVERITY = ['off', 'warn', 'error'] as const\ntype Severity = (typeof VALID_SEVERITY)[number]\n\nfunction isValidSeverity(severity: string): severity is Severity {\n return VALID_SEVERITY.includes(severity as Severity)\n}\n\nconst requiredPackages = [\n { file: 'eslint', pkg: 'eslint', exportsRestrict: false },\n {\n file: 'eslint-config-next',\n pkg: 'eslint-config-next',\n exportsRestrict: false,\n },\n]\n\nasync function cliPrompt(cwd: string): Promise<{ config?: any }> {\n console.log(\n bold(\n `${cyan(\n '?'\n )} How would you like to configure ESLint? https://nextjs.org/docs/app/api-reference/config/eslint`\n )\n )\n\n try {\n const cliSelect = (\n await Promise.resolve(\n (require('next/dist/compiled/cli-select') as typeof import('next/dist/compiled/cli-select'))\n )\n ).default\n const { value } = await cliSelect({\n values: await getESLintPromptValues(cwd),\n valueRenderer: (\n {\n title,\n recommended,\n }: { title: string; recommended?: boolean; config: any },\n selected: boolean\n ) => {\n const name = selected ? bold(underline(cyan(title))) : title\n return name + (recommended ? bold(yellow(' (recommended)')) : '')\n },\n selected: cyan('❯ '),\n unselected: ' ',\n })\n\n return { config: value?.config ?? null }\n } catch {\n return { config: null }\n }\n}\n\nasync function lint(\n baseDir: string,\n lintDirs: string[],\n eslintrcFile: string | null,\n pkgJsonPath: string | null,\n {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n }: {\n lintDuringBuild: boolean\n eslintOptions: any\n reportErrorsOnly: boolean\n maxWarnings: number\n formatter: string | null\n outputFile: string | null\n }\n): Promise<\n | string\n | null\n | {\n output: string | null\n isError: boolean\n eventInfo: EventLintCheckCompleted\n }\n> {\n try {\n // Load ESLint after we're sure it exists:\n const deps = hasNecessaryDependencies(baseDir, requiredPackages)\n const packageManager = getPkgManager(baseDir)\n\n if (deps.missing.some((dep) => dep.pkg === 'eslint')) {\n Log.error(\n `ESLint must be installed${\n lintDuringBuild ? ' in order to run during builds:' : ':'\n } ${bold(\n cyan(\n (packageManager === 'yarn'\n ? 'yarn add --dev'\n : packageManager === 'pnpm'\n ? 'pnpm install --save-dev'\n : 'npm install --save-dev') + ' eslint'\n )\n )}`\n )\n return null\n }\n\n const mod = await Promise.resolve(require(deps.resolved.get('eslint')!))\n\n // If V9 config was found, use flat config, or else use legacy.\n const useFlatConfig = eslintrcFile\n ? // eslintrcFile is absolute path\n path.basename(eslintrcFile).startsWith('eslint.config.')\n : false\n\n let ESLint\n // loadESLint is >= 8.57.0\n // PR https://github.com/eslint/eslint/pull/18098\n // Release https://github.com/eslint/eslint/releases/tag/v8.57.0\n if ('loadESLint' in mod) {\n // By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.\n // https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613\n ESLint = await mod.loadESLint({\n useFlatConfig,\n })\n } else {\n // eslint < 8.57.0, use legacy ESLint\n ESLint = mod.ESLint\n }\n\n let eslintVersion = ESLint?.version ?? mod.CLIEngine?.version\n\n if (!eslintVersion || semver.lt(eslintVersion, '7.0.0')) {\n return `${red(\n 'error'\n )} - Your project has an older version of ESLint installed${\n eslintVersion ? ' (' + eslintVersion + ')' : ''\n }. Please upgrade to ESLint version 7 or above`\n }\n\n let options: any = {\n useEslintrc: true,\n baseConfig: {},\n errorOnUnmatchedPattern: false,\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n cache: true,\n ...eslintOptions,\n }\n\n if (semver.gte(eslintVersion, '9.0.0') && useFlatConfig) {\n for (const option of [\n 'useEslintrc',\n 'extensions',\n 'ignorePath',\n 'reportUnusedDisableDirectives',\n 'resolvePluginsRelativeTo',\n 'rulePaths',\n 'inlineConfig',\n 'maxWarnings',\n ]) {\n if (option in options) {\n delete options[option]\n }\n }\n }\n\n let eslint = new ESLint(options)\n\n let nextEslintPluginIsEnabled = false\n const nextRulesEnabled = new Map<string, Severity>()\n\n for (const configFile of [eslintrcFile, pkgJsonPath]) {\n if (!configFile) continue\n\n const completeConfig: Config | undefined =\n await eslint.calculateConfigForFile(configFile)\n if (!completeConfig) continue\n\n const plugins = completeConfig.plugins\n\n const hasNextPlugin =\n // in ESLint < 9, `plugins` value is string[]\n Array.isArray(plugins)\n ? plugins.includes('@next/next')\n : // in ESLint >= 9, `plugins` value is Record<string, unknown>\n '@next/next' in plugins\n\n if (hasNextPlugin) {\n nextEslintPluginIsEnabled = true\n for (const [name, [severity]] of Object.entries(completeConfig.rules)) {\n if (!name.startsWith('@next/next/')) {\n continue\n }\n if (\n typeof severity === 'number' &&\n severity >= 0 &&\n severity < VALID_SEVERITY.length\n ) {\n nextRulesEnabled.set(name, VALID_SEVERITY[severity])\n } else if (\n typeof severity === 'string' &&\n isValidSeverity(severity)\n ) {\n nextRulesEnabled.set(name, severity)\n }\n }\n break\n }\n }\n\n const pagesDir = findPagesDir(baseDir).pagesDir\n const pagesDirRules = pagesDir ? ['@next/next/no-html-link-for-pages'] : []\n\n if (nextEslintPluginIsEnabled) {\n let updatedPagesDir = false\n\n for (const rule of pagesDirRules) {\n if (\n !options.baseConfig!.rules?.[rule] &&\n !options.baseConfig!.rules?.[\n rule.replace('@next/next', '@next/babel-plugin-next')\n ]\n ) {\n if (!options.baseConfig!.rules) {\n options.baseConfig!.rules = {}\n }\n options.baseConfig!.rules[rule] = [1, pagesDir]\n updatedPagesDir = true\n }\n }\n\n if (updatedPagesDir) {\n eslint = new ESLint(options)\n }\n } else {\n Log.warn('')\n Log.warn(\n 'The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n }\n\n const lintStart = process.hrtime()\n\n let results = await eslint.lintFiles(lintDirs)\n let selectedFormatter = null\n\n if (options.fix) await ESLint.outputFixes(results)\n if (reportErrorsOnly) results = await ESLint.getErrorResults(results) // Only return errors if --quiet flag is used\n\n if (formatter) selectedFormatter = await eslint.loadFormatter(formatter)\n const formattedResult = await formatResults(\n baseDir,\n results,\n selectedFormatter?.format\n )\n const lintEnd = process.hrtime(lintStart)\n const totalWarnings = results.reduce(\n (sum: number, file: LintResult) => sum + file.warningCount,\n 0\n )\n\n if (outputFile) await writeOutputFile(outputFile, formattedResult.output)\n\n return {\n output: formattedResult.outputWithMessages,\n isError:\n ESLint.getErrorResults(results)?.length > 0 ||\n (maxWarnings >= 0 && totalWarnings > maxWarnings),\n eventInfo: {\n durationInSeconds: lintEnd[0],\n eslintVersion: eslintVersion,\n lintedFilesCount: results.length,\n lintFix: !!options.fix,\n nextEslintPluginVersion:\n nextEslintPluginIsEnabled && deps.resolved.has('eslint-config-next')\n ? require(\n path.join(\n path.dirname(deps.resolved.get('eslint-config-next')!),\n 'package.json'\n )\n ).version\n : null,\n nextEslintPluginErrorsCount: formattedResult.totalNextPluginErrorCount,\n nextEslintPluginWarningsCount:\n formattedResult.totalNextPluginWarningCount,\n nextRulesEnabled: Object.fromEntries(nextRulesEnabled),\n },\n }\n } catch (err) {\n if (lintDuringBuild) {\n Log.error(\n `ESLint: ${\n isError(err) && err.message ? err.message.replace(/\\n/g, ' ') : err\n }`\n )\n return null\n } else {\n throw getProperError(err)\n }\n }\n}\n\nexport async function runLintCheck(\n baseDir: string,\n lintDirs: string[],\n opts: {\n lintDuringBuild?: boolean\n eslintOptions?: any\n reportErrorsOnly?: boolean\n maxWarnings?: number\n formatter?: string | null\n outputFile?: string | null\n strict?: boolean\n }\n): ReturnType<typeof lint> {\n const {\n lintDuringBuild = false,\n eslintOptions = null,\n reportErrorsOnly = false,\n maxWarnings = -1,\n formatter = null,\n outputFile = null,\n strict = false,\n } = opts\n try {\n // Find user's .eslintrc file\n // See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats\n const eslintrcFile =\n (await findUp(\n [\n // eslint v9\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n // TS extensions require to install a separate package `jiti`.\n // https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files\n 'eslint.config.ts',\n 'eslint.config.mts',\n 'eslint.config.cts',\n // eslint <= v8\n '.eslintrc.js',\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n '.eslintrc',\n ],\n {\n cwd: baseDir,\n }\n )) ?? null\n\n const pkgJsonPath = (await findUp('package.json', { cwd: baseDir })) ?? null\n let packageJsonConfig = null\n if (pkgJsonPath) {\n const pkgJsonContent = await fs.readFile(pkgJsonPath, {\n encoding: 'utf8',\n })\n packageJsonConfig = CommentJson.parse(pkgJsonContent)\n }\n\n const config = await hasEslintConfiguration(eslintrcFile, packageJsonConfig)\n let deps\n\n if (config.exists) {\n // Run if ESLint config exists\n return await lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, {\n lintDuringBuild,\n eslintOptions,\n reportErrorsOnly,\n maxWarnings,\n formatter,\n outputFile,\n })\n } else {\n // Display warning if no ESLint configuration is present inside\n // config file during \"next build\", no warning is shown when\n // no eslintrc file is present\n if (lintDuringBuild) {\n if (config.emptyPkgJsonConfig || config.emptyEslintrc) {\n Log.warn(\n `No ESLint configuration detected. Run ${bold(\n cyan('next lint')\n )} to begin setup`\n )\n }\n return null\n } else {\n // Ask user what config they would like to start with for first time \"next lint\" setup\n const { config: selectedConfig } = strict\n ? await getESLintStrictValue(baseDir)\n : await cliPrompt(baseDir)\n\n if (selectedConfig == null) {\n // Show a warning if no option is selected in prompt\n Log.warn(\n 'If you set up ESLint yourself, we recommend adding the Next.js ESLint plugin. See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config'\n )\n return null\n } else {\n // Check if necessary deps installed, and install any that are missing\n deps = await hasNecessaryDependencies(baseDir, requiredPackages)\n if (deps.missing.length > 0) {\n deps.missing.forEach((dep) => {\n if (dep.pkg === 'eslint') {\n // pin to v9 to avoid breaking changes\n dep.pkg = 'eslint@^9'\n }\n })\n\n await installDependencies(baseDir, deps.missing, true)\n }\n\n // Write default ESLint config.\n // Check for /pages and src/pages is to make sure this happens in Next.js folder\n if (\n ['app', 'src/app', 'pages', 'src/pages'].some((dir) =>\n existsSync(path.join(baseDir, dir))\n )\n ) {\n await writeDefaultConfig(\n baseDir,\n config,\n selectedConfig,\n eslintrcFile,\n pkgJsonPath,\n packageJsonConfig\n )\n }\n }\n\n Log.ready(\n `ESLint has successfully been configured. Run ${bold(\n cyan('next lint')\n )} again to view warnings and errors.`\n )\n\n return null\n }\n }\n } catch (err) {\n throw err\n }\n}\n"],"names":["runLintCheck","VALID_SEVERITY","isValidSeverity","severity","includes","requiredPackages","file","pkg","exportsRestrict","cliPrompt","cwd","console","log","bold","cyan","cliSelect","Promise","resolve","require","default","value","values","getESLintPromptValues","valueRenderer","title","recommended","selected","name","underline","yellow","unselected","config","lint","baseDir","lintDirs","eslintrcFile","pkgJsonPath","lintDuringBuild","eslintOptions","reportErrorsOnly","maxWarnings","formatter","outputFile","mod","ESLint","deps","hasNecessaryDependencies","packageManager","getPkgManager","missing","some","dep","Log","error","resolved","get","useFlatConfig","path","basename","startsWith","loadESLint","eslintVersion","version","CLIEngine","semver","lt","red","options","useEslintrc","baseConfig","errorOnUnmatchedPattern","extensions","cache","gte","option","eslint","nextEslintPluginIsEnabled","nextRulesEnabled","Map","configFile","completeConfig","calculateConfigForFile","plugins","hasNextPlugin","Array","isArray","Object","entries","rules","length","set","pagesDir","findPagesDir","pagesDirRules","updatedPagesDir","rule","replace","warn","lintStart","process","hrtime","results","lintFiles","selectedFormatter","fix","outputFixes","getErrorResults","loadFormatter","formattedResult","formatResults","format","lintEnd","totalWarnings","reduce","sum","warningCount","writeOutputFile","output","outputWithMessages","isError","eventInfo","durationInSeconds","lintedFilesCount","lintFix","nextEslintPluginVersion","has","join","dirname","nextEslintPluginErrorsCount","totalNextPluginErrorCount","nextEslintPluginWarningsCount","totalNextPluginWarningCount","fromEntries","err","message","getProperError","opts","strict","findUp","packageJsonConfig","pkgJsonContent","fs","readFile","encoding","CommentJson","parse","hasEslintConfiguration","exists","emptyPkgJsonConfig","emptyEslintrc","selectedConfig","getESLintStrictValue","forEach","installDependencies","dir","existsSync","writeDefaultConfig","ready"],"mappings":";;;;+BA6UsBA;;;eAAAA;;;QA7Uf;oBACoC;4BACQ;6DAClC;+DAEE;+DACA;qEACU;iCAEC;oCAEK;wCACI;iCACP;8BAEH;qCACO;0CACK;6DAEpB;iEAEmB;+BACV;uCAIvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOP,8GAA8G;AAC9G,MAAMC,iBAAiB;IAAC;IAAO;IAAQ;CAAQ;AAG/C,SAASC,gBAAgBC,QAAgB;IACvC,OAAOF,eAAeG,QAAQ,CAACD;AACjC;AAEA,MAAME,mBAAmB;IACvB;QAAEC,MAAM;QAAUC,KAAK;QAAUC,iBAAiB;IAAM;IACxD;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;CACD;AAED,eAAeC,UAAUC,GAAW;IAClCC,QAAQC,GAAG,CACTC,IAAAA,gBAAI,EACF,GAAGC,IAAAA,gB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BAAW;wBAAS;qBAAY,CAACC,IAAI,CAAC,CAACwG,MAC7CC,IAAAA,cAAU,EAAClG,aAAI,CAACqE,IAAI,CAAC7F,SAASyH,QAEhC;wBACA,MAAME,IAAAA,sCAAkB,EACtB3H,SACAF,QACAuH,gBACAnH,cACAC,aACAuG;oBAEJ;gBACF;gBAEAvF,KAAIyG,KAAK,CACP,CAAC,6CAA6C,EAAEhJ,IAAAA,gBAAI,EAClDC,IAAAA,gBAAI,EAAC,cACL,mCAAmC,CAAC;gBAGxC,OAAO;YACT;QACF;IACF,EAAE,OAAOuH,KAAK;QACZ,MAAMA;IACR;AACF","ignoreList":[0]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../server/require-hook';
|
|
1
2
|
import type { TypeCheckResult } from './typescript/runTypeCheck';
|
|
2
3
|
export declare function verifyTypeScriptSetup({ dir, distDir, cacheDir, intentDirs, tsconfigPath, typeCheckPreflight, disableStaticImages, hasAppDir, hasPagesDir, }: {
|
|
3
4
|
dir: string;
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "verifyTypeScriptSetup", {
|
|
|
8
8
|
return verifyTypeScriptSetup;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
require("../server/require-hook");
|
|
11
12
|
const _picocolors = require("./picocolors");
|
|
12
13
|
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
13
14
|
const _hasnecessarydependencies = require("./has-necessary-dependencies");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path 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}: {\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}): 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 tsPath = deps.resolved.get('typescript')!\n const ts = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n if (semver.lt(ts.version, '4.5.2')) {\n log.warn(\n `Minimum recommended TypeScript version is v4.5.2, older versions can potentially be incompatible with Next.js. Detected: ${ts.version}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n ts,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir\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 // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n ts,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir\n )\n }\n return { result, version: ts.version }\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","tsConfigFileName","resolvedTsConfigPath","path","join","deps","intent","getTypeScriptIntent","version","hasNecessaryDependencies","missing","length","isCI","missingDepsError","console","log","bold","yellow","cyan","installDependencies","catch","err","error","command","tsPath","resolved","get","ts","Promise","resolve","require","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","writeAppTypeDeclarations","baseDir","imageImportsEnabled","result","runTypeCheck","CompileError","red","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":";;;;+
|
|
1
|
+
{"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import '../server/require-hook'\nimport { bold, cyan, red, yellow } from './picocolors'\nimport path 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}: {\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}): 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 tsPath = deps.resolved.get('typescript')!\n const ts = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n if (semver.lt(ts.version, '4.5.2')) {\n log.warn(\n `Minimum recommended TypeScript version is v4.5.2, older versions can potentially be incompatible with Next.js. Detected: ${ts.version}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n ts,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir\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 // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n ts,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir\n )\n }\n return { result, version: ts.version }\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","tsConfigFileName","resolvedTsConfigPath","path","join","deps","intent","getTypeScriptIntent","version","hasNecessaryDependencies","missing","length","isCI","missingDepsError","console","log","bold","yellow","cyan","installDependencies","catch","err","error","command","tsPath","resolved","get","ts","Promise","resolve","require","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","writeAppTypeDeclarations","baseDir","imageImportsEnabled","result","runTypeCheck","CompileError","red","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":";;;;+BAoCsBA;;;eAAAA;;;QApCf;4BACiC;6DACvB;0CAEwB;+DAEtB;8BACU;6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IsB,OAAO;YAC3B,OAAO;gBACL7B,QAAQQ,KAAK,CAACD;YAChB;YACAuB,QAAQC,IAAI,CAAC;QACf;QACA,kFAAkF;QAClF,MAAMxB;IACR;AACF","ignoreList":[0]}
|
|
@@ -226,7 +226,7 @@ class HotReloaderWebpack {
|
|
|
226
226
|
this.previewProps = previewProps;
|
|
227
227
|
this.rewrites = rewrites;
|
|
228
228
|
this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
|
229
|
-
version: "15.6.0-bun.
|
|
229
|
+
version: "15.6.0-bun.17"
|
|
230
230
|
});
|
|
231
231
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
232
232
|
// of the current `next dev` invocation.
|
|
@@ -82,7 +82,7 @@ function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, logBu
|
|
|
82
82
|
bundlerSuffix = ' (webpack)';
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.6.0-bun.
|
|
85
|
+
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.6.0-bun.17"}`))}${bundlerSuffix}`);
|
|
86
86
|
if (appUrl) {
|
|
87
87
|
_log.bootstrap(`- Local: ${appUrl}`);
|
|
88
88
|
}
|
|
@@ -155,7 +155,7 @@ async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server
|
|
|
155
155
|
async function startServer(serverOptions) {
|
|
156
156
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
157
157
|
let { port } = serverOptions;
|
|
158
|
-
process.title = `next-server (v${"15.6.0-bun.
|
|
158
|
+
process.title = `next-server (v${"15.6.0-bun.17"})`;
|
|
159
159
|
let handlersReady = ()=>{};
|
|
160
160
|
let handlersError = ()=>{};
|
|
161
161
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -22,7 +22,7 @@ _export(exports, {
|
|
|
22
22
|
});
|
|
23
23
|
function isStableBuild() {
|
|
24
24
|
var _process_env___NEXT_VERSION;
|
|
25
|
-
return !((_process_env___NEXT_VERSION = "15.6.0-bun.
|
|
25
|
+
return !((_process_env___NEXT_VERSION = "15.6.0-bun.17") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
|
26
26
|
}
|
|
27
27
|
class CanaryOnlyError extends Error {
|
|
28
28
|
constructor(arg){
|
|
@@ -11,11 +11,11 @@ Object.defineProperty(exports, "eventCliSessionStopped", {
|
|
|
11
11
|
const EVENT_VERSION = 'NEXT_CLI_SESSION_STOPPED';
|
|
12
12
|
function eventCliSessionStopped(event) {
|
|
13
13
|
// This should be an invariant, if it fails our build tooling is broken.
|
|
14
|
-
if (typeof "15.6.0-bun.
|
|
14
|
+
if (typeof "15.6.0-bun.17" !== 'string') {
|
|
15
15
|
return [];
|
|
16
16
|
}
|
|
17
17
|
const payload = {
|
|
18
|
-
nextVersion: "15.6.0-bun.
|
|
18
|
+
nextVersion: "15.6.0-bun.17",
|
|
19
19
|
nodeVersion: process.version,
|
|
20
20
|
cliCommand: event.cliCommand,
|
|
21
21
|
durationMilliseconds: event.durationMilliseconds,
|