Skip to content

Implement RFC #1216: Deprecate the classic Component - #21630

Merged
NullVoxPopuli merged 4 commits into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/deprecate-ember-component
Nov 11, 2026
Merged

NullVoxPopuli merged 4 commits into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/deprecate-ember-component

Conversation

@NullVoxPopuli-ai-agent

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Adds the ember-component deprecation for the classic Component class, the default export of @ember/component. RFC: emberjs/rfcs#1216

The deprecation is available in 7.6.0 and is not enabled. It gets an enabled version when the RFC is Ready for Release (rfcs#1227).

This PR restarts from main. It sits on #21775, which moved the test harness to a Glimmer root.

What changes

  • New entry DEPRECATE_EMBER_COMPONENT: id ember-component, until 8.0.0.
  • It fires in init, once for each classic component instance.
  • The message links the Octane vs Classic cheat sheet, as the RFC asks.
  • The class API docs get @deprecated, with a link to the guide.
  • The named exports of @ember/component do not change.

Difference from the RFC

The RFC says that the deprecation fires when the class is extended or instantiated. This PR fires only at instantiation:

  • Code cannot detect a native class extends Component.
  • Component.extend() alone does not fire. RFC 1117 covers .extend() separately.

A subclass with no instances gets no warning. Every class that renders does.

Review

  1. A fix for getDebugFunction('deprecate'). It returned the exported wrapper, so a nested expectDeprecation(fn) dropped the outer expectation.
  2. The deprecation and the test helper. There is no exception: every classic instance fires the deprecation, also in tests.
  3. Test guards. This commit is mechanical, so hide whitespace to review it.
    • Each file in components/classic/ puts its code in one if (!DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isRemoved) block.
    • Tests outside that folder have their own guard:
      • testUnless in debug-render-tree-test.ts and in outlet-inside-component-test.js.
      • An if block around the {{-with-dynamic-var}} (classic root) module.
      • 2 Glimmer rehydration tests with @test({ skip }).
    • Each test that creates a classic component expects the deprecation.

expectClassicComponentDeprecation() expects nothing while the deprecation is not enabled. The usual isEnabled false form conflicts with other enabled deprecations in the same test.

Verified locally

All 9 CI variants pass. The default run has 9301 tests. The deprecations-removed run has 8022 tests, with 626 skipped. type-check:internals, eslint, and prettier pass.

Not in this PR

The deprecation guide in ember-learn/deprecation-app.

🤖 Generated with Claude Code

@NullVoxPopuli

Copy link
Copy Markdown
Contributor

this is draft, and thus not ready.

I wanted to see how big this PR would be, and then assess what refactoring PRs need to come first

`getDebugFunction('deprecate')` returned the exported wrapper, not the
current function. A nested `expectDeprecation(fn)` or
`ignoreDeprecation(fn)` saved that wrapper and restored it, so the outer
stub stopped receiving calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@NullVoxPopuli-ai-agent
NullVoxPopuli-ai-agent force-pushed the nvp/deprecate-ember-component branch from 499c0a8 to 4f6c2a6 Compare November 3, 2026 17:41
NullVoxPopuli and others added 2 commits November 6, 2026 15:25
Add the `ember-component` deprecation, available in 7.6.0 and not
enabled. It fires in `init`, once for each instance of the default
export of `@ember/component`. Code cannot detect a native
`class extends Component`, so `init` is the one place that sees every
use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is mechanical. Hide whitespace to review it.

Each file in `components/classic/` puts its code in one
`if (!DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isRemoved)` block. The
three tests outside that folder have their own guards. Each test that
creates a classic component calls `expectClassicComponentDeprecation()`
first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@NullVoxPopuli-ai-agent
NullVoxPopuli-ai-agent force-pushed the nvp/deprecate-ember-component branch from 4f6c2a6 to 6445029 Compare November 6, 2026 20:25
@NullVoxPopuli
NullVoxPopuli marked this pull request as ready for review November 6, 2026 22:10
case 'deprecate':
return deprecate;
// Callers save this value and restore it later with `setDebugFunction`.
return currentDeprecate ?? deprecate;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without this, a nested expectDeprecation(fn) saves the exported wrapper and restores it, so the outer stub is lost. 13 classic tests expect ember-component for the whole test and also expect a second deprecation in a callback. Those tests failed without this change. It runs in DEBUG builds only.

init(properties?: object | undefined) {
super.init(properties);

deprecateUntil(DEPRECATION_MESSAGE, DEPRECATIONS.DEPRECATE_EMBER_COMPONENT);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This fires in init, not when a subclass is defined. Code cannot detect a native class extends Component, and RFC 1117 covers .extend(). A subclass with no instances gets no warning.

that conflicts with a test that expects other deprecations.
*/
export function expectClassicComponentDeprecation(): void {
if (DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isEnabled) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This does not use expectDeprecation(msg, false), because that form asserts that no deprecations happen at all. That breaks tests that also expect a different deprecation.

content: 'bizz bizz',
});
}
if (!DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isRemoved) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Each file in components/classic/ gets one guard, not one testUnless for each test. Every test in the folder is a classic component test. Hide whitespace to review: about 850 of the added lines change only the indentation.

`);
}, /Using `-with-dynamic-scope` is only supported for `outletState` \(you used `foo`\)./);
}
if (!DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isRemoved) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These templates do not use a classic component. The deprecation comes from the root of ClassicRenderingTestCase. Ember's DynamicScope, and these assertions, exist only below an appendTo root, so this module tests code that is only reachable from a classic component.

// (`@ember/component`) or a Glimmer component, resolved by name by Ember's resolver.

@test
@test({ skip: DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isRemoved })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These 2 rehydration tests render a classic component. glimmer-workspace has no testUnless, so they use skip.

We don't mark @deprecated until a deprecation is "enabled"

Previously:
```
  @deprecated Use a Glimmer component (`@glimmer/component`) or a template-only component instead. See https://deprecations.emberjs.com/id/ember-component
```
DEPRECATE_EMBER_COMPONENT: deprecation({
id: 'ember-component',
for: 'ember-source',
since: { available: '7.6.0' },

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.

7.6.0 is currently / still main ✔️

@NullVoxPopuli
NullVoxPopuli merged commit 9ed2915 into emberjs:main Nov 11, 2026
68 checks passed
lifeart added a commit to lifeart/ember.js that referenced this pull request Nov 13, 2026
…r-component deprecation

Main deprecates the classic Component (RFC emberjs#1216, emberjs#21630):
Component#init calls deprecateUntil, so a test that creates a classic
component fails in the "All deprecations enabled" job (unexpected
deprecation) and throws in the "Deprecations as errors" jobs (the
deprecation is removed at 8.0.0). Main guarded its own tests; four tests
this series added were not:

  AngleBracket Invocation (URL sanitization of forwarded attributes):
    a bound URL attribute on a classic component element is sanitized,
    also on update
  AngleBracket Invocation (attributes are not arguments):
    a classic component does not see an attribute as a property
  Components test: argument names:
    a classic component gets an argument named SymbolTable
    a classic component invoked with curlies gets an argument named
    SymbolTable

Each now expects the deprecation and is skipped once it is removed, with
`${testUnless(DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isRemoved)} <name>`,
the form the deprecations module documents. testUnless(false) is "@test",
so the test names stay the same and native-skip.json and the baselines
still match them.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
lifeart added a commit to lifeart/ember.js that referenced this pull request Nov 13, 2026
…ponents test

Main now declares this test as
`${testUnless(DEPRECATIONS.DEPRECATE_EMBER_COMPONENT.isRemoved)} @test classic components`
(emberjs#21630). testUnless(false) is itself "@test", so the
QUnit name became " @test classic components" instead of
" classic components". native-skip.json matches tests by name, so the
gxt-native page stopped skipping this documented-drop test, ran it and
failed the native gate:

  green->red: Application test: debug render tree ::  @test classic components

The skip entry and the native baseline's skipped-test name now use the
new name. Nothing else in the GXT skip lists or baselines refers to a test
main renamed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

3 participants