@acaisoft/auth 中文文档教程
@acaisoft/auth
一个包含各种实用程序和 React 组件的共享库,允许在一个地方管理授权流和状态。
使用 typescript-library-starter
引导
Features
- Zero-setup. After running
npm install
things will setup for you :wink: - RollupJS for multiple optimized bundles following the standard convention and Tree-shaking
- Tests, coverage and interactive watch mode using Jest
- Prettier and TSLint for code formatting and consistency
- Docs automatic generation and deployment to
gh-pages
, using TypeDoc - Automatic types
(*.d.ts)
file generation
Importing library
您可以导入生成的包以使用此启动器生成的整个库:
import { ... } from '@acaisoft/auth'
此外,您可以从 dist/lib
中导入转译模块如果你有一个模块化库:
import something from '@acaisoft/auth/dist/lib/something'
NPM scripts
yarn start
: Runyarn build
in watch modeyarn test
: Run test suiteyarn test:watch
: Run test suite in interactive watch modeyarn test:prod
: Run linting and generate coverageyarn build
: Generate bundles and typings, create docsyarn lint
: Lints code
Excluding peerDependencies
在库开发中,可能想要设置一些对等依赖项,从而从最终包中删除它们。 您可以在 Rollup 文档 中查看如何执行此操作。
好消息:这里的设置是为您准备的,您必须只在 rollup.config.js
的 external
属性中包含依赖项名称。 例如,如果你想排除lodash
,就在那里写external: ['lodash']
。
@acaisoft/auth
A shared lib containing various utils and React components that allow managing authorization flow and state in a single place.
Bootstrapped with typescript-library-starter
Features
- Zero-setup. After running
npm install
things will setup for you :wink: - RollupJS for multiple optimized bundles following the standard convention and Tree-shaking
- Tests, coverage and interactive watch mode using Jest
- Prettier and TSLint for code formatting and consistency
- Docs automatic generation and deployment to
gh-pages
, using TypeDoc - Automatic types
(*.d.ts)
file generation
Importing library
You can import the generated bundle to use the whole library generated by this starter:
import { ... } from '@acaisoft/auth'
Additionally, you can import the transpiled modules from dist/lib
in case you have a modular library:
import something from '@acaisoft/auth/dist/lib/something'
NPM scripts
yarn start
: Runyarn build
in watch modeyarn test
: Run test suiteyarn test:watch
: Run test suite in interactive watch modeyarn test:prod
: Run linting and generate coverageyarn build
: Generate bundles and typings, create docsyarn lint
: Lints code
Excluding peerDependencies
On library development, one might want to set some peer dependencies, and thus remove those from the final bundle. You can see in Rollup docs how to do that.
Good news: the setup is here for you, you must only include the dependency name in external
property within rollup.config.js
. For example, if you want to exclude lodash
, just write there external: ['lodash']
.