Fix duplicate initializers appearing in dist js file#28
Fix duplicate initializers appearing in dist js file#28slannigan wants to merge 1 commit intoember-fastboot:masterfrom
Conversation
…ted when the project gets built
|
There doesn't exists Can you put in a minimal reproduction with only |
|
The removal of the initializers within a What is puzzling me is that the code sample you posted for the second initializer does not even exist in this repo in the current master branch (and so in release 0.2.1). Search for "head-browser" (https://github.com/ronco/ember-cli-head/search?utf8=✓&q=head-browser&type=), and you see that there are two initializers, however both have a FastBoot guard around their I don't think there can be two addons of the same name (different versions) active, right? Did your app maybe try to override |
|
@slannigan can you create a minimal reproduction with a dummy app? This will help us nail down the issue to come up with the correct solution. |
|
The issue is we were on v3.1.6 of https://github.com/tim-evans/ember-page-title which was tied to 0.2.0 of ember-cli-head. With ember-cli/ember-page-title#70 (v3.2.0), we no longer have this issue. |
|
To be clear, I assume it was the conflict of having both ember-page-title and ember-cli-meta-tags in our repo with them pointing at 2 different versions of ember-cli-head which was causing the issue. |
(Note: This error could only be seen when using a project using https://github.com/ronco/ember-cli-meta-tags. If just running ember-cli-meta-tags, this error doesn't appear.)
The error:
When running
ember son our project (which we'll callproject-name), we would get this console error:"Assertion Failed: The instance initializer 'head-browser' has already been registered". (https://puu.sh/w7HJm/fd018e7dc1.png)On investigation, in
dist/assets/project-name.js, there were two initializers when there should only have been one, which is what was causing this error to appear.The first one:
The second one:
My guess of what the problem is
Between 0.2.0 and 0.2.1, the non-fastboot initializers were moved from
{{appFolderName}}/instance-initializers/browser/head.jsto{{appFolderName]}/instance-initializers/head.js, while the fastboot initializers remained in{{appFolderName}}/instance-initializers/fastboot/head.js.In ember-cli-head/app/index.js,
broccoli-merge-treesis used to select the path to be used for the initializer. I think the different folder depth level of the fastboot vs non-fastboot initializers is causing broccoli-merge-trees to not merge the paths correctly, causing two initializers to be in the final distributed file.The fix
Moved the non-fastboot initializers back to their original folders, in
{{appFolderName}}/instance-initializers/browser/head.js. Regardless of what the precise cause is, I tested this solution and it does indeed fix the problem.