mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 23:47:54 +08:00
reduce production package size by set node-linker=hoisted
This commit is contained in:
Generated
-1108
File diff suppressed because it is too large
Load Diff
@@ -56,30 +56,14 @@ let puppeteer
|
|||||||
let StealthPlugin
|
let StealthPlugin
|
||||||
export async function initPuppeteer () {
|
export async function initPuppeteer () {
|
||||||
// production
|
// production
|
||||||
if (
|
const importResult = await Promise.all(
|
||||||
isRunFromUi && !isUiDev
|
[
|
||||||
) {
|
import('puppeteer-extra'),
|
||||||
const electron = await import('electron')
|
import('puppeteer-extra-plugin-stealth')
|
||||||
const runtimeDependencies = await import(
|
]
|
||||||
'file://' +
|
)
|
||||||
path.resolve(
|
puppeteer = importResult[0].default
|
||||||
electron.app.getAppPath(),
|
StealthPlugin = importResult[1].default
|
||||||
'..',
|
|
||||||
'external-node-runtime-dependencies/index.mjs'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
puppeteer = runtimeDependencies.puppeteerExtra.default
|
|
||||||
StealthPlugin = runtimeDependencies.PuppeteerExtraPluginStealth.default
|
|
||||||
} else {
|
|
||||||
const importResult = await Promise.all(
|
|
||||||
[
|
|
||||||
import('puppeteer-extra'),
|
|
||||||
import('puppeteer-extra-plugin-stealth')
|
|
||||||
]
|
|
||||||
)
|
|
||||||
puppeteer = importResult[0].default
|
|
||||||
StealthPlugin = importResult[1].default
|
|
||||||
}
|
|
||||||
puppeteer.use(StealthPlugin())
|
puppeteer.use(StealthPlugin())
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
-1108
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -21,14 +21,11 @@ import { VMarkAsNotSuitLog } from "./entity/VMarkAsNotSuitLog"
|
|||||||
import { ChatMessageRecord } from './entity/ChatMessageRecord'
|
import { ChatMessageRecord } from './entity/ChatMessageRecord'
|
||||||
|
|
||||||
import sqlite3 from 'sqlite3';
|
import sqlite3 from 'sqlite3';
|
||||||
import * as cliHighlight from 'cli-highlight';
|
|
||||||
import { saveChatStartupRecord, saveJobInfoFromRecommendPage, saveMarkAsNotSuitRecord } from "./handlers";
|
import { saveChatStartupRecord, saveJobInfoFromRecommendPage, saveMarkAsNotSuitRecord } from "./handlers";
|
||||||
import { UpdateChatStartupLogTable1729182577167 } from "./migrations/1729182577167-UpdateChatStartupLogTable";
|
import { UpdateChatStartupLogTable1729182577167 } from "./migrations/1729182577167-UpdateChatStartupLogTable";
|
||||||
import minimist from 'minimist'
|
import minimist from 'minimist'
|
||||||
import { UpdateBossInfoTable1732032381304 } from "./migrations/1732032381304-UpdateBossInfoTable";
|
import { UpdateBossInfoTable1732032381304 } from "./migrations/1732032381304-UpdateBossInfoTable";
|
||||||
|
|
||||||
Boolean(cliHighlight);
|
|
||||||
|
|
||||||
export function initDb(dbFilePath) {
|
export function initDb(dbFilePath) {
|
||||||
const { DataSource } = requireTypeorm()
|
const { DataSource } = requireTypeorm()
|
||||||
const appDataSource = new DataSource({
|
const appDataSource = new DataSource({
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import type TypeormType from 'typeorm'
|
|
||||||
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
||||||
const isUiDev = process.env.NODE_ENV === 'development'
|
const isUiDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
export function requireTypeorm (): typeof TypeormType {
|
export function requireTypeorm () {
|
||||||
const importResult = require('typeorm')
|
const importResult = require('typeorm')
|
||||||
return importResult
|
return importResult
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
electron_mirror=https://npmmirror.com/mirrors/electron/
|
electron_mirror=https://npmmirror.com/mirrors/electron/
|
||||||
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
|
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
|
||||||
shamefully-hoist=true
|
node-linker=hoisted
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ files:
|
|||||||
- '!node_modules/typeorm/browser/*'
|
- '!node_modules/typeorm/browser/*'
|
||||||
asarUnpack:
|
asarUnpack:
|
||||||
- 'resources/**'
|
- 'resources/**'
|
||||||
extraResources:
|
|
||||||
- external-node-runtime-dependencies/**
|
|
||||||
win:
|
win:
|
||||||
executableName: geekgeekrun
|
executableName: geekgeekrun
|
||||||
nsis:
|
nsis:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default defineConfig({
|
|||||||
main: {
|
main: {
|
||||||
build: {
|
build: {
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: ['puppeteer', 'puppeteer-extra', '@puppeteer/browsers', 'find-chrome-bin']
|
external: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
Object.assign(module.exports, {
|
|
||||||
puppeteerExtra: require('puppeteer-extra'),
|
|
||||||
PuppeteerExtraPluginStealth: require('puppeteer-extra-plugin-stealth'),
|
|
||||||
puppeteerManager: require('@puppeteer/browsers')
|
|
||||||
})
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
export * as puppeteerExtra from 'puppeteer-extra'
|
|
||||||
export * as PuppeteerExtraPluginStealth from 'puppeteer-extra-plugin-stealth'
|
|
||||||
export * as puppeteerManager from '@puppeteer/browsers'
|
|
||||||
export * as findChromeBin from 'find-chrome-bin'
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "geekgeekrun-external-node-runtime-dependencies",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "",
|
|
||||||
"main": "index.cjs",
|
|
||||||
"module": "index.mjs",
|
|
||||||
"scripts": {},
|
|
||||||
"author": "",
|
|
||||||
"license": "ISC",
|
|
||||||
"dependencies": {
|
|
||||||
"@puppeteer/browsers": "^2.0.0",
|
|
||||||
"find-chrome-bin": "^2.0.1",
|
|
||||||
"puppeteer": "20.1.0",
|
|
||||||
"puppeteer-extra": "3.3.6",
|
|
||||||
"puppeteer-extra-plugin-stealth": "2.11.2"
|
|
||||||
},
|
|
||||||
"packageManager": "npm"
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
"build:mac": "npm run build && electron-builder --mac",
|
"build:mac": "npm run build && electron-builder --mac",
|
||||||
"build:linux": "npm run build && electron-builder --linux",
|
"build:linux": "npm run build && electron-builder --linux",
|
||||||
"build:make-dist-for-current-platform": "npm run build && node ./scripts/make-dist-for-current-platform.mjs",
|
"build:make-dist-for-current-platform": "npm run build && node ./scripts/make-dist-for-current-platform.mjs",
|
||||||
"install": "cd ./external-node-runtime-dependencies && cross-env PUPPETEER_SKIP_DOWNLOAD=1 npm install --omit=dev",
|
|
||||||
"release": "node ./scripts/release-new-version.mjs"
|
"release": "node ./scripts/release-new-version.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -61,7 +60,7 @@
|
|||||||
"@vue/eslint-config-typescript": "^12.0.0",
|
"@vue/eslint-config-typescript": "^12.0.0",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"electron": "^28.2.0",
|
"electron": "28.2.0",
|
||||||
"electron-builder": "^24.9.1",
|
"electron-builder": "^24.9.1",
|
||||||
"electron-vite": "^2.0.0",
|
"electron-vite": "^2.0.0",
|
||||||
"element-plus": "^2.5.5",
|
"element-plus": "^2.5.5",
|
||||||
@@ -83,4 +82,4 @@
|
|||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"vue-tsc": "^1.8.27"
|
"vue-tsc": "^1.8.27"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-44
@@ -15,28 +15,7 @@ import gtag from '../../../../utils/gtag'
|
|||||||
|
|
||||||
const getPuppeteerManagerModule = async () => {
|
const getPuppeteerManagerModule = async () => {
|
||||||
let puppeteerManager
|
let puppeteerManager
|
||||||
if (process.env.NODE_ENV === 'development') {
|
puppeteerManager = await import('@puppeteer/browsers')
|
||||||
puppeteerManager = await import('@puppeteer/browsers')
|
|
||||||
} else if (isMainThread) {
|
|
||||||
const electron = await import('electron')
|
|
||||||
puppeteerManager = (
|
|
||||||
await import(
|
|
||||||
'file://' +
|
|
||||||
path.resolve(
|
|
||||||
electron.app.getAppPath(),
|
|
||||||
'..',
|
|
||||||
'external-node-runtime-dependencies/index.mjs'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).puppeteerManager
|
|
||||||
} else {
|
|
||||||
puppeteerManager = (
|
|
||||||
await import(
|
|
||||||
'file://' +
|
|
||||||
path.join(__dirname, '../../..', '/external-node-runtime-dependencies/index.mjs')
|
|
||||||
)
|
|
||||||
).puppeteerManager
|
|
||||||
}
|
|
||||||
|
|
||||||
return puppeteerManager
|
return puppeteerManager
|
||||||
}
|
}
|
||||||
@@ -177,28 +156,7 @@ export async function findAndLocateUserInstalledChromiumExecutableSync(): Promis
|
|||||||
|
|
||||||
// For other, use findChrome
|
// For other, use findChrome
|
||||||
let findChrome: typeof import('find-chrome-bin').findChrome
|
let findChrome: typeof import('find-chrome-bin').findChrome
|
||||||
if (process.env.NODE_ENV === 'development') {
|
findChrome = (await import('find-chrome-bin')).findChrome
|
||||||
findChrome = (await import('find-chrome-bin')).findChrome
|
|
||||||
} else if (isMainThread) {
|
|
||||||
const electron = await import('electron')
|
|
||||||
findChrome = (
|
|
||||||
await import(
|
|
||||||
'file://' +
|
|
||||||
path.resolve(
|
|
||||||
electron.app.getAppPath(),
|
|
||||||
'..',
|
|
||||||
'external-node-runtime-dependencies/index.mjs'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).findChromeBin.findChrome
|
|
||||||
} else {
|
|
||||||
findChrome = (
|
|
||||||
await import(
|
|
||||||
'file://' +
|
|
||||||
path.join(__dirname, '../../..', '/external-node-runtime-dependencies/index.mjs')
|
|
||||||
)
|
|
||||||
).findChromeBin.findChrome
|
|
||||||
}
|
|
||||||
const targetBrowser = await findChrome({
|
const targetBrowser = await findChrome({
|
||||||
min: exceptChromiumMainVersion
|
min: exceptChromiumMainVersion
|
||||||
})
|
})
|
||||||
|
|||||||
Generated
-1108
File diff suppressed because it is too large
Load Diff
Generated
+6
-2
@@ -191,7 +191,7 @@ importers:
|
|||||||
specifier: ^7.0.3
|
specifier: ^7.0.3
|
||||||
version: 7.0.3
|
version: 7.0.3
|
||||||
electron:
|
electron:
|
||||||
specifier: ^28.2.0
|
specifier: 28.2.0
|
||||||
version: 28.2.0
|
version: 28.2.0
|
||||||
electron-builder:
|
electron-builder:
|
||||||
specifier: ^24.9.1
|
specifier: ^24.9.1
|
||||||
@@ -1662,6 +1662,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-oZFKlC8l5YtzGQNT4zC2PiSSKzQVZ8bAwwd+EYdPLtyk0nSEq6O16SkK+rkkT2eflDAbormJgEF3QnH3oDrTSw==}
|
resolution: {integrity: sha512-oZFKlC8l5YtzGQNT4zC2PiSSKzQVZ8bAwwd+EYdPLtyk0nSEq6O16SkK+rkkT2eflDAbormJgEF3QnH3oDrTSw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 5.26.5
|
undici-types: 5.26.5
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/plist@3.0.5:
|
/@types/plist@3.0.5:
|
||||||
resolution: {integrity: sha512-E6OCaRmAe4WDmWNsL/9RMqdkkzDCY1etutkflWk4c+AcjDU07Pcz1fQwTX0TQz+Pxqn9i4L1TU3UFpjnrcDgxA==}
|
resolution: {integrity: sha512-E6OCaRmAe4WDmWNsL/9RMqdkkzDCY1etutkflWk4c+AcjDU07Pcz1fQwTX0TQz+Pxqn9i4L1TU3UFpjnrcDgxA==}
|
||||||
@@ -2571,6 +2572,7 @@ packages:
|
|||||||
|
|
||||||
/boolean@3.2.0:
|
/boolean@3.2.0:
|
||||||
resolution: {integrity: sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==}
|
resolution: {integrity: sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==}
|
||||||
|
deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
@@ -3275,7 +3277,7 @@ packages:
|
|||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@electron/get': 2.0.3
|
'@electron/get': 2.0.3
|
||||||
'@types/node': 18.19.9
|
'@types/node': 18.19.15
|
||||||
extract-zip: 2.0.1
|
extract-zip: 2.0.1
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
@@ -4912,6 +4914,7 @@ packages:
|
|||||||
|
|
||||||
/npmlog@5.0.1:
|
/npmlog@5.0.1:
|
||||||
resolution: {integrity: sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==}
|
resolution: {integrity: sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==}
|
||||||
|
deprecated: This package is no longer supported.
|
||||||
dependencies:
|
dependencies:
|
||||||
are-we-there-yet: 2.0.0
|
are-we-there-yet: 2.0.0
|
||||||
console-control-strings: 1.1.0
|
console-control-strings: 1.1.0
|
||||||
@@ -4922,6 +4925,7 @@ packages:
|
|||||||
/npmlog@6.0.2:
|
/npmlog@6.0.2:
|
||||||
resolution: {integrity: sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==}
|
resolution: {integrity: sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==}
|
||||||
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
|
||||||
|
deprecated: This package is no longer supported.
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dependencies:
|
dependencies:
|
||||||
are-we-there-yet: 3.0.1
|
are-we-there-yet: 3.0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user