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

Prepare for FastBoot 1.0 #21

Merged
merged 7 commits into from
Jun 1, 2017

Conversation

simonihmig
Copy link
Contributor

This PR adds changes to make the addon compatible with FastBoot pre 1.0 and post 1.0 (no instance-initializers/(browser|fastboot). Also added FastBoot tests (currently only running with FastBoot pre 1.0)

cc @kratiahuja

@kratiahuja
Copy link

cross referencing so i can review later: ember-cli-fastboot issue

index.js Outdated
var checker = new VersionChecker(this);
var emberVersion = checker.for('ember-source', 'npm');
treeForApp(defaultTree) {
let checker = new VersionChecker(this);
Copy link

@kratiahuja kratiahuja Apr 27, 2017

Choose a reason for hiding this comment

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

My PR exposes a process environment process.env.FASTBOOT_NEW_BUILD and addToFastBootTree for these cases. Instead of merging here you can just do this:

Let me know if this doesn't work or you feel this may not be needed but I exposed those hooks in my PR to have this in mind. More than happy to drop code 😄

treeForApp(defaultTree) {
  if (!process.env.FASTBOOT_NEW_BUILD) {
      var emberVersion = checker.for('ember-source', 'npm');

    if (!emberVersion.version) {
      emberVersion = checker.for('ember', 'bower');
    }

    var trees = [defaultTree];

    // 2.9.0-beta.1 - 2.9.0-beta.5 used glimmer2 (but 2.9.0 did not)
    // 2.10.0-beta.1+ includes glimmer2
    if (!(emberVersion.gt('2.9.0-beta') && emberVersion.lt('2.9.0')) && !emberVersion.gt('2.10.0-beta')) {
      trees.push(this.treeGenerator(path.resolve(this.root, 'app-lt-2-10')));
    }

    var tree = mergeTrees(trees, { overwrite: true });

    return filterInitializers(tree);
  } else {
     return defaultTree;
 }
}

addToFastBootTree() {
  // this hook will be invoked in post fastboot 1.0 (after my PR is merged)
  var fastbootBuilder = require('ember-cli-fastboot/lib/build-utilities/fastboot-builder');
  
  let checker = new VersionChecker(this);
  let emberVersion = checker.for('ember-source', 'npm');
 
  if (!emberVersion.version) {
     emberVersion = checker.for('ember', 'bower');
   }

  // 2.9.0-beta.1 - 2.9.0-beta.5 used glimmer2 (but 2.9.0 did not)
    // 2.10.0-beta.1+ includes glimmer2
    if (!(emberVersion.gt('2.9.0-beta') && emberVersion.lt('2.9.0')) && !emberVersion.gt('2.10.0-beta')) {
      return fastbootBuilder.addFastBootPath(path.resolve(this.root, 'fastboot-app-lt-2-9'));
    }
}

When FastBoot 1.0 is released, we can remove treeForApp.

@simonihmig simonihmig changed the title Prepare for FastBoot 1.0 [WIP] Prepare for FastBoot 1.0 Apr 27, 2017
@simonihmig
Copy link
Contributor Author

Fyi: added additional FastBoot tests, that now run pre and post FB 1.0 scenarios. That should now cover all cases, including pre-Glimmer2.

@simonihmig
Copy link
Contributor Author

@kratiahuja Just pushed some changes, is that what you had in mind?

The problem here is that tests will be failing. Because ember-cli-addon-tests will symlink the addon, the require('ember-cli-fastboot/lib/build-utilities/fastboot-builder') cannot be resolved (as it is just a dependency of the consuming app, not of the addon). This is an issue for the tests, but also all cases where the user symlinks the addon (npm link)...

Copy link

@kratiahuja kratiahuja left a comment

Choose a reason for hiding this comment

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

Can you try running the tests against ember-cli-fastboot master if possible? It should pass with those. If we can get it to run against master then we can do a release for that (rc.1) and then upgrade here.

index.js Outdated

var trees = [defaultTree];
addToFastBootTree() {

Choose a reason for hiding this comment

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

This is now called treeForFastBoot per the latest.

index.js Outdated
var trees = [defaultTree];
addToFastBootTree() {
// this hook will be invoked in post FastBoot 1.0
let fastbootBuilder = require('ember-cli-fastboot/lib/build-utilities/fastboot-builder');

Choose a reason for hiding this comment

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

You don't need this any longer. treeForFastBoot now takes a treeGenerator. See an example here

@simonihmig
Copy link
Contributor Author

@kratiahuja Updated this according to your suggestions!

Copy link

@kratiahuja kratiahuja left a comment

Choose a reason for hiding this comment

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

Assuming you have tested all the three scenarios listed here: https://gist.github.com/kratiahuja/d22de0fb1660cf0ef58f07a6bcbf1a1c#testing-guidelines, this LGTM

@@ -15,5 +15,5 @@ export function initialize(instance) {

export default {
name: 'head-fastboot',
initialize: initialize

Choose a reason for hiding this comment

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

The initialize function needs to be wrapped in a if (typeof FastBoot != 'undefined') {...} check to make sure ember-cli-head works in apps without ember-cli-fastboot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just had a look at it again... I think this is not needed, as this is not part of app

And the ember 2.4 test scenario seems to be ok!

Choose a reason for hiding this comment

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

Sounds good. Missed the filterInitializers again 👍

@simonihmig
Copy link
Contributor Author

Assuming you have tested all the three scenarios listed here

I'll give this another test drive tomorrow...

@simonihmig
Copy link
Contributor Author

There was one missing piece (merging app-lt-2-10 for pre-Glimmer2 and new FastBoot) which I fixed now.

I think this should be fine now and ready for final review/merge! cc @ronco @rwjblue

@simonihmig simonihmig changed the title [WIP] Prepare for FastBoot 1.0 Prepare for FastBoot 1.0 May 23, 2017
Copy link

@kratiahuja kratiahuja left a comment

Choose a reason for hiding this comment

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

LGTM


return filterInitializers(tree);
} else {
let trees = [defaultTree];

Choose a reason for hiding this comment

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

Can't you do this in treeForFastBoot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that's just for the browser. That's covering the new FastBoot, but with an pre 2.10 ember, where we need to merge the app-lt-2-10 browser initializer!

@stefanpenner
Copy link

@rwjblue i believe you may have commit/release, mind sharing it? So we can fix/release when this is ready.

@rwjblue
Copy link
Member

rwjblue commented May 26, 2017

Ya, will do once I am back at a computer

@mazondo
Copy link

mazondo commented May 28, 2017

I'm seeing an issue with this where instance initializer head-browser is injected twice and throws an error if you're using fastboot but pass ?fastboot=false as a param.

Edit: Actually, this is happening all the time. Going to dig into it now.

@mazondo
Copy link

mazondo commented May 29, 2017

There were a few things going on in my case that caused the error, mostly interactions between ember-page-title, ember-cli-meta-tags and ember-cli-head.

Edit: removing ember-page-title and ember-cli-meta-tags resolved this issue for me.

@kratiahuja
Copy link

Ping @rwjblue can we merge and release this?

@@ -49,7 +51,7 @@
"ember-cli-babel": "^6.0.0",
"ember-cli-htmlbars": "^1.3.0",
"ember-cli-version-checker": "^1.1.6",
"fastboot-filter-initializers": "0.0.1"
"fastboot-filter-initializers": "^0.0.2"
Copy link
Member

Choose a reason for hiding this comment

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

Caret here does nothing, we should bump to 0.1.0 (upstream) so that we can use caret deps...

@rwjblue rwjblue merged commit b3bfcbc into ember-fastboot:master Jun 1, 2017
@rwjblue
Copy link
Member

rwjblue commented Jun 1, 2017

@kratiahuja / @simonihmig - What should the version bump be? Seems to be a compatible change (lots of effort for backwards compat in this PR), so I would assume 0.2.1 but I want to double check...

@simonihmig
Copy link
Contributor Author

@rwjblue yeah, it got a bit more complicated because of trying to be compatible with FastBoot beta-series as well as 1.0 (rc). But this dual compatibility is covered by those separate FastBoot tests, so I'm pretty confident that this should not break anything (hopefully!). So 0.2.1 should be ok!

@rwjblue
Copy link
Member

rwjblue commented Jun 1, 2017

ember-cli-head 0.2.1 published 🎉

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

Successfully merging this pull request may close these issues.

5 participants