{"id":26306,"library":"remix-esbuild-override","title":"remix-esbuild-override","description":"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.","status":"active","version":"3.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/aiji42/remix-esbuild-override","tags":["javascript","typescript"],"install":[{"cmd":"npm install remix-esbuild-override","lang":"bash","label":"npm"},{"cmd":"yarn add remix-esbuild-override","lang":"bash","label":"yarn"},{"cmd":"pnpm add remix-esbuild-override","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires Remix dev environment >=1.2.0","package":"@remix-run/dev","optional":false}],"imports":[{"note":"CommonJS require is standard in remix.config.js; ESM import may cause issues.","wrong":"import { withEsbuildOverride } from 'remix-esbuild-override'","symbol":"withEsbuildOverride","correct":"const { withEsbuildOverride } = require('remix-esbuild-override')"},{"note":"No default export; the library only exports named `withEsbuildOverride`.","wrong":"const withEsbuildOverride = require('remix-esbuild-override').default","symbol":"default"},{"note":"TypeScript users can import the `EsbuildOption` type for better IntelliSense.","symbol":"types","correct":"import type { EsbuildOption } from 'remix-esbuild-override'"}],"quickstart":{"code":"// remix.config.js\nconst { withEsbuildOverride } = require('remix-esbuild-override');\n\nwithEsbuildOverride((option, { isServer, isDev }) => {\n  // Example: add a custom esbuild plugin\n  if (isServer) {\n    option.plugins = [/* your plugin */, ...(option.plugins || [])];\n  }\n  return option;\n});\n\n/** @type {import('@remix-run/dev').AppConfig} */\nmodule.exports = {\n  // your Remix config\n  appDirectory: \"app\",\n  ignoredRouteFiles: [\"*.css\"],\n};\n","lang":"javascript","description":"Shows how to use withEsbuildOverride in remix.config.js to modify esbuild options per environment."},"warnings":[{"fix":"Upgrade to v3+ and update remix.config.js to use `withEsbuildOverride` instead of previous API.","message":"v3.0.0 changed the override mechanism from symlink-based to esbuild patching. Old v2 code will not work.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Verify no conflicts with other build tools; consider pinning esbuild version.","message":"The postinstall script patches esbuild globally; it may interfere with other tools using esbuild.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use the `isServer` and `isDev` parameters to conditionally apply overrides.","message":"Compilation runs twice (server and browser); your override callback is called for each, so be careful with side effects.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Test extensively in staging before deploying to production.","message":"The library warns that it can 'destroy your product' in production; not recommended without thorough testing.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to v3 by using `withEsbuildOverride` and ensuring postinstall script runs.","message":"v2.x used a different API (no withEsbuildOverride); v3+ is the only supported version.","severity":"deprecated","affected_versions":"2.x"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install -D remix-esbuild-override` and ensure `\"postinstall\": \"remix-esbuild-override\"` is in package.json scripts, then run `npm install` again.","cause":"Package not installed or postinstall script not run.","error":"Error: Cannot find module 'remix-esbuild-override'"},{"fix":"Use `const { withEsbuildOverride } = require('remix-esbuild-override');`","cause":"Incorrect import or using default export instead of named export.","error":"TypeError: withEsbuildOverride is not a function"},{"fix":"Delete node_modules, reinstall dependencies, and ensure you have write permissions.","cause":"Permissions issue or broken node_modules; postinstall script failed.","error":"Error: esbuild patch failed. Please reinstall remix-esbuild-override."},{"fix":"Use dynamic import or rename remix.config.js to .cjs extension to force CommonJS.","cause":"Trying to use `require` in an ESM project (package.json type: module).","error":"ReferenceError: require is not defined in ES module scope"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}