Skip to content

Commit

Permalink
import DebugAdapter only if @ember-data/debug package is present Fix e…
Browse files Browse the repository at this point in the history
  • Loading branch information
sly7-7 committed May 21, 2021
1 parent 1f80a43 commit 55432ac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/-ember-data/addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'ember-inflector';
import EmberError from '@ember/error';
import { VERSION } from '@ember/version';

import require, { has } from 'require';

import Adapter, { BuildURLMixin } from '@ember-data/adapter';
import AdapterError, {
AbortError,
Expand All @@ -18,7 +20,6 @@ import AdapterError, {
} from '@ember-data/adapter/error';
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import RESTAdapter from '@ember-data/adapter/rest';
import DebugAdapter from '@ember-data/debug';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
import Serializer from '@ember-data/serializer';
import { BooleanTransform, DateTransform, NumberTransform, StringTransform } from '@ember-data/serializer/-private';
Expand All @@ -45,6 +46,8 @@ import {
} from './-private';
import setupContainer from './setup-container';

const HAS_DEBUG_PACKAGE = has('@ember-data/debug') || false;

if (VERSION.match(/^1\.([0-9]|1[0-2])\./)) {
throw new EmberError(
'Ember Data requires at least Ember 1.13.0, but you have ' +
Expand Down Expand Up @@ -85,7 +88,9 @@ DS.errorsArrayToHash = errorsArrayToHash;

DS.Serializer = Serializer;

DS.DebugAdapter = DebugAdapter;
if (HAS_DEBUG_PACKAGE) {
DS.DebugAdapter = require('@ember/debug').default;
}

DS.RecordArray = RecordArray;
DS.AdapterPopulatedRecordArray = AdapterPopulatedRecordArray;
Expand Down

0 comments on commit 55432ac

Please sign in to comment.