Skip to content

Commit e245966

Browse files
committed
Create a bundled version (closes #4)
1 parent abf411d commit e245966

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,22 @@ https://youtu.be/TBd1miOrLPQ
2727

2828
## Install
2929

30+
Install from npm.
31+
3032
```console
3133
npm install @geckos.io/typed-array-buffer-schema
3234
```
3335

36+
Or use the bundled version.
37+
38+
```html
39+
<script src="https://unpkg.com/@geckos.io/[email protected]/bundle/typed-array-buffer-schema.js"></script>
40+
<script>
41+
const { BufferSchema, Model } = Schema
42+
const { uint8, int16, uint16, int64, string8,, ...more } Schema
43+
</script>
44+
```
45+
3446
## Snapshot Interpolation
3547

3648
You can easily combine this library with the Snapshot Interpolation library [@geckos.io/snapshot-interpolation](https://www.npmjs.com/package/@geckos.io/snapshot-interpolation).

bundle/typed-array-buffer-schema.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
"dev:tsc": "tsc --watch",
1010
"dev:nodemon": "nodemon lib/dev.js --watch lib",
1111
"build": "npm run clean && tsc",
12+
"bundle": "webpack --config webpack.bundle.js",
1213
"test": "jest --collectCoverage",
1314
"clean": "rimraf lib",
1415
"format": "prettier --write src/**/*.ts",
15-
"prepublishOnly": "npm run build && npm test"
16+
"prepublishOnly": "npm run build && npm test && npm run bundle"
1617
},
1718
"keywords": [
1819
"typed",
@@ -45,6 +46,7 @@
4546
"npm-run-all": "^4.1.5",
4647
"prettier": "^2.0.5",
4748
"rimraf": "^3.0.2",
49+
"ts-loader": "^8.0.3",
4850
"typescript": "^3.9.7"
4951
},
5052
"funding": {

src/bundle.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Lib as BufferSchema } from './lib'
2+
import { Model } from './model'
3+
import { int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64, string8, string16 } from './views'
4+
5+
export default {
6+
BufferSchema,
7+
Model,
8+
int8,
9+
uint8,
10+
int16,
11+
uint16,
12+
int32,
13+
uint32,
14+
int64,
15+
uint64,
16+
float32,
17+
float64,
18+
string8,
19+
string16
20+
}

webpack.bundle.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
mode: 'production',
5+
entry: './src/bundle.ts',
6+
output: {
7+
filename: 'typed-array-buffer-schema.js',
8+
path: path.resolve(__dirname, 'bundle'),
9+
library: 'Schema',
10+
libraryExport: 'default'
11+
},
12+
resolve: {
13+
extensions: ['.ts', '.tsx', '.js']
14+
},
15+
module: {
16+
rules: [{ test: /\.tsx?$/, loader: 'ts-loader' }]
17+
}
18+
}

0 commit comments

Comments
 (0)