chore: reduce bundle size (#1970)

* chore: reduce bundle size

* chore: trimming langchainjs

* chore: trim pdf-parse
This commit is contained in:
Louis 2024-02-09 19:23:56 +07:00 committed by GitHub
parent bb11bc2933
commit eb09399fbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 26 additions and 32 deletions

View File

@ -11,7 +11,6 @@
"productName": "Jan", "productName": "Jan",
"files": [ "files": [
"renderer/**/*", "renderer/**/*",
"build/*.{js,map}",
"build/**/*.{js,map}", "build/**/*.{js,map}",
"pre-install", "pre-install",
"models/**/*", "models/**/*",
@ -77,7 +76,6 @@
"@janhq/core": "link:./core", "@janhq/core": "link:./core",
"@janhq/server": "link:./server", "@janhq/server": "link:./server",
"@npmcli/arborist": "^7.1.0", "@npmcli/arborist": "^7.1.0",
"@types/request": "^2.48.12",
"@uiball/loaders": "^1.3.0", "@uiball/loaders": "^1.3.0",
"electron-store": "^8.1.0", "electron-store": "^8.1.0",
"electron-updater": "^6.1.7", "electron-updater": "^6.1.7",
@ -86,8 +84,6 @@
"pacote": "^17.0.4", "pacote": "^17.0.4",
"request": "^2.88.2", "request": "^2.88.2",
"request-progress": "^3.0.0", "request-progress": "^3.0.0",
"rimraf": "^5.0.5",
"typescript": "^5.2.2",
"ulid": "^2.3.0", "ulid": "^2.3.0",
"use-debounce": "^9.0.4" "use-debounce": "^9.0.4"
}, },
@ -96,6 +92,7 @@
"@playwright/test": "^1.38.1", "@playwright/test": "^1.38.1",
"@types/npmcli__arborist": "^5.6.4", "@types/npmcli__arborist": "^5.6.4",
"@types/pacote": "^11.1.7", "@types/pacote": "^11.1.7",
"@types/request": "^2.48.12",
"@typescript-eslint/eslint-plugin": "^6.7.3", "@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3", "@typescript-eslint/parser": "^6.7.3",
"electron": "28.0.0", "electron": "28.0.0",
@ -103,7 +100,9 @@
"electron-devtools-installer": "^3.2.0", "electron-devtools-installer": "^3.2.0",
"electron-playwright-helpers": "^1.6.0", "electron-playwright-helpers": "^1.6.0",
"eslint-plugin-react": "^7.33.2", "eslint-plugin-react": "^7.33.2",
"run-script-os": "^1.1.6" "rimraf": "^5.0.5",
"run-script-os": "^1.1.6",
"typescript": "^5.2.2"
}, },
"installConfig": { "installConfig": {
"hoistingLimits": "workspaces" "hoistingLimits": "workspaces"

View File

@ -7,7 +7,8 @@
"author": "Jan <service@jan.ai>", "author": "Jan <service@jan.ai>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"scripts": { "scripts": {
"build": "tsc --module commonjs && rollup -c rollup.config.ts", "clean:modules": "rimraf node_modules/pdf-parse/test && cd node_modules/pdf-parse/lib/pdf.js && rimraf v1.9.426 v1.10.88 v2.0.550",
"build": "yarn clean:modules && tsc --module commonjs && rollup -c rollup.config.ts",
"build:publish:linux": "rimraf *.tgz --glob && npm run build && npm pack && cpx *.tgz ../../pre-install", "build:publish:linux": "rimraf *.tgz --glob && npm run build && npm pack && cpx *.tgz ../../pre-install",
"build:publish:darwin": "rimraf *.tgz --glob && npm run build && ../../.github/scripts/auto-sign.sh && npm pack && cpx *.tgz ../../pre-install", "build:publish:darwin": "rimraf *.tgz --glob && npm run build && ../../.github/scripts/auto-sign.sh && npm pack && cpx *.tgz ../../pre-install",
"build:publish:win32": "rimraf *.tgz --glob && npm run build && npm pack && cpx *.tgz ../../pre-install", "build:publish:win32": "rimraf *.tgz --glob && npm run build && npm pack && cpx *.tgz ../../pre-install",
@ -25,7 +26,7 @@
"rollup-plugin-define": "^1.0.1", "rollup-plugin-define": "^1.0.1",
"rollup-plugin-sourcemaps": "^0.6.3", "rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.36.0", "rollup-plugin-typescript2": "^0.36.0",
"typescript": "^5.3.3", "typescript": "^5.2.2",
"run-script-os": "^1.1.6" "run-script-os": "^1.1.6"
}, },
"dependencies": { "dependencies": {
@ -44,9 +45,6 @@
], ],
"bundleDependencies": [ "bundleDependencies": [
"@janhq/core", "@janhq/core",
"@langchain/community", "hnswlib-node"
"hnswlib-node",
"langchain",
"pdf-parse"
] ]
} }

