fix(core): avoid expand runtime config everywhere used (#7972)

This commit is contained in:
forehalo
2024-08-26 12:22:52 +00:00
parent 9ea4aaaf37
commit 0209e3fa76
5 changed files with 24 additions and 13 deletions

View File

@@ -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';

View File

@@ -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": {