Repository: vercel/next.js
Pull request: Remove pages export as it is unused

## What?

As far as I can tell there's no usage of this variable. No TS errors and all tests pass.

Closes PACK-5360

Changed files:
filename: crates/next-core/src/app_page_loader_tree.rs
patch: @@ -27,7 +27,6 @@ use crate::{
 pub struct AppPageLoaderTreeBuilder {
     base: BaseLoaderTreeBuilder,
     loader_tree_code: String,
-    pages: Vec<FileSystemPath>,
     /// next.config.js' basePath option to construct og metadata.
     base_path: Option<RcStr>,
 }
@@ -41,7 +40,6 @@ impl AppPageLoaderTreeBuilder {
         AppPageLoaderTreeBuilder {
             base: BaseLoaderTreeBuilder::new(module_asset_context, server_component_transition),
             loader_tree_code: String::new(),
-            pages: Vec::new(),
             base_path,
         }
     }
@@ -52,10 +50,6 @@ impl AppPageLoaderTreeBuilder {
         path: Option<FileSystemPath>,
     ) -> Result<()> {
         if let Some(path) = path {
-            if matches!(module_type, AppDirModuleType::Page) {
-                self.pages.push(path.clone());
-            }
-
             let tuple_code = self
                 .base
                 .create_module_tuple_code(module_type, path)
@@ -427,7 +421,6 @@ impl AppPageLoaderTreeBuilder {
             imports: self.base.imports,
             loader_tree_code: self.loader_tree_code.into(),
             inner_assets: self.base.inner_assets,
-            pages: self.pages,
         })
     }
 }
@@ -436,7 +429,6 @@ pub struct AppPageLoaderTreeModule {
     pub imports: Vec<RcStr>,
     pub loader_tree_code: RcStr,
     pub inner_assets: FxIndexMap<RcStr, ResolvedVc<Box<dyn Module>>>,
-    pub pages: Vec<FileSystemPath>,
 }
 
 impl AppPageLoaderTreeModule {

filename: crates/next-core/src/next_app/app_page_entry.rs
patch: @@ -2,7 +2,7 @@ use std::io::Write;
 
 use anyhow::Result;
 use turbo_rcstr::RcStr;
-use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc, fxindexmap};
+use turbo_tasks::{ResolvedVc, Vc, fxindexmap};
 use turbo_tasks_fs::{self, File, FileSystemPath, rope::RopeBuilder};
 use turbopack::ModuleAssetContext;
 use turbopack_core::{
@@ -13,10 +13,7 @@ use turbopack_core::{
     source::Source,
     virtual_source::VirtualSource,
 };
-use turbopack_ecmascript::{
-    runtime_functions::{TURBOPACK_LOAD, TURBOPACK_REQUIRE},
-    utils::StringifyJs,
-};
+use turbopack_ecmascript::runtime_functions::{TURBOPACK_LOAD, TURBOPACK_REQUIRE};
 
 use super::app_entry::AppEntry;
 use crate::{
@@ -64,7 +61,6 @@ pub async fn get_app_page_entry(
         inner_assets,
         imports,
         loader_tree_code,
-        pages,
     } = loader_tree;
 
     let mut result = RopeBuilder::default();
@@ -73,12 +69,6 @@ pub async fn get_app_page_entry(
         writeln!(result, "{import}")?;
     }
 
-    let pages = pages
-        .iter()
-        .map(|page| page.value_to_string())
-        .try_join()
-        .await?;
-
     let original_name: RcStr = page.to_string().into();
     let pathname: RcStr = AppPath::from(page.clone()).to_string().into();
 
@@ -100,7 +90,6 @@ pub async fn get_app_page_entry(
         ],
         &[
             ("tree", &*loader_tree_code),
-            ("pages", &StringifyJs(&pages).to_string()),
             ("__next_app_require__", &TURBOPACK_REQUIRE.bound()),
             ("__next_app_load_chunk__", &TURBOPACK_LOAD.bound()),
         ],

filename: packages/next/src/build/templates/app-page.ts
patch: @@ -63,14 +63,10 @@ import { NoFallbackError } from '../../shared/lib/no-fallback-error.external'
  * and I've updated it.
  */
 declare const tree: LoaderTree
-declare const pages: any
 
 // We inject the tree and pages here so that we can use them in the route
 // module.
 // INJECT:tree
-// INJECT:pages
-
-export { pages }
 
 import GlobalError from 'VAR_MODULE_GLOBAL_ERROR' with { 'turbopack-transition': 'next-server-utility' }
 
@@ -334,7 +330,6 @@ export async function handler(
   const ComponentMod = {
     ...entryBase,
     tree,
-    pages,
     GlobalError,
     handler,
     routeModule,

filename: packages/next/src/build/webpack/loaders/next-app-loader/index.ts
patch: @@ -152,7 +152,6 @@ async function createTreeCodeFromPath(
   }
 ): Promise<{
   treeCode: string
-  pages: string
   rootLayout: string | undefined
   globalError: string
   globalNotFound: string
@@ -163,7 +162,6 @@ async function createTreeCodeFromPath(
   const isDefaultNotFound = isAppBuiltinPage(pagePath)
 
   const appDirPrefix = isDefaultNotFound ? APP_DIR_ALIAS : splittedPath[0]
-  const pages: string[] = []
 
   let rootLayout: string | undefined
   let globalError: string = defaultGlobalErrorPath
@@ -248,8 +246,6 @@ async function createTreeCodeFromPath(
 
         const resolvedPagePath = await resolver(matchedPagePath)
         if (resolvedPagePath) {
-          pages.push(resolvedPagePath)
-
           const varName = `page${nestedCollectedDeclarations.length}`
           nestedCollectedDeclarations.push([varName, resolvedPagePath])
 
@@ -576,7 +572,6 @@ async function createTreeCodeFromPath(
 
   return {
     treeCode: `${treeCode}.children;`,
-    pages: `${JSON.stringify(pages)};`,
     rootLayout,
     globalError,
     globalNotFound,
@@ -891,7 +886,6 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
     },
     {
       tree: treeCodeResult.treeCode,
-      pages: treeCodeResult.pages,
       __next_app_require__: '__webpack_require__',
       // all modules are in the entry chunk, so we never actually need to load chunks in webpack
       __next_app_load_chunk__: '() => Promise.resolve()',