Skip to content

Commit

Permalink
docs: add readme for data content (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Dec 10, 2023
1 parent 423b0d8 commit 3e717a7
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Then you need to add two entry files `index.ts` and `lite.ts` in project root di

It will also look up for `index.<ext>` file under the directory having the name of the export path. For example, if you have `"./lite": "./dist/lite.js"` in exports field, then it will look up for `./lite/index.js` as the entry file as well.

### Special Exports Conventions
### Use Exports Conventions

For exports condition like `react-native`, `react-server` and `edge-light` as they're special platforms, they could have different exports or different code conditions. In this case bunchee provides an override input source file convention if you want to build them as different code bundle.

Expand Down Expand Up @@ -201,9 +201,12 @@ This will match the export name `"react-server"` and `"edge-light"` then use the
`bunchee` has support for checking the package bundles are matched with package exports configuration.


### `bin` Field Convention
### Executables

To build executable files with the `bin` field in package.json, `bunchee` requires you to create the `bin` directory inside your `src` directory.

To build executable files with the `bin` field in package.json, `bunchee` requires you to create the `bin` directory under `src` directory. The source file matching will be same as the entry files convention.

For example:

```bash
|- src/
Expand Down Expand Up @@ -241,7 +244,7 @@ This will match the `bin` field in package.json as:

> Note: For multiple `bin` files, the filename should match the key name in the `bin` field.
### Wildcard Exports (Experimental)
### Wildcard Exports

Bunchee implements the Node.js feature of using the asterisk `*` as a wildcard to match the exportable entry files.

Expand Down Expand Up @@ -315,6 +318,29 @@ import './style.css'
export const Foo = () => <div className="foo">foo</div>
```

### Text Files

If you just want to import a file as string content, you can name the extension as `.txt` or `.data` and it will be bundled as string content.

For example:

src/index.ts
```js
import data from './data.txt'

export default data
```

src/data.txt
```txt
hello world
```

output
```
export default "hello world"
```

### TypeScript

By default bunchee includes Typescript v3.9.x inside as a dependency. If you want to use your own version, just install typescript as another dev dependency then bunchee will automatically pick it.
Expand Down

0 comments on commit 3e717a7

Please sign in to comment.