or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-react-app-polyfill

Polyfills for various browsers including commonly used language features for React applications

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/react-app-polyfill@3.0.x

To install, run

npx @tessl/cli install tessl/npm-react-app-polyfill@3.0.0

index.mddocs/

React App Polyfill

React App Polyfill provides essential browser polyfills specifically designed for React applications built with Create React App. The package enables modern JavaScript features to work in legacy browsers like Internet Explorer 9 and 11, offering targeted polyfill modules that automatically set up compatibility layers when imported.

Package Information

  • Package Name: react-app-polyfill
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install react-app-polyfill

Core Imports

All modules are imported as side-effects that automatically configure polyfills:

// For Internet Explorer 9 support
import 'react-app-polyfill/ie9';

// For Internet Explorer 11 support  
import 'react-app-polyfill/ie11';

// For stable language features (modern browsers)
import 'react-app-polyfill/stable';

// For testing environments (jsdom/Node.js)
import 'react-app-polyfill/jsdom';

CommonJS imports:

require('react-app-polyfill/ie9');
require('react-app-polyfill/ie11');
require('react-app-polyfill/stable');
require('react-app-polyfill/jsdom');

Basic Usage

React App Polyfill modules must be imported as the first lines in your application's entry point:

// These must be the first lines in src/index.js
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));

For Internet Explorer 9 support:

// These must be the first lines in src/index.js  
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

// ... rest of your application code

Architecture

React App Polyfill is built around side-effect modules that automatically configure browser polyfills:

  • Environment Detection: Uses feature detection to conditionally apply polyfills only when needed
  • Layered Support: IE9 module includes IE11 polyfills, providing incremental compatibility
  • Dependency-Based: Leverages proven polyfill libraries (core-js, whatwg-fetch, promise, etc.)
  • Testing-Friendly: Separate jsdom module provides minimal polyfills for test environments

Capabilities

Internet Explorer 9 Support

Comprehensive polyfills for Internet Explorer 9 compatibility, including all IE11 features plus additional IE9-specific polyfills.

import 'react-app-polyfill/ie9';

Polyfills Provided:

  • All features from IE11 module
  • Map support (ES6 Maps via core-js/features/map)
  • Set support (ES6 Sets via core-js/features/set)
  • RequestAnimationFrame support (via raf.polyfill())

Internet Explorer 11 Support

Essential polyfills for Internet Explorer 11 compatibility with modern JavaScript features.

import 'react-app-polyfill/ie11';

Polyfills Provided:

  • Promise support with rejection tracking (via promise/lib/es6-extensions.js)
  • window.fetch API (browser environments only, via whatwg-fetch)
  • Object.assign method (via object-assign)
  • Symbol primitive type (via core-js/features/symbol)
  • Array.from method (via core-js/features/array/from)

Stable Language Features

Comprehensive polyfills for stable JavaScript language features. When used with Create React App, automatically configured based on your project's browserslist to include only necessary polyfills for target browsers.

import 'react-app-polyfill/stable';

Polyfills Provided:

  • All stable JavaScript features (via core-js/stable)
  • Regenerator runtime for async/await support (via regenerator-runtime/runtime)

Testing Environment Support

Minimal polyfills specifically designed for testing environments like jsdom and Node.js.

import 'react-app-polyfill/jsdom';

Polyfills Provided:

  • window.fetch API (browser environments only, via whatwg-fetch)

Usage Patterns

Single Browser Target

For targeting a single browser compatibility level:

// IE9 support only
import 'react-app-polyfill/ie9';

// IE11 support only  
import 'react-app-polyfill/ie11';

// Modern browsers with stable features
import 'react-app-polyfill/stable';

Combined Usage

For comprehensive browser support with both legacy and modern features:

// IE9 + stable features
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

// IE11 + stable features
import 'react-app-polyfill/ie11'; 
import 'react-app-polyfill/stable';

Testing Setup

For test environments using jsdom:

// In test setup files
import 'react-app-polyfill/jsdom';

Environment Detection

React App Polyfill uses intelligent environment detection to apply polyfills only when appropriate:

  • Browser Detection: typeof window !== 'undefined' prevents server-side polyfill loading
  • Feature Detection: typeof Promise === 'undefined' conditionally applies Promise polyfill
  • Native Preservation: Uses native implementations when available and not buggy (e.g., Object.assign)

Error Handling

The package includes rejection tracking for Promises to prevent common React state inconsistencies:

  • Promise rejection tracking is automatically enabled when Promise polyfill is loaded
  • Helps identify errors that would otherwise be swallowed by Promise chains
  • Improves debugging experience in legacy browser environments