4.0.0 • Published 4 months ago

@werk/command-build v4.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

Werk Build Command

Build with near-zero-configuration using common tools and opinionated configurations.

npm werk

Install

npm i -D @werk/command-build

Build

werk build

Options

  • -w, --watch: After building once, start continuously building workspaces. Generally, this means starting a development server or rebuilding when files are changed.
  • --vite: Force Vite build mode.
  • --abort-on-failure: Abort on the first build failure.

Modes

A build mode will be selected automatically in the following order, based on the presence of tool configuration files.

  • script: Run the workspace build script.
    • A build script (or start when the --start option is set) is present in the workspace package.json file.
  • rollup: Build using Rollup.
    • A rollup.config.* present in the package root.
  • vite: Build using Vite.
    • The --vite option is set.
    • An index.html or vite.config.* is present in the package root.
    • All of the following are true:
      • An exports, module, main, bin, or types entry is present in the package.json file.
      • Vite is a dev dependency of the current workspace
  • tsc: Build using the TypeScript compiler.
    • All of the following are true:
      • An exports, module, main, bin, or types entry is present in the package.json file.
      • Typescript is a dev dependency of the root or current workspace.

Mode: script

Runs the build script from the workspace package.json file. If the --start flag is set, then the start script will be run after building.

Mode: rollup

Uses the rollup.config.* file in the workspace.

Mode: vite

Uses the vite.config.* file in the workspace root if it exists.

The --vite option can be used to force this mode, because it should actually work for almost any project. However, the other modes exist because there are some edge cases that Vite doesn't handle currently (like decorators).

If no configuration exists, a default configuration will be used. Under the default configuration, library mode is enabled if the package.json file contains bin, main, or exports entry points. CommonJS and/or ESModule output is determined automatically.

When library mode is enabled, bundling is disabled (ie. "preserve modules"), unless any package entry (exports, module, main, bin, or types) is named bundle.*. Disabling bundling means that one output file per-input file is generated, which is useful for tree-shaking.

Automatic Plugin Support

See the @werk/vite-config package for more information about what Vite plugins are used automatically.

Mode: tsc

Builds once for every tsconfig.*build*.json file found in the workspace. If no matching build configuration files are present, then temporary configurations will be generated.

This mode is the default even though it doesn't support bundling and is not particularly fast, because it is considered the "reference" option, and will handle all Typescript features.

Generated configurations write output to the lib directory. CommonJS and/or ESModule output is determined automatically.

Generated configurations will extend a tsconfig.json file in the workspace or the workspaces root.

Note: A simple package.json file will also be written to each output directory, as long as it's not the workspace root. This package file contains only the type directive, set to the value which matches the TypeScript configuration (module or commonjs).

Recommendations

Build dependencies should be included in the devDependencies of each workspace, even in a mono-repo. Build dependency version mismatches in different workspaces usually won't cause problems, so this allows per-workspace build tool migration. It also makes it clear what tools are being used in the build. Typescript is the only exception to this rule, as it is used by the IDE as well as the build.

4.0.0

4 months ago

3.0.6

5 months ago

3.0.5

5 months ago

3.0.4

5 months ago

3.0.3

5 months ago

3.0.2

5 months ago

3.0.1

5 months ago

1.2.0

7 months ago

1.1.29

8 months ago

1.2.1

7 months ago

2.0.3

7 months ago

2.2.0

5 months ago

2.0.2

7 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.7

7 months ago

1.1.30

8 months ago

2.0.6

7 months ago

2.0.9

7 months ago

2.0.8

7 months ago

1.1.34

8 months ago

1.1.33

8 months ago

1.1.32

8 months ago

1.1.31

8 months ago

2.0.1

7 months ago

2.0.0

7 months ago

2.1.9

5 months ago

3.0.0

5 months ago

2.1.11

5 months ago

1.1.1

10 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.3.5

7 months ago

1.1.7

10 months ago

1.3.4

7 months ago

1.1.6

10 months ago

1.3.3

7 months ago

1.1.5

10 months ago

1.3.2

7 months ago

1.1.4

10 months ago

1.3.1

7 months ago

1.1.3

10 months ago

1.3.0

7 months ago

1.1.2

10 months ago

2.1.2

7 months ago

2.1.1

7 months ago

2.1.4

7 months ago

2.1.3

7 months ago

2.1.6

7 months ago

2.1.5

7 months ago

2.1.8

5 months ago

2.1.7

7 months ago

2.0.10

7 months ago

1.1.12

8 months ago

1.1.11

8 months ago

1.1.10

8 months ago

1.1.16

8 months ago

1.1.15

8 months ago

2.1.0

7 months ago

1.1.14

8 months ago

1.1.13

8 months ago

1.1.19

8 months ago

1.1.18

8 months ago

1.1.17

8 months ago

1.1.23

8 months ago

1.1.22

8 months ago

1.1.21

8 months ago

1.1.20

8 months ago

1.1.27

8 months ago

1.1.26

8 months ago

1.1.25

8 months ago

1.1.24

8 months ago

1.1.0

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago