@botpress/webchat 2.6.2-beta.0 → 3.0.0

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.
@@ -1,22 +1,21 @@
1
1
 
2
- > @botpress/webchat@2.6.2-beta.0 build /home/runner/work/genisys/genisys/packages/webchat-components
2
+ > @botpress/webchat@3.0.0 build /home/runner/work/genisys/genisys/packages/webchat-components
3
3
  > vite build
4
4
 
5
5
  vite v5.4.8 building for production...
6
6
  transforming...
7
- [plugin:vite:resolve] [plugin vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/home/runner/work/genisys/genisys/node_modules/.pnpm/@bpinternal+webchat-http-client@0.2.6/node_modules/@bpinternal/webchat-http-client/dist/index.mjs". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
8
- ✓ 2984 modules transformed.
7
+ ✓ 3046 modules transformed.
9
8
  rendering chunks...
10
9
 
11
10
  [vite:dts] Start generate declaration files...
12
11
  computing gzip size...
13
- dist/style.css  40.03 kB │ gzip: 7.37 kB
14
- dist/index.js 1,132.84 kB │ gzip: 292.32 kB
12
+ dist/style.css  44.76 kB │ gzip: 8.25 kB
13
+ dist/index.js 776.75 kB │ gzip: 212.99 kB
15
14
  [vite:dts] Start rollup declaration files...
16
15
  Analysis will use the bundled TypeScript version 5.4.2
17
16
  *** The target project appears to use TypeScript 5.6.2 which is newer than the bundled compiler engine; consider upgrading API Extractor.
18
- [vite:dts] Declaration files built in 31756ms.
17
+ [vite:dts] Declaration files built in 21441ms.
19
18
 
20
- dist/style.css  40.03 kB │ gzip: 7.37 kB
21
- dist/index.umd.cjs 771.48 kB │ gzip: 241.47 kB
22
- ✓ built in 39.95s
19
+ dist/style.css  44.76 kB │ gzip: 8.25 kB
20
+ dist/index.umd.cjs 517.62 kB │ gzip: 174.18 kB
21
+ ✓ built in 28.74s
@@ -0,0 +1,68 @@
1
+ import zlib from 'node:zlib'
2
+ import fs from 'node:fs'
3
+
4
+ const ESM_BUNDLE_SIZE_LIMIT = 250000
5
+ const CJS_BUNDLE_SIZE_LIMIT = 200000
6
+
7
+ class BundleSizeExceededError extends Error {
8
+ constructor(filePath, maxSize, actualSize) {
9
+ super(
10
+ `BUNDLE SIZE EXCEEDED: ${filePath} exceeded max size of ${maxSize / 1000}kB. Actual size is ${actualSize / 1000}kB (gzipped).`
11
+ )
12
+ }
13
+ }
14
+
15
+ class BundleSizeInfo {
16
+ constructor(filePath, actualSize) {
17
+ this.message = `BUNDLE SIZE OK: ${filePath} actual size is ${actualSize / 1000}kB (gzipped).`
18
+ }
19
+ }
20
+
21
+ async function reportResults(results) {
22
+ let failed = false
23
+
24
+ for (const result of results) {
25
+ if (result.status === 'rejected') {
26
+ failed = true
27
+ if (result.reason instanceof BundleSizeExceededError) {
28
+ console.error(result.reason.message)
29
+ } else {
30
+ console.error('An unknown error occured when computing the bundle size')
31
+ console.error(result.reason)
32
+ }
33
+ } else {
34
+ console.log(result.value.message)
35
+ }
36
+ }
37
+
38
+ if (failed) {
39
+ process.exit(-1)
40
+ }
41
+ }
42
+
43
+ async function assertGzipSizeBelowThreshold(filePath, maxBytes) {
44
+ const size = await getGzipSize(filePath)
45
+
46
+ if (size > maxBytes) {
47
+ throw new BundleSizeExceededError(filePath, maxBytes, size)
48
+ } else {
49
+ return new BundleSizeInfo(filePath, size)
50
+ }
51
+ }
52
+
53
+ async function getGzipSize(filePath) {
54
+ const gzipStream = fs.createReadStream(filePath).pipe(zlib.createGzip())
55
+
56
+ let size = 0
57
+
58
+ for await (const chunk of gzipStream) {
59
+ size += chunk.byteLength
60
+ }
61
+
62
+ return size
63
+ }
64
+
65
+ await Promise.allSettled([
66
+ assertGzipSizeBelowThreshold('dist/index.js', ESM_BUNDLE_SIZE_LIMIT),
67
+ assertGzipSizeBelowThreshold('dist/index.umd.cjs', CJS_BUNDLE_SIZE_LIMIT),
68
+ ]).then(reportResults)