Adapt strict resolver tests, remove AMD dependencies#21307
Adapt strict resolver tests, remove AMD dependencies#21307NullVoxPopuli-ai-agent wants to merge 5 commits intoemberjs:nvp/strict-resolver-rfc-1132from
Conversation
- 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>
There was a problem hiding this comment.
looks like you deleted too many tests!
There was a problem hiding this comment.
do we not use classify?
| return false; | ||
| } | ||
|
|
||
| parseName(fullName) { |
There was a problem hiding this comment.
this logic is probably something we need to keep
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
is this robust enough? idk, we don't have tests for it (tho we did)
|
|
||
| export let resolver; | ||
| export let loader; | ||
| export let modules; |
There was a problem hiding this comment.
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>
| "./instance": "./instance.ts", | ||
| "./parent": "./parent.ts" | ||
| "./parent": "./parent.ts", | ||
| "./lib/strict-resolver": "./lib/strict-resolver.ts", |
There was a problem hiding this comment.
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) { | |||
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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>
Summary
Replaces the classic
ember-resolvercopy with theStrictResolverfrom the polyfill and strict-resolver branch, per RFC#1132.Resolver changes
StrictResolver(~120 lines) replaces the classic resolver (~450 lines)./paths — nomodulePrefixneededresolver:currentself-lookup,type:main→typekey,type:name→types/namekey./prefix and file extensions like.ts){ default: X }and shorthandXmodule valuesEngine integration
modulesandpluralsproperties to theEngineclassresolverFor()checksnamespace.modulesfirst — if present, createsStrictResolver; otherwise falls back to traditionalResolverclassApplication.create({ modules: { './services/foo': { default: FooService } } })Test changes
StrictResolverdirectly with module mapsApplication.create({ modules: {...} })and useapp.visit('/')to bootTest plan
🤖 Generated with Claude Code