Skip to content

Adapt strict resolver tests, remove AMD dependencies#21307

Draft
NullVoxPopuli-ai-agent wants to merge 5 commits intoemberjs:nvp/strict-resolver-rfc-1132from
NullVoxPopuli-ai-agent:strict-resolver-tests-update
Draft

Adapt strict resolver tests, remove AMD dependencies#21307
NullVoxPopuli-ai-agent wants to merge 5 commits intoemberjs:nvp/strict-resolver-rfc-1132from
NullVoxPopuli-ai-agent:strict-resolver-tests-update

Conversation

@NullVoxPopuli-ai-agent
Copy link
Copy Markdown
Contributor

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent commented Apr 8, 2026

Summary

Replaces the classic ember-resolver copy with the StrictResolver from the polyfill and strict-resolver branch, per RFC#1132.

Resolver changes

  • New StrictResolver (~120 lines) replaces the classic resolver (~450 lines)
  • Uses relative ./ paths — no modulePrefix needed
  • No pods, no scoped packages, no AMD/requirejs
  • Three resolution strategies: resolver:current self-lookup, type:maintype key, type:nametypes/name key
  • Normalizes module paths (strips ./ prefix and file extensions like .ts)
  • Supports { default: X } and shorthand X module values

Engine integration

  • Added modules and plurals properties to the Engine class
  • resolverFor() checks namespace.modules first — if present, creates StrictResolver; otherwise falls back to traditional Resolver class
  • Opt-in: Application.create({ modules: { './services/foo': { default: FooService } } })

Test changes

  • Removed classic-only tests (pods, string utilities, scoped packages, custom prefixes)
  • Removed classic utilities (cache.js, class-factory.js, string.js)
  • Unit tests create StrictResolver directly with module maps
  • Integration tests create Application.create({ modules: {...} }) and use app.visit('/') to boot

Test plan

  • 18 StrictResolver unit tests pass (lookup, normalization, main lookup, addModules, path normalization, custom plurals, etc.)
  • 4 Application integration tests pass (register/lookup, resolve via modules, shorthand modules, router:main)
  • Full test suite passes (9155 tests, only pre-existing Enumerable failure)
  • Review alignment with RFC#1132

🤖 Generated with Claude Code

NullVoxPopuli and others added 2 commits April 8, 2026 16:11
- Remove ModuleRegistry class and globalThis.requirejs/require references
- Require explicit modules via Resolver.withModules() instead of AMD fallback
- Rewrite all tests to use module maps instead of AMD loader.define()
- Fix imports from 'ember-resolver' to local '@ember/engine/lib/strict-resolver'
- Fix string utility imports to '@ember/engine/lib/strict-resolver/string'
- Add package.json exports for strict-resolver and string utilities
- Add Application integration tests using Resolver.withModules()
- Fix typo: rename with-modues-test.js to with-modules-test.js

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace the classic ember-resolver copy with the StrictResolver from
  the polyfill/strict-resolver branch (~120 lines vs ~450)
- Integrate into Engine: add modules/plurals properties, modify
  resolverFor() to create StrictResolver when modules is set
- Modules use relative ./paths (normalized by stripping ./ and extensions)
- No pods, no scoped packages, no AMD — simple type:name resolution
- Remove classic-only utilities (cache, class-factory, string helpers)
- Remove classic-only tests (pods, string utilities, custom prefixes)
- Rewrite tests for StrictResolver API using modules = {} pattern
- Application integration tests use Application.create({ modules: {...} })

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you deleted too many tests!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we not use classify?

return false;
}

parseName(fullName) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic is probably something we need to keep

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tho maybe in a slimmed down capacity, since there are a couple things in here we don't want to support


this.pluralizedTypes = this.pluralizedTypes || Object.create(null);

if (!this.pluralizedTypes.config) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to support proper inflectors, and the customizations of these (this is why the string utilities were initially added)

return module;
}
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
function decamelize(str: string): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this robust enough? idk, we don't have tests for it (tho we did)


export let resolver;
export let loader;
export let modules;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not exist in module space. it should stay in the function

…olver

- Restore cache.js and string.js with proper inflectors (dasherize,
  classify, underscore, decamelize) and their caching
- Import dasherize from string utilities in StrictResolver instead of
  inlining
- Restore string utility tests (classify, dasherize, decamelize,
  underscore) with create-test-function helper
- Add back tests for all lookup types: component, modifier, template,
  view, route, controller (not just service/adapter/helper)
- Restore full normalization test coverage from original test suite
- Add config plural override test
- Fix setup-resolver: modules stays in function scope, not module scope
- Re-export string utilities from package.json

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread packages/@ember/engine/package.json Outdated
"./instance": "./instance.ts",
"./parent": "./parent.ts"
"./parent": "./parent.ts",
"./lib/strict-resolver": "./lib/strict-resolver.ts",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't change this file

@@ -462,6 +483,10 @@ class Engine extends Namespace.extend(RegistryProxyMixin) {
@return {*} the resolved value for a given lookup
*/
function resolverFor(namespace: Engine) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this for?

you need to add a scenario test, a new scenario in scenarios.ts that uses a strict application definition

- Revert package.json to original (no export changes needed)
- Add strict-resolver scenario in smoke-tests/scenarios/scenarios.ts
- Add strict-resolver-test.ts with acceptance + unit tests that exercise
  an Application using modules = {} with import.meta.glob

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
}
`,
},
templates: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add templates/routes for /index (/) /application (/*) and a few sub-routes. Also explore if pod (route, template, controller) still works.
Also see if old school hbs works since components are in the modules registry

…nt types

- Add application template with service injection and hbs component
- Add index route (/) with model
- Add nested posts route with sub-route posts/show (/:post_id)
- Add hbs component (site-header.hbs) to test classic template resolution
- Add gjs component (post-card.gjs) to test modern component resolution
- Acceptance tests cover: index, application, sub-routes, dynamic
  segments, hbs components, gjs components, service injection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NullVoxPopuli NullVoxPopuli marked this pull request as draft April 10, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants