File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Generates browser compatible versions of the package with dependencies
3
+ # bundled as well as the type declaration.
4
+ set -euo pipefail
5
+
6
+ entrypoint=./src/opa.js
7
+ outdir=./dist
8
+ package=$( node -pe ' require("./package.json").name.split("/").pop()' )
9
+
10
+ if [[ ! -x $( npm bin) /esbuild || ! -x $( npm bin) /tsc ]]; then
11
+ echo " Installing dependencies…"
12
+ npm install
13
+ fi
14
+
15
+ echo " Generating default browser build…"
16
+ $( npm bin) /esbuild $entrypoint \
17
+ --outfile=$outdir /$package -browser.js \
18
+ --bundle \
19
+ --sourcemap \
20
+ --minify \
21
+ --format=iife \
22
+ --platform=browser \
23
+ --define:global=window \
24
+ --global-name=opa
25
+
26
+ echo " Generating esm browser build…"
27
+ $( npm bin) /esbuild $entrypoint \
28
+ --outfile=$outdir /$package -browser.esm.js \
29
+ --bundle \
30
+ --sourcemap \
31
+ --minify \
32
+ --format=esm \
33
+ --platform=browser \
34
+ --define:global=window
35
+
36
+ echo " Generating TypeScript declaration file…"
37
+ $( npm bin) /tsc ./src/index.mjs \
38
+ --declaration \
39
+ --allowJs \
40
+ --emitDeclarationOnly \
41
+ --outDir $outdir
You can’t perform that action at this time.
0 commit comments