# Eden Library BoilerPlate

This repository is designed for util project with TypeScript. It contains several useful features you may interested in, including auto build multiple formats of bundle, built in unit tests, auto replace aliases in declaration files with TypeScript transformation API and so on.

## Develop

Simply run `npm start`, a compiling process will be started, it will watch for file changes and auto re-compile.

## Build

Run `npm build` can compile your project into several formats of bundles. You can configure the formats in `eden.config.js`'s `output.format` and location of bundles in `output.file` or `output.dir` (depending on number of entries, one for `output.file`, multiple for `output.dir`).

## Auto Documenter

This project supports auto document generation powered by Eden TypeScript Documenter, run `npm run build:docs` to build a static web site in `website`, for more information, see [here](https://bytedance.feishu.cn/wiki/wikcnCbm2r8yG9hscINwLbeJKfh).

## Configuration files

### tsconfig.json

This repository has a default configuration for TypeScript, it enables several compiler options which may improve project's quality and robustness, such as `noImplicitAny`, `noImplicitReturns`, `noFallthroughCasesInSwitch`, `noUnusedLocals`, `noUnusedParameters`, `noImplicitThis` and `strictNullChecks`, with these options on, common mistakes can be avoided in developing period.

#### Auto replace aliases in declaration files

As TypeScript designed, `tsc` is a compiler, not a bundler, and `paths` in `tsconfig.json` will only works in developing period, aliases in source code will not be replaced with actual relative paths after compile, so if you use aliases in source code, your declaration files in compile result will have the unchanged aliases, which will cause declaration files cannot reference other declaration files correctly. But `ttypescript` and `typescript-transform-paths` use TypeScript transformation API solved this problem.

See more on this in [ttypescript](https://github.com/cevek/ttypescript).

### jest.config.js

`jest.config.js` tells `jest` what and how to run tests in project. You can define unit tests for any file with a TypeScript file which filename ends with `.spec.ts`, `.test.ts` or under `__tests__` directories. Simply run `npm test` will run all unit tests in the project, while developing, you can run `npm test:watch` to let jest re-run tests automatically.

### eden.config.js

`eden.config.js` tells Eden what is entry/entries of the project and what format and location should this project be compiled to.

#### Compile for multiple formats in one compilation

You can compile your project into several different formats in only one compilation, simply specify `output.format` as an array of string, each item in the array should be one of supported formats, which are `cjs`, `es`, `umd`, `amd`, `iife` and `system`.

#### Compile for multiple entries

You can compile for multiple entries in your project, just set `input` as an array of entries, each element of the array is a entry point, or you can specify `input` as an object, in each key-value pair, key is the name of the entry that will be used as `[name]` portion of `output.entryFileNames` (if set), and the value is the entry point.

See more on this in [input](https://eden.bytedance.net/docs/configuration/util-input-cn).

#### Other abilities

Eden provide many abilities for compile, which are the following:

- [ts](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.ts)
- [react](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.react)
- [json](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.json)
- [commonjs](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.commonjs)
- [resolve](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.resolve)
- [copy](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.copy)
- [autoExternal](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.autoExternal)
- [babel](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.babel)
- [terser](https://eden.bytedance.net/docs/configuration/util-abilities-cn#abilities.terser)

You can see detail for every ability by clicking on the links above.

smart-translate-bdt
.npmrc
registry=https://registry.npmjs.org
