Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embroider: Use of ember-data internals #740

Closed
fsmanuel opened this issue Oct 29, 2023 · 1 comment · Fixed by #741
Closed

Embroider: Use of ember-data internals #740

fsmanuel opened this issue Oct 29, 2023 · 1 comment · Fixed by #741

Comments

@fsmanuel
Copy link
Contributor

Similar to #739 we use ember-data internals to detect if ember-data is installed and if it's a DS.Model, DS.ManyArray, or DS.PromiseManyArray .

function requireModule(module, exportName = 'default') {
  if (require.has(module)) {
    return require(module)[exportName];
  }
}

const DS = requireModule('ember-data');

export function isDsModel(o) {
  return !!(DS && o && o instanceof DS.Model);
}

export function isDSManyArray(o) {
  return !!(
    DS &&
    o &&
    isArray(o) &&
    (o instanceof DS.PromiseManyArray || o instanceof DS.ManyArray)
  );
}

I wonder how long the ember-data import will be arround and if @ember-data/model/-private could be an embroider safe alternative.

const Model = requireModule('@ember-data/model');
const { ManyArray, PromiseManyArray } = requireModule('@ember-data/model/-private');

//cc @runspired @ef4 @gilest

This was referenced Oct 29, 2023
@runspired
Copy link

isDSManyArray should just go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants