Skip to content

Commit

Permalink
Remove @glimmer/env in favor of @embroider/macros
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Dec 2, 2024
1 parent c5e54b3 commit cfb5ac6
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 108 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bower_components/
node_modules/

# misc
.prototools
.env*
.pnp*
.sass-cache
Expand Down
12 changes: 6 additions & 6 deletions addon/addon/build-waiter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Primitive, TestWaiter, TestWaiterDebugInfo, WaiterName } from './';

import { DEBUG } from '@glimmer/env';
import { macroCondition, isDevelopingApp } from '@embroider/macros';
import { warn } from '@ember/debug';
import Token from './token';
import { register } from './waiter-manager';

const WAITER_NAME_PATTERN = /^[^:]*:?.*/;
let WAITER_NAMES = DEBUG ? new Set() : undefined;
let WAITER_NAMES = macroCondition(isDevelopingApp()) ? new Set() : undefined;

export function _resetWaiterNames() {
WAITER_NAMES = new Set();
Expand Down Expand Up @@ -128,7 +128,7 @@ class NoopTestWaiter implements TestWaiter {
/**
* Builds and returns a test waiter. The type of the
* returned waiter is dependent on whether the app or
* addon is in `DEBUG` mode or not.
* addon is in `isDevopingApp()` mode or not.
*
* @public
*
Expand All @@ -140,7 +140,7 @@ class NoopTestWaiter implements TestWaiter {
* import Component from '@ember/component';
* import { buildWaiter } from '@ember/test-waiters';
*
* if (DEBUG) {
* if (macroCondition(isDevelopingApp())) {
* let waiter = buildWaiter('friend-waiter');
* }
*
Expand All @@ -155,14 +155,14 @@ class NoopTestWaiter implements TestWaiter {
* }
*/
export default function buildWaiter(name: string): TestWaiter {
if (DEBUG) {
if (macroCondition(isDevelopingApp())) {
warn(`The waiter name '${name}' is already in use`, !WAITER_NAMES!.has(name), {
id: '@ember/test-waiters.duplicate-waiter-name',
});
WAITER_NAMES!.add(name);
}

if (!DEBUG) {
if (macroCondition(!isDevelopingApp())) {
return new NoopTestWaiter(name);
} else {
warn(
Expand Down
4 changes: 2 additions & 2 deletions addon/addon/wait-for-promise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEBUG } from '@glimmer/env';
import { macroCondition, isDevelopingApp } from '@embroider/macros';
import buildWaiter from './build-waiter';

import { PromiseType, Thenable } from './types';
Expand Down Expand Up @@ -32,7 +32,7 @@ export default function waitForPromise<T, KindOfPromise extends PromiseType<T>>(
): KindOfPromise {
let result = promise;

if (DEBUG) {
if (macroCondition(isDevelopingApp())) {
PROMISE_WAITER.beginAsync(promise, label);

result = (promise as unknown as Thenable<T, KindOfPromise>).then(
Expand Down
6 changes: 3 additions & 3 deletions addon/addon/wait-for.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEBUG } from '@glimmer/env';
import { macroCondition, isDevelopingApp } from '@embroider/macros';
import waitForPromise from './wait-for-promise';
import buildWaiter from './build-waiter';
import { PromiseType } from './types';
Expand Down Expand Up @@ -75,7 +75,7 @@ export default function waitFor(
} else {
const [, , descriptor, label] = args as DecoratorArguments;

if (!DEBUG) {
if (macroCondition(!isDevelopingApp())) {
return descriptor;
}

Expand All @@ -88,7 +88,7 @@ export default function waitFor(
}

function wrapFunction(fn: Function, label?: string) {
if (!DEBUG) {
if (macroCondition(!isDevelopingApp())) {
return fn;
}

Expand Down
2 changes: 1 addition & 1 deletion addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"@babel/core": "^7.26.0",
"@glimmer/env": "^0.1.7",
"@embroider/macros": "^1.16.9",
"ember-auto-import": "^2.10.0",
"ember-cli-babel": "^8.2.0",
"ember-cli-typescript": "^5.3.0",
Expand Down
104 changes: 20 additions & 84 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-apps/base-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"@ember/test-helpers": "^3.2.0",
"@embroider/compat": "^3.7.0",
"@embroider/core": "^3.4.19",
"@embroider/macros": "^1.16.9",
"@embroider/webpack": "^4.0.8",
"@eslint/js": "^9.15.0",
"@glimmer/component": "^1.1.2",
"@glimmer/env": "^0.1.7",
"@glimmer/tracking": "^1.1.2",
"@glint/environment-ember-loose": "^1.1.0",
"@glint/template": "^1.5.0",
Expand Down
4 changes: 2 additions & 2 deletions test-apps/base-tests/tests/unit/wait-for-promise-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
} from '@ember/test-waiters';
import { module, test } from 'qunit';

import { DEBUG } from '@glimmer/env';
import { macroCondition, isDevelopingApp } from '@embroider/macros';
import RSVP from 'rsvp';

if (DEBUG) {
if (macroCondition(isDevelopingApp())) {
module('wait-for-promise', function (hooks) {
hooks.afterEach(function () {
_reset();
Expand Down
Loading

0 comments on commit cfb5ac6

Please sign in to comment.