Skip to content

Commit

Permalink
Add bundled esm-build. Add installtion instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 18, 2022
1 parent 4d48846 commit 422f34f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@ ASN1.js V2 (ES2015 version) is **incompatible** with ASN1.js V1 code.
* All types can be initialized in static or dynamic ways.
* [ASN1js][] fully tested against [ASN.1:2008 TestSuite][].

## Installation

### Node

`npm install --save asn1js`

```javascript
// ESM
import { fromBER, /* ... */ } from "asn1js";

// CommonJS
const asn1js = require("asn1js");
```

### Browser

Import one of the following files using cdn or manual inclusion

* `src/asn1.js`: ESM with remote dependency of pvutils
* `build/asn1.bundle.mjs`: ESM with bundled pvutils

### Deno

Import `build/asn1.bundle.mjs` using you favorite method

## Examples

```javascript
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"babel-plugin-istanbul": "latest",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"@rollup/plugin-node-resolve": "^13.2.1",
"asn1-test-suite": "latest",
"babel-plugin-istanbul": "latest",
"cross-env": "latest",
"mocha": "latest",
"rollup": "latest",
"nyc": "latest",
"cross-env": "latest",
"rollup-plugin-node-resolve": "latest",
"asn1-test-suite": "latest"
"rollup": "latest",
"rollup-plugin-node-resolve": "latest"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -62,7 +63,7 @@
"index.d.ts"
],
"scripts": {
"build": "babel src --compact=false --out-dir build --source-maps",
"build": "babel src --compact=false --out-dir build --source-maps && rollup -c ./rollup.config.js",
"watch": "babel src --compact=false --out-dir build --source-maps --watch",
"ex1": "cd examples/ASN1Usage && npm run build && cd ../..",
"build:examples": "npm run ex1",
Expand Down
12 changes: 12 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';

export default [
{
input: "./src/asn1.js",
output: {
file: "build/asn1.bundle.mjs",
format: "es"
},
plugins: [nodeResolve()]
}
];

0 comments on commit 422f34f

Please sign in to comment.