Skip to content

Commit 4be5c06

Browse files
committed
inline globalThis usage, remove global.ts
1 parent b641aeb commit 4be5c06

4 files changed

Lines changed: 14 additions & 27 deletions

File tree

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './lib/context';
22
export * from './lib/env';
3-
export { default as global } from './lib/global';

packages/@ember/-internals/environment/lib/context.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import global from './global';
2-
31
export interface GlobalContext {
42
imports: object;
53
exports: object;
64
lookup: Record<string, unknown>;
75
}
86

7+
const global = globalThis as Record<string, unknown>;
8+
const Ember = global['Ember'] as Partial<GlobalContext> | undefined;
9+
910
// legacy imports/exports/lookup stuff (should we keep this??)
10-
export const context = (function (
11-
global: Record<string, unknown>,
12-
Ember: Partial<GlobalContext> | undefined
13-
): GlobalContext {
14-
return Ember === undefined
11+
export const context: GlobalContext =
12+
Ember === undefined
1513
? { imports: global, exports: global, lookup: global }
1614
: {
1715
// import jQuery
@@ -21,7 +19,6 @@ export const context = (function (
2119
// search for Namespaces
2220
lookup: Ember.lookup || global,
2321
};
24-
})(global, global.Ember);
2522

2623
export function getLookup(): Record<string, unknown> {
2724
return context.lookup;

packages/@ember/-internals/environment/lib/env.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { DEBUG } from '@glimmer/env';
2-
import global from './global';
32

43
/**
54
The hash of environment variables used to control various configuration
@@ -154,9 +153,15 @@ export const ENV = {
154153
},
155154
};
156155

157-
((EmberENV) => {
158-
if (typeof EmberENV !== 'object' || EmberENV === null) return;
156+
interface EmberENVConfig extends Record<string, unknown> {
157+
EXTEND_PROTOTYPES?: boolean;
158+
EMBER_LOAD_HOOKS?: Record<string, unknown>;
159+
FEATURES?: Record<string, unknown>;
160+
}
161+
162+
const EmberENV = (globalThis as { EmberENV?: EmberENVConfig }).EmberENV;
159163

164+
if (typeof EmberENV === 'object' && EmberENV !== null) {
160165
for (let flag in EmberENV) {
161166
if (
162167
!Object.prototype.hasOwnProperty.call(EmberENV, flag) ||
@@ -197,7 +202,7 @@ export const ENV = {
197202
if (DEBUG) {
198203
ENV._DEBUG_RENDER_TREE = true;
199204
}
200-
})(global.EmberENV);
205+
}
201206

202207
export function getENV(): object {
203208
return ENV;

packages/@ember/-internals/environment/lib/global.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)