File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ export interface Options {
11
11
schemaLoadingOptions ?: SchemaLoadingOptions ;
12
12
}
13
13
14
+ const privateName = '_appConfig' ;
15
+
14
16
// vite resolves first before passing to the rollup plugin
15
17
export const appConfigImportRegex = / ( a p p - c o n f i g | a p p - c o n f i g - m a i n ) \/ d i s t ( \/ e s ) ? \/ i n d e x \. j s / ;
16
18
@@ -53,9 +55,13 @@ export default function appConfigRollup({
53
55
54
56
const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {};
55
57
56
- // if the global was already defined, use it (and define it if not)
57
- const config = globalNamespace._appConfig =
58
- (globalNamespace._appConfig || configValue);
58
+ // if the global was already defined, use it
59
+ const config = (globalNamespace.${ privateName } || configValue);
60
+
61
+ // if the global is frozen then it was set by electron and we can't change it, but we'll set it if we can
62
+ if (!Object.isFrozen(globalNamespace.${ privateName } )) {
63
+ globalNamespace.${ privateName } = config;
64
+ }
59
65
` ;
60
66
} else {
61
67
generatedText = `
Original file line number Diff line number Diff line change @@ -44,9 +44,13 @@ const loader = function AppConfigLoader(this: Loader) {
44
44
45
45
const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {};
46
46
47
- // if the global was already defined, use it (and define it if not)
48
- const config = globalNamespace.${ privateName } =
49
- (globalNamespace.${ privateName } || configValue);
47
+ // if the global was already defined, use it
48
+ const config = (globalNamespace.${ privateName } || configValue);
49
+
50
+ // if the global is frozen then it was set by electron and we can't change it, but we'll set it if we can
51
+ if (!Object.isFrozen(globalNamespace.${ privateName } )) {
52
+ globalNamespace.${ privateName } = config;
53
+ }
50
54
51
55
export { config };
52
56
export default config;
You can’t perform that action at this time.
0 commit comments