Adapt strict resolver tests, remove AMD dependencies#21307
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
| @param {Ember.Enginer} namespace the namespace to look for classes | ||
| @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>
- Destroy Application in test afterEach so namespaces don't leak into
subsequent tests (caused "Should not have any NAMESPACES after tests"
failure in the Enumerable suite).
- Pass required BootOptions to app.visit('/', {}) for type-check.
- Drop the reference to the non-existent ember/no-private-routing-service
eslint rule.
- Rewrite classify/dasherize/decamelize/underscore tests to call qunit's
test() directly so eslint no longer misreads the 2nd arg as an expect
count and const is at module scope.
- Hoist classifyReplace1/2 in strict-resolver/string.js to module scope.
- Mark decamelize/underscore as @Private and register all four string
helpers (and Engine's modules/plurals) in tests/docs/expected.js so
docs coverage passes.
- Regenerate package.json with the three strict-resolver path aliases
so the package preparation diff check stays clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ember/test-helpers' setApplication() does
`const Resolver = application.Resolver; Resolver.create({namespace})`,
which threw TypeError in strict-resolver apps because Resolver was
only declared, never assigned. Provide a default Resolver with a
create() that returns a StrictResolver built from namespace.modules
and namespace.plurals. resolverFor() now just delegates to Resolver,
so classic apps that override Resolver keep working as before.
Also narrow the smoke-test globs to the extensions documented for the
strict resolver (js/ts/gjs/gts for code, hbs for route templates) and
convert site-header to a template-only .gjs — raw .hbs components
without a paired .js file still aren't wrapped by the strict resolver.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Review feedback on the strict resolver boiled down to three things:
proper pluralization with customization, nested-colocation component
lookup, and dead code in strict-resolver/string.js.
Pluralization: #plural now handles -s/-ss/-sh/-ch/-x/-z suffixes,
consonant + y, and the common irregulars (child/children,
person/people, man/men, woman/women, mouse/mice, tooth/teeth,
foot/feet). The plurals constructor option still overrides anything,
so a user can opt their "childs" type back in.
Nested colocation: added #nestedColocationLookup so component:my-widget
resolves to ./components/my-widget/index.{js,ts,gjs,gts} — the common
pattern for a class paired with a template in a folder. Direct module
matches still take precedence.
Dead code: classify and underscore weren't used by the resolver or
anything else in ember-source, so they're gone (along with their test
files). decamelize is collapsed inside dasherize's implementation.
The setStrings/getStrings/getString runtime string table was also
unused; removed. dasherize loses its yuidoc @method tag since the same
name is already documented via @ember/-internals/string.
Tests: cover -s/-es suffix rules, consonant-y, irregular plurals,
custom plural overriding an irregular, and the three colocation
cases (component/helper/modifier, plus direct-wins-over-colocation).
tests/docs/expected.js drops the entries whose only source was the
trimmed strict-resolver/string.js.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
578bd7b
into
emberjs:nvp/strict-resolver-rfc-1132
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