From e3808f050d5cfdf3c5c0cb3c6e2c79493c7ab73f Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 18 May 2026 12:58:29 -0400 Subject: [PATCH 1/3] Support RFC#1132, strict-resolver --- addon/src/application.ts | 9 +++++++++ test-app/tests/unit/application-test.js | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/addon/src/application.ts b/addon/src/application.ts index 485df4b0b..6814c50c9 100644 --- a/addon/src/application.ts +++ b/addon/src/application.ts @@ -16,6 +16,15 @@ let __application__: Application | undefined; export function setApplication(application: Application): void { __application__ = application; + /** + * For RFC#1132, the strict resolver is not accessible. + * It is closed off from extension. + * + * SAFETY: modules is a new API, so older Application + * types will not have it. + */ + if ((application as any).modules) return; + if (!getResolver()) { const Resolver = (application as any).Resolver; const resolver = Resolver.create({ namespace: application }); diff --git a/test-app/tests/unit/application-test.js b/test-app/tests/unit/application-test.js index 2a746c809..65d56c236 100644 --- a/test-app/tests/unit/application-test.js +++ b/test-app/tests/unit/application-test.js @@ -1,3 +1,4 @@ +import Application from '@ember/application'; import { module, test } from 'qunit'; import { application, resolver } from '../helpers/resolver'; import { @@ -18,6 +19,18 @@ module('application', function (hooks) { setResolver(resolver); }); + test('RFC#1132: calling set application does not set resolver if the application has modules = {}', function (assert) { + class App extends Application { + modules = {}; + } + + setApplication(App); + + let actualResolver = getResolver(); + assert.notOk(actualResolver, 'there is no resolver'); + assert.deepEqual(getApplication().constructor, application.constructor); + }); + test('calling setApplication sets resolver when resolver is unset', function (assert) { setApplication(application); From 315eb9c6603d006905bb9c8a61e56e36075b9410 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 18 May 2026 13:56:00 -0400 Subject: [PATCH 2/3] Fix tests --- addon/src/application.ts | 2 +- test-app/tests/unit/application-test.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/addon/src/application.ts b/addon/src/application.ts index 6814c50c9..f61e1717c 100644 --- a/addon/src/application.ts +++ b/addon/src/application.ts @@ -23,7 +23,7 @@ export function setApplication(application: Application): void { * SAFETY: modules is a new API, so older Application * types will not have it. */ - if ((application as any).modules) return; + if ((application as any)?.modules) return; if (!getResolver()) { const Resolver = (application as any).Resolver; diff --git a/test-app/tests/unit/application-test.js b/test-app/tests/unit/application-test.js index 65d56c236..169ee02ef 100644 --- a/test-app/tests/unit/application-test.js +++ b/test-app/tests/unit/application-test.js @@ -22,13 +22,24 @@ module('application', function (hooks) { test('RFC#1132: calling set application does not set resolver if the application has modules = {}', function (assert) { class App extends Application { modules = {}; + + // TODO: This isn't needed once we upgrade to + // a new enough ember that supports this. + // But to support the implementation PR, @ember/test-helpers + // needs to be compatible with modules = {} first for the smoke tests + // to pass in https://github.com/emberjs/ember.js/pull/21303 + // + // Once the above PR lands, we'll want to wrap this test in a macroCondition + buildRegistry() {} } - setApplication(App); + setApplication( + App.create({ autoboot: false, rootElement: '#ember-testing' }) + ); let actualResolver = getResolver(); assert.notOk(actualResolver, 'there is no resolver'); - assert.deepEqual(getApplication().constructor, application.constructor); + assert.deepEqual(getApplication().constructor, App); }); test('calling setApplication sets resolver when resolver is unset', function (assert) { From f5d8f6692686c265d7ecc3f4786db79a7b3ea393 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 18 May 2026 14:00:44 -0400 Subject: [PATCH 3/3] Ensure that the polyfill still works --- test-app/package.json | 1 + test-app/pnpm-lock.yaml | 14 ++++++++++++++ test-app/tests/unit/application-test.js | 15 +++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/test-app/package.json b/test-app/package.json index acb3d98e2..261445503 100644 --- a/test-app/package.json +++ b/test-app/package.json @@ -55,6 +55,7 @@ "ember-resolver": "^13.1.0", "ember-source": "~5.12.0", "ember-source-channel-url": "^3.0.0", + "ember-strict-application-resolver": "^0.1.1", "ember-template-lint": "^5.7.2", "ember-try": "^3.0.0", "eslint": "^8.37.0", diff --git a/test-app/pnpm-lock.yaml b/test-app/pnpm-lock.yaml index 275a66fca..3153fb31e 100644 --- a/test-app/pnpm-lock.yaml +++ b/test-app/pnpm-lock.yaml @@ -93,6 +93,9 @@ importers: ember-source-channel-url: specifier: ^3.0.0 version: 3.0.0 + ember-strict-application-resolver: + specifier: ^0.1.1 + version: 0.1.1(@babel/core@7.29.0) ember-template-lint: specifier: ^5.7.2 version: 5.13.0 @@ -2686,6 +2689,9 @@ packages: peerDependencies: '@glimmer/component': ^1.1.2 + ember-strict-application-resolver@0.1.1: + resolution: {integrity: sha512-/49JZ2Yk2ggicAGIoFNWcz05llhe2i+/2dpH5Pv1KlwZOBKkqMMJpTKEB4IMg+FjKBiE0r2yxuZzo9Oly9vc1A==} + ember-template-imports@3.4.2: resolution: {integrity: sha512-OS8TUVG2kQYYwP3netunLVfeijPoOKIs1SvPQRTNOQX4Pu8xGGBEZmrv0U1YTnQn12Eg+p6w/0UdGbUnITjyzw==} engines: {node: 12.* || >= 14} @@ -9568,6 +9574,14 @@ snapshots: - supports-color - webpack + ember-strict-application-resolver@0.1.1(@babel/core@7.29.0): + dependencies: + '@embroider/addon-shim': 1.10.2 + decorator-transforms: 2.3.1(@babel/core@7.29.0) + transitivePeerDependencies: + - '@babel/core' + - supports-color + ember-template-imports@3.4.2: dependencies: babel-import-util: 0.2.0 diff --git a/test-app/tests/unit/application-test.js b/test-app/tests/unit/application-test.js index 169ee02ef..8faf514ef 100644 --- a/test-app/tests/unit/application-test.js +++ b/test-app/tests/unit/application-test.js @@ -1,6 +1,7 @@ import Application from '@ember/application'; import { module, test } from 'qunit'; import { application, resolver } from '../helpers/resolver'; +import ApplicationPolyfill from 'ember-strict-application-resolver'; import { getApplication, setApplication, @@ -42,6 +43,20 @@ module('application', function (hooks) { assert.deepEqual(getApplication().constructor, App); }); + test('RFC#1132 (polyfilled): calling set application does not set resolver if the application has modules = {}', function (assert) { + class App extends ApplicationPolyfill { + modules = {}; + } + + setApplication( + App.create({ autoboot: false, rootElement: '#ember-testing' }) + ); + + let actualResolver = getResolver(); + assert.notOk(actualResolver, 'there is no resolver'); + assert.deepEqual(getApplication().constructor, App); + }); + test('calling setApplication sets resolver when resolver is unset', function (assert) { setApplication(application);