Registry / testing / ember-classic-decorator

ember-classic-decorator

JSON →
library4.0.0jsnpmunverified

A dev-time only decorator to aid migrating from Ember's classic class system to native classes in Ember Octane. The @classic decorator flags classes that still rely on classic APIs (reopen, reopenClass) and prevents timing bugs with init/constructor. Version 4.0.0 is the latest stable, requires ember-source >= 4.0.0. It is no longer needed and can be safely removed; it must be removed before switching to Vite. Ships TypeScript types. Low maintenance, intended for transitional use.

npm install ember-classic-decorator
INSTALL
IMPORT
SIG · EMBER-CLASSIC-DECO
E
ember-classic-decorator
testingjavascriptv4.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

classic
✓ import classic from 'ember-classic-decorator';
✗ import { classic } from 'ember-classic-decorator';
Default export; named import does not work.
@classic
✓ @classic class MyComponent extends Component {}
✗ class MyComponent extends Component {} // missing decorator
Decorate classic classes to avoid assertion errors.
require('ember-classic-decorator')
✓ const classic = require('ember-classic-decorator');
✗ const { classic } = require('ember-classic-decorator');
CommonJS usage is possible but discouraged; prefer ESM import.

Install the addon, configure ESLint, and use @classic decorator on classic-style Ember classes to suppress assertions and aid migration.

// Install the addon // ember install ember-classic-decorator // Add eslint rules to .eslintrc.js // 'ember/classic-decorator-hooks': 'error', // 'ember/classic-decorator-no-classic-methods': 'error' // Use @classic decorator on classes still using classic APIs import classic from 'ember-classic-decorator'; import Component from '@ember/component'; @classic export default class MyComponent extends Component { init() { super.init(...arguments); // classic setup } // Using reopen in a @classic decorated class is allowed // Without @classic, it would throw an error static reopen() { /* ... */ } } // To remove @classic, convert to Glimmer component and remove decorator. // Note: @classic is not needed and can be safely removed from all classes.
Debug
Known issues
deprecatedThis library is no longer needed; it can be safely removed from projects without runtime or buildtime changes.
fix
Remove ember-classic-decorator from package.json and delete any @classic decorators.
affects: >=4.0.0
breakingMust be removed before switching to Vite; otherwise Vite builds may fail or have unexpected behavior.
fix
Remove the addon before migrating to Vite.
affects: >=4.0.0
gotchaThe @classic decorator only affects dev-time assertions; it is removed from production builds. Do not rely on it for runtime behavior.
fix
Use eslint rules to catch classic APIs rather than depending on runtime assertions.
affects: >=1.0.0
deprecatedEmber classic classes are deprecated in favor of native classes and Glimmer components.
fix
Migrate all classes to native syntax and remove @classic decorator.
affects: >=3.15
gotchaUsing constructor in a subclass when the parent has init causes timing bugs; @classic prevents this but only in dev.
fix
Avoid constructor in subclasses that override init; use init instead.
affects: >=1.0.0
Errors
Common errors & fixes
Assertion Failed: You attempted to use `reopen` on a class that is not marked as @classic.
Using reopen on a native class without @classic decorator.
fix
Add @classic decorator to the class definition, or remove the reopen call.
Assertion Failed: You attempted to use `reopenClass` on a class that is not marked as @classic.
Using reopenClass on a native class without @classic decorator.
fix
Add @classic decorator or refactor away from reopenClass.
Lint error: 'ember/classic-decorator-no-classic-methods' - Do not use classic methods on non-classic classes.
Using get/set/addObserver/etc. on a class that is not marked @classic.
fix
Add @classic decorator or convert usage to modern alternatives.
TypeError: Cannot read properties of undefined (reading 'reopen')
Missing @classic decorator but class extends EmberObject and uses reopen.
fix
Add @classic decorator and ensure eslint rules are active to catch these errors.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
ember-sourcerequiredPeer dependency; library decorates Ember classes and must match Ember version.
Agent activity
5 hits · last 30 days
node
4
Resources
ember-classic-decorator — npm install ember-classic-decorator · libregistry