next 16.0.2-canary.10 → 16.0.2-canary.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/babel/loader/get-config.js +5 -0
  3. package/dist/build/babel/loader/get-config.js.map +1 -1
  4. package/dist/build/index.js +7 -4
  5. package/dist/build/index.js.map +1 -1
  6. package/dist/build/jest/jest.js +2 -1
  7. package/dist/build/jest/jest.js.map +1 -1
  8. package/dist/build/load-entrypoint.js +1 -2
  9. package/dist/build/load-entrypoint.js.map +1 -1
  10. package/dist/build/lockfile.d.ts +1 -1
  11. package/dist/build/lockfile.js +5 -9
  12. package/dist/build/lockfile.js.map +1 -1
  13. package/dist/build/next-config-ts/transpile-config.js +13 -3
  14. package/dist/build/next-config-ts/transpile-config.js.map +1 -1
  15. package/dist/build/swc/index.d.ts +4 -2
  16. package/dist/build/swc/index.js +54 -51
  17. package/dist/build/swc/index.js.map +1 -1
  18. package/dist/build/swc/install-bindings.d.ts +15 -0
  19. package/dist/build/swc/install-bindings.js +30 -0
  20. package/dist/build/swc/install-bindings.js.map +1 -0
  21. package/dist/build/templates/app-page.js +7 -1
  22. package/dist/build/templates/app-page.js.map +1 -1
  23. package/dist/build/turbopack-build/impl.js +9 -4
  24. package/dist/build/turbopack-build/impl.js.map +1 -1
  25. package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
  26. package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
  27. package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
  28. package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
  29. package/dist/build/webpack/loaders/next-app-loader/index.js +6 -0
  30. package/dist/build/webpack/loaders/next-app-loader/index.js.map +1 -1
  31. package/dist/build/webpack/loaders/next-barrel-loader.js +5 -0
  32. package/dist/build/webpack/loaders/next-barrel-loader.js.map +1 -1
  33. package/dist/build/webpack/loaders/next-metadata-image-loader.js +5 -0
  34. package/dist/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
  35. package/dist/build/webpack/loaders/next-metadata-route-loader.js +5 -0
  36. package/dist/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
  37. package/dist/build/webpack/loaders/next-swc-loader.js +10 -6
  38. package/dist/build/webpack/loaders/next-swc-loader.js.map +1 -1
  39. package/dist/build/webpack-build/impl.js +4 -1
  40. package/dist/build/webpack-build/impl.js.map +1 -1
  41. package/dist/build/webpack-config.js +2 -7
  42. package/dist/build/webpack-config.js.map +1 -1
  43. package/dist/cli/next-typegen.js +3 -0
  44. package/dist/cli/next-typegen.js.map +1 -1
  45. package/dist/client/app-bootstrap.js +1 -1
  46. package/dist/client/index.js +1 -1
  47. package/dist/compiled/@next/font/dist/google/font-data.json +63 -0
  48. package/dist/compiled/@next/font/dist/google/index.d.ts +40 -0
  49. package/dist/esm/build/babel/loader/get-config.js +5 -0
  50. package/dist/esm/build/babel/loader/get-config.js.map +1 -1
  51. package/dist/esm/build/index.js +7 -4
  52. package/dist/esm/build/index.js.map +1 -1
  53. package/dist/esm/build/load-entrypoint.js +2 -3
  54. package/dist/esm/build/load-entrypoint.js.map +1 -1
  55. package/dist/esm/build/lockfile.js +5 -9
  56. package/dist/esm/build/lockfile.js.map +1 -1
  57. package/dist/esm/build/next-config-ts/transpile-config.js +13 -3
  58. package/dist/esm/build/next-config-ts/transpile-config.js.map +1 -1
  59. package/dist/esm/build/swc/index.js +52 -49
  60. package/dist/esm/build/swc/index.js.map +1 -1
  61. package/dist/esm/build/swc/install-bindings.js +20 -0
  62. package/dist/esm/build/swc/install-bindings.js.map +1 -0
  63. package/dist/esm/build/templates/app-page.js +7 -1
  64. package/dist/esm/build/templates/app-page.js.map +1 -1
  65. package/dist/esm/build/turbopack-build/impl.js +10 -5
  66. package/dist/esm/build/turbopack-build/impl.js.map +1 -1
  67. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
  68. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
  69. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
  70. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
  71. package/dist/esm/build/webpack/loaders/next-app-loader/index.js +6 -0
  72. package/dist/esm/build/webpack/loaders/next-app-loader/index.js.map +1 -1
  73. package/dist/esm/build/webpack/loaders/next-barrel-loader.js +5 -0
  74. package/dist/esm/build/webpack/loaders/next-barrel-loader.js.map +1 -1
  75. package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js +5 -0
  76. package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
  77. package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js +5 -0
  78. package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
  79. package/dist/esm/build/webpack/loaders/next-swc-loader.js +11 -7
  80. package/dist/esm/build/webpack/loaders/next-swc-loader.js.map +1 -1
  81. package/dist/esm/build/webpack-build/impl.js +4 -1
  82. package/dist/esm/build/webpack-build/impl.js.map +1 -1
  83. package/dist/esm/build/webpack-config.js +2 -7
  84. package/dist/esm/build/webpack-config.js.map +1 -1
  85. package/dist/esm/client/app-bootstrap.js +1 -1
  86. package/dist/esm/client/index.js +1 -1
  87. package/dist/esm/server/config.js +2 -2
  88. package/dist/esm/server/config.js.map +1 -1
  89. package/dist/esm/server/dev/hot-reloader-turbopack.js +3 -4
  90. package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
  91. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  92. package/dist/esm/server/lib/app-info-log.js +1 -1
  93. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js +3 -0
  94. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  95. package/dist/esm/server/lib/start-server.js +1 -1
  96. package/dist/esm/server/lib/trace/tracer.js +6 -5
  97. package/dist/esm/server/lib/trace/tracer.js.map +1 -1
  98. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  99. package/dist/server/config.js +2 -2
  100. package/dist/server/config.js.map +1 -1
  101. package/dist/server/dev/hot-reloader-turbopack.js +2 -3
  102. package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
  103. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  104. package/dist/server/lib/app-info-log.js +1 -1
  105. package/dist/server/lib/router-utils/setup-dev-bundler.js +3 -0
  106. package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  107. package/dist/server/lib/start-server.js +1 -1
  108. package/dist/server/lib/trace/tracer.js +6 -5
  109. package/dist/server/lib/trace/tracer.js.map +1 -1
  110. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  111. package/dist/telemetry/anonymous-meta.js +1 -1
  112. package/dist/telemetry/events/session-stopped.js +2 -2
  113. package/dist/telemetry/events/version.js +2 -2
  114. package/package.json +15 -15
@@ -23,6 +23,7 @@ const _pagetypes = require("../lib/page-types");
23
23
  const _routetypesutils = require("../server/lib/router-utils/route-types-utils");
24
24
  const _cachelifetypeutils = require("../server/lib/router-utils/cache-life-type-utils");
25
25
  const _findpagefile = require("../server/lib/find-page-file");
26
+ const _installbindings = require("../build/swc/install-bindings");
26
27
  function _interop_require_default(obj) {
27
28
  return obj && obj.__esModule ? obj : {
28
29
  default: obj
@@ -70,12 +71,14 @@ function _interop_require_wildcard(obj, nodeInterop) {
70
71
  return newObj;
71
72
  }
72
73
  const nextTypegen = async (_options, directory)=>{
74
+ var _nextConfig_experimental;
73
75
  const baseDir = (0, _getprojectdir.getProjectDir)(directory);
74
76
  // Check if the provided directory exists
75
77
  if (!(0, _fs.existsSync)(baseDir)) {
76
78
  (0, _utils.printAndExit)(`> No such directory exists as the project root: ${baseDir}`);
77
79
  }
78
80
  const nextConfig = await (0, _config.default)(_constants.PHASE_PRODUCTION_BUILD, baseDir);
81
+ await (0, _installbindings.installBindings)((_nextConfig_experimental = nextConfig.experimental) == null ? void 0 : _nextConfig_experimental.useWasmBinary);
79
82
  const distDir = (0, _path.join)(baseDir, nextConfig.distDir);
80
83
  const { pagesDir, appDir } = (0, _findpagesdir.findPagesDir)(baseDir);
81
84
  await (0, _verifytypescriptsetup.verifyTypeScriptSetup)({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/next-typegen.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { existsSync } from 'fs'\nimport path, { join } from 'path'\nimport { mkdir } from 'fs/promises'\n\nimport loadConfig from '../server/config'\nimport { printAndExit } from '../server/lib/utils'\nimport { PHASE_PRODUCTION_BUILD } from '../shared/lib/constants'\nimport { getProjectDir } from '../lib/get-project-dir'\nimport { findPagesDir } from '../lib/find-pages-dir'\nimport { verifyTypeScriptSetup } from '../lib/verify-typescript-setup'\nimport {\n createPagesMapping,\n collectAppFiles,\n collectPagesFiles,\n processPageRoutes,\n processAppRoutes,\n processLayoutRoutes,\n extractSlotsFromAppRoutes,\n extractSlotsFromDefaultFiles,\n combineSlots,\n type RouteInfo,\n type SlotInfo,\n} from '../build/entries'\nimport { PAGE_TYPES } from '../lib/page-types'\n\nimport {\n createRouteTypesManifest,\n writeRouteTypesManifest,\n writeValidatorFile,\n} from '../server/lib/router-utils/route-types-utils'\nimport { writeCacheLifeTypes } from '../server/lib/router-utils/cache-life-type-utils'\nimport { createValidFileMatcher } from '../server/lib/find-page-file'\n\nexport type NextTypegenOptions = {\n dir?: string\n}\n\nconst nextTypegen = async (\n _options: NextTypegenOptions,\n directory?: string\n) => {\n const baseDir = getProjectDir(directory)\n\n // Check if the provided directory exists\n if (!existsSync(baseDir)) {\n printAndExit(`> No such directory exists as the project root: ${baseDir}`)\n }\n\n const nextConfig = await loadConfig(PHASE_PRODUCTION_BUILD, baseDir)\n const distDir = join(baseDir, nextConfig.distDir)\n const { pagesDir, appDir } = findPagesDir(baseDir)\n\n await verifyTypeScriptSetup({\n dir: baseDir,\n distDir: nextConfig.distDir,\n intentDirs: [pagesDir, appDir].filter(Boolean) as string[],\n typeCheckPreflight: false,\n tsconfigPath: nextConfig.typescript.tsconfigPath,\n disableStaticImages: nextConfig.images.disableStaticImages,\n hasAppDir: !!appDir,\n hasPagesDir: !!pagesDir,\n isolatedDevBuild: nextConfig.experimental.isolatedDevBuild,\n })\n\n console.log('Generating route types...')\n\n const routeTypesFilePath = join(distDir, 'types', 'routes.d.ts')\n const validatorFilePath = join(distDir, 'types', 'validator.ts')\n await mkdir(join(distDir, 'types'), { recursive: true })\n\n let pageRoutes: RouteInfo[] = []\n let appRoutes: RouteInfo[] = []\n let appRouteHandlers: RouteInfo[] = []\n let layoutRoutes: RouteInfo[] = []\n let slots: SlotInfo[] = []\n\n let pageApiRoutes: RouteInfo[] = []\n\n let mappedPages: { [page: string]: string } = {}\n let mappedAppPages: { [page: string]: string } = {}\n let mappedAppLayouts: { [page: string]: string } = {}\n\n // Helper function to reduce createPagesMapping duplication\n const createMapping = (pagePaths: string[], pagesType: any) =>\n createPagesMapping({\n pagePaths,\n isDev: false,\n pagesType,\n pageExtensions: nextConfig.pageExtensions,\n pagesDir,\n appDir,\n appDirOnly: !!appDir && !pagesDir,\n })\n\n const validFileMatcher = createValidFileMatcher(\n nextConfig.pageExtensions,\n appDir\n )\n\n const isSrcDir = path\n .relative(baseDir, pagesDir || appDir || '')\n .startsWith('src')\n\n // Build pages routes\n if (pagesDir) {\n const pagePaths = await collectPagesFiles(pagesDir, validFileMatcher)\n\n mappedPages = await createMapping(pagePaths, PAGE_TYPES.PAGES)\n\n // Process pages routes\n const processedPages = processPageRoutes(mappedPages, baseDir, isSrcDir)\n pageRoutes = processedPages.pageRoutes\n pageApiRoutes = processedPages.pageApiRoutes\n }\n\n // Build app routes\n if (appDir) {\n // Collect app pages, layouts, and default files in a single directory traversal\n const { appPaths, layoutPaths, defaultPaths } = await collectAppFiles(\n appDir,\n validFileMatcher\n )\n\n mappedAppPages = await createMapping(appPaths, PAGE_TYPES.APP)\n mappedAppLayouts = await createMapping(layoutPaths, PAGE_TYPES.APP)\n const mappedDefaultFiles = await createMapping(defaultPaths, PAGE_TYPES.APP)\n\n // Process app routes and extract slots from both pages and default files\n const slotsFromPages = extractSlotsFromAppRoutes(mappedAppPages)\n const slotsFromDefaults = extractSlotsFromDefaultFiles(mappedDefaultFiles)\n\n // Combine slots and deduplicate using Set\n slots = combineSlots(slotsFromPages, slotsFromDefaults)\n\n const result = processAppRoutes(\n mappedAppPages,\n validFileMatcher,\n baseDir,\n isSrcDir\n )\n appRoutes = result.appRoutes\n appRouteHandlers = result.appRouteHandlers\n\n // Process layout routes\n layoutRoutes = processLayoutRoutes(mappedAppLayouts, baseDir, isSrcDir)\n }\n\n const routeTypesManifest = await createRouteTypesManifest({\n dir: baseDir,\n pageRoutes,\n appRoutes,\n appRouteHandlers,\n pageApiRoutes,\n layoutRoutes,\n slots,\n redirects: nextConfig.redirects,\n rewrites: nextConfig.rewrites,\n validatorFilePath,\n })\n\n await writeRouteTypesManifest(\n routeTypesManifest,\n routeTypesFilePath,\n nextConfig\n )\n\n await writeValidatorFile(routeTypesManifest, validatorFilePath)\n\n // Generate cache-life types if cacheLife config exists\n const cacheLifeFilePath = join(distDir, 'types', 'cache-life.d.ts')\n writeCacheLifeTypes(nextConfig.cacheLife, cacheLifeFilePath)\n\n console.log('✓ Types generated successfully')\n}\n\nexport { nextTypegen }\n"],"names":["nextTypegen","_options","directory","baseDir","getProjectDir","existsSync","printAndExit","nextConfig","loadConfig","PHASE_PRODUCTION_BUILD","distDir","join","pagesDir","appDir","findPagesDir","verifyTypeScriptSetup","dir","intentDirs","filter","Boolean","typeCheckPreflight","tsconfigPath","typescript","disableStaticImages","images","hasAppDir","hasPagesDir","isolatedDevBuild","experimental","console","log","routeTypesFilePath","validatorFilePath","mkdir","recursive","pageRoutes","appRoutes","appRouteHandlers","layoutRoutes","slots","pageApiRoutes","mappedPages","mappedAppPages","mappedAppLayouts","createMapping","pagePaths","pagesType","createPagesMapping","isDev","pageExtensions","appDirOnly","validFileMatcher","createValidFileMatcher","isSrcDir","path","relative","startsWith","collectPagesFiles","PAGE_TYPES","PAGES","processedPages","processPageRoutes","appPaths","layoutPaths","defaultPaths","collectAppFiles","APP","mappedDefaultFiles","slotsFromPages","extractSlotsFromAppRoutes","slotsFromDefaults","extractSlotsFromDefaultFiles","combineSlots","result","processAppRoutes","processLayoutRoutes","routeTypesManifest","createRouteTypesManifest","redirects","rewrites","writeRouteTypesManifest","writeValidatorFile","cacheLifeFilePath","writeCacheLifeTypes","cacheLife"],"mappings":";;;;;+BAiLSA;;;eAAAA;;;oBA/KkB;8DACA;0BACL;+DAEC;uBACM;2BACU;+BACT;8BACD;uCACS;yBAa/B;2BACoB;iCAMpB;oCAC6B;8BACG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMvC,MAAMA,cAAc,OAClBC,UACAC;IAEA,MAAMC,UAAUC,IAAAA,4BAAa,EAACF;IAE9B,yCAAyC;IACzC,IAAI,CAACG,IAAAA,cAAU,EAACF,UAAU;QACxBG,IAAAA,mBAAY,EAAC,CAAC,gDAAgD,EAAEH,SAAS;IAC3E;IAEA,MAAMI,aAAa,MAAMC,IAAAA,eAAU,EAACC,iCAAsB,EAAEN;IAC5D,MAAMO,UAAUC,IAAAA,UAAI,EAACR,SAASI,WAAWG,OAAO;IAChD,MAAM,EAAEE,QAAQ,EAAEC,MAAM,EAAE,GAAGC,IAAAA,0BAAY,EAACX;IAE1C,MAAMY,IAAAA,4CAAqB,EAAC;QAC1BC,KAAKb;QACLO,SAASH,WAAWG,OAAO;QAC3BO,YAAY;YAACL;YAAUC;SAAO,CAACK,MAAM,CAACC;QACtCC,oBAAoB;QACpBC,cAAcd,WAAWe,UAAU,CAACD,YAAY;QAChDE,qBAAqBhB,WAAWiB,MAAM,CAACD,mBAAmB;QAC1DE,WAAW,CAAC,CAACZ;QACba,aAAa,CAAC,CAACd;QACfe,kBAAkBpB,WAAWqB,YAAY,CAACD,gBAAgB;IAC5D;IA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EAAE,GAAG,MAAMC,IAAAA,wBAAe,EACnEpD,QACAsC;QAGFT,iBAAiB,MAAME,cAAckB,UAAUJ,qBAAU,CAACQ,GAAG;QAC7DvB,mBAAmB,MAAMC,cAAcmB,aAAaL,qBAAU,CAACQ,GAAG;QAClE,MAAMC,qBAAqB,MAAMvB,cAAcoB,cAAcN,qBAAU,CAACQ,GAAG;QAE3E,yEAAyE;QACzE,MAAME,iBAAiBC,IAAAA,kCAAyB,EAAC3B;QACjD,MAAM4B,oBAAoBC,IAAAA,qCAA4B,EAACJ;QAEvD,0CAA0C;QAC1C5B,QAAQiC,IAAAA,qBAAY,EAACJ,gBAAgBE;QAErC,MAAMG,SAASC,IAAAA,yBAAgB,EAC7BhC,gBACAS,kBACAhD,SACAkD;QAEFjB,YAAYqC,OAAOrC,SAAS;QAC5BC,mBAAmBoC,OAAOpC,gBAAgB;QAE1C,wBAAwB;QACxBC,eAAeqC,IAAAA,4BAAmB,EAAChC,kBAAkBxC,SAASkD;IAChE;IAEA,MAAMuB,qBAAqB,MAAMC,IAAAA,yCAAwB,EAAC;QACxD7D,KAAKb;QACLgC;QACAC;QACAC;QACAG;QACAF;QACAC;QACAuC,WAAWvE,WAAWuE,SAAS;QAC/BC,UAAUxE,WAAWwE,QAAQ;QAC7B/C;IACF;IAEA,MAAMgD,IAAAA,wCAAuB,EAC3BJ,oBACA7C,oBACAxB;IAGF,MAAM0E,IAAAA,mCAAkB,EAACL,oBAAoB5C;IAE7C,uDAAuD;IACvD,MAAMkD,oBAAoBvE,IAAAA,UAAI,EAACD,SAAS,SAAS;IACjDyE,IAAAA,uCAAmB,EAAC5E,WAAW6E,SAAS,EAAEF;IAE1CrD,QAAQC,GAAG,CAAC;AACd","ignoreList":[0]}
1
+ {"version":3,"sources":["../../src/cli/next-typegen.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { existsSync } from 'fs'\nimport path, { join } from 'path'\nimport { mkdir } from 'fs/promises'\n\nimport loadConfig from '../server/config'\nimport { printAndExit } from '../server/lib/utils'\nimport { PHASE_PRODUCTION_BUILD } from '../shared/lib/constants'\nimport { getProjectDir } from '../lib/get-project-dir'\nimport { findPagesDir } from '../lib/find-pages-dir'\nimport { verifyTypeScriptSetup } from '../lib/verify-typescript-setup'\nimport {\n createPagesMapping,\n collectAppFiles,\n collectPagesFiles,\n processPageRoutes,\n processAppRoutes,\n processLayoutRoutes,\n extractSlotsFromAppRoutes,\n extractSlotsFromDefaultFiles,\n combineSlots,\n type RouteInfo,\n type SlotInfo,\n} from '../build/entries'\nimport { PAGE_TYPES } from '../lib/page-types'\n\nimport {\n createRouteTypesManifest,\n writeRouteTypesManifest,\n writeValidatorFile,\n} from '../server/lib/router-utils/route-types-utils'\nimport { writeCacheLifeTypes } from '../server/lib/router-utils/cache-life-type-utils'\nimport { createValidFileMatcher } from '../server/lib/find-page-file'\nimport { installBindings } from '../build/swc/install-bindings'\n\nexport type NextTypegenOptions = {\n dir?: string\n}\n\nconst nextTypegen = async (\n _options: NextTypegenOptions,\n directory?: string\n) => {\n const baseDir = getProjectDir(directory)\n\n // Check if the provided directory exists\n if (!existsSync(baseDir)) {\n printAndExit(`> No such directory exists as the project root: ${baseDir}`)\n }\n\n const nextConfig = await loadConfig(PHASE_PRODUCTION_BUILD, baseDir)\n await installBindings(nextConfig.experimental?.useWasmBinary)\n const distDir = join(baseDir, nextConfig.distDir)\n const { pagesDir, appDir } = findPagesDir(baseDir)\n\n await verifyTypeScriptSetup({\n dir: baseDir,\n distDir: nextConfig.distDir,\n intentDirs: [pagesDir, appDir].filter(Boolean) as string[],\n typeCheckPreflight: false,\n tsconfigPath: nextConfig.typescript.tsconfigPath,\n disableStaticImages: nextConfig.images.disableStaticImages,\n hasAppDir: !!appDir,\n hasPagesDir: !!pagesDir,\n isolatedDevBuild: nextConfig.experimental.isolatedDevBuild,\n })\n\n console.log('Generating route types...')\n\n const routeTypesFilePath = join(distDir, 'types', 'routes.d.ts')\n const validatorFilePath = join(distDir, 'types', 'validator.ts')\n await mkdir(join(distDir, 'types'), { recursive: true })\n\n let pageRoutes: RouteInfo[] = []\n let appRoutes: RouteInfo[] = []\n let appRouteHandlers: RouteInfo[] = []\n let layoutRoutes: RouteInfo[] = []\n let slots: SlotInfo[] = []\n\n let pageApiRoutes: RouteInfo[] = []\n\n let mappedPages: { [page: string]: string } = {}\n let mappedAppPages: { [page: string]: string } = {}\n let mappedAppLayouts: { [page: string]: string } = {}\n\n // Helper function to reduce createPagesMapping duplication\n const createMapping = (pagePaths: string[], pagesType: any) =>\n createPagesMapping({\n pagePaths,\n isDev: false,\n pagesType,\n pageExtensions: nextConfig.pageExtensions,\n pagesDir,\n appDir,\n appDirOnly: !!appDir && !pagesDir,\n })\n\n const validFileMatcher = createValidFileMatcher(\n nextConfig.pageExtensions,\n appDir\n )\n\n const isSrcDir = path\n .relative(baseDir, pagesDir || appDir || '')\n .startsWith('src')\n\n // Build pages routes\n if (pagesDir) {\n const pagePaths = await collectPagesFiles(pagesDir, validFileMatcher)\n\n mappedPages = await createMapping(pagePaths, PAGE_TYPES.PAGES)\n\n // Process pages routes\n const processedPages = processPageRoutes(mappedPages, baseDir, isSrcDir)\n pageRoutes = processedPages.pageRoutes\n pageApiRoutes = processedPages.pageApiRoutes\n }\n\n // Build app routes\n if (appDir) {\n // Collect app pages, layouts, and default files in a single directory traversal\n const { appPaths, layoutPaths, defaultPaths } = await collectAppFiles(\n appDir,\n validFileMatcher\n )\n\n mappedAppPages = await createMapping(appPaths, PAGE_TYPES.APP)\n mappedAppLayouts = await createMapping(layoutPaths, PAGE_TYPES.APP)\n const mappedDefaultFiles = await createMapping(defaultPaths, PAGE_TYPES.APP)\n\n // Process app routes and extract slots from both pages and default files\n const slotsFromPages = extractSlotsFromAppRoutes(mappedAppPages)\n const slotsFromDefaults = extractSlotsFromDefaultFiles(mappedDefaultFiles)\n\n // Combine slots and deduplicate using Set\n slots = combineSlots(slotsFromPages, slotsFromDefaults)\n\n const result = processAppRoutes(\n mappedAppPages,\n validFileMatcher,\n baseDir,\n isSrcDir\n )\n appRoutes = result.appRoutes\n appRouteHandlers = result.appRouteHandlers\n\n // Process layout routes\n layoutRoutes = processLayoutRoutes(mappedAppLayouts, baseDir, isSrcDir)\n }\n\n const routeTypesManifest = await createRouteTypesManifest({\n dir: baseDir,\n pageRoutes,\n appRoutes,\n appRouteHandlers,\n pageApiRoutes,\n layoutRoutes,\n slots,\n redirects: nextConfig.redirects,\n rewrites: nextConfig.rewrites,\n validatorFilePath,\n })\n\n await writeRouteTypesManifest(\n routeTypesManifest,\n routeTypesFilePath,\n nextConfig\n )\n\n await writeValidatorFile(routeTypesManifest, validatorFilePath)\n\n // Generate cache-life types if cacheLife config exists\n const cacheLifeFilePath = join(distDir, 'types', 'cache-life.d.ts')\n writeCacheLifeTypes(nextConfig.cacheLife, cacheLifeFilePath)\n\n console.log('✓ Types generated successfully')\n}\n\nexport { nextTypegen }\n"],"names":["nextTypegen","_options","directory","nextConfig","baseDir","getProjectDir","existsSync","printAndExit","loadConfig","PHASE_PRODUCTION_BUILD","installBindings","experimental","useWasmBinary","distDir","join","pagesDir","appDir","findPagesDir","verifyTypeScriptSetup","dir","intentDirs","filter","Boolean","typeCheckPreflight","tsconfigPath","typescript","disableStaticImages","images","hasAppDir","hasPagesDir","isolatedDevBuild","console","log","routeTypesFilePath","validatorFilePath","mkdir","recursive","pageRoutes","appRoutes","appRouteHandlers","layoutRoutes","slots","pageApiRoutes","mappedPages","mappedAppPages","mappedAppLayouts","createMapping","pagePaths","pagesType","createPagesMapping","isDev","pageExtensions","appDirOnly","validFileMatcher","createValidFileMatcher","isSrcDir","path","relative","startsWith","collectPagesFiles","PAGE_TYPES","PAGES","processedPages","processPageRoutes","appPaths","layoutPaths","defaultPaths","collectAppFiles","APP","mappedDefaultFiles","slotsFromPages","extractSlotsFromAppRoutes","slotsFromDefaults","extractSlotsFromDefaultFiles","combineSlots","result","processAppRoutes","processLayoutRoutes","routeTypesManifest","createRouteTypesManifest","redirects","rewrites","writ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AACQ,GAAG;QAClE,MAAMC,qBAAqB,MAAMvB,cAAcoB,cAAcN,qBAAU,CAACQ,GAAG;QAE3E,yEAAyE;QACzE,MAAME,iBAAiBC,IAAAA,kCAAyB,EAAC3B;QACjD,MAAM4B,oBAAoBC,IAAAA,qCAA4B,EAACJ;QAEvD,0CAA0C;QAC1C5B,QAAQiC,IAAAA,qBAAY,EAACJ,gBAAgBE;QAErC,MAAMG,SAASC,IAAAA,yBAAgB,EAC7BhC,gBACAS,kBACAjD,SACAmD;QAEFjB,YAAYqC,OAAOrC,SAAS;QAC5BC,mBAAmBoC,OAAOpC,gBAAgB;QAE1C,wBAAwB;QACxBC,eAAeqC,IAAAA,4BAAmB,EAAChC,kBAAkBzC,SAASmD;IAChE;IAEA,MAAMuB,qBAAqB,MAAMC,IAAAA,yCAAwB,EAAC;QACxD5D,KAAKf;QACLiC;QACAC;QACAC;QACAG;QACAF;QACAC;QACAuC,WAAW7E,WAAW6E,SAAS;QAC/BC,UAAU9E,WAAW8E,QAAQ;QAC7B/C;IACF;IAEA,MAAMgD,IAAAA,wCAAuB,EAC3BJ,oBACA7C,oBACA9B;IAGF,MAAMgF,IAAAA,mCAAkB,EAACL,oBAAoB5C;IAE7C,uDAAuD;IACvD,MAAMkD,oBAAoBtE,IAAAA,UAAI,EAACD,SAAS,SAAS;IACjDwE,IAAAA,uCAAmB,EAAClF,WAAWmF,SAAS,EAAEF;IAE1CrD,QAAQC,GAAG,CAAC;AACd","ignoreList":[0]}
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "appBootstrap", {
15
15
  });
16
16
  const _assetprefix = require("./asset-prefix");
17
17
  const _setattributesfromprops = require("./set-attributes-from-props");
18
- const version = "16.0.2-canary.10";
18
+ const version = "16.0.2-canary.12";
19
19
  window.next = {
20
20
  version,
21
21
  appDir: true
@@ -60,7 +60,7 @@ const _hooksclientcontextsharedruntime = require("../shared/lib/hooks-client-con
60
60
  const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-error");
61
61
  const _tracer = /*#__PURE__*/ _interop_require_default._(require("./tracing/tracer"));
62
62
  const _isnextroutererror = require("./components/is-next-router-error");
63
- const version = "16.0.2-canary.10";
63
+ const version = "16.0.2-canary.12";
64
64
  let router;
65
65
  const emitter = (0, _mitt.default)();
66
66
  const looseToArray = (input)=>[].slice.call(input);
@@ -4695,6 +4695,30 @@
4695
4695
  "styles": ["normal"],
4696
4696
  "subsets": ["latin"]
4697
4697
  },
4698
+ "Elms Sans": {
4699
+ "weights": [
4700
+ "100",
4701
+ "200",
4702
+ "300",
4703
+ "400",
4704
+ "500",
4705
+ "600",
4706
+ "700",
4707
+ "800",
4708
+ "900",
4709
+ "variable"
4710
+ ],
4711
+ "styles": ["normal", "italic"],
4712
+ "axes": [
4713
+ {
4714
+ "tag": "wght",
4715
+ "min": 100,
4716
+ "max": 900,
4717
+ "defaultValue": 400
4718
+ }
4719
+ ],
4720
+ "subsets": ["latin", "latin-ext", "vietnamese"]
4721
+ },
4698
4722
  "Elsie": {
4699
4723
  "weights": ["400", "900"],
4700
4724
  "styles": ["normal"],
@@ -16748,6 +16772,45 @@
16748
16772
  "styles": ["normal"],
16749
16773
  "subsets": ["latin", "latin-ext"]
16750
16774
  },
16775
+ "Stack Sans Headline": {
16776
+ "weights": ["200", "300", "400", "500", "600", "700", "variable"],
16777
+ "styles": ["normal"],
16778
+ "axes": [
16779
+ {
16780
+ "tag": "wght",
16781
+ "min": 200,
16782
+ "max": 700,
16783
+ "defaultValue": 400
16784
+ }
16785
+ ],
16786
+ "subsets": ["latin", "latin-ext"]
16787
+ },
16788
+ "Stack Sans Notch": {
16789
+ "weights": ["200", "300", "400", "500", "600", "700", "variable"],
16790
+ "styles": ["normal"],
16791
+ "axes": [
16792
+ {
16793
+ "tag": "wght",
16794
+ "min": 200,
16795
+ "max": 700,
16796
+ "defaultValue": 400
16797
+ }
16798
+ ],
16799
+ "subsets": ["latin", "latin-ext"]
16800
+ },
16801
+ "Stack Sans Text": {
16802
+ "weights": ["200", "300", "400", "500", "600", "700", "variable"],
16803
+ "styles": ["normal"],
16804
+ "axes": [
16805
+ {
16806
+ "tag": "wght",
16807
+ "min": 200,
16808
+ "max": 700,
16809
+ "defaultValue": 400
16810
+ }
16811
+ ],
16812
+ "subsets": ["latin", "latin-ext"]
16813
+ },
16751
16814
  "Stalemate": {
16752
16815
  "weights": ["400"],
16753
16816
  "styles": ["normal"],
@@ -4508,6 +4508,16 @@ export declare function Electrolize<T extends CssVariable | undefined = undefine
4508
4508
  adjustFontFallback?: boolean;
4509
4509
  subsets?: Array<'latin'>;
4510
4510
  }): T extends undefined ? NextFont : NextFontWithVariable;
4511
+ export declare function Elms_Sans<T extends CssVariable | undefined = undefined>(options?: {
4512
+ weight?: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | 'variable' | Array<'100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'>;
4513
+ style?: 'normal' | 'italic' | Array<'normal' | 'italic'>;
4514
+ display?: Display;
4515
+ variable?: T;
4516
+ preload?: boolean;
4517
+ fallback?: string[];
4518
+ adjustFontFallback?: boolean;
4519
+ subsets?: Array<'latin' | 'latin-ext' | 'vietnamese'>;
4520
+ }): T extends undefined ? NextFont : NextFontWithVariable;
4511
4521
  export declare function Elsie<T extends CssVariable | undefined = undefined>(options: {
4512
4522
  weight: '400' | '900' | Array<'400' | '900'>;
4513
4523
  style?: 'normal' | Array<'normal'>;
@@ -16906,6 +16916,36 @@ export declare function Staatliches<T extends CssVariable | undefined = undefine
16906
16916
  adjustFontFallback?: boolean;
16907
16917
  subsets?: Array<'latin' | 'latin-ext'>;
16908
16918
  }): T extends undefined ? NextFont : NextFontWithVariable;
16919
+ export declare function Stack_Sans_Headline<T extends CssVariable | undefined = undefined>(options?: {
16920
+ weight?: '200' | '300' | '400' | '500' | '600' | '700' | 'variable' | Array<'200' | '300' | '400' | '500' | '600' | '700'>;
16921
+ style?: 'normal' | Array<'normal'>;
16922
+ display?: Display;
16923
+ variable?: T;
16924
+ preload?: boolean;
16925
+ fallback?: string[];
16926
+ adjustFontFallback?: boolean;
16927
+ subsets?: Array<'latin' | 'latin-ext'>;
16928
+ }): T extends undefined ? NextFont : NextFontWithVariable;
16929
+ export declare function Stack_Sans_Notch<T extends CssVariable | undefined = undefined>(options?: {
16930
+ weight?: '200' | '300' | '400' | '500' | '600' | '700' | 'variable' | Array<'200' | '300' | '400' | '500' | '600' | '700'>;
16931
+ style?: 'normal' | Array<'normal'>;
16932
+ display?: Display;
16933
+ variable?: T;
16934
+ preload?: boolean;
16935
+ fallback?: string[];
16936
+ adjustFontFallback?: boolean;
16937
+ subsets?: Array<'latin' | 'latin-ext'>;
16938
+ }): T extends undefined ? NextFont : NextFontWithVariable;
16939
+ export declare function Stack_Sans_Text<T extends CssVariable | undefined = undefined>(options?: {
16940
+ weight?: '200' | '300' | '400' | '500' | '600' | '700' | 'variable' | Array<'200' | '300' | '400' | '500' | '600' | '700'>;
16941
+ style?: 'normal' | Array<'normal'>;
16942
+ display?: Display;
16943
+ variable?: T;
16944
+ preload?: boolean;
16945
+ fallback?: string[];
16946
+ adjustFontFallback?: boolean;
16947
+ subsets?: Array<'latin' | 'latin-ext'>;
16948
+ }): T extends undefined ? NextFont : NextFontWithVariable;
16909
16949
  export declare function Stalemate<T extends CssVariable | undefined = undefined>(options: {
16910
16950
  weight: '400' | Array<'400'>;
16911
16951
  style?: 'normal' | Array<'normal'>;
@@ -6,6 +6,7 @@ import loadFullConfig from 'next/dist/compiled/babel/core-lib-config';
6
6
  import { consumeIterator } from './util';
7
7
  import * as Log from '../../output/log';
8
8
  import { isReactCompilerRequired } from '../../swc';
9
+ import { installBindings } from '../../swc/install-bindings';
9
10
  const nextDistPath = /(next[\\/]dist[\\/]shared[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/;
10
11
  function shouldSkipBabel(transformMode, configFilePath, hasReactCompiler) {
11
12
  return transformMode === 'standalone' && configFilePath == null && !hasReactCompiler;
@@ -346,6 +347,10 @@ const configFiles = new Set();
346
347
  };
347
348
  }
348
349
  export default async function getConfig(ctx, { source, target, loaderOptions, filename, inputSourceMap }) {
350
+ // Install bindings early so they are definitely available to the loader.
351
+ // When run by webpack in next this is already done with correct configuration so this is a no-op.
352
+ // In turbopack loaders are run in a subprocess so it may or may not be done.
353
+ await installBindings();
349
354
  const cacheCharacteristics = await getCacheCharacteristics(loaderOptions, source, filename);
350
355
  if (loaderOptions.configFile) {
351
356
  // Ensures webpack invalidates the cache for this loader when the config file changes
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/build/babel/loader/get-config.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { inspect } from 'node:util'\nimport JSON5 from 'next/dist/compiled/json5'\n\nimport { createConfigItem, loadOptions } from 'next/dist/compiled/babel/core'\nimport loadFullConfig from 'next/dist/compiled/babel/core-lib-config'\n\nimport type {\n NextBabelLoaderOptionDefaultPresets,\n NextBabelLoaderOptions,\n NextJsLoaderContext,\n} from './types'\nimport {\n consumeIterator,\n type SourceMap,\n type BabelLoaderTransformOptions,\n} from './util'\nimport * as Log from '../../output/log'\nimport { isReactCompilerRequired } from '../../swc'\n\n/**\n * An internal (non-exported) type used by babel.\n */\nexport type ResolvedBabelConfig = {\n options: BabelLoaderTransformOptions\n passes: BabelPluginPasses\n externalDependencies: ReadonlyArray<string>\n}\n\nexport type BabelPlugin = unknown\nexport type BabelPluginPassList = ReadonlyArray<BabelPlugin>\nexport type BabelPluginPasses = ReadonlyArray<BabelPluginPassList>\n\nconst nextDistPath =\n /(next[\\\\/]dist[\\\\/]shared[\\\\/]lib)|(next[\\\\/]dist[\\\\/]client)|(next[\\\\/]dist[\\\\/]pages)/\n\n/**\n * The properties defined here are the conditions with which subsets of inputs\n * can be identified that are able to share a common Babel config. For example,\n * in dev mode, different transforms must be applied to a source file depending\n * on whether you're compiling for the client or for the server - thus `isServer`\n * is germane.\n *\n * However, these characteristics need not protect against circumstances that\n * will not be encountered in Next.js. For example, a source file may be\n * transformed differently depending on whether we're doing a production compile\n * or for HMR in dev mode. However, those two circumstances will never be\n * encountered within the context of a single V8 context (and, thus, shared\n * cache). Therefore, hasReactRefresh is _not_ germane to caching.\n *\n * NOTE: This approach does not support multiple `.babelrc` files in a\n * single project. A per-cache-key config will be generated once and,\n * if `.babelrc` is present, that config will be used for any subsequent\n * transformations.\n */\ninterface CharacteristicsGermaneToCaching {\n isStandalone: boolean\n isServer: boolean | undefined\n isPageFile: boolean | undefined\n isNextDist: boolean\n hasModuleExports: boolean\n hasReactCompiler: boolean\n fileExt: string\n configFilePath: string | undefined\n}\n\nfunction shouldSkipBabel(\n transformMode: 'standalone' | 'default',\n configFilePath: string | undefined,\n hasReactCompiler: boolean\n) {\n return (\n transformMode === 'standalone' &&\n configFilePath == null &&\n !hasReactCompiler\n )\n}\n\nconst fileExtensionRegex = /\\.([a-z]+)$/\nasync function getCacheCharacteristics(\n loaderOptions: NextBabelLoaderOptions,\n source: string,\n filename: string\n): Promise<CharacteristicsGermaneToCaching> {\n let isStandalone, isServer, pagesDir\n switch (loaderOptions.transformMode) {\n case 'default':\n isStandalone = false\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n break\n case 'standalone':\n isStandalone = true\n break\n default:\n throw new Error(\n `unsupported transformMode in loader options: ${inspect(loaderOptions)}`\n )\n }\n\n const isPageFile = pagesDir != null && filename.startsWith(pagesDir)\n const isNextDist = nextDistPath.test(filename)\n const hasModuleExports = source.indexOf('module.exports') !== -1\n const fileExt = fileExtensionRegex.exec(filename)?.[1] || 'unknown'\n\n let {\n reactCompilerPlugins,\n reactCompilerExclude,\n configFile: configFilePath,\n transformMode,\n } = loaderOptions\n\n // Compute `hasReactCompiler` as part of the cache characteristics / key,\n // rather than inside of `getFreshConfig`:\n // - `isReactCompilerRequired` depends on the file contents\n // - `node_modules` and `reactCompilerExclude` depend on the file path, which\n // isn't part of the cache characteristics\n let hasReactCompiler =\n reactCompilerPlugins != null &&\n reactCompilerPlugins.length !== 0 &&\n !loaderOptions.isServer &&\n !/[/\\\\]node_modules[/\\\\]/.test(filename) &&\n // Assumption: `reactCompilerExclude` is cheap because it should only\n // operate on the file path and *not* the file contents (it's sync)\n !reactCompilerExclude?.(filename)\n\n // `isReactCompilerRequired` is expensive to run (parses/visits with SWC), so\n // only run it if there's a good chance we might be able to skip calling Babel\n // entirely (speculatively call `shouldSkipBabel`).\n //\n // Otherwise, we can let react compiler handle this logic for us. It should\n // behave equivalently.\n if (\n hasReactCompiler &&\n shouldSkipBabel(transformMode, configFilePath, /*hasReactCompiler*/ false)\n ) {\n hasReactCompiler &&= await isReactCompilerRequired(filename)\n }\n\n return {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n }\n}\n\n/**\n * Return an array of Babel plugins, conditioned upon loader options and\n * source file characteristics.\n */\nfunction getPlugins(\n loaderOptions: NextBabelLoaderOptionDefaultPresets,\n cacheCharacteristics: CharacteristicsGermaneToCaching\n) {\n const { isServer, isPageFile, isNextDist, hasModuleExports } =\n cacheCharacteristics\n\n const { development, hasReactRefresh } = loaderOptions\n\n const applyCommonJsItem = hasModuleExports\n ? createConfigItem(\n require('../plugins/commonjs') as typeof import('../plugins/commonjs'),\n { type: 'plugin' }\n )\n : null\n const reactRefreshItem = hasReactRefresh\n ? createConfigItem(\n [\n require('next/dist/compiled/react-refresh/babel') as typeof import('next/dist/compiled/react-refresh/babel'),\n { skipEnvCheck: true },\n ],\n { type: 'plugin' }\n )\n : null\n const pageConfigItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-config') as typeof import('../plugins/next-page-config'),\n ],\n {\n type: 'plugin',\n }\n )\n : null\n const disallowExportAllItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-disallow-re-export-all-exports') as typeof import('../plugins/next-page-disallow-re-export-all-exports'),\n ],\n { type: 'plugin' }\n )\n : null\n const transformDefineItem = createConfigItem(\n [\n require.resolve('next/dist/compiled/babel/plugin-transform-define'),\n {\n 'process.env.NODE_ENV': development ? 'development' : 'production',\n 'typeof window': isServer ? 'undefined' : 'object',\n 'process.browser': isServer ? false : true,\n },\n 'next-js-transform-define-instance',\n ],\n { type: 'plugin' }\n )\n const nextSsgItem =\n !isServer && isPageFile\n ? createConfigItem([require.resolve('../plugins/next-ssg-transform')], {\n type: 'plugin',\n })\n : null\n const commonJsItem = isNextDist\n ? createConfigItem(\n require('next/dist/compiled/babel/plugin-transform-modules-commonjs') as typeof import('next/dist/compiled/babel/plugin-transform-modules-commonjs'),\n { type: 'plugin' }\n )\n : null\n const nextFontUnsupported = createConfigItem(\n [\n require('../plugins/next-font-unsupported') as typeof import('../plugins/next-font-unsupported'),\n ],\n { type: 'plugin' }\n )\n\n return [\n reactRefreshItem,\n pageConfigItem,\n disallowExportAllItem,\n applyCommonJsItem,\n transformDefineItem,\n nextSsgItem,\n commonJsItem,\n nextFontUnsupported,\n ].filter(Boolean)\n}\n\nconst isJsonFile = /\\.(json|babelrc)$/\nconst isJsFile = /\\.js$/\n\n/**\n * While this function does block execution while reading from disk, it\n * should not introduce any issues. The function is only invoked when\n * generating a fresh config, and only a small handful of configs should\n * be generated during compilation.\n */\nfunction getCustomBabelConfig(configFilePath: string) {\n if (isJsonFile.exec(configFilePath)) {\n const babelConfigRaw = readFileSync(configFilePath, 'utf8')\n return JSON5.parse(babelConfigRaw)\n } else if (isJsFile.exec(configFilePath)) {\n return require(configFilePath)\n }\n throw new Error(\n 'The Next.js Babel loader does not support .mjs or .cjs config files.'\n )\n}\n\nlet babelConfigWarned = false\n/**\n * Check if custom babel configuration from user only contains options that\n * can be migrated into latest Next.js features supported by SWC.\n *\n * This raises soft warning messages only, not making any errors yet.\n */\nfunction checkCustomBabelConfigDeprecation(\n config: Record<string, any> | undefined\n) {\n if (!config || Object.keys(config).length === 0) {\n return\n }\n\n const { plugins, presets, ...otherOptions } = config\n if (Object.keys(otherOptions ?? {}).length > 0) {\n return\n }\n\n if (babelConfigWarned) {\n return\n }\n\n babelConfigWarned = true\n\n const isPresetReadyToDeprecate =\n !presets ||\n presets.length === 0 ||\n (presets.length === 1 && presets[0] === 'next/babel')\n const pluginReasons = []\n const unsupportedPlugins = []\n\n if (Array.isArray(plugins)) {\n for (const plugin of plugins) {\n const pluginName = Array.isArray(plugin) ? plugin[0] : plugin\n\n // [NOTE]: We cannot detect if the user uses babel-plugin-macro based transform plugins,\n // such as `styled-components/macro` in here.\n switch (pluginName) {\n case 'styled-components':\n case 'babel-plugin-styled-components':\n pluginReasons.push(\n `\\t- 'styled-components' can be enabled via 'compiler.styledComponents' in 'next.config.js'`\n )\n break\n case '@emotion/babel-plugin':\n pluginReasons.push(\n `\\t- '@emotion/babel-plugin' can be enabled via 'compiler.emotion' in 'next.config.js'`\n )\n break\n case 'babel-plugin-relay':\n pluginReasons.push(\n `\\t- 'babel-plugin-relay' can be enabled via 'compiler.relay' in 'next.config.js'`\n )\n break\n case 'react-remove-properties':\n pluginReasons.push(\n `\\t- 'react-remove-properties' can be enabled via 'compiler.reactRemoveProperties' in 'next.config.js'`\n )\n break\n case 'transform-remove-console':\n pluginReasons.push(\n `\\t- 'transform-remove-console' can be enabled via 'compiler.removeConsole' in 'next.config.js'`\n )\n break\n default:\n unsupportedPlugins.push(pluginName)\n break\n }\n }\n }\n\n if (isPresetReadyToDeprecate && unsupportedPlugins.length === 0) {\n Log.warn(\n `It looks like there is a custom Babel configuration that can be removed${\n pluginReasons.length > 0 ? ':' : '.'\n }`\n )\n\n if (pluginReasons.length > 0) {\n Log.warn(`Next.js supports the following features natively: `)\n Log.warn(pluginReasons.join(''))\n Log.warn(\n `For more details configuration options, please refer https://nextjs.org/docs/architecture/nextjs-compiler#supported-features`\n )\n }\n }\n}\n\n/**\n * Generate a new, flat Babel config, ready to be handed to Babel-traverse.\n * This config should have no unresolved overrides, presets, etc.\n *\n * The config returned by this function is cached, so the function should not\n * depend on file-specific configuration or configuration that could change\n * across invocations without a process restart.\n */\nasync function getFreshConfig(\n ctx: NextJsLoaderContext,\n cacheCharacteristics: CharacteristicsGermaneToCaching,\n loaderOptions: NextBabelLoaderOptions,\n target: string\n): Promise<ResolvedBabelConfig | null> {\n const { transformMode } = loaderOptions\n const { hasReactCompiler, configFilePath, fileExt } = cacheCharacteristics\n\n let customConfig = configFilePath && getCustomBabelConfig(configFilePath)\n if (shouldSkipBabel(transformMode, configFilePath, hasReactCompiler)) {\n // Optimization: There's nothing useful to do, bail out and skip babel on\n // this file\n return null\n }\n\n checkCustomBabelConfigDeprecation(customConfig)\n\n // We can assume that `reactCompilerPlugins` does not change without a process\n // restart (it's safe to cache), as it's specified in the `next.config.js`,\n // which always causes a full restart of `next dev` if changed.\n const reactCompilerPluginsIfEnabled = hasReactCompiler\n ? (loaderOptions.reactCompilerPlugins ?? [])\n : []\n\n let isServer, pagesDir, srcDir, development\n if (transformMode === 'default') {\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n srcDir = loaderOptions.srcDir\n development = loaderOptions.development\n }\n\n let options: BabelLoaderTransformOptions = {\n babelrc: false,\n cloneInputAst: false,\n\n // Use placeholder file info. `updateBabelConfigWithFileDetails` will\n // replace this after caching.\n filename: `basename.${fileExt}`,\n inputSourceMap: undefined,\n sourceFileName: `basename.${fileExt}`,\n\n // Set the default sourcemap behavior based on Webpack's mapping flag,\n // but allow users to override if they want.\n sourceMaps:\n loaderOptions.sourceMaps === undefined\n ? ctx.sourceMap\n : loaderOptions.sourceMaps,\n }\n\n const baseCaller = {\n name: 'next-babel-turbo-loader',\n supportsStaticESM: true,\n supportsDynamicImport: true,\n\n // Provide plugins with insight into webpack target.\n // https://github.com/babel/babel-loader/issues/787\n target,\n\n // Webpack 5 supports TLA behind a flag. We enable it by default\n // for Babel, and then webpack will throw an error if the experimental\n // flag isn't enabled.\n supportsTopLevelAwait: true,\n\n isServer,\n srcDir,\n pagesDir,\n isDev: development,\n\n transformMode,\n\n ...loaderOptions.caller,\n }\n\n options.plugins = [\n ...(transformMode === 'default'\n ? getPlugins(loaderOptions, cacheCharacteristics)\n : []),\n ...reactCompilerPluginsIfEnabled,\n ...(customConfig?.plugins || []),\n ]\n\n // target can be provided in babelrc\n options.target = isServer ? undefined : customConfig?.target\n\n // env can be provided in babelrc\n options.env = customConfig?.env\n\n options.presets = (() => {\n // If presets is defined the user will have next/babel in their babelrc\n if (customConfig?.presets) {\n return customConfig.presets\n }\n\n // If presets is not defined the user will likely have \"env\" in their babelrc\n if (customConfig) {\n return undefined\n }\n\n // If no custom config is provided the default is to use next/babel\n return ['next/babel']\n })()\n\n options.overrides = loaderOptions.overrides\n\n options.caller = {\n ...baseCaller,\n hasJsxRuntime:\n transformMode === 'default' ? loaderOptions.hasJsxRuntime : undefined,\n }\n\n // Babel does strict checks on the config so undefined is not allowed\n if (typeof options.target === 'undefined') {\n delete options.target\n }\n\n Object.defineProperty(options.caller, 'onWarning', {\n enumerable: false,\n writable: false,\n value: (reason: any) => {\n if (!(reason instanceof Error)) {\n reason = new Error(reason)\n }\n ctx.emitWarning(reason)\n },\n })\n\n const loadedOptions = loadOptions(options)\n const config = consumeIterator(loadFullConfig(loadedOptions))\n\n return config\n}\n\n/**\n * Each key returned here corresponds with a Babel config that can be shared.\n * The conditions of permissible sharing between files is dependent on specific\n * file attributes and Next.js compiler states: `CharacteristicsGermaneToCaching`.\n */\nfunction getCacheKey(cacheCharacteristics: CharacteristicsGermaneToCaching) {\n const {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n } = cacheCharacteristics\n\n const flags =\n 0 |\n (isStandalone ? 0b000001 : 0) |\n (isServer ? 0b000010 : 0) |\n (isPageFile ? 0b000100 : 0) |\n (isNextDist ? 0b001000 : 0) |\n (hasModuleExports ? 0b010000 : 0) |\n (hasReactCompiler ? 0b100000 : 0)\n\n // separate strings with null bytes, assuming null bytes are not valid in file\n // paths\n return `${configFilePath || ''}\\x00${fileExt}\\x00${flags}`\n}\n\nconst configCache: Map<any, ResolvedBabelConfig | null> = new Map()\nconst configFiles: Set<string> = new Set()\n\n/**\n * Applies file-specific values to a potentially-cached configuration object.\n */\nfunction updateBabelConfigWithFileDetails(\n cachedConfig: ResolvedBabelConfig | null | undefined,\n loaderOptions: NextBabelLoaderOptions,\n filename: string,\n inputSourceMap: SourceMap | undefined\n): ResolvedBabelConfig | null {\n if (cachedConfig == null) {\n return null\n }\n return {\n ...cachedConfig,\n options: {\n ...cachedConfig.options,\n cwd: loaderOptions.cwd,\n root: loaderOptions.cwd,\n filename,\n inputSourceMap,\n // Ensure that Webpack will get a full absolute path in the sourcemap\n // so that it can properly map the module back to its internal cached\n // modules.\n sourceFileName: filename,\n },\n }\n}\n\nexport default async function getConfig(\n ctx: NextJsLoaderContext,\n {\n source,\n target,\n loaderOptions,\n filename,\n inputSourceMap,\n }: {\n source: string\n loaderOptions: NextBabelLoaderOptions\n target: string\n filename: string\n inputSourceMap?: SourceMap | undefined\n }\n): Promise<ResolvedBabelConfig | null> {\n const cacheCharacteristics = await getCacheCharacteristics(\n loaderOptions,\n source,\n filename\n )\n\n if (loaderOptions.configFile) {\n // Ensures webpack invalidates the cache for this loader when the config file changes\n ctx.addDependency(loaderOptions.configFile)\n }\n\n const cacheKey = getCacheKey(cacheCharacteristics)\n const cachedConfig = configCache.get(cacheKey)\n if (cachedConfig !== undefined) {\n return updateBabelConfigWithFileDetails(\n cachedConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n }\n\n if (loaderOptions.configFile && !configFiles.has(loaderOptions.configFile)) {\n configFiles.add(loaderOptions.configFile)\n Log.info(\n `Using external babel configuration from ${loaderOptions.configFile}`\n )\n }\n\n const freshConfig = await getFreshConfig(\n ctx,\n cacheCharacteristics,\n loaderOptions,\n target\n )\n\n configCache.set(cacheKey, freshConfig)\n\n return updateBabelConfigWithFileDetails(\n freshConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n}\n"],"names":["readFileSync","inspect","JSON5","createConfigItem","loadOptions","loadFullConfig","consumeIterator","Log","isReactCompilerRequired","nextDistPath","shouldSkipBabel","transformMode","configFilePath","hasReactCompiler","fileExtensionRegex","getCacheCharacteristics","loaderOptions","source","filename","isStandalone","isServer","pagesDir","Error","isPageFile","startsWith","isNextDist","test","hasModuleExports","indexOf","fileExt","exec","reactCompilerPlugins","reactCompilerExclude","configFile","length","getPlugins","cacheCharacteristics","development","hasReactRefresh","applyCommonJsItem","require","type","reactRefreshItem","skipEnvCheck","pageConfigItem","disallowExportAllItem","transformDefineItem","resolve","nextSsgItem","commonJsItem","nextFontUnsupported","filter","Boolean","isJsonFile","isJsFile","getCustomBabelConfig","babelConfigRaw","parse","babelConfigWarned","checkCustomBabelConfigDeprecation","config","Object","keys","plugins","presets","otherOptions","isPresetReadyToDeprecate","pluginReasons","unsupportedPlugins","Array","isArray","plugin","pluginName","push","warn","join","getFreshConfig","ctx","target","customConfig","reactCompilerPluginsIfEnabled","srcDir","options","babelrc","cloneInputAst","inputSourceMap","undefined","sourceFileName","sourceMaps","sourceMap","baseCaller","name","supportsStaticESM","supportsDynamicImport","supportsTopLevelAwait","isDev","caller","env","overrides","hasJsxRuntime","defineProperty","enumerable","writable","value","reason","emitWarning","loadedOptions","getCacheKey","flags","configCache","Map","configFiles","Set","updateBabelConfigWithFileDetails","cachedConfig","cwd","root","getConfig","addDependency","cacheKey","get","has","add","info","freshConfig","set"],"mappings":"AAAA,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,OAAO,QAAQ,YAAW;AACnC,OAAOC,WAAW,2BAA0B;AAE5C,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,gCAA+B;AAC7E,OAAOC,oBAAoB,2CAA0C;AAOrE,SACEC,eAAe,QAGV,SAAQ;AACf,YAAYC,SAAS,mBAAkB;AACvC,SAASC,uBAAuB,QAAQ,YAAW;AAenD,MAAMC,eACJ;AAgCF,SAASC,gBACPC,aAAuC,EACvCC,cAAkC,EAClCC,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,OAAO;YACvBiC,KAAKnG,cAAcmG,GAAG;YACtBC,MAAMpG,cAAcmG,GAAG;YACvBjG;YACAmE;YACA,qEAAqE;YACrE,qEAAqE;YACrE,WAAW;YACXE,gBAAgBrE;QAClB;IACF;AACF;AAEA,eAAe,eAAemG,UAC5BxC,GAAwB,EACxB,EACE5D,MAAM,EACN6D,MAAM,EACN9D,aAAa,EACbE,QAAQ,EACRmE,cAAc,EAOf;IAED,MAAMjD,uBAAuB,MAAMrB,wBACjCC,eACAC,QACAC;IAGF,IAAIF,cAAciB,UAAU,EAAE;QAC5B,qFAAqF;QACrF4C,IAAIyC,aAAa,CAACtG,cAAciB,UAAU;IAC5C;IAEA,MAAMsF,WAAWZ,YAAYvE;IAC7B,MAAM8E,eAAeL,YAAYW,GAAG,CAACD;IACrC,IAAIL,iBAAiB5B,WAAW;QAC9B,OAAO2B,iCACLC,cACAlG,eACAE,UACAmE;IAEJ;IAEA,IAAIrE,cAAciB,UAAU,IAAI,CAAC8E,YAAYU,GAAG,CAACzG,cAAciB,UAAU,GAAG;QAC1E8E,YAAYW,GAAG,CAAC1G,cAAciB,UAAU;QACxC1B,IAAIoH,IAAI,CACN,CAAC,wCAAwC,EAAE3G,cAAciB,UAAU,EAAE;IAEzE;IAEA,MAAM2F,cAAc,MAAMhD,eACxBC,KACAzC,sBACApB,eACA8D;IAGF+B,YAAYgB,GAAG,CAACN,UAAUK;IAE1B,OAAOX,iCACLW,aACA5G,eACAE,UACAmE;AAEJ","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../../src/build/babel/loader/get-config.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport { inspect } from 'node:util'\nimport JSON5 from 'next/dist/compiled/json5'\n\nimport { createConfigItem, loadOptions } from 'next/dist/compiled/babel/core'\nimport loadFullConfig from 'next/dist/compiled/babel/core-lib-config'\n\nimport type {\n NextBabelLoaderOptionDefaultPresets,\n NextBabelLoaderOptions,\n NextJsLoaderContext,\n} from './types'\nimport {\n consumeIterator,\n type SourceMap,\n type BabelLoaderTransformOptions,\n} from './util'\nimport * as Log from '../../output/log'\nimport { isReactCompilerRequired } from '../../swc'\nimport { installBindings } from '../../swc/install-bindings'\n\n/**\n * An internal (non-exported) type used by babel.\n */\nexport type ResolvedBabelConfig = {\n options: BabelLoaderTransformOptions\n passes: BabelPluginPasses\n externalDependencies: ReadonlyArray<string>\n}\n\nexport type BabelPlugin = unknown\nexport type BabelPluginPassList = ReadonlyArray<BabelPlugin>\nexport type BabelPluginPasses = ReadonlyArray<BabelPluginPassList>\n\nconst nextDistPath =\n /(next[\\\\/]dist[\\\\/]shared[\\\\/]lib)|(next[\\\\/]dist[\\\\/]client)|(next[\\\\/]dist[\\\\/]pages)/\n\n/**\n * The properties defined here are the conditions with which subsets of inputs\n * can be identified that are able to share a common Babel config. For example,\n * in dev mode, different transforms must be applied to a source file depending\n * on whether you're compiling for the client or for the server - thus `isServer`\n * is germane.\n *\n * However, these characteristics need not protect against circumstances that\n * will not be encountered in Next.js. For example, a source file may be\n * transformed differently depending on whether we're doing a production compile\n * or for HMR in dev mode. However, those two circumstances will never be\n * encountered within the context of a single V8 context (and, thus, shared\n * cache). Therefore, hasReactRefresh is _not_ germane to caching.\n *\n * NOTE: This approach does not support multiple `.babelrc` files in a\n * single project. A per-cache-key config will be generated once and,\n * if `.babelrc` is present, that config will be used for any subsequent\n * transformations.\n */\ninterface CharacteristicsGermaneToCaching {\n isStandalone: boolean\n isServer: boolean | undefined\n isPageFile: boolean | undefined\n isNextDist: boolean\n hasModuleExports: boolean\n hasReactCompiler: boolean\n fileExt: string\n configFilePath: string | undefined\n}\n\nfunction shouldSkipBabel(\n transformMode: 'standalone' | 'default',\n configFilePath: string | undefined,\n hasReactCompiler: boolean\n) {\n return (\n transformMode === 'standalone' &&\n configFilePath == null &&\n !hasReactCompiler\n )\n}\n\nconst fileExtensionRegex = /\\.([a-z]+)$/\nasync function getCacheCharacteristics(\n loaderOptions: NextBabelLoaderOptions,\n source: string,\n filename: string\n): Promise<CharacteristicsGermaneToCaching> {\n let isStandalone, isServer, pagesDir\n switch (loaderOptions.transformMode) {\n case 'default':\n isStandalone = false\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n break\n case 'standalone':\n isStandalone = true\n break\n default:\n throw new Error(\n `unsupported transformMode in loader options: ${inspect(loaderOptions)}`\n )\n }\n\n const isPageFile = pagesDir != null && filename.startsWith(pagesDir)\n const isNextDist = nextDistPath.test(filename)\n const hasModuleExports = source.indexOf('module.exports') !== -1\n const fileExt = fileExtensionRegex.exec(filename)?.[1] || 'unknown'\n\n let {\n reactCompilerPlugins,\n reactCompilerExclude,\n configFile: configFilePath,\n transformMode,\n } = loaderOptions\n\n // Compute `hasReactCompiler` as part of the cache characteristics / key,\n // rather than inside of `getFreshConfig`:\n // - `isReactCompilerRequired` depends on the file contents\n // - `node_modules` and `reactCompilerExclude` depend on the file path, which\n // isn't part of the cache characteristics\n let hasReactCompiler =\n reactCompilerPlugins != null &&\n reactCompilerPlugins.length !== 0 &&\n !loaderOptions.isServer &&\n !/[/\\\\]node_modules[/\\\\]/.test(filename) &&\n // Assumption: `reactCompilerExclude` is cheap because it should only\n // operate on the file path and *not* the file contents (it's sync)\n !reactCompilerExclude?.(filename)\n\n // `isReactCompilerRequired` is expensive to run (parses/visits with SWC), so\n // only run it if there's a good chance we might be able to skip calling Babel\n // entirely (speculatively call `shouldSkipBabel`).\n //\n // Otherwise, we can let react compiler handle this logic for us. It should\n // behave equivalently.\n if (\n hasReactCompiler &&\n shouldSkipBabel(transformMode, configFilePath, /*hasReactCompiler*/ false)\n ) {\n hasReactCompiler &&= await isReactCompilerRequired(filename)\n }\n\n return {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n }\n}\n\n/**\n * Return an array of Babel plugins, conditioned upon loader options and\n * source file characteristics.\n */\nfunction getPlugins(\n loaderOptions: NextBabelLoaderOptionDefaultPresets,\n cacheCharacteristics: CharacteristicsGermaneToCaching\n) {\n const { isServer, isPageFile, isNextDist, hasModuleExports } =\n cacheCharacteristics\n\n const { development, hasReactRefresh } = loaderOptions\n\n const applyCommonJsItem = hasModuleExports\n ? createConfigItem(\n require('../plugins/commonjs') as typeof import('../plugins/commonjs'),\n { type: 'plugin' }\n )\n : null\n const reactRefreshItem = hasReactRefresh\n ? createConfigItem(\n [\n require('next/dist/compiled/react-refresh/babel') as typeof import('next/dist/compiled/react-refresh/babel'),\n { skipEnvCheck: true },\n ],\n { type: 'plugin' }\n )\n : null\n const pageConfigItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-config') as typeof import('../plugins/next-page-config'),\n ],\n {\n type: 'plugin',\n }\n )\n : null\n const disallowExportAllItem =\n !isServer && isPageFile\n ? createConfigItem(\n [\n require('../plugins/next-page-disallow-re-export-all-exports') as typeof import('../plugins/next-page-disallow-re-export-all-exports'),\n ],\n { type: 'plugin' }\n )\n : null\n const transformDefineItem = createConfigItem(\n [\n require.resolve('next/dist/compiled/babel/plugin-transform-define'),\n {\n 'process.env.NODE_ENV': development ? 'development' : 'production',\n 'typeof window': isServer ? 'undefined' : 'object',\n 'process.browser': isServer ? false : true,\n },\n 'next-js-transform-define-instance',\n ],\n { type: 'plugin' }\n )\n const nextSsgItem =\n !isServer && isPageFile\n ? createConfigItem([require.resolve('../plugins/next-ssg-transform')], {\n type: 'plugin',\n })\n : null\n const commonJsItem = isNextDist\n ? createConfigItem(\n require('next/dist/compiled/babel/plugin-transform-modules-commonjs') as typeof import('next/dist/compiled/babel/plugin-transform-modules-commonjs'),\n { type: 'plugin' }\n )\n : null\n const nextFontUnsupported = createConfigItem(\n [\n require('../plugins/next-font-unsupported') as typeof import('../plugins/next-font-unsupported'),\n ],\n { type: 'plugin' }\n )\n\n return [\n reactRefreshItem,\n pageConfigItem,\n disallowExportAllItem,\n applyCommonJsItem,\n transformDefineItem,\n nextSsgItem,\n commonJsItem,\n nextFontUnsupported,\n ].filter(Boolean)\n}\n\nconst isJsonFile = /\\.(json|babelrc)$/\nconst isJsFile = /\\.js$/\n\n/**\n * While this function does block execution while reading from disk, it\n * should not introduce any issues. The function is only invoked when\n * generating a fresh config, and only a small handful of configs should\n * be generated during compilation.\n */\nfunction getCustomBabelConfig(configFilePath: string) {\n if (isJsonFile.exec(configFilePath)) {\n const babelConfigRaw = readFileSync(configFilePath, 'utf8')\n return JSON5.parse(babelConfigRaw)\n } else if (isJsFile.exec(configFilePath)) {\n return require(configFilePath)\n }\n throw new Error(\n 'The Next.js Babel loader does not support .mjs or .cjs config files.'\n )\n}\n\nlet babelConfigWarned = false\n/**\n * Check if custom babel configuration from user only contains options that\n * can be migrated into latest Next.js features supported by SWC.\n *\n * This raises soft warning messages only, not making any errors yet.\n */\nfunction checkCustomBabelConfigDeprecation(\n config: Record<string, any> | undefined\n) {\n if (!config || Object.keys(config).length === 0) {\n return\n }\n\n const { plugins, presets, ...otherOptions } = config\n if (Object.keys(otherOptions ?? {}).length > 0) {\n return\n }\n\n if (babelConfigWarned) {\n return\n }\n\n babelConfigWarned = true\n\n const isPresetReadyToDeprecate =\n !presets ||\n presets.length === 0 ||\n (presets.length === 1 && presets[0] === 'next/babel')\n const pluginReasons = []\n const unsupportedPlugins = []\n\n if (Array.isArray(plugins)) {\n for (const plugin of plugins) {\n const pluginName = Array.isArray(plugin) ? plugin[0] : plugin\n\n // [NOTE]: We cannot detect if the user uses babel-plugin-macro based transform plugins,\n // such as `styled-components/macro` in here.\n switch (pluginName) {\n case 'styled-components':\n case 'babel-plugin-styled-components':\n pluginReasons.push(\n `\\t- 'styled-components' can be enabled via 'compiler.styledComponents' in 'next.config.js'`\n )\n break\n case '@emotion/babel-plugin':\n pluginReasons.push(\n `\\t- '@emotion/babel-plugin' can be enabled via 'compiler.emotion' in 'next.config.js'`\n )\n break\n case 'babel-plugin-relay':\n pluginReasons.push(\n `\\t- 'babel-plugin-relay' can be enabled via 'compiler.relay' in 'next.config.js'`\n )\n break\n case 'react-remove-properties':\n pluginReasons.push(\n `\\t- 'react-remove-properties' can be enabled via 'compiler.reactRemoveProperties' in 'next.config.js'`\n )\n break\n case 'transform-remove-console':\n pluginReasons.push(\n `\\t- 'transform-remove-console' can be enabled via 'compiler.removeConsole' in 'next.config.js'`\n )\n break\n default:\n unsupportedPlugins.push(pluginName)\n break\n }\n }\n }\n\n if (isPresetReadyToDeprecate && unsupportedPlugins.length === 0) {\n Log.warn(\n `It looks like there is a custom Babel configuration that can be removed${\n pluginReasons.length > 0 ? ':' : '.'\n }`\n )\n\n if (pluginReasons.length > 0) {\n Log.warn(`Next.js supports the following features natively: `)\n Log.warn(pluginReasons.join(''))\n Log.warn(\n `For more details configuration options, please refer https://nextjs.org/docs/architecture/nextjs-compiler#supported-features`\n )\n }\n }\n}\n\n/**\n * Generate a new, flat Babel config, ready to be handed to Babel-traverse.\n * This config should have no unresolved overrides, presets, etc.\n *\n * The config returned by this function is cached, so the function should not\n * depend on file-specific configuration or configuration that could change\n * across invocations without a process restart.\n */\nasync function getFreshConfig(\n ctx: NextJsLoaderContext,\n cacheCharacteristics: CharacteristicsGermaneToCaching,\n loaderOptions: NextBabelLoaderOptions,\n target: string\n): Promise<ResolvedBabelConfig | null> {\n const { transformMode } = loaderOptions\n const { hasReactCompiler, configFilePath, fileExt } = cacheCharacteristics\n\n let customConfig = configFilePath && getCustomBabelConfig(configFilePath)\n if (shouldSkipBabel(transformMode, configFilePath, hasReactCompiler)) {\n // Optimization: There's nothing useful to do, bail out and skip babel on\n // this file\n return null\n }\n\n checkCustomBabelConfigDeprecation(customConfig)\n\n // We can assume that `reactCompilerPlugins` does not change without a process\n // restart (it's safe to cache), as it's specified in the `next.config.js`,\n // which always causes a full restart of `next dev` if changed.\n const reactCompilerPluginsIfEnabled = hasReactCompiler\n ? (loaderOptions.reactCompilerPlugins ?? [])\n : []\n\n let isServer, pagesDir, srcDir, development\n if (transformMode === 'default') {\n isServer = loaderOptions.isServer\n pagesDir = loaderOptions.pagesDir\n srcDir = loaderOptions.srcDir\n development = loaderOptions.development\n }\n\n let options: BabelLoaderTransformOptions = {\n babelrc: false,\n cloneInputAst: false,\n\n // Use placeholder file info. `updateBabelConfigWithFileDetails` will\n // replace this after caching.\n filename: `basename.${fileExt}`,\n inputSourceMap: undefined,\n sourceFileName: `basename.${fileExt}`,\n\n // Set the default sourcemap behavior based on Webpack's mapping flag,\n // but allow users to override if they want.\n sourceMaps:\n loaderOptions.sourceMaps === undefined\n ? ctx.sourceMap\n : loaderOptions.sourceMaps,\n }\n\n const baseCaller = {\n name: 'next-babel-turbo-loader',\n supportsStaticESM: true,\n supportsDynamicImport: true,\n\n // Provide plugins with insight into webpack target.\n // https://github.com/babel/babel-loader/issues/787\n target,\n\n // Webpack 5 supports TLA behind a flag. We enable it by default\n // for Babel, and then webpack will throw an error if the experimental\n // flag isn't enabled.\n supportsTopLevelAwait: true,\n\n isServer,\n srcDir,\n pagesDir,\n isDev: development,\n\n transformMode,\n\n ...loaderOptions.caller,\n }\n\n options.plugins = [\n ...(transformMode === 'default'\n ? getPlugins(loaderOptions, cacheCharacteristics)\n : []),\n ...reactCompilerPluginsIfEnabled,\n ...(customConfig?.plugins || []),\n ]\n\n // target can be provided in babelrc\n options.target = isServer ? undefined : customConfig?.target\n\n // env can be provided in babelrc\n options.env = customConfig?.env\n\n options.presets = (() => {\n // If presets is defined the user will have next/babel in their babelrc\n if (customConfig?.presets) {\n return customConfig.presets\n }\n\n // If presets is not defined the user will likely have \"env\" in their babelrc\n if (customConfig) {\n return undefined\n }\n\n // If no custom config is provided the default is to use next/babel\n return ['next/babel']\n })()\n\n options.overrides = loaderOptions.overrides\n\n options.caller = {\n ...baseCaller,\n hasJsxRuntime:\n transformMode === 'default' ? loaderOptions.hasJsxRuntime : undefined,\n }\n\n // Babel does strict checks on the config so undefined is not allowed\n if (typeof options.target === 'undefined') {\n delete options.target\n }\n\n Object.defineProperty(options.caller, 'onWarning', {\n enumerable: false,\n writable: false,\n value: (reason: any) => {\n if (!(reason instanceof Error)) {\n reason = new Error(reason)\n }\n ctx.emitWarning(reason)\n },\n })\n\n const loadedOptions = loadOptions(options)\n const config = consumeIterator(loadFullConfig(loadedOptions))\n\n return config\n}\n\n/**\n * Each key returned here corresponds with a Babel config that can be shared.\n * The conditions of permissible sharing between files is dependent on specific\n * file attributes and Next.js compiler states: `CharacteristicsGermaneToCaching`.\n */\nfunction getCacheKey(cacheCharacteristics: CharacteristicsGermaneToCaching) {\n const {\n isStandalone,\n isServer,\n isPageFile,\n isNextDist,\n hasModuleExports,\n hasReactCompiler,\n fileExt,\n configFilePath,\n } = cacheCharacteristics\n\n const flags =\n 0 |\n (isStandalone ? 0b000001 : 0) |\n (isServer ? 0b000010 : 0) |\n (isPageFile ? 0b000100 : 0) |\n (isNextDist ? 0b001000 : 0) |\n (hasModuleExports ? 0b010000 : 0) |\n (hasReactCompiler ? 0b100000 : 0)\n\n // separate strings with null bytes, assuming null bytes are not valid in file\n // paths\n return `${configFilePath || ''}\\x00${fileExt}\\x00${flags}`\n}\n\nconst configCache: Map<any, ResolvedBabelConfig | null> = new Map()\nconst configFiles: Set<string> = new Set()\n\n/**\n * Applies file-specific values to a potentially-cached configuration object.\n */\nfunction updateBabelConfigWithFileDetails(\n cachedConfig: ResolvedBabelConfig | null | undefined,\n loaderOptions: NextBabelLoaderOptions,\n filename: string,\n inputSourceMap: SourceMap | undefined\n): ResolvedBabelConfig | null {\n if (cachedConfig == null) {\n return null\n }\n return {\n ...cachedConfig,\n options: {\n ...cachedConfig.options,\n cwd: loaderOptions.cwd,\n root: loaderOptions.cwd,\n filename,\n inputSourceMap,\n // Ensure that Webpack will get a full absolute path in the sourcemap\n // so that it can properly map the module back to its internal cached\n // modules.\n sourceFileName: filename,\n },\n }\n}\n\nexport default async function getConfig(\n ctx: NextJsLoaderContext,\n {\n source,\n target,\n loaderOptions,\n filename,\n inputSourceMap,\n }: {\n source: string\n loaderOptions: NextBabelLoaderOptions\n target: string\n filename: string\n inputSourceMap?: SourceMap | undefined\n }\n): Promise<ResolvedBabelConfig | null> {\n // Install bindings early so they are definitely available to the loader.\n // When run by webpack in next this is already done with correct configuration so this is a no-op.\n // In turbopack loaders are run in a subprocess so it may or may not be done.\n await installBindings()\n const cacheCharacteristics = await getCacheCharacteristics(\n loaderOptions,\n source,\n filename\n )\n\n if (loaderOptions.configFile) {\n // Ensures webpack invalidates the cache for this loader when the config file changes\n ctx.addDependency(loaderOptions.configFile)\n }\n\n const cacheKey = getCacheKey(cacheCharacteristics)\n const cachedConfig = configCache.get(cacheKey)\n if (cachedConfig !== undefined) {\n return updateBabelConfigWithFileDetails(\n cachedConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n }\n\n if (loaderOptions.configFile && !configFiles.has(loaderOptions.configFile)) {\n configFiles.add(loaderOptions.configFile)\n Log.info(\n `Using external babel configuration from ${loaderOptions.configFile}`\n )\n }\n\n const freshConfig = await getFreshConfig(\n ctx,\n cacheCharacteristics,\n loaderOptions,\n target\n )\n\n configCache.set(cacheKey, freshConfig)\n\n return updateBabelConfigWithFileDetails(\n freshConfig,\n loaderOptions,\n filename,\n inputSourceMap\n )\n}\n"],"names":["readFileSync","inspect","JSON5","createConfigItem","loadOptions","loadFullConfig","consumeIterator","Log","isReactCompilerRequired","installBindings","nextDistPath","shouldSkipBabel","transformMode","configFilePath","hasReactCompiler","fileExtensionRegex","getCacheCharacteristics","loaderOptions","source","filename","isStandalone","isServer","pagesDir","Error","isPageFile","startsWith","isNextDist","test","hasModuleExports","indexOf","fileExt","exec","reactCompilerPlugins","reactCompilerExclude","configFile","length","getPlugins","cacheCharacteristics","development","hasReactRefresh","applyCommonJsItem","require","type","reactRefreshItem","skipEnvCheck","pageConfigItem","disallowExportAllItem","transformDefineItem","resolve","nextSsgItem","commonJsItem","nextFontUnsupported","filter","Boolean","isJsonFile","isJsFile","getCustomBabelConfig","babelConfigRaw","parse","babelConfigWarned","checkCustomBabelConfigDeprecation","config","Object","keys","plugins","presets","otherOptions","isPresetReadyToDeprecate","pluginReasons","unsupportedPlugins","Array","isArray","plugin","pluginName","push","warn","join","getFreshConfig","ctx","target","customConfig","reactCompilerPluginsIfEnabled","srcDir","options","babelrc","cloneInputAst","inputSourceMap","undefined","sourceFileName","sourceMaps","sourceMap","baseCaller","name","supportsStaticESM","supportsDynamicImport","supportsTopLevelAwait","isDev","caller","env","overrides","hasJsxRuntime","defineProperty","enumerable","writable","value","reason","emitWarning","loadedOptions","getCacheKey","flags","configCache","Map","configFiles","Set","updateBabelConfigWithFileDetails","cachedConfig","cwd","root","getConfig","addDependency","cacheKey","get","has","add","info","freshConfig","set"],"mappings":"AAAA,SAASA,YAAY,QAAQ,UAAS;AACtC,SAASC,OAAO,QAAQ,YAAW;AACnC,OAAOC,WAAW,2BAA0B;AAE5C,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,gCAA+B;AAC7E,OAAOC,oBAAoB,2CAA0C;AAOrE,SACEC,eAAe,QAGV,SAAQ;AACf,YAAYC,SAAS,mBAAkB;AACvC,SAASC,uBAAuB,QAAQ,YAAW;AACnD,SAASC,eAAe,QAAQ,6BAA4B;AAe5D,MAAMC,eACJ;AAgCF,SAASC,gBACPC,aAAuC,EACvCC,cAAkC,EAClCC,gBAAyB;IAEzB,OACEF,kBAAkB,gBAClBC,kBAAkB,QAClB,CAACC;AAEL;AAEA,MAAMC,qBAAqB;AAC3B,eAAeC,wBACbC,aAAqC,EACrCC,MAAc,EACdC,QAAgB;QAqBAJ;IAnBhB,IAAIK,cAAcC,UAAUC;IAC5B,OAAQL,cAAcL,aAAa;QACjC,KAAK;YACHQ,eAAe;YACfC,WAAWJ,cAAcI,QAAQ;YACjCC,WAAWL,cAAcK,QAAQ;YACjC;QACF,KAAK;YACHF,eAAe;YACf;QACF;YACE,MAAM,qBAEL,CAFK,IAAIG,MACR,CAAC,6CAA6C,EAAEtB,QAAQgB,gBAAgB,GADpE,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;IACJ;IAEA,MA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G,cAAciB,UAAU;IAC5C;IAEA,MAAMsF,WAAWZ,YAAYvE;IAC7B,MAAM8E,eAAeL,YAAYW,GAAG,CAACD;IACrC,IAAIL,iBAAiB5B,WAAW;QAC9B,OAAO2B,iCACLC,cACAlG,eACAE,UACAmE;IAEJ;IAEA,IAAIrE,cAAciB,UAAU,IAAI,CAAC8E,YAAYU,GAAG,CAACzG,cAAciB,UAAU,GAAG;QAC1E8E,YAAYW,GAAG,CAAC1G,cAAciB,UAAU;QACxC3B,IAAIqH,IAAI,CACN,CAAC,wCAAwC,EAAE3G,cAAciB,UAAU,EAAE;IAEzE;IAEA,MAAM2F,cAAc,MAAMhD,eACxBC,KACAzC,sBACApB,eACA8D;IAGF+B,YAAYgB,GAAG,CAACN,UAAUK;IAE1B,OAAOX,iCACLW,aACA5G,eACAE,UACAmE;AAEJ","ignoreList":[0]}
@@ -44,6 +44,7 @@ import isError from '../lib/is-error';
44
44
  import { isEdgeRuntime } from '../lib/is-edge-runtime';
45
45
  import { recursiveCopy } from '../lib/recursive-copy';
46
46
  import { lockfilePatchPromise, teardownTraceSubscriber } from './swc';
47
+ import { installBindings } from './swc/install-bindings';
47
48
  import { getNamedRouteRegex } from '../shared/lib/router/utils/route-regex';
48
49
  import { getFilesInDir } from '../lib/get-files-in-dir';
49
50
  import { eventSwcPlugins } from '../telemetry/events/swc-plugins';
@@ -308,7 +309,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
308
309
  try {
309
310
  const nextBuildSpan = trace('next-build', undefined, {
310
311
  buildMode: experimentalBuildMode,
311
- version: "16.0.2-canary.10"
312
+ version: "16.0.2-canary.12"
312
313
  });
313
314
  NextBuildContext.nextBuildSpan = nextBuildSpan;
314
315
  NextBuildContext.dir = dir;
@@ -317,7 +318,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
317
318
  NextBuildContext.noMangling = noMangling;
318
319
  NextBuildContext.debugPrerender = debugPrerender;
319
320
  await nextBuildSpan.traceAsyncFn(async ()=>{
320
- var _mappedPages_404, _mappedPages__error;
321
+ var _config_experimental, _mappedPages_404, _mappedPages__error;
321
322
  // attempt to load global env values so they are available in next.config.js
322
323
  const { loadedEnvFiles } = nextBuildSpan.traceChild('load-dotenv').traceFn(()=>loadEnvConfig(dir, false, Log));
323
324
  NextBuildContext.loadedEnvFiles = loadedEnvFiles;
@@ -332,6 +333,8 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
332
333
  // Reading the config can modify environment variables that influence the bundler selection.
333
334
  bundler = finalizeBundlerFromConfig(bundler);
334
335
  nextBuildSpan.setAttribute('bundler', getBundlerForTelemetry(bundler));
336
+ // Install the native bindings early so we can have synchronous access later.
337
+ await installBindings((_config_experimental = config.experimental) == null ? void 0 : _config_experimental.useWasmBinary);
335
338
  process.env.NEXT_DEPLOYMENT_ID = config.deploymentId || '';
336
339
  NextBuildContext.config = config;
337
340
  let configOutDir = 'out';
@@ -834,7 +837,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
834
837
  // Files outside of the distDir can be "type": "module"
835
838
  await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
836
839
  // These are written to distDir, so they need to come after creating and cleaning distDr.
837
- await recordFrameworkVersion("16.0.2-canary.10");
840
+ await recordFrameworkVersion("16.0.2-canary.12");
838
841
  await updateBuildDiagnostics({
839
842
  buildStage: 'start'
840
843
  });
@@ -2513,7 +2516,7 @@ export default async function build(dir, experimentalAnalyze = false, reactProdu
2513
2516
  configOutDir: path.join(dir, configOutDir),
2514
2517
  staticPages,
2515
2518
  serverPropsPages,
2516
- nextVersion: "16.0.2-canary.10",
2519
+ nextVersion: "16.0.2-canary.12",
2517
2520
  tracingRoot: outputFileTracingRoot,
2518
2521
  hasNodeMiddleware,
2519
2522
  hasInstrumentationHook,