Skip to content

Commit 8231942

Browse files
committed
Use import.meta.env?.DEV
This will require a dev environment to enable (or manually setting import.meta.env.DEV = true. Otherwise prod behavior will be received.
1 parent 02c62b0 commit 8231942

143 files changed

Lines changed: 468 additions & 531 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ There are helpers for many of these functions, which will resolve this for you:
276276
If your tests can't or aren't covered by a helper, one common solution is the use of `DEBUG` flag. Wrapping the debug-only dependent test in a check of this flag will cause that test to not be run in the prod test suite:
277277

278278
```javascript
279-
import { DEBUG } from '@glimmer/env';
280-
281-
if (DEBUG) {
279+
if (import.meta.env?.DEV ?? true) {
282280
// Development-only test goes here
283281
}
284282
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,4 @@
390390
}
391391
},
392392
"packageManager": "[email protected]"
393-
}
393+
}

packages/@ember/-internals/container/lib/container.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
import { setOwner } from '@ember/-internals/owner';
1010
import { dictionary } from '@ember/-internals/utils';
1111
import { assert } from '@ember/debug';
12-
import { DEBUG } from '@glimmer/env';
12+
1313
import type { DebugRegistry } from './registry';
1414
import type Registry from './registry';
1515

@@ -24,7 +24,7 @@ declare const gc: undefined | (() => void);
2424

2525
let leakTracking: LeakTracking;
2626
let containers: WeakSet<Container>;
27-
if (DEBUG) {
27+
if (import.meta.env?.DEV) {
2828
// requires v8
2929
// chrome --js-flags="--allow-natives-syntax --expose-gc"
3030
// node --allow-natives-syntax --expose-gc
@@ -92,7 +92,7 @@ export default class Container {
9292
this.isDestroyed = false;
9393
this.isDestroying = false;
9494

95-
if (DEBUG) {
95+
if (import.meta.env?.DEV) {
9696
this.validationCache = dictionary(options.validationCache || null);
9797
if (containers !== undefined) {
9898
containers.add(this);
@@ -232,7 +232,7 @@ export default class Container {
232232
}
233233
}
234234

235-
if (DEBUG) {
235+
if (import.meta.env?.DEV) {
236236
Container._leakTracking = leakTracking!;
237237
}
238238

@@ -312,13 +312,13 @@ function factoryFor(
312312
return;
313313
}
314314

315-
if (DEBUG && factory && typeof factory._onLookup === 'function') {
315+
if (import.meta.env?.DEV && factory && typeof factory._onLookup === 'function') {
316316
factory._onLookup(fullName);
317317
}
318318

319319
let manager = new InternalFactoryManager(container, factory, fullName, normalizedName);
320320

321-
if (DEBUG) {
321+
if (import.meta.env?.DEV) {
322322
manager = wrapManagerInDeprecationProxy(manager);
323323
}
324324

@@ -541,7 +541,7 @@ export class InternalFactoryManager<
541541
setOwner(props, container.owner!);
542542
setFactoryFor(props, this);
543543

544-
if (DEBUG) {
544+
if (import.meta.env?.DEV) {
545545
let lazyInjections;
546546
let validationCache = this.container.validationCache;
547547
// Ensure that all lazy injections are valid at instantiation time

packages/@ember/-internals/container/lib/registry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
import { dictionary, intern } from '@ember/-internals/utils';
1111
import { assert } from '@ember/debug';
1212
import type { set } from '@ember/object';
13-
import { DEBUG } from '@glimmer/env';
13+
1414
import type { ContainerOptions, LazyInjection } from './container';
1515
import Container from './container';
1616

@@ -468,7 +468,7 @@ export declare class DebugRegistry extends Registry {
468468
validateInjections(injections: Injection[]): void;
469469
}
470470

471-
if (DEBUG) {
471+
if (import.meta.env?.DEV) {
472472
const proto = Registry.prototype as DebugRegistry;
473473
proto.normalizeInjectionsHash = function (hash: { [key: string]: LazyInjection }) {
474474
let injections: Injection[] = [];

packages/@ember/-internals/container/tests/container_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getOwner } from '@ember/-internals/owner';
22
import Service from '@ember/service';
3-
import { DEBUG } from '@glimmer/env';
3+
44
import { Registry } from '..';
55
import { factory, moduleFor, AbstractTestCase, runTask } from 'internal-test-helpers';
66

@@ -447,7 +447,7 @@ moduleFor(
447447
}
448448

449449
['@test Lazy injection validations are cached'](assert) {
450-
if (!DEBUG) {
450+
if (!import.meta.env?.DEV) {
451451
assert.expect(0);
452452
return;
453453
}

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

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

43
/**
@@ -91,7 +90,7 @@ export const ENV = {
9190
@default false
9291
@private
9392
*/
94-
_DEBUG_RENDER_TREE: DEBUG,
93+
_DEBUG_RENDER_TREE: import.meta.env?.DEV,
9594

9695
/**
9796
Whether to force all deprecations to be enabled. This is used internally by
@@ -200,7 +199,7 @@ export const ENV = {
200199
}
201200
}
202201

203-
if (DEBUG) {
202+
if (import.meta.env?.DEV) {
204203
ENV._DEBUG_RENDER_TREE = true;
205204
}
206205
})(global.EmberENV);

packages/@ember/-internals/glimmer/lib/component-managers/curly.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { addChildView, setElementView, setViewElement } from '@ember/-internals/
99
import type { Nullable } from '@ember/-internals/utility-types';
1010
import { assert, debugFreeze } from '@ember/debug';
1111
import { _instrumentStart } from '@ember/instrumentation';
12-
import { DEBUG } from '@glimmer/env';
12+
1313
import type {
1414
Bounds,
1515
CapturedArguments,
@@ -337,7 +337,7 @@ export default class CurlyComponentManager
337337
bucket.classRef = args.named.get('class');
338338
}
339339

340-
if (DEBUG) {
340+
if (import.meta.env?.DEV) {
341341
processComponentInitializationAssertions(component, props);
342342
}
343343

packages/@ember/-internals/glimmer/lib/component-managers/root.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getFactoryFor } from '@ember/-internals/container';
22
import { assert } from '@ember/debug';
33
import { _instrumentStart } from '@ember/instrumentation';
4-
import { DEBUG } from '@glimmer/env';
4+
55
import type {
66
ComponentDefinition,
77
Environment,
@@ -57,7 +57,7 @@ class RootComponentManager extends CurlyComponentManager {
5757
}
5858
}
5959

60-
if (DEBUG) {
60+
if (import.meta.env?.DEV) {
6161
processComponentInitializationAssertions(component, {});
6262
}
6363

packages/@ember/-internals/glimmer/lib/component-managers/route-template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
WithCustomDebugRenderTree,
1515
} from '@glimmer/interfaces';
1616
import type { Nullable } from '@ember/-internals/utility-types';
17-
import { DEBUG } from '@glimmer/env';
17+
1818
import { capabilityFlagsFrom } from '@glimmer/manager';
1919
import type { Reference } from '@glimmer/reference';
2020
import { createDebugAliasRef, valueForRef } from '@glimmer/reference';
@@ -61,7 +61,7 @@ class RouteTemplateManager
6161
): RouteTemplateInstanceState {
6262
let self = args.named.get('controller');
6363

64-
if (DEBUG) {
64+
if (import.meta.env?.DEV) {
6565
self = createDebugAliasRef!('this', self);
6666
}
6767

packages/@ember/-internals/glimmer/lib/component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '@ember/-internals/views';
2020
import { guidFor } from '@ember/-internals/utils';
2121
import { assert } from '@ember/debug';
22-
import { DEBUG } from '@glimmer/env';
22+
2323
import type { Environment, Template, TemplateFactory } from '@glimmer/interfaces';
2424
import { setInternalComponentManager } from '@glimmer/manager';
2525
import { isUpdatableRef, updateRef } from '@glimmer/reference';
@@ -939,7 +939,12 @@ class Component<S = unknown>
939939
}
940940
}
941941

942-
if (DEBUG && eventDispatcher && this.renderer._isInteractive && this.tagName === '') {
942+
if (
943+
import.meta.env?.DEV &&
944+
eventDispatcher &&
945+
this.renderer._isInteractive &&
946+
this.tagName === ''
947+
) {
943948
let eventNames = [];
944949
let events = eventDispatcher.finalEventNameMapping;
945950

0 commit comments

Comments
 (0)