@botpress/client 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build.ts ADDED
@@ -0,0 +1,58 @@
1
+ import esbuild from 'esbuild'
2
+
3
+ const common: esbuild.BuildOptions = {
4
+ bundle: true,
5
+ minify: true,
6
+ sourcemap: true,
7
+ }
8
+
9
+ const buildNode = () =>
10
+ esbuild.build({
11
+ ...common,
12
+ platform: 'node',
13
+ format: 'cjs',
14
+ external: ['axios', 'browser-or-node'],
15
+ outfile: 'dist/index.cjs',
16
+ entryPoints: ['src/index.ts'],
17
+ })
18
+
19
+ const buildBrowser = () =>
20
+ esbuild.build({
21
+ ...common,
22
+ platform: 'browser',
23
+ format: 'esm',
24
+ external: ['crypto', 'axios', 'browser-or-node'],
25
+ outfile: 'dist/index.mjs',
26
+ entryPoints: ['src/index.ts'],
27
+ })
28
+
29
+ const buildBundle = () =>
30
+ esbuild.build({
31
+ ...common,
32
+ platform: 'node',
33
+ outfile: 'dist/bundle.cjs',
34
+ entryPoints: ['src/index.ts'],
35
+ })
36
+
37
+ const main = async (argv: string[]) => {
38
+ if (argv.includes('--node')) {
39
+ return buildNode()
40
+ }
41
+ if (argv.includes('--browser')) {
42
+ return buildBrowser()
43
+ }
44
+ if (argv.includes('--bundle')) {
45
+ return buildBundle()
46
+ }
47
+ throw new Error('Please specify --node, --browser, or --bundle')
48
+ }
49
+
50
+ void main(process.argv.slice(2))
51
+ .then(() => {
52
+ console.info('Done')
53
+ process.exit(0)
54
+ })
55
+ .catch((error) => {
56
+ console.error(error)
57
+ process.exit(1)
58
+ })