Git Product home page Git Product logo

react-axe-es's Introduction

react-axe-es

This project is a thin wrapper around react-axe, the only difference is the addition of the sideEffects flag set to false in the package.json.

Please, read to the official react-axe docs for the full documentation.

Why?

The only supported way to use react-axe is to use CommonJS to conditionally import the dependency, or to use dynamic import() statements, that will make your initial app rendering asyncronous.

Neither of the above approaches are acceptable solutions for consumers that follow a pure ES modules approach, as reccomended by the webpack documentation.

To overcome this limitation, react-axe-es allows its consumers to statically import the dependency with a standard static import statement, while allowing the consumer's bundler (such as webpack, rollup, parcel, etc...) to dead code eliminate the imported dependency in case it ends up not being used in the production code.

The following example will bundle react-axe-es when NODE_ENV is not set to production, but will strip it out completely in the other case:

import React from 'react';
import ReactDOM from 'react-dom';
import axe from 'react-axe-es';

if (process.env.NODE_ENV !== 'production') {
  axe(React, ReactDOM, 1000);
}

How

This package has as only dependency react-axe, with the 3.0.0 version configured to allow any [email protected] version, this means you don't need to wait for a new react-axe-es release to use the new react-axe features.

We tried to get this functionality baked it into the core library, but the maintainers refused to merge our pull request.

For a list of not suitable approaches supported by react-axe, please refer to the wiki.

react-axe-es's People

Contributors

fezvrasta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.