From ae182bfd785ffe6796896f7ac9953f889bb74c1a Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 19 Jul 2023 17:58:51 +0800 Subject: [PATCH] chore: update runtime (#3312) --- apps/core/.webpack/config.ts | 2 +- apps/core/.webpack/webpack.config.ts | 7 ++++++- apps/core/src/bootstrap/before-app.ts | 1 + apps/core/src/bootstrap/register-plugins.ts | 2 +- apps/core/src/index.tsx | 1 - apps/electron/src/main/index.ts | 2 ++ 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/core/.webpack/config.ts b/apps/core/.webpack/config.ts index 2ad658a2f5..22b08fc63f 100644 --- a/apps/core/.webpack/config.ts +++ b/apps/core/.webpack/config.ts @@ -249,7 +249,7 @@ export const createConfiguration: ( inject: 'body', scriptLoading: 'defer', minify: false, - chunks: ['index'], + chunks: ['index', 'plugin'], filename: 'index.html', }), new MiniCssExtractPlugin({ diff --git a/apps/core/.webpack/webpack.config.ts b/apps/core/.webpack/webpack.config.ts index 5e43fb2c6c..9c58cf63cc 100644 --- a/apps/core/.webpack/webpack.config.ts +++ b/apps/core/.webpack/webpack.config.ts @@ -15,9 +15,14 @@ export default async function (cli_env: any, _: any) { return merge(config, { entry: { index: { - asyncChunks: true, + asyncChunks: false, import: resolve(rootPath, 'src/index.tsx'), }, + plugin: { + dependOn: ['index'], + asyncChunks: true, + import: resolve(rootPath, 'src/bootstrap/register-plugins.ts'), + }, }, }); } diff --git a/apps/core/src/bootstrap/before-app.ts b/apps/core/src/bootstrap/before-app.ts index 94b8d401f2..526faef857 100644 --- a/apps/core/src/bootstrap/before-app.ts +++ b/apps/core/src/bootstrap/before-app.ts @@ -21,6 +21,7 @@ import { rootStore } from '@toeverything/plugin-infra/manager'; import { WorkspaceAdapters } from '../adapters/workspace'; +console.log('setup global'); setupGlobal(); rootStore.set( diff --git a/apps/core/src/bootstrap/register-plugins.ts b/apps/core/src/bootstrap/register-plugins.ts index fe7b54f107..15d6eec7ed 100644 --- a/apps/core/src/bootstrap/register-plugins.ts +++ b/apps/core/src/bootstrap/register-plugins.ts @@ -3,4 +3,4 @@ if (runtimeConfig.enablePlugin) { import('@affine/copilot'); } -export {}; +console.log('register plugins finished'); diff --git a/apps/core/src/index.tsx b/apps/core/src/index.tsx index d2ba1cbee0..741c8e61fd 100644 --- a/apps/core/src/index.tsx +++ b/apps/core/src/index.tsx @@ -8,7 +8,6 @@ async function main() { assertExists(root); createRoot(root).render(); - await import('./bootstrap/register-plugins'); } await main(); diff --git a/apps/electron/src/main/index.ts b/apps/electron/src/main/index.ts index d50609d1dd..34c61f11d7 100644 --- a/apps/electron/src/main/index.ts +++ b/apps/electron/src/main/index.ts @@ -12,6 +12,8 @@ import { registerPlugin } from './plugin'; import { registerProtocol } from './protocol'; import { registerUpdater } from './updater'; +app.enableSandbox(); + if (require('electron-squirrel-startup')) app.quit(); // allow tests to overwrite app name through passing args if (process.argv.includes('--app-name')) {