remix-esbuild-override

raw JSON →
3.1.0 verified Fri May 01 auth: no javascript

A third-party library that allows overriding esbuild configuration in the Remix compiler. Current stable version is 3.1.0 (May 2023). It patches esbuild at runtime to let developers modify plugins, loaders, and other esbuild options. Unlike Remix's intentional restriction on exposing compiler config, this library provides a workaround via a postinstall script and a `withEsbuildOverride` function in `remix.config.js`. Requires @remix-run/dev >=1.2.0. Ships TypeScript types. Known for potential instability in production; use with caution.

error Error: Cannot find module 'remix-esbuild-override'
cause Package not installed or postinstall script not run.
fix
Run npm install -D remix-esbuild-override and ensure "postinstall": "remix-esbuild-override" is in package.json scripts, then run npm install again.
error TypeError: withEsbuildOverride is not a function
cause Incorrect import or using default export instead of named export.
fix
Use const { withEsbuildOverride } = require('remix-esbuild-override');
error Error: esbuild patch failed. Please reinstall remix-esbuild-override.
cause Permissions issue or broken node_modules; postinstall script failed.
fix
Delete node_modules, reinstall dependencies, and ensure you have write permissions.
error ReferenceError: require is not defined in ES module scope
cause Trying to use `require` in an ESM project (package.json type: module).
fix
Use dynamic import or rename remix.config.js to .cjs extension to force CommonJS.
breaking v3.0.0 changed the override mechanism from symlink-based to esbuild patching. Old v2 code will not work.
fix Upgrade to v3+ and update remix.config.js to use `withEsbuildOverride` instead of previous API.
gotcha The postinstall script patches esbuild globally; it may interfere with other tools using esbuild.
fix Verify no conflicts with other build tools; consider pinning esbuild version.
gotcha Compilation runs twice (server and browser); your override callback is called for each, so be careful with side effects.
fix Use the `isServer` and `isDev` parameters to conditionally apply overrides.
gotcha The library warns that it can 'destroy your product' in production; not recommended without thorough testing.
fix Test extensively in staging before deploying to production.
deprecated v2.x used a different API (no withEsbuildOverride); v3+ is the only supported version.
fix Migrate to v3 by using `withEsbuildOverride` and ensuring postinstall script runs.
npm install remix-esbuild-override
yarn add remix-esbuild-override
pnpm add remix-esbuild-override