Skip to content

Commit

Permalink
Merge pull request #20686 from NullVoxPopuli/deprecate-import-ember-f…
Browse files Browse the repository at this point in the history
…rom-ember

Deprecate `import Ember from 'ember'`
  • Loading branch information
ef4 committed May 10, 2024
2 parents 53b2de8 + a47224e commit fbe8738
Show file tree
Hide file tree
Showing 8 changed files with 898 additions and 826 deletions.
12 changes: 12 additions & 0 deletions packages/@ember/-internals/deprecations/index.ts
Expand Up @@ -2,6 +2,7 @@ import type { DeprecationOptions } from '@ember/debug/lib/deprecate';
import { ENV } from '@ember/-internals/environment';
import { VERSION } from '@ember/version';
import { deprecate, assert } from '@ember/debug';
import { dasherize } from '../string/index';

function isEnabled(options: DeprecationOptions) {
return Object.hasOwnProperty.call(options.since, 'enabled') || ENV._ALL_DEPRECATIONS_ENABLED;
Expand Down Expand Up @@ -90,6 +91,17 @@ function deprecation(options: DeprecationOptions) {
test the behavior without encountering the deprecated feature, just as users would.
*/
export const DEPRECATIONS = {
DEPRECATE_IMPORT_EMBER(importName: string) {
return deprecation({
id: `deprecate-import-${dasherize(importName).toLowerCase()}-from-ember`,
for: 'ember-source',
since: { available: '5.9.0' },
until: '6.0.0',
url: `https://deprecations.emberjs.com/id/import-${dasherize(
importName
).toLowerCase()}-from-ember`,
});
},
DEPRECATE_IMPLICIT_ROUTE_MODEL: deprecation({
id: 'deprecate-implicit-route-model',
for: 'ember-source',
Expand Down
13 changes: 11 additions & 2 deletions packages/ember-testing/tests/reexports_test.js
@@ -1,7 +1,8 @@
import Ember from 'ember';
import { confirmExport } from 'internal-test-helpers';
import { confirmExport, testUnless } from 'internal-test-helpers';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
import * as emberTesting from 'ember-testing';
import { DEPRECATIONS } from '@ember/-internals/deprecations';

class ReexportsTestCase extends AbstractTestCase {}

Expand All @@ -19,7 +20,15 @@ class ReexportsTestCase extends AbstractTestCase {}
exportName = path;
}

ReexportsTestCase.prototype[`@test Ember.${path} exports correctly`] = function (assert) {
ReexportsTestCase.prototype[
`${testUnless(
DEPRECATIONS.DEPRECATE_IMPORT_EMBER(path).isRemoved
)} Ember.${path} exports correctly`
] = function (assert) {
expectDeprecation(
/'ember' barrel file is deprecated/,
DEPRECATIONS.DEPRECATE_IMPORT_EMBER(path || exportName).isEnabled
);
confirmExport(Ember, assert, path, moduleId, exportName, emberTesting);
};
});
Expand Down

0 comments on commit fbe8738

Please sign in to comment.