next 15.2.0-canary.43 → 15.2.0-canary.45

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.

Potentially problematic release.


This version of next might be problematic. Click here for more details.

Files changed (95) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +14 -5
  3. package/dist/build/index.js.map +1 -1
  4. package/dist/build/swc/index.js +1 -1
  5. package/dist/build/utils.d.ts +1 -1
  6. package/dist/build/utils.js +6 -1
  7. package/dist/build/utils.js.map +1 -1
  8. package/dist/build/webpack/plugins/define-env-plugin.js +1 -3
  9. package/dist/build/webpack/plugins/define-env-plugin.js.map +1 -1
  10. package/dist/build/webpack-config.js +2 -2
  11. package/dist/client/app-bootstrap.js +1 -1
  12. package/dist/client/components/react-dev-overlay/_experimental/internal/components/copy-button/index.js +2 -1
  13. package/dist/client/components/react-dev-overlay/_experimental/internal/components/copy-button/index.js.map +1 -1
  14. package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +1 -1
  15. package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
  16. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dialog/header.js +2 -1
  17. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/dialog/header.js.map +1 -1
  18. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js +4 -3
  19. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js.map +1 -1
  20. package/dist/client/components/react-dev-overlay/_experimental/internal/components/toast/toast.js +2 -1
  21. package/dist/client/components/react-dev-overlay/_experimental/internal/components/toast/toast.js.map +1 -1
  22. package/dist/client/components/react-dev-overlay/_experimental/internal/components/version-staleness-info/version-staleness-info.js +3 -2
  23. package/dist/client/components/react-dev-overlay/_experimental/internal/components/version-staleness-info/version-staleness-info.js.map +1 -1
  24. package/dist/client/components/react-dev-overlay/_experimental/internal/helpers/cx.d.ts +7 -0
  25. package/dist/client/components/react-dev-overlay/_experimental/internal/helpers/cx.js +29 -0
  26. package/dist/client/components/react-dev-overlay/_experimental/internal/helpers/cx.js.map +1 -0
  27. package/dist/client/components/react-dev-overlay/_experimental/internal/helpers/cx.test.d.ts +1 -0
  28. package/dist/client/components/react-dev-overlay/internal/helpers/stack-frame.js +10 -0
  29. package/dist/client/components/react-dev-overlay/internal/helpers/stack-frame.js.map +1 -1
  30. package/dist/client/index.js +1 -1
  31. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +3 -3
  32. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
  33. package/dist/compiled/next-server/app-page.runtime.dev.js +3 -3
  34. package/dist/compiled/next-server/app-page.runtime.dev.js.map +1 -1
  35. package/dist/compiled/next-server/server.runtime.prod.js +1 -1
  36. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  37. package/dist/esm/build/index.js +14 -5
  38. package/dist/esm/build/index.js.map +1 -1
  39. package/dist/esm/build/swc/index.js +1 -1
  40. package/dist/esm/build/utils.js +6 -1
  41. package/dist/esm/build/utils.js.map +1 -1
  42. package/dist/esm/build/webpack/plugins/define-env-plugin.js +1 -3
  43. package/dist/esm/build/webpack/plugins/define-env-plugin.js.map +1 -1
  44. package/dist/esm/build/webpack-config.js +2 -2
  45. package/dist/esm/client/app-bootstrap.js +1 -1
  46. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/copy-button/index.js +2 -1
  47. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/copy-button/index.js.map +1 -1
  48. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +1 -1
  49. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
  50. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dialog/header.js +2 -1
  51. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/dialog/header.js.map +1 -1
  52. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js +4 -3
  53. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay-footer/error-feedback/error-feedback.js.map +1 -1
  54. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/toast/toast.js +2 -1
  55. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/toast/toast.js.map +1 -1
  56. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/version-staleness-info/version-staleness-info.js +3 -2
  57. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/version-staleness-info/version-staleness-info.js.map +1 -1
  58. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/helpers/cx.js +13 -0
  59. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/helpers/cx.js.map +1 -0
  60. package/dist/esm/client/components/react-dev-overlay/internal/helpers/stack-frame.js +10 -0
  61. package/dist/esm/client/components/react-dev-overlay/internal/helpers/stack-frame.js.map +1 -1
  62. package/dist/esm/client/index.js +1 -1
  63. package/dist/esm/lib/verify-typescript-setup.js +1 -1
  64. package/dist/esm/lib/verify-typescript-setup.js.map +1 -1
  65. package/dist/esm/lib/worker.js +3 -2
  66. package/dist/esm/lib/worker.js.map +1 -1
  67. package/dist/esm/server/config.js +23 -20
  68. package/dist/esm/server/config.js.map +1 -1
  69. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  70. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  71. package/dist/esm/server/lib/app-info-log.js +1 -1
  72. package/dist/esm/server/lib/start-server.js +1 -1
  73. package/dist/esm/server/next-server.js +4 -0
  74. package/dist/esm/server/next-server.js.map +1 -1
  75. package/dist/esm/server/web/sandbox/resource-managers.js +28 -2
  76. package/dist/esm/server/web/sandbox/resource-managers.js.map +1 -1
  77. package/dist/lib/verify-typescript-setup.js +1 -1
  78. package/dist/lib/verify-typescript-setup.js.map +1 -1
  79. package/dist/lib/worker.js +3 -2
  80. package/dist/lib/worker.js.map +1 -1
  81. package/dist/server/config.js +23 -20
  82. package/dist/server/config.js.map +1 -1
  83. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  84. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  85. package/dist/server/lib/app-info-log.js +1 -1
  86. package/dist/server/lib/start-server.js +1 -1
  87. package/dist/server/next-server.js +4 -0
  88. package/dist/server/next-server.js.map +1 -1
  89. package/dist/server/web/sandbox/resource-managers.d.ts +3 -3
  90. package/dist/server/web/sandbox/resource-managers.js +28 -2
  91. package/dist/server/web/sandbox/resource-managers.js.map +1 -1
  92. package/dist/telemetry/anonymous-meta.js +1 -1
  93. package/dist/telemetry/events/session-stopped.js +2 -2
  94. package/dist/telemetry/events/version.js +2 -2
  95. package/package.json +15 -15
