Setu-TS
    Preparing search index...

    Function viteDevExternals

    • Creates a Vite plugin for React Router development mode.

      Keep framework packages and workspace libraries resolved by the server runtime, so route modules and the entry share one module instance. The context keys contextKeyFor() returns match by identity: a second copy would read different keys from those setu.config.ts sets. This plugin resolves each listed package with the runtime's own resolver and marks the result as a runtime built-in, so the runner imports it natively and shares the instance the server already holds.

      Pass it to vite.createServer({ plugins: [...] }) from the development entry, where import.meta.resolve is the server runtime's resolver; inside vite.config.ts that function is Vite's.

      Parameters

      Returns ViteDevExternalsPlugin

      A Vite plugin

      import * as vite from 'vite';
      import { viteDevExternals } from '@setu-ts/react-router-plugin';

      const server = await vite.createServer({
      configFile: new URL('./vite.config.ts', import.meta.url).pathname,
      plugins: [viteDevExternals({
      packages: ['@setu-ts/common', '@setu-ts/react-router-plugin'],
      resolve: (specifier) => import.meta.resolve(specifier),
      })],
      });

      0.9.0