feat: plugin system with isolated bundles (#2660)

(cherry picked from commit 94d20f1bdc)
This commit is contained in:
Himself65
2023-06-02 16:28:47 +08:00
committed by himself65
parent 66653d1d8a
commit bb8bfd0c9e
19 changed files with 147 additions and 28 deletions

View File

@@ -2,7 +2,10 @@ import { resolve } from 'node:path';
import { fileURLToPath } from 'url';
export const root = fileURLToPath(new URL('..', import.meta.url));
export const electronDir = fileURLToPath(new URL('..', import.meta.url));
export const rootDir = resolve(electronDir, '..', '..');
export const NODE_MAJOR_VERSION = 18;
// hard-coded for now:
@@ -33,10 +36,13 @@ export const config = () => {
return {
main: {
entryPoints: [
resolve(root, './layers/main/src/index.ts'),
resolve(root, './layers/main/src/workers/merge-update.worker.ts'),
resolve(electronDir, './layers/main/src/index.ts'),
resolve(
electronDir,
'./layers/main/src/workers/merge-update.worker.ts'
),
],
outdir: resolve(root, './dist/layers/main'),
outdir: resolve(electronDir, './dist/layers/main'),
bundle: true,
target: `node${NODE_MAJOR_VERSION}`,
platform: 'node',
@@ -50,8 +56,8 @@ export const config = () => {
treeShaking: true,
},
preload: {
entryPoints: [resolve(root, './layers/preload/src/index.ts')],
outdir: resolve(root, './dist/layers/preload'),
entryPoints: [resolve(electronDir, './layers/preload/src/index.ts')],
outdir: resolve(electronDir, './dist/layers/preload'),
bundle: true,
target: `node${NODE_MAJOR_VERSION}`,
platform: 'node',