ember-cli / rfcs

Archive of RFCs for changes to ember-cli (for current RFC repo see https://github.com/emberjs/rfcs)
45 stars 54 forks source link

Making addon dummy apps less special #119

Closed ef4 closed 5 years ago

ef4 commented 6 years ago

I would like to make dummy apps less of a special case. Right now they have some weird behaviors, like:

The general shape of my proposal is:

The only chunk of API design that I see missing from the above is deciding in detail what to put into the top-level ember-cli-build such that you can conveniently

A totally strawman example of the new top-level ember-cli-build.js would look like:

const AddonDevSetup = require('ember-cli/addon-dev-setup');
module.exports = new AddonDevSetup({
  sampleApps: [
    {
      // the app we're loading
      app: require('./sample-app/ember-cli-build.js'),

      // where to mount the app in the ember development server. Could 
      // potentially allow seting to `null` if you don't want the app to start 
      // automatically when you do a top-level `ember s`.
      rootURL: '/'

      // whether to run this app's `ember test` when we do a top-level `ember test`
      includeTests: true
    }
  ]
});
kellyselden commented 6 years ago

The first point has a PR https://github.com/ember-cli/ember-cli/pull/7602

knownasilya commented 6 years ago

Should these be split up and submitted as RFCs?

lennyburdette commented 6 years ago

dummy apps would become 100% normal ember apps. They should have their own package.json (like ./sample-app/package.json) ...

Otherwise, :+1: ! I'm hoping that moving acceptance tests into the dummy app make engine tests easier. The sample-app application tests can run setApplication(), while the engine's rendering/container tests use setResolver(engineResolverFor(...)). Though I have no idea how that would work at runtime since setApplication and setResolver set global state ...

ef4 commented 6 years ago

Based on what I described, it would necessarily be possible to add dependencies directly to the dummy app if you really want to. I'm not sure we'd want to rule that out -- maybe you need to test your addon both with and without another dependency present. But if you do that, you will need to run npm install in the dummy app.

Sticking to a subset of the main package.json and using * does seem like the sensible default behavior we should encourage.

ef4 commented 6 years ago

I edited the main post above to add another bad case I had forgotten about:

Because the dummy app and the addon share a package.json, it's not possible to test what happens when an app depends on your addon but does not directly depend on your addon's own addon dependencies. In a dummy app, all the addon's dependencies are forced to be direct dependencies of the app too. For example, if you addon uses ember-cli-sass, you can't test what happens when your addon is used in an app that doesn't happen to also use ember-cli-sass.

bravo-kernel commented 6 years ago

From an end-user perspective I would really welcome the ability to create multiple dummy/sample apps.

ASH-Michael commented 6 years ago

@bravo-kernel Isn't this already possible with routes in the dummy app?

From an end-user perspective I would really welcome the ability to create multiple dummy/sample apps.

bravo-kernel commented 6 years ago

Not completely separated as far as I know. I think I need something like https://github.com/mansona/testing-mu to get what I'm after; completely isolating ember-addon-docs and my demo-app. Update: but I'm pretty new to Ember so I could be mistaken.

ASH-Michael commented 6 years ago

@bravo-kernel I see what you are trying to accomplish now. Interesting.

rwjblue commented 5 years ago

We are working on closing the ember-cli/rfcs repo in favor of using a single central RFC's repo for everything. This was laid out in https://emberjs.github.io/rfcs/0300-rfc-process-update.html.

Sorry for the troubles, but would you mind reviewing to see if this is still something we need, and if so migrating this over to emberjs/rfcs?