From ec9f64997187a31d2c7457eb33da137bf465d93e 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addon/converter/fixture-converter.js b/addon/converter/fixture-converter.js index ad51af46..f19aed77 100644 --- a/addon/converter/fixture-converter.js +++ b/addon/converter/fixture-converter.js @@ -4,6 +4,20 @@ import { entries } from '../utils/helper-functions'; import { typeOf } from '@ember/utils'; import { getOwner } from '@ember/application'; import { camelize } from '@ember/string'; +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