Registry / web-framework / babel-plugin-transform-proxy-compat

babel-plugin-transform-proxy-compat

JSON →
library0.22.4jsnpmunverified

Babel plugin that rewrites property lookups, assignments, deletions, function invocations, 'in' statements, and 'for...in' loops to use function calls from a proxy-compat library, enabling Proxy semantics in environments like IE 11 that lack native Proxy support. Current stable version is 0.22.4, with maintenance-level releases. Key differentiator: allows using modern Proxy-based reactivity or interceptors while targeting legacy browsers without polyfilling Proxy itself. Typically paired with libraries like `proxy-compat` that provide the runtime helper functions.

npm install babel-plugin-transform-proxy-compat
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-proxy-compat
web-frameworkjavascriptv0.22.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

babel-plugin-transform-proxy-compat
import plugin from 'babel-plugin-transform-proxy-compat';
const plugin = require('babel-plugin-transform-proxy-compat');
CommonJS require works; this plugin is not ESM-only.
callKey
import { callKey } from 'proxy-compat';
import callKey from 'proxy-compat';
callKey is a named export from proxy-compat; default export is the whole module.
ProxyCompat
import ProxyCompat from 'proxy-compat';
const ProxyCompat = require('proxy-compat').default;
CommonJS users should use const ProxyCompat = require('proxy-compat'); (no .default)

Configures Babel to transform Proxy operations to use proxy-compat runtime for IE 11 compatibility.

// babel.config.js module.exports = { plugins: [ ['babel-plugin-transform-proxy-compat', { resolveProxyCompat: { module: 'proxy-compat' } }] ] }; // source.js const obj = new Proxy({}, { get(target, prop) { return prop in target ? target[prop] : 42; } }); console.log(obj.foo); // becomes: console.log(callKey(obj, 'foo'));
Debug
Known issues
gotchaPlugin rewrites ALL object property access, assignment, deletion, and 'in'/'for...in' expressions, even if not related to a Proxy. This can cause significant code bloat and performance degradation.
fix
Use /* proxy-compat-disable */ comment at top of files that are performance-sensitive and do not use Proxy.
affects: *
breakingOption 'resolveProxyCompat' changed from accepting a string to an object with module/global/independent properties (v0.16+).
fix
Update config to use { module: '...' } or { global: '...' } instead of just a string.
affects: >=0.16 <0.22
deprecatedThe 'polyfill' option was removed in favor of 'resolveProxyCompat' (v0.10+).
fix
Use resolveProxyCompat with module or global sub-option.
affects: >=0.10 <0.16
gotchaWhen using 'global' mode, the global variable must be defined before the transformed code runs. The plugin does not inject a polyfill.
fix
Ensure a global variable (e.g., window.MyProxyCompat) is defined via a script tag or other means.
affects: *
gotchaPlugin does not transform property access on literals (e.g., 'abc'.length) or built-in objects like Array.prototype. Only object property access is transformed.
fix
Be aware that some property accesses may not be rewritten; test thoroughly.
affects: *
Errors
Common errors & fixes
Error: Could not find module 'proxy-compat'
The runtime dependency 'proxy-compat' is not installed.
fix
Run: npm install proxy-compat --save
TypeError: callKey is not a function
Using 'independent' mode but importing the wrong export.
fix
Change import to: import callKey from 'proxy-compat/callKey'; (not from 'proxy-compat')
TypeError: ProxyCompat.callKey is undefined
Using CommonJS require without the correct import pattern.
fix
Use: const ProxyCompat = require('proxy-compat'); (no .default)
Upgrade
Version history
0.22.4latest on npm
Audit
Dependencies
proxy-compatrequiredRuntime module that provides the actual proxy-compat functions (callKey, getKey, setKey, etc.) when using module or independent modes.
Agent activity
16 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
babel-plugin-transform-proxy-compat — npm install babel-plugin-transform-proxy-compat · libregistry