Skip to content

Commit

Permalink
add command for analyzing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbasten17 committed May 18, 2023
1 parent 9eb4b8c commit 45d23da
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
36 changes: 32 additions & 4 deletions tutorial/esbuild-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs, { readFileSync } from 'fs'
import fs, { readFileSync, writeFileSync } from 'fs'
import path, { join } from 'path'
import esbuild from 'esbuild'
import { sassPlugin } from 'esbuild-sass-plugin'
Expand All @@ -24,6 +24,7 @@ const nodeBundle: esbuild.BuildOptions = {
minify: true,
sourcemap: true,
keepNames: true,
metafile: true,
format: 'cjs',
external: ['esbuild'],
loader: {
Expand All @@ -47,6 +48,7 @@ const webchatBundle: esbuild.BuildOptions = {
sourcemap: false,
keepNames: true,
format: 'iife',
metafile: true,
globalName: 'Botonic',
external: ['esbuild'],
loader: {
Expand Down Expand Up @@ -123,6 +125,32 @@ const webviewsBundle: esbuild.BuildOptions = {
],
}

esbuild.build(nodeBundle).catch(() => process.exit(1))
esbuild.build(webchatBundle).catch(() => process.exit(1))
esbuild.build(webviewsBundle).catch(() => process.exit(1))
async function botonicBundle() {
const nodeBundleResult = await esbuild
.build(nodeBundle)
.catch(() => process.exit(1))

fs.writeFileSync(
'meta-node-bundle.json',
JSON.stringify(nodeBundleResult.metafile),
)

const webchatBundleResult = await esbuild
.build(webchatBundle)
.catch(() => process.exit(1))

fs.writeFileSync(
'meta-webchat-bundle.json',
JSON.stringify(webchatBundleResult.metafile),
)
const webviewsBundleResult = await esbuild
.build(webviewsBundle)
.catch(() => process.exit(1))

fs.writeFileSync(
'meta-webviews-bundle.json',
JSON.stringify(webviewsBundleResult.metafile),
)
}

botonicBundle()
4 changes: 3 additions & 1 deletion tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "tutorial",
"version": "1.0.0",
"scripts": {
"analyze": "esbuild-visualizer --metadata ./meta.json",
"build": "ts-node ./esbuild-config.ts",
"build:webpack": "rm -rf ./dist; webpack --env target=all --mode=production;",
"start": "webpack serve --env target=dev --mode=development",
Expand All @@ -22,7 +23,7 @@
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"@botonic/react": "0.22.0-alpha.2",
"@botonic/react": "0.22.0-beta.1",
"@types/node": "^18.16.1",
"core-js": "^3.30.2"
},
Expand All @@ -45,6 +46,7 @@
"esbuild-plugin-imagemin": "^1.0.1",
"esbuild-plugin-inline-image": "0.0.9",
"esbuild-sass-plugin": "^2.9.0",
"esbuild-visualizer": "^0.4.0",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.0.0-alpha.17",
"imagemin-gifsicle": "^6.0.0",
Expand Down

0 comments on commit 45d23da

Please sign in to comment.