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

Ember Data JavaScript Modules API #238

Closed
wants to merge 6 commits into from
Closed

Ember Data JavaScript Modules API #238

wants to merge 6 commits into from

Conversation

locks
Copy link
Contributor

@locks locks commented Jul 25, 2017

Rendered

Originally authored by @bmac.

| Global | Module |
|--- | --- |
| `DS.Serializer` | `import Serializer from '@ember-data/serializer'` |
| `DS.EmbeddedRecordsMixin` | `import EmbeddedRecordsMixin from '@ember-data/serializer/src/embedded-record-mixin'` |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be @ember-data/serializer/src/embedded-records-mixin (note records as plural)


# Detailed design

Ember Data will stick with 1 top level namespace of `@ember-data`. Under it there are 6 nested module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Ember Data will stick with 1 top level namespace of `@ember-data`. Under it there are 6 nested module
namespaces where exposed components could live. Someday these namespaces could be moved into their own
top level scoped package (for example `@ember-data/serializer` could become `@ember-data/serializer`) however,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between @ember-data/serializer and @ember-data/serializer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad edit from the draft.

# Alternatives

The easiest alternative would be to continue using the current exports.
Alternatively, we could use the current shims, which do not follow the RFC #176 heuristics as closely.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what current shims?

Copy link
Contributor Author

@locks locks Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import attr from 'ember-data/attr; and company.
If you generate a model in Ember Twiddle you'll unfortunately see what I mean :P

| Global | Module |
|--- | --- |
| `DS.Store` | `import Store from '@ember-data/store'` |
| `DS.AdapterPopulatedRecordArray` | `import AdapterPopulatedRecordArray from '@ember-data/store/src/adapter-populated-record-array'` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src in the module import path is needed due to the new module unification semantics, which obviously makes it a little harder to build nice looking APIs based on import paths. IMHO we should first figure out how we could accomplish nice looking paths and then afterwards think about new Ember Data module APIs. Otherwise we might create more churn than needed.

@t-sauer
Copy link

t-sauer commented Jul 26, 2017

What's the reasoning behind using the @ember-data scope?
As far as I understood the reason behind the @ember scope was to work towards standalone modules (e.g. @ember/array) which can be removed from applications if they are not needed.
Does the same idea apply to Ember Data? I would assume that if Ember Data is used in a project, it is probably used entirely (e.g. not only models and transforms). So probably most (if not all) applications have 6 packages just to get Ember Data working, which seems to be unnecessary complicated for new people ("Why do I need to add six packages just to use this one library?").

What probably makes sense, is that most people don't need all the adapters and serializers that are included by default (I don't need the RESTAdapter if I only use the JSONAPIAdapter) and they could be left out. But in my opinion this should be solved by a different solution than splitting up the whole library into small chunks. For example tree shaking could make them have no costs for end users and they could stay in the main package or maybe they could be separated into their own addons. But I guess this would be a concern of a different RFC.

So I think it makes more sense, to keep Ember Data as a single package instead of using a scope with multiple packages, to avoid unnecessary complexity.

@tomdale
Copy link
Member

tomdale commented Jul 28, 2017

One thing we discussed in the core team meeting today was keeping Ember data under the @ember scope, to communicate that it's an "official," core-supported package. Then we would have things like:

  • @ember/data/store
  • @ember/data/model

This would also allow us to break out modules we no longer wish to ship with the default distribution into packages like:

  • @ember/json-api-adapter

@lolmaus
Copy link

lolmaus commented Jul 29, 2017

The link in the top comment is incorrect. Should be https://github.com/emberjs/rfcs/blob/ember-data-modules/text/0000-ember-data-javascript-module-api.md .

@rwjblue
Copy link
Member

rwjblue commented Jul 29, 2017

Thanks, updated.

@mmun mmun added the T-ember-data RFCs that impact the ember-data library label Aug 1, 2017
@Samsinite
Copy link
Contributor

@t-sauer while this RFC doesn't explicitly mention it (maybe it should), a meta package could be used to include all of the 6 ember-data dependencies (hopefully keeping the name ember-data) to make it so only one module is explicitly depended on in the package.json file.

@locks
Copy link
Contributor Author

locks commented Aug 1, 2017

@Samsinite we already have the meta package named ember-data, and like RFC #176, it isn't strictly about how the packages are published, as we are scheduled to land the new modules api in 2.16 through the ember-source addon.

@Samsinite
Copy link
Contributor

@locks exactly what I assumed, was just addressing t-sauer's concern. Thanks for clarifying!

@locks
Copy link
Contributor Author

locks commented Feb 15, 2018

I am no longer the right person to push this forward, and it would necessitate a complete rewrite at any rate.

@locks locks closed this Feb 15, 2018
@locks locks deleted the ember-data-modules branch February 15, 2018 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-ember-data RFCs that impact the ember-data library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants