mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
fix(core): avoid expand runtime config everywhere used (#7972)
This commit is contained in:
14
packages/common/env/src/global.ts
vendored
14
packages/common/env/src/global.ts
vendored
@@ -87,11 +87,23 @@ interface Desktop extends ChromeBrowser {
|
|||||||
|
|
||||||
export type Environment = Browser | Server | Desktop;
|
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() {
|
export function setupGlobal() {
|
||||||
if (globalThis.$AFFINE_SETUP) {
|
if (globalThis.$AFFINE_SETUP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runtimeFlagsSchema.parse(runtimeConfig);
|
|
||||||
|
setupRuntimeConfig();
|
||||||
|
|
||||||
let environment: Environment;
|
let environment: Environment;
|
||||||
const isDebug = process.env.NODE_ENV === 'development';
|
const isDebug = process.env.NODE_ENV === 'development';
|
||||||
|
|||||||
@@ -4,10 +4,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.16.0",
|
"version": "0.16.0",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./app": "./src/app.tsx",
|
|
||||||
"./router": "./src/router.tsx",
|
|
||||||
"./bootstrap/register-plugins": "./src/bootstrap/register-plugins.ts",
|
|
||||||
"./hooks/*": "./src/hooks/*",
|
|
||||||
"./*": "./src/*"
|
"./*": "./src/*"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { getRuntimeConfig } from '@affine/cli/src/webpack/runtime-config';
|
import { getRuntimeConfig } from '@affine/cli/src/webpack/runtime-config';
|
||||||
import { setupGlobal } from '@affine/env/global';
|
import { setupGlobal } from '@affine/env/global';
|
||||||
|
|
||||||
globalThis.runtimeConfig = getRuntimeConfig({
|
process.env.RUNTIME_CONFIG = JSON.stringify(
|
||||||
distribution: 'browser',
|
getRuntimeConfig({
|
||||||
mode: 'development',
|
distribution: 'browser',
|
||||||
channel: 'canary',
|
mode: 'development',
|
||||||
static: false,
|
channel: 'canary',
|
||||||
});
|
static: false,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
window.location.search = '?prefixUrl=http://127.0.0.1:3010/';
|
window.location.search = '?prefixUrl=http://127.0.0.1:3010/';
|
||||||
|
|||||||
@@ -346,7 +346,9 @@ export const createConfiguration: (
|
|||||||
process.env.MIXPANEL_TOKEN
|
process.env.MIXPANEL_TOKEN
|
||||||
),
|
),
|
||||||
'process.env.DEBUG_JOTAI': JSON.stringify(process.env.DEBUG_JOTAI),
|
'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'
|
buildFlags.distribution === 'admin'
|
||||||
? null
|
? null
|
||||||
|
|||||||
@@ -48,7 +48,6 @@
|
|||||||
"skipLibCheck": true, // skip all type checks for .d.ts files
|
"skipLibCheck": true, // skip all type checks for .d.ts files
|
||||||
"paths": {
|
"paths": {
|
||||||
"@affine/core/*": ["./packages/frontend/core/src/*"],
|
"@affine/core/*": ["./packages/frontend/core/src/*"],
|
||||||
"@affine/core": ["./packages/frontend/core/src/index.ts"],
|
|
||||||
"@affine/admin/*": ["./packages/frontend/admin/src/*"],
|
"@affine/admin/*": ["./packages/frontend/admin/src/*"],
|
||||||
"@affine/admin/components/ui/*": [
|
"@affine/admin/components/ui/*": [
|
||||||
"./packages/frontend/admin/src/components/ui/*"
|
"./packages/frontend/admin/src/components/ui/*"
|
||||||
|
|||||||
Reference in New Issue
Block a user