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