remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.3k stars 10.33k forks source link

[Bug]: v7 regression in a monorepo since prerelease #12390

Open xalechez opened 4 days ago

xalechez commented 4 days ago

What version of React Router are you using?

7.0.1

Steps to Reproduce

RR7 config:

import { join } from 'node:path';

import { build } from 'esbuild';

import type { Config } from '@react-router/dev/config';

export default {
  appDirectory: join(import.meta.dirname, 'app'),
  buildDirectory: join(
    import.meta.dirname,
    '../../dist/apps/test-app/static',
  ),
  serverModuleFormat: 'esm',
  ssr: true,
  buildEnd: async () => {
    await build({
      outfile: join(import.meta.dirname, '../../dist/apps/test-app/rr7.mjs'),
      entryPoints: [join(import.meta.dirname, 'rr7.mts')],
      external: [
        join(
          import.meta.dirname,
          '../../dist/apps/test-app/static/server/index.js',
        ),
      ],
      platform: 'node',
      format: 'esm',
      packages: 'external',
      bundle: true,
      logLevel: 'info',
    }).catch((error: unknown) => {
      console.error('Error building server:', error);
      process.exit(1);
    });
  },
} satisfies Config;

Expected Behavior

I would like to be able to run my application from the root of my monorepo by specifying the location of vite.config.ts like I did when I tested a pre-release version

OR

I would like to be able to run my application from apps/test-app with the package.json resolved from the root of my monorepo

Actual Behavior

Currently it works in two modes:

This problem can be solved just by adding a package.json to the app folder, but we opted in to single version policy per monorepo as it becomes quite tedious to maintain dependencies for multiple applications at the same time. React Router 7 pre-release satisfied our needs, but as vite config and RR config are now separated, it looks like this functionality is no longer supported