From 1d6cd99d8852e826060d6fd2bbfd6354eed93e9a Mon Sep 17 00:00:00 2001 From: Lukas Kohler Date: Fri, 21 Oct 2022 21:34:06 +0200 Subject: [PATCH] fix: remove hard dependency on model-fragments (#468) * fix: remove hard dependency on model-fragments * fix: instanceof Fragment and FragmentArray is not an object Co-authored-by: Gabriel Cousin <7649529+GabrielCousin@users.noreply.github.com> --- addon/converter/fixture-converter.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/addon/converter/fixture-converter.js b/addon/converter/fixture-converter.js index 34140010..b1f1a4fe 100644 --- a/addon/converter/fixture-converter.js +++ b/addon/converter/fixture-converter.js @@ -3,8 +3,20 @@ import { entries } from '../utils/helper-functions'; import { typeOf } from '@ember/utils'; import { getOwner } from '@ember/application'; import { camelize } from '@ember/string'; -import Fragment from 'ember-data-model-fragments/fragment'; -import FragmentArray from 'ember-data-model-fragments/array/fragment'; +import require from 'require'; + +let Fragment; +let FragmentArray; +try { + let MF = require('ember-data-model-fragments/fragment'); + let MFA = require('ember-data-model-fragments/array/fragment'); + Fragment = MF && MF.default; + FragmentArray = MFA && MFA.default; +} catch (e) { + // create empty constructors + Fragment = function Fragment() {}; + FragmentArray = function FragmentArray() {}; +} /** Base class for converting the base fixture that factory guy creates to