Skip to content

Rspack doesn't work with manifest file. #77267

@Marukome0743

Description

@Marukome0743

Link to the code that reproduces this issue

https://github.com/Marukome0743/rspack-manifest

To Reproduce

  1. Run create-next-app@canary -e reproduction-template to use repro template.
  2. Install next-rspack to use Rspack. (e.g. npm install next-rspack)
  3. Add next-rspack settings to next.config.ts.
next.config.ts code

import type { NextConfig } from "next";
import withRspack from "next-rspack";

const nextConfig: NextConfig = {
  /* config options here */
  reactStrictMode: true,
};

export default withRspack(nextConfig);

  1. Make manifest.ts file in the app directory.
manifest.ts code

import type { MetadataRoute } from 'next'
 
export default function manifest(): MetadataRoute.Manifest {
  return {
    name: 'Next.js App',
    short_name: 'Next.js App',
    description: 'Next.js App',
    start_url: '/',
    display: 'standalone',
    background_color: '#fff',
    theme_color: '#fff',
    icons: [
      {
        src: '/favicon.ico',
        sizes: 'any',
        type: 'image/x-icon',
      },
    ],
  }
}

  1. Run next dev in the terminal.
  2. Build Error occurred and it doesn't work.
Error details

$ next dev
   ▲ Next.js 15.3.0-canary.13
   - Local:        http://localhost:3000
   - Network:      http://10.255.255.254:3000

 ✓ Starting...
 ✓ Ready in 1846ms
 ○ Compiling / ...
 ✓ Compiled / in 2.1s (637 modules)
 GET / 200 in 2466ms
 ⨯ next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
  × Module build failed:
  ╰─▶   × TypeError: context.loadModule is not a function
        │     at mod (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:76:17)
        │     at new Promise (<anonymous>)
        │     at getLoaderModuleNamedExports (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:75:23)
        │     at createReExportsCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:40:70)
        │     at getDynamicTextRouteCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:122:9)
        │     at Object.nextMetadataRouterLoader (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:256:26)
        │     at LOADER_EXECUTION (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5762:18)
        │     at runSyncOrAsync2 (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5763:6)
        │     at node:internal/util:456:21
        │     at new Promise (<anonymous>)
        │     at runSyncOrAsync2 (node:internal/util:442:12)
        │     at runLoaders (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:6279:56)

Import trace for requested module:
next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
 ○ Compiling /_not-found ...
 ⨯ next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
  × Module build failed:
  ╰─▶   × TypeError: context.loadModule is not a function
        │     at mod (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:76:17)
        │     at new Promise (<anonymous>)
        │     at getLoaderModuleNamedExports (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:75:23)
        │     at createReExportsCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:40:70)
        │     at getDynamicTextRouteCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:122:9)
        │     at Object.nextMetadataRouterLoader (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:256:26)
        │     at LOADER_EXECUTION (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5762:18)
        │     at runSyncOrAsync2 (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5763:6)
        │     at node:internal/util:456:21
        │     at new Promise (<anonymous>)
        │     at runSyncOrAsync2 (node:internal/util:442:12)
        │     at runLoaders (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:6279:56)

Import trace for requested module:
next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
Failed to lookup module by ID ("│     at node:internal/util"): Error: Unable to access compilation with id = CompilationId(13) now. The compilation have been removed on the Rust side. The latest compilation id is CompilationId(17)
    at Array.map (<anonymous>) {
  code: 'GenericFailure'
}
Failed to lookup module by ID ("│     at node:internal/util"): Error: Unable to access compilation with id = CompilationId(13) now. The compilation have been removed on the Rust side. The latest compilation id is CompilationId(17)
    at Array.map (<anonymous>) {
  code: 'GenericFailure'
}
 ⨯ next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
  × Module build failed:
  ╰─▶   × TypeError: context.loadModule is not a function
        │     at mod (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:76:17)
        │     at new Promise (<anonymous>)
        │     at getLoaderModuleNamedExports (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:75:23)
        │     at createReExportsCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:40:70)
        │     at getDynamicTextRouteCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:122:9)
        │     at Object.nextMetadataRouterLoader (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:256:26)
        │     at LOADER_EXECUTION (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5762:18)
        │     at runSyncOrAsync2 (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5763:6)
        │     at node:internal/util:456:21
        │     at new Promise (<anonymous>)
        │     at runSyncOrAsync2 (node:internal/util:442:12)
        │     at runLoaders (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:6279:56)

Import trace for requested module:
next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
 ⨯ next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
  × Module build failed:
  ╰─▶   × TypeError: context.loadModule is not a function
        │     at mod (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:76:17)
        │     at new Promise (<anonymous>)
        │     at getLoaderModuleNamedExports (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/utils.js:75:23)
        │     at createReExportsCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:40:70)
        │     at getDynamicTextRouteCode (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:122:9)
        │     at Object.nextMetadataRouterLoader (/home/marukome/workspace/rspack-manifest/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js:256:26)
        │     at LOADER_EXECUTION (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5762:18)
        │     at runSyncOrAsync2 (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:5763:6)
        │     at node:internal/util:456:21
        │     at new Promise (<anonymous>)
        │     at runSyncOrAsync2 (node:internal/util:442:12)
        │     at runLoaders (/home/marukome/workspace/rspack-manifest/node_modules/@rspack/core/dist/index.js:6279:56)

Import trace for requested module:
next-metadata-route-loader?filePath=%2Fhome%2Fmarukome%2Fworkspace%2Frspack-manifest%2Fapp%2Fmanifest.ts&isDynamicRouteExtension=1!?__next_metadata_route__
 GET /manifest.webmanifest 500 in 5352ms
 GET / 500 in 1152ms
 GET / 500 in 21ms
 GET / 500 in 15ms

Current vs. Expected behavior

Current behavior shows error message, but expected behavior is no error.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sat Feb  8 02:00:20 UTC 2025
  Available memory (MB): 15897
  Available CPU cores: 8
Binaries:
  Node: 23.10.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 9.6.0
Relevant Packages:
  next: 15.3.0-canary.13 // Latest available version is detected (15.3.0-canary.13).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
  @next/plugin-rspack: 15.3.0-canary.13
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

This repro works correctly without next-rspack.

The success console outputs

$ next dev
   ▲ Next.js 15.3.0-canary.13
   - Local:        http://localhost:3000
   - Network:      http://10.255.255.254:3000

 ✓ Starting...
 ✓ Ready in 1740ms
 ○ Compiling / ...
 ✓ Compiled / in 3.9s (668 modules)
 GET / 200 in 4297ms
 ○ Compiling /favicon.ico ...
 ✓ Compiled /favicon.ico in 1745ms (688 modules)
 GET /favicon.ico 200 in 1813ms
 GET /manifest.webmanifest 200 in 1866ms

Which area(s) are affected?

There isn't bundler or rspack, so I selected Not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions