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

proposal for a new folder for adapters, serializers and transformers #38

Closed
fsmanuel opened this issue Apr 6, 2014 · 5 comments
Closed

Comments

@fsmanuel
Copy link

fsmanuel commented Apr 6, 2014

i would like to put adapters, serializers and transforms under one directory. i think they belong together and shouldn't be cluttered around in app/
let's say app/data. the folder layout would be:

app/data
  adapters
    application.js
    post.js
  serializers
    application.js
    post.js
  transforms
    raw.js
    currency.js

it would require to add 4 lines of code and shouldn't affect the resolver:

  // if router:main or adapter:main look for a module with just the type first
  tmpModuleName = prefix + '/' + parsedName.type;
  if (!moduleName && name === 'main' && moduleEntries[tmpModuleName]) {
    moduleName = prefix + '/' + parsedName.type;
  }

  // load adapters, serializers and transformers in app/data
  tmpModuleName = prefix + '/data/' + pluralizedType + '/' + name;
  if (!moduleName && moduleEntries[tmpModuleName]) {
    moduleName = prefix + '/data/' + pluralizedType + '/' + name;
  }

  // fallback if not type:main or POD format
  if (!moduleName) { moduleName = prefix + '/' +  pluralizedType + '/' + name; }

@rjackson @stefanpenner what do you think?

@fsmanuel
Copy link
Author

fsmanuel commented Apr 6, 2014

data-store would be a better name i guess.

@stefanpenner
Copy link
Contributor

I like the idea :)

@rwjblue
Copy link
Member

rwjblue commented Apr 6, 2014

By default we use the generic modulePrefix value for everything, but customizing is super simple, by overriding adapterPrefix, serializerPrefix, and transformPrefix with 'app/data-store':

App = Ember.Application.create({
  Resolver: Resolver, // imported
  adapterPrefix: 'app/data-store',
  serializerPrefix: 'app/data-store',
  transformPrefix: 'app/data-store'
})

In general I agree that these things should be lumped together, but I would prefer to use the extension points for this customization for now.

@fsmanuel
Copy link
Author

fsmanuel commented Apr 6, 2014

@rjackson ah now i got the + 'Prefix' thing. i'm totally ok using the prefixes.
@stefanpenner what about having them as defaults in ember-cli?

@rwjblue
Copy link
Member

rwjblue commented Apr 6, 2014

👍 on the default in ember-cli.

The way I see it: we make this resolver maximally flexible, and give good defaults in consumer projects (like EAKR/EAK and ember-cli). This seems to fall in line with "The Ember Way".

@rwjblue rwjblue closed this as completed Apr 6, 2014
kratiahuja pushed a commit to kratiahuja/ember-resolver that referenced this issue Aug 5, 2016
Allow package to be usable via npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants