2.3.3 • Published 5 months ago

jiek v2.3.3

Weekly downloads
-
License
-
Repository
github
Last release
5 months ago

Jiek

| English | 简体中文 | 繁体中文 | 日本語 | Français

npm version npm downloads

A lightweight toolkit for compiling and managing libraries based on package.json metadata and suitable for Monorepo.

  • Automatic inference: Automatically infer build rules based on relevant fields in package.json, reducing the need for configuration files, making it more lightweight and standard-compliant
    • exports: Infer build targets and types based on entry files
    • imports: Define path aliases and automatically bundle them during the build
    • type: module: Intelligently decide the output file suffix based on options, eliminating the need to consider cjs and esm compatibility issues
    • dependencies, peerDependencies, optionalDependencies: Automatically mark dependencies that meet the rules as external
    • devDependencies: Bundle dependencies marked as development dependencies into the corresponding final product
  • Build tools: Support multiple build tools, no need to struggle with using swc, esbuild, or tsc
    • esbuild
    • swc
    • typescript
  • Workspace-friendly: Support development paradigms in pnpm workspaces
    • Support more PMs
    • Better workspace task flow
  • Type definition files: Support aggregated generation of type definition files
  • Watch mode: Adapt to rollup's watch mode
  • Publish adaptation: Support isomorphic generation of package.json and other related fields
    • Automatically replace relative path links in README.md with corresponding network links based on paths in package.json
    • Automatically generate common fields such as license, author, homepage, repository, etc. based on the repository and project
  • CommonJS: Compatible with users who are still using cjs
  • Plugin system
    • Dotenv: Support dotenv configuration files
    • Replacer: Support replacing file content
  • Hooks: prepublish, postpublish
    • Automatically generate changelog
    • Automatically decide the next version number
      • feat: xxx -> patch
      • feat!: xxx -> minor
      • feat!!: xxx -> major

Installation

npm i -D jiek
# or
pnpm i -D jiek
# or
yarn add -D jiek

Quick Start

Generate the required products quickly and easily through some simple methods.

  • Add entry files in package.json, here you need to set the original file path.

    You can see more about exports in the Node.js documentation.

{
  ...
  "exports": "./src/index.ts",
  ...
}
  • Suppose you have a package named @monorepo/utils in the workspace, then you can run jk -f utils build to build this package.

  • When you need to publish the current package, you can first run jk -f utils prepublish to prepare the publishing content, then run jk -f utils publish to publish, and finally run jk -f utils postpublish to clean up the publishing content.

  • Of course, you may find the above operations a bit cumbersome, you can simplify the operations by adding scripts in the corresponding package's package.json.

{
  ...
  "scripts": {
    "prepublish": "jb && jk",
    "postpublish": "jk"
  },
  ...
}

If you need to check the content to be published before publishing, you can use the prepublish subcommand to generate the relevant package.json file in your dist product directory (configurable), and you can review the generated files.

  • After configuring the above hooks, you can complete the build and publish actions with one command jk publish.

CLI

jk/jiek [options] [command]
jb/jiek-build [options] [filters/entries]

Custom Build Entry

You can specify the build entry through --entries, the entry definition here is based on the exports field in package.json.

jb -e .
jb --entries .
jb --entries ./foo
jb --entries ./foo,./bar

When your project is a non-monorepo project, you can directly build through jb [entries].

jb .
jb ./foo
jb ./foo,./bar

Filters

You can filter the packages to be built through --filter, we use the same filter rules as pnpm, so you can check the pnpm filter rules here.

