Skip to content

Commit

Permalink
chore(library-builder): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed Jul 12, 2023
1 parent 1d15df4 commit be49322
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
48 changes: 36 additions & 12 deletions packages/library-builder/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,49 @@

This library provides tools and plugins for building UI libraries.

## Why you should use this library?
## Why you should use this library build tool?
There are few thing to consider when building UI library:
- Components must be tree-shakable (both JS and CSS).
- Components must be optimized for SSR.
- Library must provide Nuxt support.
- Web components (*)
- It must be easy and fast to build as UI library for Vuejs.
- Generates correct `exports` in `package.json`, so library works within any bundler and components are tree-shakable

Library produces builds:
- cjs - for node (SSR like vite-ssr)
- iife - for browsers
- es - for bundlers (like Vite)
- esm-node - for bundlers, but without vue and css plugins (pure Rollup)
- nuxt - nuxt module for nuxt3
- web-components - ES build optimized to be used as web-components (not ready for production usage yet)
- types - ts types
- styles - compiled css styles

## Usage
As a CLI:
```bash
library-build
```
Arguments:
- entry - path to main.ts file. Default `./src/main.ts`
- nuxtDir - path to nuxt folder where `module.ts` and `runtime` folder are stored. Default: entry file dir + `./nuxt`
- outDir - path where to put output files. Default `./dist`

As a library: (not ready yet)

## Recommended project structure

- src
- components
- [component-name]
- [component-name].vue
- composables
- nuxt (can be changed with nuxtDir argument)
- runtime
- plugin.ts
module.ts
- utils
- 📁 src
- 📁 components
- 📁 [component-name]
- 📄 [component-name].vue
- 📁 composables
- 📁 nuxt (can be changed with nuxtDir argument)
- 📁 runtime
- 📄 plugin.ts
- 📄 module.ts
- 📁 utils
- 📁 styles (*)

## Nuxt module

Expand Down
2 changes: 1 addition & 1 deletion packages/library-builder/src/builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const build = async (options: {
cwd = process.cwd(),
outDir = 'dist',
// TODO: Make it possible to build without web-components
targets = ['nuxt'], //'esm-node', 'cjs', 'iife', 'web-components', 'types', 'es'],
targets = ['nuxt', 'esm-node', 'cjs', 'iife', 'web-components', 'types', 'es'],
entry = 'src/main.ts',
nuxtDir = join(dirname(entry), 'nuxt'),
} = options
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Button } from './Button.vue'

0 comments on commit be49322

Please sign in to comment.