Skip to content

Commit 6270d39

Browse files
committed
added build script
1 parent 0712b2d commit 6270d39

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ IndexedDB is allowed more storage space than localStorage. It can also store mor
66

77
IndexedDB can do a _lot_ more, but the reasons above are enough to use it even in relatively simple cases. This DataStore class is woefully underusing IndexedDB features. It merely replicates localStorage but by using IndexedDB behind the scenes for its advantages.
88

9+
## Install
10+
11+
_Instructions coming soon_
12+
913
## Usage
1014

1115
While DataStore aims to be as simple as localStorage, it does have one extra setup step: you must create an instance.

build.mjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as esbuild from 'esbuild';
2+
3+
// ESM build options
4+
const esmBuildOptions = {
5+
entryPoints: ['DataStore.js'],
6+
outfile: 'dist/datastore.esm.js',
7+
bundle: true,
8+
format: 'esm',
9+
};
10+
11+
// ESM build
12+
esbuild.build(esmBuildOptions);
13+
14+
// Minified ESM build
15+
esbuild.build({
16+
...esmBuildOptions,
17+
outfile: 'dist/datastore.esm.min.js',
18+
minify: true,
19+
});
20+
21+
// Global build options
22+
const globalBuildOptions = {
23+
entryPoints: ['DataStore.js'],
24+
outfile: 'dist/datastore.global.js',
25+
bundle: true,
26+
format: 'iife',
27+
globalName: '_DataStoreExports',
28+
footer: {
29+
js: 'window.DataStore = _DataStoreExports.default;',
30+
},
31+
};
32+
33+
// Global build
34+
esbuild.build(globalBuildOptions);
35+
36+
// Minified global build
37+
esbuild.build({
38+
...globalBuildOptions,
39+
outfile: 'dist/datastore.global.min.js',
40+
minify: true,
41+
});

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
"description": "Save data to IndexedDB using localStorage APIs.",
55
"main": "DataStore.js",
66
"scripts": {
7-
"build:esm:min": "esbuild DataStore.js --bundle --minify --format=esm --outfile=dist/datastore.esm.min.js",
8-
"build:esm": "esbuild DataStore.js --bundle --format=esm --outfile=dist/datastore.esm.js",
9-
"build:global:min": "esbuild DataStore.js --bundle --minify --format=iife --outfile=dist/datastore.global.min.js",
10-
"build:global": "esbuild DataStore.js --bundle --format=iife --outfile=dist/datastore.global.js",
11-
"build": "npm run build:esm && npm run build:global && npm run build:esm:min && npm run build:global:min"
7+
"build": "node build.mjs"
128
},
139
"repository": {
1410
"type": "git",

0 commit comments

Comments
 (0)