@@ -2,6 +2,11 @@ import type { Resolver } from '@ember/owner';
22import ApplicationInstance from '@ember/application/instance' ;
33import Application from '@ember/application' ;
44import EmberObject from '@ember/object' ;
5+ import {
6+ macroCondition ,
7+ importSync ,
8+ dependencySatisfies ,
9+ } from '@embroider/macros' ;
510
611import require , { has } from 'require' ;
712import Ember from 'ember' ;
@@ -147,14 +152,21 @@ export default function buildRegistry(resolver: Resolver) {
147152
148153 exposeRegistryMethodsWithoutDeprecations ( container ) ;
149154
150- if ( has ( 'ember-data/setup-container' ) ) {
151- // ember-data is a proper ember-cli addon since 2.3; if no 'import
152- // 'ember-data'' is present somewhere in the tests, there is also no `DS`
153- // available on the globalContext and hence ember-data wouldn't be setup
154- // correctly for the tests; that's why we import and call setupContainer
155- // here; also see https://github.com/emberjs/data/issues/4071 for context
156- let setupContainer = require ( 'ember-data/setup-container' ) [ 'default' ] ;
157- setupContainer ( owner ) ;
155+ // ember-data is a proper ember-cli addon since 2.3; if no 'import
156+ // 'ember-data'' is present somewhere in the tests, there is also no `DS`
157+ // available on the globalContext and hence ember-data wouldn't be setup
158+ // correctly for the tests; that's why we import and call setupContainer
159+ // here; also see https://github.com/emberjs/data/issues/4071 for context
160+ if ( macroCondition ( dependencySatisfies ( 'ember-data' , '>= 2.3' ) ) ) {
161+ // Additionally, this file is deprecated with no replacement for
162+ // removal in ember-data v6.0
163+ // See: ember-data/dist/setup-container
164+ if ( macroCondition ( dependencySatisfies ( 'ember-data' , '< 6.0' ) ) ) {
165+ let { default : setupContainer } = importSync (
166+ 'ember-data/setup-container'
167+ ) as any ;
168+ setupContainer ( owner ) ;
169+ }
158170 }
159171
160172 return {
0 commit comments