Skip to content

Commit

Permalink
update readme and package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
luisfilipegoncalves committed Dec 8, 2020
1 parent 19147d8 commit 213e3ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 63 deletions.
79 changes: 18 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# TSDX React w/ Storybook User Guide
# Taikai Design System

Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.

> This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
Built with [TSDX](https://tsdx.io/)

> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
Expand Down Expand Up @@ -60,35 +58,6 @@ Jest tests are set up to run with `npm test` or `yarn test`.

Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.

#### Setup Files

This is the folder structure we set up for you:

```txt
/example
index.html
index.tsx # test your component here in a demo app
package.json
tsconfig.json
/src
index.tsx # EDIT THIS
/test
blah.test.tsx # EDIT THIS
/stories
Thing.stories.tsx # EDIT THIS
/.storybook
main.js
preview.js
.gitignore
package.json
README.md # EDIT THIS
tsconfig.json
```

#### React Testing Library

We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.

### Rollup

TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
Expand Down Expand Up @@ -122,12 +91,6 @@ if (__DEV__) {

You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.

## Module Formats

CJS, ESModules, and UMD module formats are supported.

The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.

## Deploying the Example Playground

The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
Expand All @@ -147,35 +110,29 @@ netlify init
# pick yes for netlify.toml
```

## Named Exports
## Publishing to Github Package Registry

Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
We are using [np](https://github.com/sindresorhus/np)

## Including Styles

There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.

For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.

## Publishing to NPM
```bash
npm install --global np
```

We recommend using [np](https://github.com/sindresorhus/np).
### Get Github Personnal Access Token

## Usage with Lerna
Follow this guide:
https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token

When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
you need the following scopes (read:packages, write:packages, delete:packages, repo).

The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
Once you get the TOKEN, you can login:

Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
```
$ npm login --scope=@OWNER --registry=https://npm.pkg.github.com
```diff
"alias": {
- "react": "../node_modules/react",
- "react-dom": "../node_modules/react-dom"
+ "react": "../../../node_modules/react",
+ "react-dom": "../../../node_modules/react-dom"
},
> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
```

An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"version": "0.1.1-1",
"license": "MIT",
"repository": "taikai/taikai-design-system",
"repository": {
"type": "git",
"url": "https://github.com/taikai/taikai-design-system.git"
},
"keywords": [
"react",
"design-system",
Expand Down Expand Up @@ -43,7 +46,7 @@
"singleQuote": true,
"trailingComma": "es5"
},
"name": "taikai-design-system",
"name": "@taikai/taikai-design-system",
"author": "taikai",
"module": "dist/taikai-design-system.esm.js",
"size-limit": [
Expand Down

0 comments on commit 213e3ed

Please sign in to comment.