-
Notifications
You must be signed in to change notification settings - Fork 16
/
export.sh
executable file
·92 lines (67 loc) · 2.37 KB
/
export.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
if [ "$1" = "debug" ]; then
DEBUG_ARG="--define:debug=true"
MINIFY_ARG=""
else
DEBUG_ARG="--define:debug=false"
MINIFY_ARG="--minify --line-limit=80"
fi
# CJS code: index.js
npx esbuild export/index.ts \
--format=cjs \
--bundle \
--keep-names \
--inject:shims/shims.js \
--target=es2020 \
--outfile=dist/npm/index.js \
$DEBUG_ARG $MINIFY_ARG
# ESM code: index.mjs
npx esbuild export/index.ts \
--format=esm \
--bundle \
--keep-names \
--inject:shims/shims.js \
--target=es2020 \
--outfile=dist/npm/index.mjs \
$DEBUG_ARG $MINIFY_ARG
# CJS TS types: index.d.ts
# updated manually
# ESM TS types: index.d.mts
echo "
// DON'T EDIT THIS FILE
// It's a simple automatic copy of index.d.ts
" > dist/npm/index.d.mts
cat dist/npm/index.d.ts >> dist/npm/index.d.mts
# static assets
cp LICENSE README.md CHANGELOG.md CONFIG.md DEPLOY.md DEVELOP.md dist/npm/
# Prepare jsr package
cp dist/npm/index.d.ts dist/jsr/
echo "/// <reference types=\"./index.d.ts\" />
" > dist/jsr/index.js
cat dist/npm/index.mjs >> dist/jsr/index.js
cp LICENSE README.md dist/jsr/
# Note: --keep-names adds about 10KB to the bundle size, but it gives us error
# messages and stack traces with no short, cryptic variable names
# WITHOUT (see `xe`, `pe`):
# Uncaught:
# xe [NeonDbError]: db error: ERROR: function xnow() does not exist
# HINT: No function matches the given name and argument types. You might need to add explicit type casts.
# Caused by:
# ERROR: function xnow() does not exist
# HINT: No function matches the given name and argument types. You might need to add explicit type casts.
# at processTicksAndRejections (node:internal/process/task_queues:95:5)
# at pe (/Users/george/Development/neon/pgshims/dist/npm/index.js:1459:56) {
# code: '42883',
# sourceError: undefined
# }
# WITH:
# Uncaught NeonDbError: db error: ERROR: function xnow() does not exist
# HINT: No function matches the given name and argument types. You might need to add explicit type casts.
# Caused by:
# ERROR: function xnow() does not exist
# HINT: No function matches the given name and argument types. You might need to add explicit type casts.
# at processTicksAndRejections (node:internal/process/task_queues:95:5)
# at execute (/Users/george/Development/neon/pgshims/dist/npm/index.js:1539:48) {
# code: '42883',
# sourceError: undefined
# }