There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): avoid expand runtime config everywhere used (#7972)
forehalo0209e3fa76f5
diff --git a/packages/common/env/src/global.ts b/packages/common/env/src/global.tsindex 349a80a5f1..725f899094 100644--- a/packages/common/env/src/global.ts+++ b/packages/common/env/src/global.ts@@ -87,11 +87,23 @@ interface Desktop extends ChromeBrowser {export type Environment = Browser | Server | Desktop;+function setupRuntimeConfig() {+ if (!process.env.RUNTIME_CONFIG) {+ return;+ }++ // registered by [webpack.DefinePlugin]+ const runtimeConfig = JSON.parse(process.env.RUNTIME_CONFIG ?? '');+ runtimeFlagsSchema.parse(runtimeConfig);+ globalThis.runtimeConfig = runtimeConfig;+}+export function setupGlobal() {if (globalThis.$AFFINE_SETUP) {return;}- runtimeFlagsSchema.parse(runtimeConfig);++ setupRuntimeConfig();let environment: Environment;const isDebug = process.env.NODE_ENV === 'development';diff --git a/packages/frontend/core/package.json b/packages/frontend/core/package.jsonindex 02e8073ac7..df2b940909 100644--- a/packages/frontend/core/package.json+++ b/packages/frontend/core/package.json@@ -4,10 +4,6 @@"private": true,"version": "0.16.0","exports": {- "./app": "./src/app.tsx",- "./router": "./src/router.tsx",- "./bootstrap/register-plugins": "./src/bootstrap/register-plugins.ts",- "./hooks/*": "./src/hooks/*","./*": "./src/*"},"dependencies": {diff --git a/scripts/setup/global.ts b/scripts/setup/global.tsindex 458891b8b9..da7d1f0b8d 100644--- a/scripts/setup/global.ts+++ b/scripts/setup/global.ts@@ -1,12 +1,14 @@import { getRuntimeConfig } from '@affine/cli/src/webpack/runtime-config';import { setupGlobal } from '@affine/env/global';-globalThis.runtimeConfig = getRuntimeConfig({- distribution: 'browser',- mode: 'development',- channel: 'canary',- static: false,-});+process.env.RUNTIME_CONFIG = JSON.stringify(+ getRuntimeConfig({+ distribution: 'browser',+ mode: 'development',+ channel: 'canary',+ static: false,+ })+);if (typeof window !== 'undefined') {window.location.search = '?prefixUrl=http://127.0.0.1:3010/';diff --git a/tools/cli/src/webpack/config.ts b/tools/cli/src/webpack/config.tsindex c6ab787be8..e11d67a375 100644--- a/tools/cli/src/webpack/config.ts+++ b/tools/cli/src/webpack/config.ts@@ -346,7 +346,9 @@ export const createConfiguration: (process.env.MIXPANEL_TOKEN),'process.env.DEBUG_JOTAI': JSON.stringify(process.env.DEBUG_JOTAI),- runtimeConfig: JSON.stringify(runtimeConfig),+ 'process.env.RUNTIME_CONFIG': JSON.stringify(+ JSON.stringify(runtimeConfig)+ ),}),buildFlags.distribution === 'admin'? nulldiff --git a/tsconfig.json b/tsconfig.jsonindex 53b9b80758..12d348fd04 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -48,7 +48,6 @@"skipLibCheck": true, // skip all type checks for .d.ts files"paths": {"@affine/core/*": ["./packages/frontend/core/src/*"],- "@affine/core": ["./packages/frontend/core/src/index.ts"],"@affine/admin/*": ["./packages/frontend/admin/src/*"],"@affine/admin/components/ui/*": ["./packages/frontend/admin/src/components/ui/*"