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
|
12 | npm i -D rapidbundle
|
13 | # or with yarn
|
14 | yarn add -D rapidbundle
|
15 | ```
|
16 |
|
17 | ## Usage
|
18 |
|
19 | ```bash
|
20 | npx rapidbundle
|
21 | # or with yarn
|
22 | yarn 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 |
|
35 | 1. Entry file should be located in the `src` directory.
|
36 | 2. Output files should be located in the `dist` directory.
|
37 |
|
38 | This allows us to properly infer entry point name from the `action.yml`.
|
39 |
|
40 | For example, if you have `action.yml` like that:
|
41 |
|
42 | ```yaml
|
43 | runs:
|
44 | using: "node12"
|
45 | pre: "./dist/setup.js"
|
46 | main: "./dist/index.js"
|
47 | post: "./dist/cleanup.js"
|
48 | ```
|
49 |
|
50 | It will produce 3 output files in `dist` directory and look for the same file
|
51 | paths 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 |
|
75 | 1. Entry file should be located in the `src` directory.
|
76 | 2. Output files should be located in the `dist` directory.
|
77 |
|
78 | This allows us to properly infer entry point names from the `package.json`.
|
79 |
|
80 | For 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 |
|
91 | It 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 |
|
107 | File 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
|