Skip to content

[Feature] Update initializer blueprint for module unification#16489

Merged
rwjblue merged 1 commit intoemberjs:masterfrom
sduquej:sd/initializer-blueprint
Jun 8, 2018
Merged

[Feature] Update initializer blueprint for module unification#16489
rwjblue merged 1 commit intoemberjs:masterfrom
sduquej:sd/initializer-blueprint

Conversation

@sduquej
Copy link
Contributor

@sduquej sduquej commented Apr 11, 2018

For ember-cli/ember-cli#7530

TODO:

  • Addons – unsure of how this might work given the following in RFC143

The specific format of collection and type declarations for addons is TBD.

);

expect(_file('src/init/initializers/foo/bar-test.js')).to.contain(
"import { initialize } from 'my-app/initializers/foo/bar';"
Copy link
Member

@GavinJoyce GavinJoyce Apr 16, 2018

Choose a reason for hiding this comment

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

I think this will have to change to point to the new path under src

Choose a reason for hiding this comment

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

I came to this PR looking for how to do that, haha. I'm in the same situation where my tests are passing without updating the import statement and I'm not sure why 🤔 Or where the import statement is generated.

Choose a reason for hiding this comment

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

I think I've got it sorted now 👍

@GavinJoyce
Copy link
Member

Perhaps update the title to be Update initializer blueprint for module unification?

@GavinJoyce
Copy link
Member

We'll also need to add tests to initializer-test-test.js to ensure that we're generating co-located tests.

I manually tried this in a local MU app and it seems to fail with a Uncaught Error: mu-app/src/init/initializers/foo-test must export an initializer. exception. We might have to modify https://github.com/ember-cli/ember-load-initializers to ignore colocated tests:

screen shot 2018-04-16 at 08 27 14

LMK if you'd like to pair on this

@GavinJoyce
Copy link
Member

The specific format of collection and type declarations for addons is TBD

For the purpose of making progress in the PR, I think a good assumption is that they should follow the same rules as apps. If we hit any barriers when implementing, we can raise it.

@sduquej sduquej changed the title [WIP] [Feature] Update service blueprint for module unification [WIP] [Feature] Update initializer blueprint for module unification Apr 16, 2018
@GavinJoyce
Copy link
Member

@sduquej ^ that's been resolved, perhaps you could rebase?

Also, could you add an in-repo-addon test similar to this? This will ensure that we're not breaking existing functionality.

@sduquej
Copy link
Contributor Author

sduquej commented Apr 21, 2018

👍 I've rebased.
The initializer blueprint already had tests similar to those.
Thanks for unblocking this! 🙌

@sduquej sduquej force-pushed the sd/initializer-blueprint branch 2 times, most recently from 03a4396 to 98c2e32 Compare June 3, 2018 23:20
import Application from '@ember/application';
import { run } from '@ember/runloop';

import { initialize } from 'my-app/init/initializers/foo';
Copy link
Contributor Author

@sduquej sduquej Jun 3, 2018

Choose a reason for hiding this comment

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

the addition of init/ is the only new thing in these fixture files.

There's a possibility that they can get out of date if changes to the classic fixtures happened. While not ideal the risk seems minimum given how infrequent these type of changes are and duplicating these has the upside of easier clean-up and similarity to what was done in ember-cli

@sduquej sduquej force-pushed the sd/initializer-blueprint branch from 98c2e32 to f3cd9ff Compare June 3, 2018 23:29
@sduquej sduquej changed the title [WIP] [Feature] Update initializer blueprint for module unification [Feature] Update initializer blueprint for module unification Jun 4, 2018
if (options.pod) {
throw 'Pods arenʼt supported within a module unification app';
} else if (options.inDummy) {
return path.join('tests', 'dummy', 'src/init');
Copy link
Member

Choose a reason for hiding this comment

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

return path.join('tests', 'dummy', 'src', 'init'); perhaps?

} else if (options.inDummy) {
return path.join('tests', 'dummy', 'src/init');
}
return 'src/init';
Copy link
Member

Choose a reason for hiding this comment

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

return path.join('src', 'init'); perhaps?

import { run } from '@ember/runloop';
import Application from '@ember/application';
import { initialize } from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>';
import { initialize } from '<%= dasherizedModulePrefix %>/<% if (isModuleUnificationProject) { %>init/<% } %>initializers/<%= dasherizedModuleName %>';
Copy link
Member

@GavinJoyce GavinJoyce Jun 5, 2018

Choose a reason for hiding this comment

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

perhaps it would be simpler to replace dasherizedModulePrefix with a modulePrefix in locals so that we don't have to litter lots of files with <% if (isModuleUnificationProject) { %>init/<% } %> statements?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 great suggestion!

@sduquej sduquej force-pushed the sd/initializer-blueprint branch from f3cd9ff to a15ca10 Compare June 6, 2018 20:43
@sduquej
Copy link
Contributor Author

sduquej commented Jun 7, 2018

@GavinJoyce I think this is ready for review whenever you've some time 👀

@GavinJoyce
Copy link
Member

@sduquej 👀. Can you prefix the commit with [Feature]?

@sduquej sduquej force-pushed the sd/initializer-blueprint branch 5 times, most recently from 7ecc071 to fc1014c Compare June 8, 2018 12:14
@sduquej sduquej force-pushed the sd/initializer-blueprint branch from fc1014c to 3661007 Compare June 8, 2018 12:21
@rwjblue
Copy link
Member

rwjblue commented Jun 8, 2018

Restarted CI

@sduquej
Copy link
Contributor Author

sduquej commented Jun 8, 2018

@rwjblue could you give it one more kick please? seems to have timed out

Copy link
Member

@GavinJoyce GavinJoyce left a comment

Choose a reason for hiding this comment

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

I'm 👍 too, nice one @sduquej

@rwjblue rwjblue merged commit bd8ad77 into emberjs:master Jun 8, 2018
@rwjblue
Copy link
Member

rwjblue commented Jun 8, 2018

Awesome, thank you!

@sduquej sduquej deleted the sd/initializer-blueprint branch June 9, 2018 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants