-
Notifications
You must be signed in to change notification settings - Fork 2
Develop
# bundle library code to lib folder in the root of project.
npm build:lib
# build Storybook
npm build:docsModule type declarations can be overridden at src/types.d.ts. src/lib/index.ts is used as an entry point to collect type definitions for build.
Library uses rollup to bundle code. Rollup config can be found at rollup.config.cjs. CommonJS (dist/index.cjs.js) and ES Modules (dist/index.esm.js) builds are emitted.
Development takes place inside src directory. There are two subdirectories inside:
-
libis where your library code should live, this code will be bundled with rollup and published to NPM. Imports fromenvironmentdirectory are forbidden, eslint will throw an error. Exports fromsrc/lib/index.tswill be included in the library. -
environmentis where your development code lives (CSS frameworks, demo code, mocks etc.). Contents will not be bundled inside the library.src/index.tsxdefines what CRA will render in browser during development.
|-- environment # development code
| └── App
| |-- App.js
| |-- App.module.css # CSS module
| |-- App.spec.js # test file
| |-- __snapshots__
| | └── App.spec.js.snap # test snapshot
| └── index.js
|-- index.js # entry point for CRA
|-- lib # library code
| |-- Component
| | |-- Component.js # Component will be exposed as a part of library
| | |-- Component.module.css # CSS module
| | |-- Component.spec.js # test file
| | |-- __snapshots__
| | | └── Component.spec.js.snap # test snapshot
| | └── index.js
| └── index.js # entry point for rollup build
└── setupTests.js