Skip to content

Commit

Permalink
check debug package presence before import Fix #7053 (#7531)
Browse files Browse the repository at this point in the history
* import DebugAdapter only if @ember-data/debug package is present Fix #7053

* fix stripping and enable tests to work when stripped

Co-authored-by: Chris Thoburn <[email protected]>
  • Loading branch information
sly7-7 and runspired authored May 25, 2021
1 parent 714dedb commit 64d3692
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 266 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-data/debug').default;
}

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

0 comments on commit 64d3692

Please sign in to comment.