@@ -19,7 +19,7 @@ class ResourceManager {
19
19
  class IntervalsManager extends ResourceManager {
20
20
  create(args) {
21
21
  // TODO: use the edge runtime provided `setInterval` instead
22
- return setInterval(...args)[Symbol.toPrimitive]();
22
+ return webSetIntervalPolyfill(...args);
23
23
  }
24
24
  destroy(interval) {
25
25
  clearInterval(interval);
@@ -28,12 +28,38 @@ class IntervalsManager extends ResourceManager {
28
28
  class TimeoutsManager extends ResourceManager {
29
29
  create(args) {
30
30
  // TODO: use the edge runtime provided `setTimeout` instead
31
- return setTimeout(...args)[Symbol.toPrimitive]();
31
+ return webSetTimeoutPolyfill(...args);
32
32
  }
33
33
  destroy(timeout) {
34
34
  clearTimeout(timeout);
35
35
  }
36
36
  }
37
+ function webSetIntervalPolyfill(callback, ms, ...args) {
38
+ return setInterval(()=>{
39
+ // node's `setInterval` sets `this` to the `Timeout` instance it returned,
40
+ // but web `setInterval` always sets `this` to `window`
41
+ // see: https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval#the_this_problem
42
+ return callback.apply(globalThis, args);
43
+ }, ms)[Symbol.toPrimitive]();
44
+ }
45
+ function webSetTimeoutPolyfill(callback, ms, ...args) {
46
+ const wrappedCallback = ()=>{
47
+ try {
48
+ // node's `setTimeout` sets `this` to the `Timeout` instance it returned,
49
+ // but web `setTimeout` always sets `this` to `window`
50
+ // see: https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#the_this_problem
51
+ return callback.apply(globalThis, args);
52
+ } finally{
53
+ // On certain older node versions (<20.16.0, <22.4.0),
54
+ // a `setTimeout` whose Timeout was converted to a primitive will leak.
55
+ // See: https://github.com/nodejs/node/issues/53335
56
+ // We can work around this by explicitly calling `clearTimeout` after the callback runs.
57
+ clearTimeout(timeout);
58
+ }
59
+ };
60
+ const timeout = setTimeout(wrappedCallback, ms);
61
+ return timeout[Symbol.toPrimitive]();
62
+ }
37
63
  export const intervalsManager = new IntervalsManager();
38
64
  export const timeoutsManager = new TimeoutsManager();
39
65
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/server/web/sandbox/resource-managers.ts"],"sourcesContent":["abstract class ResourceManager<T, K> {\n private resources: T[] = []\n\n abstract create(resourceArgs: K): T\n abstract destroy(resource: T): void\n\n add(resourceArgs: K) {\n const resource = this.create(resourceArgs)\n this.resources.push(resource)\n return resource\n }\n\n remove(resource: T) {\n this.resources = this.resources.filter((r) => r !== resource)\n this.destroy(resource)\n }\n\n removeAll() {\n this.resources.forEach(this.destroy)\n this.resources = []\n }\n}\n\nclass IntervalsManager extends ResourceManager<\n number,\n Parameters<typeof setInterval>\n> {\n create(args: Parameters<typeof setInterval>) {\n // TODO: use the edge runtime provided `setInterval` instead\n return setInterval(...args)[Symbol.toPrimitive]()\n }\n\n destroy(interval: number) {\n clearInterval(interval)\n }\n}\n\nclass TimeoutsManager extends ResourceManager<\n number,\n Parameters<typeof setTimeout>\n> {\n create(args: Parameters<typeof setTimeout>) {\n // TODO: use the edge runtime provided `setTimeout` instead\n return setTimeout(...args)[Symbol.toPrimitive]()\n }\n\n destroy(timeout: number) {\n clearTimeout(timeout)\n }\n}\n\nexport const intervalsManager = new IntervalsManager()\nexport const timeoutsManager = new TimeoutsManager()\n"],"names":["ResourceManager","add","resourceArgs","resource","create","resources","push","remove","filter","r","destroy","removeAll","forEach","IntervalsManager","args","setInterval","Symbol","toPrimitive","interval","clearInterval","TimeoutsManager","setTimeout","timeout","clearTimeout","intervalsManager","timeoutsManager"],"mappings":"AAAA,MAAeA;IAMbC,IAAIC,YAAe,EAAE;QACnB,MAAMC,WAAW,IAAI,CAACC,MAAM,CAACF;QAC7B,IAAI,CAACG,SAAS,CAACC,IAAI,CAACH;QACpB,OAAOA;IACT;IAEAI,OAAOJ,QAAW,EAAE;QAClB,IAAI,CAACE,SAAS,GAAG,IAAI,CAACA,SAAS,CAACG,MAAM,CAAC,CAACC,IAAMA,MAAMN;QACpD,IAAI,CAACO,OAAO,CAACP;IACf;IAEAQ,YAAY;QACV,IAAI,CAACN,SAAS,CAACO,OAAO,CAAC,IAAI,CAACF,OAAO;QACnC,IAAI,CAACL,SAAS,GAAG,EAAE;IACrB;;aAnBQA,YAAiB,EAAE;;AAoB7B;AAEA,MAAMQ,yBAAyBb;IAI7BI,OAAOU,IAAoC,EAAE;QAC3C,4DAA4D;QAC5D,OAAOC,eAAeD,KAAK,CAACE,OAAOC,WAAW,CAAC;IACjD;IAEAP,QAAQQ,QAAgB,EAAE;QACxBC,cAAcD;IAChB;AACF;AAEA,MAAME,wBAAwBpB;IAI5BI,OAAOU,IAAmC,EAAE;QAC1C,2DAA2D;QAC3D,OAAOO,cAAcP,KAAK,CAACE,OAAOC,WAAW,CAAC;IAChD;IAEAP,QAAQY,OAAe,EAAE;QACvBC,aAAaD;IACf;AACF;AAEA,OAAO,MAAME,mBAAmB,IAAIX,mBAAkB;AACtD,OAAO,MAAMY,kBAAkB,IAAIL,kBAAiB"}
1
+ {"version":3,"sources":["../../../../src/server/web/sandbox/resource-managers.ts"],"sourcesContent":["abstract class ResourceManager<T, Args> {\n private resources: T[] = []\n\n abstract create(resourceArgs: Args): T\n abstract destroy(resource: T): void\n\n add(resourceArgs: Args) {\n const resource = this.create(resourceArgs)\n this.resources.push(resource)\n return resource\n }\n\n remove(resource: T) {\n this.resources = this.resources.filter((r) => r !== resource)\n this.destroy(resource)\n }\n\n removeAll() {\n this.resources.forEach(this.destroy)\n this.resources = []\n }\n}\n\nclass IntervalsManager extends ResourceManager<\n number,\n Parameters<typeof setInterval>\n> {\n create(args: Parameters<typeof setInterval>) {\n // TODO: use the edge runtime provided `setInterval` instead\n return webSetIntervalPolyfill(...args)\n }\n\n destroy(interval: number) {\n clearInterval(interval)\n }\n}\n\nclass TimeoutsManager extends ResourceManager<\n number,\n Parameters<typeof setTimeout>\n> {\n create(args: Parameters<typeof setTimeout>) {\n // TODO: use the edge runtime provided `setTimeout` instead\n return webSetTimeoutPolyfill(...args)\n }\n\n destroy(timeout: number) {\n clearTimeout(timeout)\n }\n}\n\nfunction webSetIntervalPolyfill<TArgs extends any[]>(\n callback: (...args: TArgs) => void,\n ms?: number,\n ...args: TArgs\n): number {\n return setInterval(() => {\n // node's `setInterval` sets `this` to the `Timeout` instance it returned,\n // but web `setInterval` always sets `this` to `window`\n // see: https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval#the_this_problem\n return callback.apply(globalThis, args)\n }, ms)[Symbol.toPrimitive]()\n}\n\nfunction webSetTimeoutPolyfill<TArgs extends any[]>(\n callback: (...args: TArgs) => void,\n ms?: number,\n ...args: TArgs\n): number {\n const wrappedCallback = () => {\n try {\n // node's `setTimeout` sets `this` to the `Timeout` instance it returned,\n // but web `setTimeout` always sets `this` to `window`\n // see: https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#the_this_problem\n return callback.apply(globalThis, args)\n } finally {\n // On certain older node versions (<20.16.0, <22.4.0),\n // a `setTimeout` whose Timeout was converted to a primitive will leak.\n // See: https://github.com/nodejs/node/issues/53335\n // We can work around this by explicitly calling `clearTimeout` after the callback runs.\n clearTimeout(timeout)\n }\n }\n const timeout = setTimeout(wrappedCallback, ms)\n return timeout[Symbol.toPrimitive]()\n}\n\nexport const intervalsManager = new IntervalsManager()\nexport const timeoutsManager = new TimeoutsManager()\n"],"names":["ResourceManager","add","resourceArgs","resource","create","resources","push","remove","filter","r","destroy","removeAll","forEach","IntervalsManager","args","webSetIntervalPolyfill","interval","clearInterval","TimeoutsManager","webSetTimeoutPolyfill","timeout","clearTimeout","callback","ms","setInterval","apply","globalThis","Symbol","toPrimitive","wrappedCallback","setTimeout","intervalsManager","timeoutsManager"],"mappings":"AAAA,MAAeA;IAMbC,IAAIC,YAAkB,EAAE;QACtB,MAAMC,WAAW,IAAI,CAACC,MAAM,CAACF;QAC7B,IAAI,CAACG,SAAS,CAACC,IAAI,CAACH;QACpB,OAAOA;IACT;IAEAI,OAAOJ,QAAW,EAAE;QAClB,IAAI,CAACE,SAAS,GAAG,IAAI,CAACA,SAAS,CAACG,MAAM,CAAC,CAACC,IAAMA,MAAMN;QACpD,IAAI,CAACO,OAAO,CAACP;IACf;IAEAQ,YAAY;QACV,IAAI,CAACN,SAAS,CAACO,OAAO,CAAC,IAAI,CAACF,OAAO;QACnC,IAAI,CAACL,SAAS,GAAG,EAAE;IACrB;;aAnBQA,YAAiB,EAAE;;AAoB7B;AAEA,MAAMQ,yBAAyBb;IAI7BI,OAAOU,IAAoC,EAAE;QAC3C,4DAA4D;QAC5D,OAAOC,0BAA0BD;IACnC;IAEAJ,QAAQM,QAAgB,EAAE;QACxBC,cAAcD;IAChB;AACF;AAEA,MAAME,wBAAwBlB;IAI5BI,OAAOU,IAAmC,EAAE;QAC1C,2DAA2D;QAC3D,OAAOK,yBAAyBL;IAClC;IAEAJ,QAAQU,OAAe,EAAE;QACvBC,aAAaD;IACf;AACF;AAEA,SAASL,uBACPO,QAAkC,EAClCC,EAAW,EACX,GAAGT,IAAW;IAEd,OAAOU,YAAY;QACjB,0EAA0E;QAC1E,uDAAuD;QACvD,4FAA4F;QAC5F,OAAOF,SAASG,KAAK,CAACC,YAAYZ;IACpC,GAAGS,GAAG,CAACI,OAAOC,WAAW,CAAC;AAC5B;AAEA,SAAST,sBACPG,QAAkC,EAClCC,EAAW,EACX,GAAGT,IAAW;IAEd,MAAMe,kBAAkB;QACtB,IAAI;YACF,yEAAyE;YACzE,sDAAsD;YACtD,2FAA2F;YAC3F,OAAOP,SAASG,KAAK,CAACC,YAAYZ;QACpC,SAAU;YACR,sDAAsD;YACtD,uEAAuE;YACvE,mDAAmD;YACnD,wFAAwF;YACxFO,aAAaD;QACf;IACF;IACA,MAAMA,UAAUU,WAAWD,iBAAiBN;IAC5C,OAAOH,OAAO,CAACO,OAAOC,WAAW,CAAC;AACpC;AAEA,OAAO,MAAMG,mBAAmB,IAAIlB,mBAAkB;AACtD,OAAO,MAAMmB,kBAAkB,IAAId,kBAAiB"}
@@ -149,7 +149,7 @@ async function verifyTypeScriptSetup({ dir, distDir, cacheDir, intentDirs, tscon
149
149
  * or run in a worker (during next build). In the latter case, we need to print the error message, as the
150
150
  * parent process will only receive an `Jest worker encountered 1 child process exceptions, exceeding retry limit`.
151
151
  */ // we are in a worker, print the error message and exit the process
152
- if (process.env.JEST_WORKER_ID) {
152
+ if (process.env.IS_NEXT_WORKER) {
153
153
  if (err instanceof Error) {
154
154
  console.error(err.message);
155
155
  } else {
@@ -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\n intentDirs: string[]\n typeCheckPreflight: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const resolvedTsConfigPath = path.join(dir, tsconfigPath)\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsconfigPath)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = await 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 = await 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 imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } = require('./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.JEST_WORKER_ID) {\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","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","JEST_WORKER_ID","Error"],"mappings":";;;;+BAmCsBA;;;eAAAA;;;4BAnCkB;6DACvB;0CAEwB;+DAEtB;8BACU;6DACR;qCAEe;0CAEK;4CACE;qCACP;wBACf;wCACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,MAAMC,mBAAmB;IACvB;QACEC,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;CACD;AAEM,eAAeJ,sBAAsB,EAC1CK,GAAG,EACHC,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,YAAY,EACZC,kBAAkB,EAClBC,mBAAmB,EACnBC,SAAS,EACTC,WAAW,EAWZ;IACC,MAAMC,uBAAuBC,aAAI,CAACC,IAAI,CAACX,KAAKI;IAE5C,IAAI;YAaEQ;QAZJ,wCAAwC;QACxC,MAAMC,SAAS,MAAMC,IAAAA,wCAAmB,EAACd,KAAKG,YAAYC;QAC1D,IAAI,CAACS,QAAQ;YACX,OAAO;gBAAEE,SAAS;YAAK;QACzB;QAEA,4DAA4D;QAC5D,IAAIH,OAA8B,MAAMI,IAAAA,kDAAwB,EAC9DhB,KACAJ;QAGF,IAAIgB,EAAAA,gBAAAA,KAAKK,OAAO,qBAAZL,cAAcM,MAAM,IAAG,GAAG;YAC5B,IAAIC,YAAI,EAAE;gBACR,4DAA4D;gBAC5D,2DAA2D;gBAC3DC,IAAAA,wCAAgB,EAACpB,KAAKY,KAAKK,OAAO;YACpC;YACAI,QAAQC,GAAG,CACTC,IAAAA,gBAAI,EACFC,IAAAA,kBAAM,EACJ,CAAC,gGAAgG,CAAC,KAGpG,OACA,4BACA,SACAD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AK,CAACD,IAAIsB,OAAO;YACzBC,QAAQC,IAAI,CAAC;QACf;QAEA;;;;KAIC,GAED,mEAAmE;QACnE,IAAID,QAAQE,GAAG,CAACC,cAAc,EAAE;YAC9B,IAAI1B,eAAe2B,OAAO;gBACxBlC,QAAQQ,KAAK,CAACD,IAAIsB,OAAO;YAC3B,OAAO;gBACL7B,QAAQQ,KAAK,CAACD;YAChB;YACAuB,QAAQC,IAAI,CAAC;QACf;QACA,kFAAkF;QAClF,MAAMxB;IACR;AACF"}
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\n intentDirs: string[]\n typeCheckPreflight: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const resolvedTsConfigPath = path.join(dir, tsconfigPath)\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsconfigPath)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = await 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 = await 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 imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } = require('./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","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":";;;;+BAmCsBA;;;eAAAA;;;4BAnCkB;6DACvB;0CAEwB;+DAEtB;8BACU;6DACR;qCAEe;0CAEK;4CACE;qCACP;wBACf;wCACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,MAAMC,mBAAmB;IACvB;QACEC,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,i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ions) == null ? void 0 : _farmOptions_forkOptions.env) || {},
40
- ...process.env
40
+ ...process.env,
41
+ IS_NEXT_WORKER: 'true'
41
42
  }
42
43
  },
43
44
  maxRetries: 0
@@ -59,7 +60,7 @@ class Worker {
59
60
  _worker__child1;
60
61
  (_worker__child = worker._child) == null ? void 0 : _worker__child.on('exit', (code, signal)=>{
61
62
  if ((code || signal && signal !== 'SIGINT') && this._worker) {
62
- logger.error(`Static worker exited with code: ${code} and signal: ${signal}`);
63
+ logger.error(`Next.js build worker exited with code: ${code} and signal: ${signal}`);
63
64
  // if a child process doesn't exit gracefully, we want to bubble up the exit code to the parent process
64
65
  process.exit(code ?? 1);
65
66
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/worker.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process'\nimport { Worker as JestWorker } from 'next/dist/compiled/jest-worker'\nimport { Transform } from 'stream'\n\ntype FarmOptions = ConstructorParameters<typeof JestWorker>[1]\n\nconst RESTARTED = Symbol('restarted')\n\nconst cleanupWorkers = (worker: JestWorker) => {\n for (const curWorker of ((worker as any)._workerPool?._workers || []) as {\n _child?: ChildProcess\n }[]) {\n curWorker._child?.kill('SIGINT')\n }\n}\n\nexport class Worker {\n private _worker: JestWorker | undefined\n\n constructor(\n workerPath: string,\n options: FarmOptions & {\n timeout?: number\n onActivity?: () => void\n onActivityAbort?: () => void\n onRestart?: (method: string, args: any[], attempts: number) => void\n logger?: Pick<typeof console, 'error' | 'info' | 'warn'>\n exposedMethods: ReadonlyArray<string>\n enableWorkerThreads?: boolean\n }\n ) {\n let { timeout, onRestart, logger = console, ...farmOptions } = options\n\n let restartPromise: Promise<typeof RESTARTED>\n let resolveRestartPromise: (arg: typeof RESTARTED) => void\n let activeTasks = 0\n\n this._worker = undefined\n\n // ensure we end workers if they weren't before exit\n process.on('exit', () => {\n this.close()\n })\n\n const createWorker = () => {\n this._worker = new JestWorker(workerPath, {\n ...farmOptions,\n forkOptions: {\n ...farmOptions.forkOptions,\n env: {\n ...((farmOptions.forkOptions?.env || {}) as any),\n ...process.env,\n } as any,\n },\n maxRetries: 0,\n }) as JestWorker\n restartPromise = new Promise(\n (resolve) => (resolveRestartPromise = resolve)\n )\n\n /**\n * Jest Worker has two worker types, ChildProcessWorker (uses child_process) and NodeThreadWorker (uses worker_threads)\n * Next.js uses ChildProcessWorker by default, but it can be switched to NodeThreadWorker with an experimental flag\n *\n * We only want to handle ChildProcessWorker's orphan process issue, so we access the private property \"_child\":\n * https://github.com/facebook/jest/blob/b38d7d345a81d97d1dc3b68b8458b1837fbf19be/packages/jest-worker/src/workers/ChildProcessWorker.ts\n *\n * But this property is not available in NodeThreadWorker, so we need to check if we are using ChildProcessWorker\n */\n if (!farmOptions.enableWorkerThreads) {\n for (const worker of ((this._worker as any)._workerPool?._workers ||\n []) as {\n _child?: ChildProcess\n }[]) {\n worker._child?.on('exit', (code, signal) => {\n if ((code || (signal && signal !== 'SIGINT')) && this._worker) {\n logger.error(\n `Static worker exited with code: ${code} and signal: ${signal}`\n )\n\n // if a child process doesn't exit gracefully, we want to bubble up the exit code to the parent process\n process.exit(code ?? 1)\n }\n })\n\n // if a child process emits a particular message, we track that as activity\n // so the parent process can keep track of progress\n worker._child?.on('message', ([, data]: [number, unknown]) => {\n if (\n data &&\n typeof data === 'object' &&\n 'type' in data &&\n data.type === 'activity'\n ) {\n onActivity()\n }\n })\n }\n }\n\n let aborted = false\n const onActivityAbort = () => {\n if (!aborted) {\n options.onActivityAbort?.()\n aborted = true\n }\n }\n\n // Listen to the worker's stdout and stderr, if there's any thing logged, abort the activity first\n const abortActivityStreamOnLog = new Transform({\n transform(_chunk, _encoding, callback) {\n onActivityAbort()\n callback()\n },\n })\n // Stop the activity if there's any output from the worker\n this._worker.getStdout().pipe(abortActivityStreamOnLog)\n this._worker.getStderr().pipe(abortActivityStreamOnLog)\n\n // Pipe the worker's stdout and stderr to the parent process\n this._worker.getStdout().pipe(process.stdout)\n this._worker.getStderr().pipe(process.stderr)\n }\n createWorker()\n\n const onHanging = () => {\n const worker = this._worker\n if (!worker) return\n const resolve = resolveRestartPromise\n createWorker()\n logger.warn(\n `Sending SIGTERM signal to static worker due to timeout${\n timeout ? ` of ${timeout / 1000} seconds` : ''\n }. Subsequent errors may be a result of the worker exiting.`\n )\n worker.end().then(() => {\n resolve(RESTARTED)\n })\n }\n\n let hangingTimer: NodeJS.Timeout | false = false\n\n const onActivity = () => {\n if (hangingTimer) clearTimeout(hangingTimer)\n if (options.onActivity) options.onActivity()\n\n hangingTimer = activeTasks > 0 && setTimeout(onHanging, timeout)\n }\n\n for (const method of farmOptions.exposedMethods) {\n if (method.startsWith('_')) continue\n ;(this as any)[method] = timeout\n ? // eslint-disable-next-line no-loop-func\n async (...args: any[]) => {\n activeTasks++\n try {\n let attempts = 0\n for (;;) {\n onActivity()\n const result = await Promise.race([\n (this._worker as any)[method](...args),\n restartPromise,\n ])\n if (result !== RESTARTED) return result\n if (onRestart) onRestart(method, args, ++attempts)\n }\n } finally {\n activeTasks--\n onActivity()\n }\n }\n : (this._worker as any)[method].bind(this._worker)\n }\n }\n\n end(): ReturnType<JestWorker['end']> {\n const worker = this._worker\n if (!worker) {\n throw new Error('Farm is ended, no more calls can be done to it')\n }\n cleanupWorkers(worker)\n this._worker = undefined\n return worker.end()\n }\n\n /**\n * Quietly end the worker if it exists\n */\n close(): void {\n if (this._worker) {\n cleanupWorkers(this._worker)\n this._worker.end()\n }\n }\n}\n"],"names":["Worker","RESTARTED","Symbol","cleanupWorkers","worker","curWorker","_workerPool","_workers","_child","kill","constructor","workerPath","options","timeout","onRestart","logger","console","farmOptions","restartPromise","resolveRestartPromise","activeTasks","_worker","undefined","process","on","close","createWorker","JestWorker","forkOptions","env","maxRetries","Promise","resolve","enableWorkerThreads","code","signal","error","exit","data","type","onActivity","aborted","onActivityAbort","abortActivityStreamOnLog","Transform","transform","_chunk","_encoding","callback","getStdout","pipe","getStderr","stdout","stderr","onHanging","warn","end","then","hangingTimer","clearTimeout","setTimeout","method","exposedMethods","startsWith","args","attempts","result","race","bind","Error"],"mappings":";;;;+BAgBaA;;;eAAAA;;;4BAfwB;wBACX;AAI1B,MAAMC,YAAYC,OAAO;AAEzB,MAAMC,iBAAiB,CAACC;QACG;IAAzB,KAAK,MAAMC,aAAc,EAAA,sBAAA,AAACD,OAAeE,WAAW,qBAA3B,oBAA6BC,QAAQ,KAAI,EAAE,CAE/D;YACHF;SAAAA,oBAAAA,UAAUG,MAAM,qBAAhBH,kBAAkBI,IAAI,CAAC;IACzB;AACF;AAEO,MAAMT;IAGXU,YACEC,UAAkB,EAClBC,OAQC,CACD;QACA,IAAI,EAAEC,OAAO,EAAEC,SAAS,EAAEC,SAASC,OAAO,EAAE,GAAGC,aAAa,GAAGL;QAE/D,IAAIM;QACJ,IAAIC;QACJ,IAAIC,cAAc;QAElB,IAAI,CAACC,OAAO,GAAGC;QAEf,oDAAoD;QACpDC,QAAQC,EAAE,CAAC,QAAQ;YACjB,IAAI,CAACC,KAAK;QACZ;QAEA,MAAMC,eAAe;gBAMRT;YALX,IAAI,CAACI,OAAO,GAAG,IAAIM,kBAAU,CAAChB,YAAY;gBACxC,GAAGM,WAAW;gBACdW,aAAa;oBACX,GAAGX,YAAYW,WAAW;oBAC1BC,KAAK;wBACH,GAAKZ,EAAAA,2BAAAA,YAAYW,WAAW,qBAAvBX,yBAAyBY,GAAG,KAAI,CAAC,CAAC;wBACvC,GAAGN,QAAQM,GAAG;oBAChB;gBACF;gBACAC,YAAY;YACd;YACAZ,iBAAiB,IAAIa,QACnB,CAACC,UAAab,wBAAwBa;YAGxC;;;;;;;;OAQC,GACD,IAAI,CAACf,YAAYgB,mBAAmB,EAAE;oBACd;gBAAtB,KAAK,MAAM7B,UAAW,EAAA,4BAAA,AAAC,IAAI,CAACiB,OAAO,CAASf,WAAW,qBAAjC,0BAAmCC,QAAQ,KAC/D,EAAE,CAEC;wBACHH,gBAWA,2EAA2E;oBAC3E,mDAAmD;oBACnDA;qBAbAA,iBA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OAAO,EAAE;YAChBlB,eAAe,IAAI,CAACkB,OAAO;YAC3B,IAAI,CAACA,OAAO,CAACmC,GAAG;QAClB;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/lib/worker.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process'\nimport { Worker as JestWorker } from 'next/dist/compiled/jest-worker'\nimport { Transform } from 'stream'\n\ntype FarmOptions = ConstructorParameters<typeof JestWorker>[1]\n\nconst RESTARTED = Symbol('restarted')\n\nconst cleanupWorkers = (worker: JestWorker) => {\n for (const curWorker of ((worker as any)._workerPool?._workers || []) as {\n _child?: ChildProcess\n }[]) {\n curWorker._child?.kill('SIGINT')\n }\n}\n\nexport class Worker {\n private _worker: JestWorker | undefined\n\n constructor(\n workerPath: string,\n options: FarmOptions & {\n timeout?: number\n onActivity?: () => void\n onActivityAbort?: () => void\n onRestart?: (method: string, args: any[], attempts: number) => void\n logger?: Pick<typeof console, 'error' | 'info' | 'warn'>\n exposedMethods: ReadonlyArray<string>\n enableWorkerThreads?: boolean\n }\n ) {\n let { timeout, onRestart, logger = console, ...farmOptions } = options\n\n let restartPromise: Promise<typeof RESTARTED>\n let resolveRestartPromise: (arg: typeof RESTARTED) => void\n let activeTasks = 0\n\n this._worker = undefined\n\n // ensure we end workers if they weren't before exit\n process.on('exit', () => {\n this.close()\n })\n\n const createWorker = () => {\n this._worker = new JestWorker(workerPath, {\n ...farmOptions,\n forkOptions: {\n ...farmOptions.forkOptions,\n env: {\n ...((farmOptions.forkOptions?.env || {}) as any),\n ...process.env,\n IS_NEXT_WORKER: 'true',\n } as any,\n },\n maxRetries: 0,\n }) as JestWorker\n restartPromise = new Promise(\n (resolve) => (resolveRestartPromise = resolve)\n )\n\n /**\n * Jest Worker has two worker types, ChildProcessWorker (uses child_process) and NodeThreadWorker (uses worker_threads)\n * Next.js uses ChildProcessWorker by default, but it can be switched to NodeThreadWorker with an experimental flag\n *\n * We only want to handle ChildProcessWorker's orphan process issue, so we access the private property \"_child\":\n * https://github.com/facebook/jest/blob/b38d7d345a81d97d1dc3b68b8458b1837fbf19be/packages/jest-worker/src/workers/ChildProcessWorker.ts\n *\n * But this property is not available in NodeThreadWorker, so we need to check if we are using ChildProcessWorker\n */\n if (!farmOptions.enableWorkerThreads) {\n for (const worker of ((this._worker as any)._workerPool?._workers ||\n []) as {\n _child?: ChildProcess\n }[]) {\n worker._child?.on('exit', (code, signal) => {\n if ((code || (signal && signal !== 'SIGINT')) && this._worker) {\n logger.error(\n `Next.js build worker exited with code: ${code} and signal: ${signal}`\n )\n\n // if a child process doesn't exit gracefully, we want to bubble up the exit code to the parent process\n process.exit(code ?? 1)\n }\n })\n\n // if a child process emits a particular message, we track that as activity\n // so the parent process can keep track of progress\n worker._child?.on('message', ([, data]: [number, unknown]) => {\n if (\n data &&\n typeof data === 'object' &&\n 'type' in data &&\n data.type === 'activity'\n ) {\n onActivity()\n }\n })\n }\n }\n\n let aborted = false\n const onActivityAbort = () => {\n if (!aborted) {\n options.onActivityAbort?.()\n aborted = true\n }\n }\n\n // Listen to the worker's stdout and stderr, if there's any thing logged, abort the activity first\n const abortActivityStreamOnLog = new Transform({\n transform(_chunk, _encoding, callback) {\n onActivityAbort()\n callback()\n },\n })\n // Stop the activity if there's any output from the worker\n this._worker.getStdout().pipe(abortActivityStreamOnLog)\n this._worker.getStderr().pipe(abortActivityStreamOnLog)\n\n // Pipe the worker's stdout and stderr to the parent process\n this._worker.getStdout().pipe(process.stdout)\n this._worker.getStderr().pipe(process.stderr)\n }\n createWorker()\n\n const onHanging = () => {\n const worker = this._worker\n if (!worker) return\n const resolve = resolveRestartPromise\n createWorker()\n logger.warn(\n `Sending SIGTERM signal to static worker due to timeout${\n timeout ? ` of ${timeout / 1000} seconds` : ''\n }. Subsequent errors may be a result of the worker exiting.`\n )\n worker.end().then(() => {\n resolve(RESTARTED)\n })\n }\n\n let hangingTimer: NodeJS.Timeout | false = false\n\n const onActivity = () => {\n if (hangingTimer) clearTimeout(hangingTimer)\n if (options.onActivity) options.onActivity()\n\n hangingTimer = activeTasks > 0 && setTimeout(onHanging, timeout)\n }\n\n for (const method of farmOptions.exposedMethods) {\n if (method.startsWith('_')) continue\n ;(this as any)[method] = timeout\n ? // eslint-disable-next-line no-loop-func\n async (...args: any[]) => {\n activeTasks++\n try {\n let attempts = 0\n for (;;) {\n onActivity()\n const result = await Promise.race([\n (this._worker as any)[method](...args),\n restartPromise,\n ])\n if (result !== RESTARTED) return result\n if (onRestart) onRestart(method, args, ++attempts)\n }\n } finally {\n activeTasks--\n onActivity()\n }\n }\n : (this._worker as any)[method].bind(this._worker)\n }\n }\n\n end(): ReturnType<JestWorker['end']> {\n const worker = this._worker\n if (!worker) {\n throw new Error('Farm is ended, no more calls can be done to it')\n }\n cleanupWorkers(worker)\n this._worker = undefined\n return worker.end()\n }\n\n /**\n * Quietly end the worker if it exists\n */\n close(): void {\n if (this._worker) {\n cleanupWorkers(this._worker)\n this._worker.end()\n }\n }\n}\n"],"names":["Worker","RESTARTED","Symbol","cleanupWorkers","worker","curWorker","_workerPool","_workers","_child","kill","constructor","workerPath","options","timeout","onRestart","logger","console","farmOptions","restartPromise","resolveRestartPromise","activeTasks","_worker","undefined","process","on","close","createWorker","JestWorker","forkOptions","env","IS_NEXT_WORKER","maxRetries","Promise","resolve","enableWorkerThreads","code","signal","error","exit","data","type","onActivity","aborted","onActivityAbort","abortActivityStreamOnLog","Transform","transform","_chunk","_encoding","callback","getStdout","pipe","getStderr","stdout","stderr","onHanging","warn","end","then","hangingTimer","clearTimeout","setTimeout","method","exposedMethods","startsWith","args","attempts","result","race","bind","Error"],"mappings":";;;;+BAgBaA;;;eAAAA;;;4BAfwB;wBACX;AAI1B,MAAMC,YAAYC,OAAO;AAEzB,MAAMC,iBAAiB,CAACC;QACG;IAAzB,KAAK,MAAMC,aAAc,EAAA,sBAAA,AAACD,OAAeE,WAAW,qBAA3B,oBAA6BC,QAAQ,KAAI,EAAE,CAE/D;YACHF;SAAAA,oBAAAA,UAAUG,MAAM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AU,EAAE7B,QAAQ6B,UAAU;YAE1CkB,eAAevC,cAAc,KAAKyC,WAAWN,WAAW1C;QAC1D;QAEA,KAAK,MAAMiD,UAAU7C,YAAY8C,cAAc,CAAE;YAC/C,IAAID,OAAOE,UAAU,CAAC,MAAM;YAC3B,AAAC,IAAI,AAAQ,CAACF,OAAO,GAAGjD,UAErB,OAAO,GAAGoD;gBACR7C;gBACA,IAAI;oBACF,IAAI8C,WAAW;oBACf,OAAS;wBACPzB;wBACA,MAAM0B,SAAS,MAAMnC,QAAQoC,IAAI,CAAC;4BAC/B,IAAI,CAAC/C,OAAO,AAAQ,CAACyC,OAAO,IAAIG;4BACjC/C;yBACD;wBACD,IAAIiD,WAAWlE,WAAW,OAAOkE;wBACjC,IAAIrD,WAAWA,UAAUgD,QAAQG,MAAM,EAAEC;oBAC3C;gBACF,SAAU;oBACR9C;oBACAqB;gBACF;YACF,IACA,AAAC,IAAI,CAACpB,OAAO,AAAQ,CAACyC,OAAO,CAACO,IAAI,CAAC,IAAI,CAAChD,OAAO;QACrD;IACF;IAEAoC,MAAqC;QACnC,MAAMrD,SAAS,IAAI,CAACiB,OAAO;QAC3B,IAAI,CAACjB,QAAQ;YACX,MAAM,qBAA2D,CAA3D,IAAIkE,MAAM,mDAAV,qBAAA;uBAAA;4BAAA;YAA0D;QAClE;QACAnE,eAAeC;QACf,IAAI,CAACiB,OAAO,GAAGC;QACf,OAAOlB,OAAOqD,GAAG;IACnB;IAEA;;GAEC,GACDhC,QAAc;QACZ,IAAI,IAAI,CAACJ,OAAO,EAAE;YAChBlB,eAAe,IAAI,CAACkB,OAAO;YAC3B,IAAI,CAACA,OAAO,CAACoC,GAAG;QAClB;IACF;AACF"}
@@ -161,7 +161,7 @@ function warnCustomizedOption(config, key, defaultValue, customMessage, configFi
161
161
  }
162
162
  }
163
163
  function assignDefaults(dir, userConfig, silent) {
164
- var _defaultConfig_experimental, _result_experimental, _process_env___NEXT_VERSION, _result_experimental1, _result_experimental_serverActions, _result_experimental2, _result_experimental_turbo, _result_experimental3, _result_experimental_turbo1, _result_experimental4, _result_experimental_turbo2, _result_experimental5, _result_devIndicators, _result_experimental6, _result_experimental7;
164
+ var _defaultConfig_experimental, _result_experimental, _process_env___NEXT_VERSION, _result_experimental_serverActions, _result_experimental1, _result_experimental_turbo, _result_experimental2, _result_experimental_turbo1, _result_experimental3, _result_experimental_turbo2, _result_experimental4, _result_devIndicators, _result_experimental5, _result_experimental6;
165
165
  const configFileName = userConfig.configFileName;
166
166
  if (typeof userConfig.exportTrailingSlash !== 'undefined') {
167
167
  if (!silent) {
@@ -256,20 +256,20 @@ function assignDefaults(dir, userConfig, silent) {
256
256
  enumerable: false
257
257
  });
258
258
  }
259
- if (!((_process_env___NEXT_VERSION = "15.2.0-canary.43") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV) {
260
- var _result_experimental8, _result_experimental9, _result_experimental_turbo3, _result_experimental10;
259
+ if (!((_process_env___NEXT_VERSION = "15.2.0-canary.45") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV) {
260
+ var _result_experimental7, _result_experimental8, _result_experimental_turbo3, _result_experimental9;
261
261
  // Prevents usage of certain experimental features outside of canary
262
- if ((_result_experimental8 = result.experimental) == null ? void 0 : _result_experimental8.ppr) {
262
+ if ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.ppr) {
263
263
  throw Object.defineProperty(new CanaryOnlyError('experimental.ppr'), "__NEXT_ERROR_CODE", {
264
264
  value: "E544",
265
265
  enumerable: false
266
266
  });
267
- } else if ((_result_experimental9 = result.experimental) == null ? void 0 : _result_experimental9.dynamicIO) {
267
+ } else if ((_result_experimental8 = result.experimental) == null ? void 0 : _result_experimental8.dynamicIO) {
268
268
  throw Object.defineProperty(new CanaryOnlyError('experimental.dynamicIO'), "__NEXT_ERROR_CODE", {
269
269
  value: "E607",
270
270
  enumerable: false
271
271
  });
272
- } else if ((_result_experimental10 = result.experimental) == null ? void 0 : (_result_experimental_turbo3 = _result_experimental10.turbo) == null ? void 0 : _result_experimental_turbo3.unstablePersistentCaching) {
272
+ } else if ((_result_experimental9 = result.experimental) == null ? void 0 : (_result_experimental_turbo3 = _result_experimental9.turbo) == null ? void 0 : _result_experimental_turbo3.unstablePersistentCaching) {
273
273
  throw Object.defineProperty(new CanaryOnlyError('experimental.turbo.unstablePersistentCaching'), "__NEXT_ERROR_CODE", {
274
274
  value: "E551",
275
275
  enumerable: false
@@ -433,12 +433,6 @@ function assignDefaults(dir, userConfig, silent) {
433
433
  images.loaderFile = absolutePath;
434
434
  }
435
435
  }
436
- // TODO(jiwon): remove once we've made new UI default
437
- // Enable reactOwnerStack when newDevOverlay is enabled to have
438
- // better call stack output in the new UI.
439
- if ((_result_experimental1 = result.experimental) == null ? void 0 : _result_experimental1.newDevOverlay) {
440
- result.experimental.reactOwnerStack = true;
441
- }
442
436
  warnCustomizedOption(result, 'experimental.esmExternals', true, 'experimental.esmExternals is not recommended to be modified as it may disrupt module resolution', configFileName, silent);
443
437
  warnOptionHasBeenDeprecated(result, 'experimental.instrumentationHook', `\`experimental.instrumentationHook\` is no longer needed, because \`instrumentation.js\` is available by default. You can remove it from ${configFileName}.`, silent);
444
438
  warnOptionHasBeenDeprecated(result, 'experimental.after', `\`experimental.after\` is no longer needed, because \`after\` is available by default. You can remove it from ${configFileName}.`, silent);
@@ -459,7 +453,7 @@ function assignDefaults(dir, userConfig, silent) {
459
453
  }
460
454
  result.output = 'standalone';
461
455
  }
462
- if (typeof ((_result_experimental2 = result.experimental) == null ? void 0 : (_result_experimental_serverActions = _result_experimental2.serverActions) == null ? void 0 : _result_experimental_serverActions.bodySizeLimit) !== 'undefined') {
456
+ if (typeof ((_result_experimental1 = result.experimental) == null ? void 0 : (_result_experimental_serverActions = _result_experimental1.serverActions) == null ? void 0 : _result_experimental_serverActions.bodySizeLimit) !== 'undefined') {
463
457
  var _result_experimental_serverActions1;
464
458
  const value = parseInt((_result_experimental_serverActions1 = result.experimental.serverActions) == null ? void 0 : _result_experimental_serverActions1.bodySizeLimit.toString());
465
459
  if (isNaN(value) || value < 1) {
@@ -478,7 +472,7 @@ function assignDefaults(dir, userConfig, silent) {
478
472
  _log.warn(`outputFileTracingRoot should be absolute, using: ${result.outputFileTracingRoot}`);
479
473
  }
480
474
  }
481
- if ((result == null ? void 0 : (_result_experimental3 = result.experimental) == null ? void 0 : (_result_experimental_turbo = _result_experimental3.turbo) == null ? void 0 : _result_experimental_turbo.root) && !(0, _path.isAbsolute)(result.experimental.turbo.root)) {
475
+ if ((result == null ? void 0 : (_result_experimental2 = result.experimental) == null ? void 0 : (_result_experimental_turbo = _result_experimental2.turbo) == null ? void 0 : _result_experimental_turbo.root) && !(0, _path.isAbsolute)(result.experimental.turbo.root)) {
482
476
  result.experimental.turbo.root = (0, _path.resolve)(result.experimental.turbo.root);
483
477
  if (!silent) {
484
478
  _log.warn(`experimental.turbo.root should be absolute, using: ${result.experimental.turbo.root}`);
@@ -488,7 +482,7 @@ function assignDefaults(dir, userConfig, silent) {
488
482
  if (process.env.NEXT_DEPLOYMENT_ID) {
489
483
  result.deploymentId = process.env.NEXT_DEPLOYMENT_ID;
490
484
  }
491
- if ((result == null ? void 0 : result.outputFileTracingRoot) && !(result == null ? void 0 : (_result_experimental4 = result.experimental) == null ? void 0 : (_result_experimental_turbo1 = _result_experimental4.turbo) == null ? void 0 : _result_experimental_turbo1.root)) {
485
+ if ((result == null ? void 0 : result.outputFileTracingRoot) && !(result == null ? void 0 : (_result_experimental3 = result.experimental) == null ? void 0 : (_result_experimental_turbo1 = _result_experimental3.turbo) == null ? void 0 : _result_experimental_turbo1.root)) {
492
486
  (0, _dset.dset)(result, [
493
487
  'experimental',
494
488
  'turbo',
@@ -496,15 +490,15 @@ function assignDefaults(dir, userConfig, silent) {
496
490
  ], result.outputFileTracingRoot);
497
491
  }
498
492
  // use the closest lockfile as tracing root
499
- if (!(result == null ? void 0 : result.outputFileTracingRoot) || !(result == null ? void 0 : (_result_experimental5 = result.experimental) == null ? void 0 : (_result_experimental_turbo2 = _result_experimental5.turbo) == null ? void 0 : _result_experimental_turbo2.root)) {
493
+ if (!(result == null ? void 0 : result.outputFileTracingRoot) || !(result == null ? void 0 : (_result_experimental4 = result.experimental) == null ? void 0 : (_result_experimental_turbo2 = _result_experimental4.turbo) == null ? void 0 : _result_experimental_turbo2.root)) {
500
494
  let rootDir = (0, _findroot.findRootDir)(dir);
501
495
  if (rootDir) {
502
- var _result_experimental_turbo4, _result_experimental11;
496
+ var _result_experimental_turbo4, _result_experimental10;
503
497
  if (!(result == null ? void 0 : result.outputFileTracingRoot)) {
504
498
  result.outputFileTracingRoot = rootDir;
505
499
  _configshared.defaultConfig.outputFileTracingRoot = result.outputFileTracingRoot;
506
500
  }
507
- if (!(result == null ? void 0 : (_result_experimental11 = result.experimental) == null ? void 0 : (_result_experimental_turbo4 = _result_experimental11.turbo) == null ? void 0 : _result_experimental_turbo4.root)) {
501
+ if (!(result == null ? void 0 : (_result_experimental10 = result.experimental) == null ? void 0 : (_result_experimental_turbo4 = _result_experimental10.turbo) == null ? void 0 : _result_experimental_turbo4.root)) {
508
502
  (0, _dset.dset)(result, [
509
503
  'experimental',
510
504
  'turbo',
@@ -691,7 +685,7 @@ function assignDefaults(dir, userConfig, silent) {
691
685
  secondsCacheLifeProfile.stale = dynamicStaleTime ?? ((_defaultConfig_experimental5 = _configshared.defaultConfig.experimental) == null ? void 0 : (_defaultConfig_experimental_staleTimes2 = _defaultConfig_experimental5.staleTimes) == null ? void 0 : _defaultConfig_experimental_staleTimes2.dynamic);
692
686
  }
693
687
  }
694
- if ((_result_experimental6 = result.experimental) == null ? void 0 : _result_experimental6.cacheHandlers) {
688
+ if ((_result_experimental5 = result.experimental) == null ? void 0 : _result_experimental5.cacheHandlers) {
695
689
  const allowedHandlerNameRegex = /[a-z-]/;
696
690
  if (typeof result.experimental.cacheHandlers !== 'object') {
697
691
  throw Object.defineProperty(new Error(`Invalid "experimental.cacheHandlers" provided, expected an object e.g. { default: '/my-handler.js' }, received ${JSON.stringify(result.experimental.cacheHandlers)}`), "__NEXT_ERROR_CODE", {
@@ -737,10 +731,19 @@ function assignDefaults(dir, userConfig, silent) {
737
731
  transform: 'lodash/{{member}}'
738
732
  }
739
733
  };
740
- const userProvidedOptimizePackageImports = ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.optimizePackageImports) || [];
734
+ const userProvidedOptimizePackageImports = ((_result_experimental6 = result.experimental) == null ? void 0 : _result_experimental6.optimizePackageImports) || [];
741
735
  if (!result.experimental) {
742
736
  result.experimental = {};
743
737
  }
738
+ // TODO(jiwon): remove once we've made new UI default
739
+ // Enable reactOwnerStack when newDevOverlay is enabled to have
740
+ // better call stack output in the new UI.
741
+ if (process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true') {
742
+ result.experimental.newDevOverlay = true;
743
+ }
744
+ if (result.experimental.newDevOverlay) {
745
+ result.experimental.reactOwnerStack = true;
746
+ }
744
747
  result.experimental.optimizePackageImports = [
745
748
  ...new Set([
746
749
  ...userProvidedOptimizePackageImports,