UNPKG

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