Skip to content

Commit 22d46fa

Browse files
feat: updated forge.mjs and readme
1 parent fe06686 commit 22d46fa

File tree

3 files changed

+56859
-55500
lines changed

3 files changed

+56859
-55500
lines changed

extension/lib/README.md

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,70 @@ Libraries that remain here verbatim are planned to use this mechanism in the fut
66

77
Only add a copy of a library here if it's not published as a npm module.
88

9-
## How to update a non-minimzed forge.js
10-
1) Checkout the needed tag, e.g.
11-
```
12-
git clone -b v1.3.1 https://github.com/digitalbazaar/forge
9+
## How to update forge.js and forge.mjs
10+
11+
Both `forge.js` and `forge.mjs` need to be rebuilt when updating node-forge to a new version.
12+
13+
### 1) Clone the forge repository at the desired version
14+
15+
```bash
16+
git clone -b v1.3.2 https://github.com/digitalbazaar/forge
1317
cd forge
1418
```
1519

16-
2) In `webpack.config.js` add a line `devtool: 'cheap-module-source-map'` for the plain unoptimized unminified bundle configuration similar to what there is in the optimized and minified bundle configuration.
20+
Replace `v1.3.2` with the desired version tag.
1721

18-
3) Build the package
19-
```
20-
sudo apt install webpack
22+
### 2) Install dependencies
23+
24+
```bash
2125
npm install
26+
```
27+
28+
### 3) Build forge.js (UMD bundle with source maps)
29+
30+
In `webpack.config.js`, add a line `devtool: 'cheap-module-source-map'` in the plain unoptimized unminified bundle configuration (around line 82), similar to what exists in the optimized bundle configuration.
31+
32+
Then build:
33+
34+
```bash
2235
npm run build
2336
```
2437

25-
4) A newly-generated `forge.js` should appear in `dist` subfolder, copy it over the file in this repo.
38+
Copy `dist/forge.js` to `extension/lib/forge.js` in this repository.
39+
40+
### 4) Build forge.mjs (ES module)
41+
42+
Install rollup and create a rollup configuration:
43+
44+
```bash
45+
npm install --save-dev rollup @rollup/plugin-node-resolve @rollup/plugin-commonjs
46+
```
47+
48+
Create `rollup.config.js`:
49+
50+
```javascript
51+
import resolve from '@rollup/plugin-node-resolve';
52+
import commonjs from '@rollup/plugin-commonjs';
53+
54+
export default {
55+
input: 'lib/index.js',
56+
output: {
57+
file: 'dist/forge.mjs',
58+
format: 'es',
59+
sourcemap: true
60+
},
61+
plugins: [
62+
resolve(),
63+
commonjs()
64+
]
65+
};
66+
```
67+
68+
Build the ES module:
69+
70+
```bash
71+
npx rollup -c rollup.config.js
72+
```
73+
74+
Copy `dist/forge.mjs` to `extension/lib/forge.mjs` in this repository.
75+

0 commit comments

Comments
 (0)