jb --filter @monorepo/*
jb --filter @monorepo/utils
jb -f utils

When your project is a monorepo project, you can directly build through jb [filters].

jb @monorepo/*
jb @monorepo/utils
jb utils

Custom Build Tools

We support multiple build tools, you can specify the build tool through --type <type: esbuild | swc>.

  • By default, esbuild (rollup-plugin-esbuild) will be used
  • If the swc (rollup-plugin-swc3) dependency exists in your dependency space, we will automatically switch to swc
  • If both exist, esbuild will be used by default
jb --type swc

If the build tool dependency is not installed, we will prompt you to install the corresponding dependency.

Minification

We provide multiple ways to support minified builds, which are enabled by default, and we will use the build tool's built-in minification plugin for minification by default.

  • You can choose to use terser (rollup-plugin-terser) for minification through --minType, if you have not installed terser, we will prompt you to install it.
  • You can disable the generation of minified products through --noMin.
  • You can generate only minified products through --onlyMinify, in this case, we will directly replace the original product path instead of adding a .min suffix before outputting.
jb --minType terser
jb --onlyMinify

Exclude Specific Build Content

You can disable the build of js through --noJs, and disable the build of dts through --noDts.

jb --noJs
jb --noDts

Custom Output Directory

You can specify the output directory through --outdir.

jb --outdir lib

Watch Mode

You can enable watch mode through --watch.

jb --watch

External Modules

In addition to automatically marking external modules through dependencies, peerDependencies, optionalDependencies in package.json, you can also manually mark external modules through --external.

jb --external react
jb --external react,react-dom

Disable Automatic Cleanup of Products

You can disable the automatic cleanup of products through --noClean.

jb --noClean

Custom tsconfig Path

You can specify the path of tsconfig through --tsconfig.

jb --tsconfig ./tsconfig.custom-build.json

You can also specify the path of dtsconfig used by the dts plugin through --dtsconfig (although I don't recommend doing this).

jb --dtsconfig ./tsconfig.custom-dts.json

Publish Command

The publish command allows you to publish the current package to the npm registry. It also automatically generates the exports field and other fields in the published package.json.

jk publish [options]

Options

  • -b, --bumper <bumper>: Bump version (default: patch)
  • -no-b, --no-bumper: No bump version
  • -o, --outdir <OUTDIR>: Specify the output directory (default: dist)

Pass-through Options

If you want to pass options to the pnpm publish command, you can pass the options after --.

jk publish -- --access public --no-git-checks

Why not use X?

Similar tools to jiek include: tsup, unbuild, bunchee, pkgroll, tsdown. However, they all have some common issues that have not been resolved, such as:

  • There are certain issues with monorepo support, and dependencies on other packages in the workspace must be recompiled
  • The rules for writing entry files are too cumbersome and not natural enough
  • Unable to handle issues related to Project Reference in tsconfig.json
  • Unable to fully utilize conditional features
  • Unable to choose the required builder, can only replace the entire toolchain

Who is using Jiek?

About this README

This README is generated by copilot workspace and originates from the zh-Hans/README.md file.

1.1.9-alpha.1

7 months ago

2.2.3-alpha.1

6 months ago

2.0.2

7 months ago

2.2.3-alpha.3

6 months ago

2.2.3-alpha.2

6 months ago

2.2.3-alpha.5

6 months ago

2.2.3-alpha.4

6 months ago

2.0.1

7 months ago

2.0.0

7 months ago

2.1.9

7 months ago

2.1.12

7 months ago

2.1.13

7 months ago

2.1.10

7 months ago

2.1.11

7 months ago

2.0.2-alpha.10

7 months ago

1.1.1

7 months ago

2.0.2-alpha.11

7 months ago

1.1.0

7 months ago

2.0.2-alpha.12

7 months ago

2.0.2-alpha.13

7 months ago

1.1.9

7 months ago

1.1.8

7 months ago

1.1.7

7 months ago

1.1.6

7 months ago

2.0.2-alpha.14

7 months ago

1.1.5

7 months ago

2.0.2-alpha.15

7 months ago

1.1.4

7 months ago

2.0.2-alpha.16

7 months ago

1.1.3

7 months ago

2.0.2-alpha.17

7 months ago

1.1.2

7 months ago

2.3.0

6 months ago

2.3.2

5 months ago

2.3.1

5 months ago

2.3.3

5 months ago

1.1.12

7 months ago

1.1.11

7 months ago

1.1.10

7 months ago

1.1.13

7 months ago

2.2.5-alpha.1

6 months ago

2.0.2-alpha.8

7 months ago

2.0.2-alpha.7

7 months ago

2.0.2-alpha.6

7 months ago

2.0.2-alpha.5

7 months ago

2.0.2-alpha.9

7 months ago

1.1.7-alpha.2

7 months ago

1.1.7-alpha.1

7 months ago

2.2.1

6 months ago

2.2.0

6 months ago

2.2.3

6 months ago

2.2.2

6 months ago

2.2.5

6 months ago

2.2.4

6 months ago

2.2.7

6 months ago

2.2.6

6 months ago

2.0.2-alpha.4

7 months ago

2.0.2-alpha.3

7 months ago

2.0.2-alpha.2

7 months ago

2.0.2-alpha.1

7 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

7 months ago

2.1.7

7 months ago

2.1.0

7 months ago

2.2.7-alpha.3

6 months ago

2.2.7-alpha.4

6 months ago

2.2.7-alpha.5

6 months ago

2.2.7-alpha.1

6 months ago

2.1.13-alpha.1

6 months ago

2.1.13-alpha.2

6 months ago

2.1.13-alpha.3

6 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

0.4.7-alpha.11

8 months ago

0.4.7-alpha.12

8 months ago

0.4.7-alpha.10

8 months ago

0.4.7-alpha.1

8 months ago

0.4.7-alpha.3

8 months ago

0.4.7-alpha.4

8 months ago

0.4.7-alpha.5

8 months ago

0.4.7-alpha.6

8 months ago

0.4.7-alpha.7

8 months ago

0.4.7-alpha.8

8 months ago

0.4.7-alpha.9

8 months ago

0.4.7-alpha.13

8 months ago

0.4.7-alpha.14

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

0.3.0

1 year ago

0.4.5

1 year ago

0.4.4

1 year ago

0.4.7

1 year ago

0.4.6

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.2.2-alpha.1

1 year ago

0.2.10

1 year ago

0.2.7

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.3

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.1-alpha.2

1 year ago

0.2.1-alpha.1

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0-alpha.1

1 year ago

0.1.12-alpha.3

1 year ago

0.1.12-alpha.4

1 year ago

0.1.12-alpha.1

1 year ago

0.2.0

1 year ago

0.1.12-alpha.2

1 year ago

0.1.12-alpha.5

1 year ago

0.1.12

1 year ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.9

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

1.0.0

2 years ago