Skip to content

Commit

Permalink
docs: create website
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Dec 7, 2024
1 parent 982e711 commit 8164dac
Show file tree
Hide file tree
Showing 9 changed files with 665 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ yalc.lock
test/**/*.js.map
.DS_Store
test/**/tsconfig.json
!test/**/node_modules
!test/**/node_modules
.next
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,17 @@ It uses the standard exports configuration in `package.json` as the only source

### Installation

```sh
npm install --save-dev bunchee
```

If you're using TypeScript

```sh
npm install --save-dev bunchee typescript
```

### Configuration

#### Entry Files

Create your library entry file and `package.json`.
Create entry files of your library and `package.json`.

```sh
cd ./coffee
mkdir src && touch ./src/index.ts
mkdir src && touch ./src/index.ts && touch package.json
```

Add the exports in `package.json`.
Expand All @@ -57,8 +49,6 @@ Add the exports in `package.json`.

#### Build

Run the npm `build` script.

```sh
npm run build
```
Expand Down
50 changes: 50 additions & 0 deletions docs/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
* {
box-sizing: border-box;
}

html {
font-size: 16px;
font-family: 'Inter', sans-serif;
line-height: 1.5;
}

pre {
background-color: #f5f5f5;
padding: 1rem;
border-radius: 5px;
overflow-x: auto;
line-height: 1.5;
}

pre > code {
font-family: monospace;
font-size: 0.95rem;
color: #333;
display: block;
}

.root {
margin-left: auto;
margin-right: auto;
max-width: 700px;
padding-left: 5rem;
padding-right: 5rem;
}

.nav {
display: flex;
justify-content: space-between;
align-items: center;
}

.link {
text-decoration-line: underline;
color: #333;
}

a, a:visited {
color: #333;
}
a:hover {
color: #999;
}
10 changes: 10 additions & 0 deletions docs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import './globals.css'

export default function Layout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
69 changes: 69 additions & 0 deletions docs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react'

export default function Page() {
return (
<div className="root">
<nav className="nav">
<h2>Bunchee</h2>

<div className="link">
<a href="https://github.com/huozhi/bunchee">{`docs ↗`}</a>
</div>
</nav>
<h3>Installation</h3>
<pre>
<code>{`npm install --save-dev bunchee typescript`}</code>
</pre>

<h3>Configuration</h3>
<p>
Create entry files of your library and <code>package.json</code>.
</p>

<pre>
<code>
{`$ cd ./coffee
$ mkdir src && touch ./src/index.ts && touch package.json`}
</code>
</pre>

<p>
Add the exports in <code>package.json</code>.
</p>

<pre>
<code>
{`{
"name": "coffee",
"type": "module",
"main": "./dist/index.js",
"scripts": {
"build": "bunchee"
}
}`}
</code>
</pre>

<h4>Build</h4>
<p>
Run the npm <code>build</code> script.
</p>

<pre>
<code>{`$ npm run build`}</code>
</pre>

<h4>Output</h4>
<pre>
<code>
{`$ Exports File Size
$ . dist/index.js 5.6 kB`}
</code>
</pre>

<footer>
<p>huozhi © {new Date().getFullYear()}</p>
</footer>
</div>
)
}
5 changes: 5 additions & 0 deletions docs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
24 changes: 24 additions & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"noEmit": true,
"incremental": true,
"module": "esnext",
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"test:ci": "pnpm test -- --ci",
"test:update": "TEST_UPDATE_SNAPSHOT=1 pnpm test",
"test:post": "cross-env POST_BUILD=1 pnpm jest test/compile.test.ts test/integration.test.ts",
"docs:dev": "next dev docs",
"docs:build": "next build docs",
"clean": "rm -rf ./dist",
"typecheck": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
"prepare-release": "pnpm clean && pnpm build",
Expand Down Expand Up @@ -94,15 +96,18 @@
"@types/jest": "29.0.0",
"@types/node": "^22.9.3",
"@types/picomatch": "^3.0.1",
"@types/react": "19.0.1",
"@types/yargs": "^17.0.33",
"bunchee": "link:./",
"cross-env": "^7.0.3",
"husky": "^9.0.11",
"jest": "29.0.1",
"lint-staged": "^15.2.2",
"next": "^15.0.4",
"picocolors": "^1.0.0",
"prettier": "^3.0.0",
"react": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"typescript": "^5.6.2"
},
"lint-staged": {
Expand Down
Loading

0 comments on commit 8164dac

Please sign in to comment.