Registry / devops / remix-esbuild-override

remix-esbuild-override

JSON →
library3.1.0jsnpmunverified

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.

npm install remix-esbuild-override
INSTALL
IMPORT
SIG · REMIX-ESBUILD-OVER
R
remix-esbuild-override
devopsjavascriptv3.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

withEsbuildOverride
const { withEsbuildOverride } = require('remix-esbuild-override')
import { withEsbuildOverride } from 'remix-esbuild-override'
CommonJS require is standard in remix.config.js; ESM import may cause issues.
default
const withEsbuildOverride = require('remix-esbuild-override').default
No default export; the library only exports named `withEsbuildOverride`.
types
import type { EsbuildOption } from 'remix-esbuild-override'
TypeScript users can import the `EsbuildOption` type for better IntelliSense.

Shows how to use withEsbuildOverride in remix.config.js to modify esbuild options per environment.

// remix.config.js const { withEsbuildOverride } = require('remix-esbuild-override'); withEsbuildOverride((option, { isServer, isDev }) => { // Example: add a custom esbuild plugin if (isServer) { option.plugins = [/* your plugin */, ...(option.plugins || [])]; } return option; }); /** @type {import('@remix-run/dev').AppConfig} */ module.exports = { // your Remix config appDirectory: "app", ignoredRouteFiles: ["*.css"], };
Debug
Known issues
breakingv3.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.
affects: <3.0.0
gotchaThe 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.
affects: >=3.0.0
gotchaCompilation 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.
affects: >=1.0.0
gotchaThe library warns that it can 'destroy your product' in production; not recommended without thorough testing.
fix
Test extensively in staging before deploying to production.
affects: >=1.0.0
deprecatedv2.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.
affects: 2.x
Errors
Common errors & fixes
Error: Cannot find module 'remix-esbuild-override'
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.
TypeError: withEsbuildOverride is not a function
Incorrect import or using default export instead of named export.
fix
Use `const { withEsbuildOverride } = require('remix-esbuild-override');`
Error: esbuild patch failed. Please reinstall remix-esbuild-override.
Permissions issue or broken node_modules; postinstall script failed.
fix
Delete node_modules, reinstall dependencies, and ensure you have write permissions.
ReferenceError: require is not defined in ES module scope
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.
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
@remix-run/devrequiredpeer dependency: requires Remix dev environment >=1.2.0
Agent activity
4 hits · last 30 days
node
4
Resources
remix-esbuild-override — npm install remix-esbuild-override · libregistry