javascriptreactjsviterollup

Could not load /__w/repo-name/repo-name/src/__vite-browser-external


I'm in the process of migrating our legacy frontend app from Create React App (CRA) to Vite. The transition has had its challenges, but I'm nearly done. Everything is up and running locally, and I'm able to build the app successfully on my machine. However, I'm encountering an issue when deploying the app through my GitHub Actions workflow. Specifically, I'm receiving the following error during the deployment job:

[vite:load-fallback] Could not load /__w/[repo-name]/[repo-name]/src/__vite-browser-external (imported by __vite-browser-external?commonjs-proxy): ENOENT: no such file or directory, open '/__w/[repo-name]/[repo-name]/src/__vite-browser-external'

this is my vite.config.js

import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import jsconfigPaths from 'vite-jsconfig-paths';
import eslintPlugin from 'vite-plugin-eslint';

export default defineConfig({
    build: {
        outDir: 'build',
        sourcemap: true,
    },
    plugins: [react(), jsconfigPaths(), eslintPlugin()],
    server: {
        open: true,
        port: 3000,
    },
});

I'm not sure how to debug this or where to start, your help is much appreciated 🙏🙏

I looked up similar questions on vite github repo discussion but no luck


Solution

  • after many many hours, the issue was with vite-jsconfig-paths it plays well with esbuild in development but it didn't play well with rollup on production for an unknown reason to me atm .. I fixed the issue by replicating my aliases from from jsconfig in vite.config