@arters/web-scripts
Build, lint, test, format, and release your React app or JS library.
Last updated 4 months ago by arthur.saenz .
Original npm · Tarball · package.json
$ cnpm install @arters/web-scripts 
SYNC missed versions from official npm registry.

web-scripts

Description

Build, lint, test, format, and release your React App or JS library. This CLI tool bundles all the necessary configuration and dependencies so you can focus on the code.

Usage

npm i @arters/web-scripts husky --save-dev

Add the scripts and commit hooks to your package.json:

{
  "scripts": {
    "test": "web-scripts test",
    "lint": "web-scripts lint",
    "start": "web-scripts dev:spa",
    "build": "web-scripts build:[options]",
    "commit": "web-scripts commit",
    "release": "web-scripts release"
  },
  "husky": {
    "hooks": {
      "commit-msg": "web-scripts commitmsg",
      "pre-commit": "web-scripts precommit"
    }
  }
}

If you plan to use web-scripts build to build ESM, CommonJS, and types for your library with ease, update your package.json to define the locations where those will end up. Read more about our the build script.

{
  "main": "dist/index.cjs.js",
  "module": "dist/index.esm.js",
  "types": "types"
}

Editor support steps

Add a root .prettierrc.js:

module.exports = require('@arters/web-scripts/config/prettier.config.js')

Add a root .eslintrc.js:

module.exports = require('@arters/web-scripts/config/eslintrc.js')

Add a root jest.config.js:

module.exports = require('@arters/web-scripts/config/jest.config.js')

Watchers

Both web-scripts build:[options] and web-scripts test support a --watch flag which runs the underlying CLIs (tsc and jest) as watchers.

# re-compile the cjs, esm, and types on each change to your src with tsc
web-scripts build --watch

# re-run the tests that are relevant to your file changes with jest
web-scripts test --watch

The build script

web-scripts build runs three parallel calls to the TypeScript compiler.

  • One of them transpiles the files as CommonJS and outputs it to the cjs directory. Your repo should have "cjs/index.js" set as main in your package.json. You can turn this off using --no-cjs when running build.
  • Another does the exact same thing but only transpiles to EcmaScript modules. This is super helpful if your consuming project is using Babel or TypeScript, and you'll end up avoiding playing games of transpilation telephone along the way. Your repo should have "esm/index.js" set as module in your package.json if using this. You can turn this off with the --no-esm flag when running build.
  • Finally, tsc will be run to output type definitions. Your repo should have the "types" directory set as types in your package.json if using this. You can turn this off with the --no-types flag when running build.

These parallel builds are set up to share resources and work efficiently.

If you need to use Babel for some reason, that's ok! Simply use babel directly instead of using web-scripts build. Teams inside Spotify mix and match which scripts they use to serve their needs. In many cases, tsc is all you need and is lighter and simpler to set up.

Current Tags

  • 0.23.0                                ...           latest (4 months ago)

25 Versions

  • 0.23.0                                ...           4 months ago
  • 0.22.0                                ...           4 months ago
  • 0.21.0                                ...           4 months ago
  • 0.20.0                                ...           4 months ago
  • 0.19.0                                ...           4 months ago
  • 0.18.0                                ...           4 months ago
  • 0.17.1                                ...           4 months ago
  • 0.14.0                                ...           4 months ago
  • 0.12.0                                ...           4 months ago
  • 0.10.0                                ...           4 months ago
  • 0.9.70                                ...           4 months ago
  • 0.9.50                                ...           4 months ago
  • 0.9.3                                ...           4 months ago
  • 0.9.11                                ...           4 months ago
  • 0.9.0                                ...           4 months ago
  • 0.8.1                                ...           4 months ago
  • 0.8.0                                ...           4 months ago
  • 0.7.4                                ...           4 months ago
  • 0.3.2                                ...           4 months ago
  • 0.3.1                                ...           4 months ago
  • 0.2.95                                ...           4 months ago
  • 0.1.0                                ...           4 months ago
  • 0.2.9                                ...           4 months ago
  • 0.2.8                                ...           4 months ago
  • 0.2.7                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 25
Last Month 50
Dependencies (27)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |