Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate import Ember from 'ember' #20686

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/@ember/-internals/deprecations/index.ts
Original file line number Diff line number Diff line change
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) {
kategengler marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
@@ -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
kategengler marked this conversation as resolved.
Show resolved Hide resolved
);
confirmExport(Ember, assert, path, moduleId, exportName, emberTesting);
};
});
Expand Down
Loading
Loading