npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

craco-esbuild

v0.6.1

Published

Use [esbuild](https://github.com/evanw/esbuild) in your [create-react-app](https://create-react-app.dev/) with [craco](https://github.com/gsoft-inc/craco) for faster compilation, development and tests.

Downloads

76,417

Readme

🚀 craco-esbuild 🚀

Use esbuild in your create-react-app with craco for faster compilation, development and tests.

Features

  • Replace babel-loader with esbuild during development
  • Replace babel-loader with esbuild for faster build time
  • Replace terser with esbuild for faster build time
  • Replace OptimizeCssAssetsWebpackPlugin with esbuild for faster build time
  • Use esbuild when running jest

Installation

Run the following command to install craco-esbuild in your project:

yarn add --dev craco-esbuild @craco/craco

OR

npm install --save-dev craco-esbuild @craco/craco

Usage

Add this configuration to your craco.config.js configuration file:

// craco.config.js
const CracoEsbuildPlugin = require('craco-esbuild');

module.exports = {
  plugins: [{ plugin: CracoEsbuildPlugin }],
};

To use craco instead of react-scripts to manage our application, edit the scripts section of your package.json.

/* package.json */

"scripts": {
-   "start": "react-scripts start",
+   "start": "craco start",
-   "build": "react-scripts build",
+   "build": "craco build"
-   "test": "react-scripts test",
+   "test": "craco test"
}

Configuration

You can configure the options of the plugin by passing an options object.

  • esbuildLoaderOptions: customise the options passed down to the esbuild loader. Note: This will be used only by webpack
  • esbuildMinimizerOptions: customise the options passed down to ESBuildMinifyPlugin. Note: This will be used only by webpack
  • includePaths: include external directories in loader.
  • skipEsbuildJest: Avoid using esbuild-jest for jest configuration. Could be useful to avoid compatibility issues with transpiling tests.
  • esbuildJestOptions: customise the options passed down to the esbuild-jest transformer.

For example add this configuration to your craco.config.js configuration file:

// craco.config.js
const CracoEsbuildPlugin = require('craco-esbuild');

module.exports = {
  plugins: [
    {
      plugin: CracoEsbuildPlugin,
      options: {
        includePaths: ['/external/dir/with/components'], // Optional. If you want to include components which are not in src folder
        esbuildLoaderOptions: {
          // Optional. Defaults to auto-detect loader.
          loader: 'jsx', // Set the value to 'tsx' if you use typescript
          target: 'es2015',
        },
        esbuildMinimizerOptions: {
          // Optional. Defaults to:
          target: 'es2015',
          css: true, // if true, OptimizeCssAssetsWebpackPlugin will also be replaced by esbuild.
        },
        skipEsbuildJest: false, // Optional. Set to true if you want to use babel for jest tests,
        esbuildJestOptions: {
          loaders: {
            '.ts': 'ts',
            '.tsx': 'tsx',
          },
        },
      },
    },
  ],
};

License

MIT © Léo Pradel