View File

@ -48,9 +48,6 @@ export default [
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash') // Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [ external: [
"@janhq/core/node", "@janhq/core/node",
"@langchain/community",
"langchain",
"langsmith",
"path", "path",
"hnswlib-node", "hnswlib-node",
], ],

View File

@ -17,12 +17,12 @@
"cpx": "^1.5.0", "cpx": "^1.5.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"webpack": "^5.88.2", "webpack": "^5.88.2",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4",
"ts-loader": "^9.5.0"
}, },
"dependencies": { "dependencies": {
"@janhq/core": "file:../../core", "@janhq/core": "file:../../core",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1"
"ts-loader": "^9.5.0"
}, },
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"

View File

@ -35,12 +35,12 @@
"rollup-plugin-sourcemaps": "^0.6.3", "rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.36.0", "rollup-plugin-typescript2": "^0.36.0",
"run-script-os": "^1.1.6", "run-script-os": "^1.1.6",
"typescript": "^5.2.2" "typescript": "^5.2.2",
"@types/os-utils": "^0.0.4",
"@rollup/plugin-replace": "^5.0.5"
}, },
"dependencies": { "dependencies": {
"@janhq/core": "file:../../core", "@janhq/core": "file:../../core",
"@rollup/plugin-replace": "^5.0.5",
"@types/os-utils": "^0.0.4",
"fetch-retry": "^5.0.6", "fetch-retry": "^5.0.6",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",

View File

@ -18,13 +18,13 @@
"cpx": "^1.5.0", "cpx": "^1.5.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"webpack": "^5.88.2", "webpack": "^5.88.2",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4",
"ts-loader": "^9.5.0"
}, },
"dependencies": { "dependencies": {
"@janhq/core": "file:../../core", "@janhq/core": "file:../../core",
"fetch-retry": "^5.0.6", "fetch-retry": "^5.0.6",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1",
"ts-loader": "^9.5.0",
"ulid": "^2.3.0" "ulid": "^2.3.0"
}, },
"engines": { "engines": {

View File

@ -18,13 +18,13 @@
"cpx": "^1.5.0", "cpx": "^1.5.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"webpack": "^5.88.2", "webpack": "^5.88.2",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4",
"ts-loader": "^9.5.0"
}, },
"dependencies": { "dependencies": {
"@janhq/core": "file:../../core", "@janhq/core": "file:../../core",
"fetch-retry": "^5.0.6", "fetch-retry": "^5.0.6",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1",
"ts-loader": "^9.5.0",
"ulid": "^2.3.0", "ulid": "^2.3.0",
"rxjs": "^7.8.1" "rxjs": "^7.8.1"
}, },

View File

@ -14,7 +14,8 @@
"cpx": "^1.5.0", "cpx": "^1.5.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"webpack": "^5.88.2", "webpack": "^5.88.2",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4",
"ts-loader": "^9.5.0"
}, },
"files": [ "files": [
"dist/*", "dist/*",
@ -23,7 +24,6 @@
], ],
"dependencies": { "dependencies": {
"@janhq/core": "file:../../core", "@janhq/core": "file:../../core",
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1"
"ts-loader": "^9.5.0"
} }
} }

View File

@ -13,12 +13,12 @@
"devDependencies": { "devDependencies": {
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"webpack": "^5.88.2", "webpack": "^5.88.2",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4",
"ts-loader": "^9.5.0"
}, },
"dependencies": { "dependencies": {
"@janhq/core": "file:../../core", "@janhq/core": "file:../../core",
"node-os-utils": "^1.3.7", "node-os-utils": "^1.3.7"
"ts-loader": "^9.5.0"
}, },
"files": [ "files": [
"dist/*", "dist/*",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 MiB

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 MiB

After

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 352 KiB

View File

@ -10,7 +10,7 @@ const ExploreModelList: React.FC<Props> = ({ models }) => {
const takenModelIds: string[] = [] const takenModelIds: string[] = []
const featuredModels = models const featuredModels = models
.filter((m) => { .filter((m) => {
if (m.metadata.tags.includes('Featured')) { if (m.metadata?.tags?.includes('Featured')) {
takenModelIds.push(m.id) takenModelIds.push(m.id)
return m return m
} }
@ -19,7 +19,7 @@ const ExploreModelList: React.FC<Props> = ({ models }) => {
const recommendedModels = models const recommendedModels = models
.filter((m) => { .filter((m) => {
if (m.metadata.tags.includes('Recommended')) { if (m.metadata?.tags?.includes('Recommended')) {
takenModelIds.push(m.id) takenModelIds.push(m.id)
return m return m
} }