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

carlribbegaardh-react-scripts

v5.0.2-beta.2

Published

Configuration and scripts for Create React App.

Downloads

12

Readme

react-scripts with custom tsconfigs

React scripts with support for custom build and start (watch) tsconfigs like this:

"build": "env-cmd carlribbegaardh-react-scripts build"

TSCONFIG_BUILD=tsconfig.build.json

react-scripts

This package includes scripts and configuration used by Create React App. Please refer to its documentation:

background

If you are working in a monorepo with vscode you likely have a tsconfig like this:

{
  "extends": "../../tsconfig-base.json",
  ...
}

And a base tsconfig like this:

{
  "compilerOptions": {
    "baseUrl": "./packages",
    "paths": {
      "@your-project/*": ["*/src"],
       ...
  ...
}

or something similar.

While this is nice, providing navigation between projects, and an updated linting whenever you edit the library projects, it has a negative side when it comes to building. A setup like this causes the compiler to consider the source files instead of the build or dist folders of the library projects in your setup. Ideally you want a build tsconfig free from paths into src.

The most often used solution is to update the config on the fly while building, but with this package you can configure a separate tsconfig for building and watchching, making the build process much easier and faster.

special instructions

This package is only intended for testing while the PR is open.

The react-scripts bin file is named carlribbegaardh-react-scripts in this package to be able to coexist along the normal react-scripts in a monorepo.

Usage

yarn add -D carlribbegaardh-react-scripts
yarn workspace {your-workspace} add -D carlribbegaardh-react-scripts

Then change your package.json build (and/or start) command from
"build": "react-scripts build"
to
"build": "carlribbegaardh-react-scripts build"

custom tsconfig!

  1. Add env-cmd to your project
  2. Copy tsconfig.json to tsconfig.build.json
  3. Adjust them to build/start your project the optimal way. Most importantly, make them not inherit the config with your path aliases.
  4. Add a .env file like this:
TSCONFIG_BUILD=tsconfig.build.json
  1. Change your tsconfig.json to
    "build": "env-cmd carlribbegaardh-react-scripts build"
    "start": "env-cmd carlribbegaardh-react-scripts start"

  2. Change your react-app-env.d.ts to
    /// <reference types="carlribbegaardh-react-scripts" />

Now the environment will behave like this:
tsconfig.json is the file your editor will pick up.
tsconfig.build.json is the file used during build and start of your cra app.