UNPKG

3.28 kBMarkdownView Raw
1# RapidBundle
2
3[![Build](https://github.com/umidbekk/rapidbundle/workflows/Main/badge.svg)](https://github.com/umidbekk/rapidbundle/actions/workflows/main.yml)
4[![install size](https://packagephobia.com/badge?p=rapidbundle)](https://packagephobia.com/result?p=rapidbundle)
5[![npm version](https://img.shields.io/npm/v/rapidbundle.svg)](https://www.npmjs.com/package/rapidbundle)
6[![npm downloads](https://img.shields.io/npm/dm/rapidbundle.svg)](https://www.npmjs.com/package/rapidbundle)
7[![Codecov](https://img.shields.io/codecov/c/gh/umidbekk/rapidbundle.svg)](https://codecov.io/gh/umidbekk/rapidbundle)
8
9## Installation
10
11```bash
12npm i -D rapidbundle
13# or with yarn
14yarn add -D rapidbundle
15```
16
17## Usage
18
19```bash
20npx rapidbundle
21# or with yarn
22yarn rapidbundle
23```
24
25# GitHub Action
26
27- Creates a single file bundle for each entry
28- Scans `action.yml` to obtain build info
29
30 - Infers entries from the `.runs.main`, `.runs.pre` and `.runs.post` fields
31 - Infers target Node version from the `.runs.using` field
32
33### Constraints:
34
351. Entry file should be located in the `src` directory.
362. Output files should be located in the `dist` directory.
37
38This allows us to properly infer entry point name from the `action.yml`.
39
40For example, if you have `action.yml` like that:
41
42```yaml
43runs:
44 using: "node12"
45 pre: "./dist/setup.js"
46 main: "./dist/index.js"
47 post: "./dist/cleanup.js"
48```
49
50It will produce 3 output files in `dist` directory and look for the same file
51paths in `src` directory
52
53```
54├─ src
55│ ├─ setup.ts
56│ ├─ index.ts
57│ └─ cleanup.ts
58├─ dist
59│ ├─ setup.js
60│ ├─ index.js
61│ └─ cleanup.js
62└─ action.yml
63```
64
65# Node Package
66
67- Creates a single file bundle for each entry
68- Scans `package.json` to obtain build info
69
70 - Infers entries from the `.bin`, `.main`, `.module` and `.types` fields
71 - Infers target Node version from the `.engines.node` field
72
73### Constraints:
74
751. Entry file should be located in the `src` directory.
762. Output files should be located in the `dist` directory.
77
78This allows us to properly infer entry point names from the `package.json`.
79
80For example, if you have `package.json` like that:
81
82```json
83{
84 "bin": "./dist/cli.js",
85 "main": "./dist/index.cjs",
86 "module": "./dist/index.js",
87 "types": "./dist/index.d.ts"
88}
89```
90
91It will produce 3 output files in `dist` directory.
92
93```
94├─ src
95│ ├─ cli.ts
96│ └─ index.ts
97├─ dist
98│ ├─ cli.js
99│ ├─ index.js
100│ ├─ index.cjs
101│ └─ types.d.ts
102└─ action.yml
103```
104
105### Limitations
106
107File names should not have multiple `.` signs in it:
108
109- `dist/mod.js` will be mapped to `src/mod` and extension will be resolved automatically
110- `dist/mod.es.js` will be mapped to `src/mod.es` and will use `.es` extension
111
112### Babel Support
113
114There are limited support for Babel.
115We only support:
116
117- `.babel.test` – string value for `RegExp`
118- `.babel.plugins` – array of plugin entries (https://babeljs.io/docs/en/options#plugins)
119- `.babel.presets` – array of preset entries (https://babeljs.io/docs/en/options#presets)
120
121```json
122{
123 "main": "./dist/index.cjs",
124 "module": "./dist/index.js",
125 "babel": {
126 "test": "\\.tsx?",
127 "plugins": [["babel-plugin-styled-components", { "namespace": "app" }]]
128 }
129}
130```