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

Framework: Move to Node 4 #1204

Merged
merged 9 commits into from
Dec 17, 2015
Merged

Framework: Move to Node 4 #1204

merged 9 commits into from
Dec 17, 2015

Conversation

blowery
Copy link
Contributor

@blowery blowery commented Dec 2, 2015

This moves us up to Node v4.2.3, the current LTS version, in the Docker container. This needs a fair bit of testing and should not be merged until we're pretty happy with it.

Yes, the branch name is wrong.

To test, you'll need to

  1. install Vagrant,
  2. add a env-config.sh to the root of the project which exports CALYPSO_ENV set to a environment you want to test
  3. run vagrant up
  4. add the correct entries to /etc/hosts to hit your local env for the host you want to pretend to be
  5. add in a forwarder from port 80 to port 3000 locally, using nginx or polipo

TODO:

  • Bump Dockerfile up to 4.2.3
  • Add circle.yml to tell Circle CI which node to use
  • Upgrade any packages that need updates to run well on 4
  • Fix up tests
  • Bump engines in package.json
  • Add Makefile target that checks node version and explodes if the dev is on pre 4.2.3.

@blowery blowery added Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 2, 2015
@blowery blowery self-assigned this Dec 2, 2015
@ehg
Copy link
Member

ehg commented Dec 3, 2015

It would be cool to merge #730 to avoid some duplication.

I will give 4.4.2 a test with vagrant. With regards to merging this, I think a similar approach to the webpack server bundler is a good idea. e.g. notify systems, disable deploys to production for 30 minutes.

@blowery
Copy link
Contributor Author

blowery commented Dec 3, 2015

One little wrinkle I ran into: on Node v4+, it appears that the default http listener only listens on an IPv6 loopback, if it's available. If not, it falls back to the normal 127.0.0.1 IPv4 address. I had to update my /etc/hosts to point calypso.localhost at ::1 instead of 127.0.0.1 to make things work as expected.

@blowery
Copy link
Contributor Author

blowery commented Dec 3, 2015

Bah, I transposed the node version on the branch name and the commit. Should be 4.2.2, not 4.4.2.

Fixing the commit.

@blowery blowery force-pushed the try/node-4.4.2 branch 2 times, most recently from 1d3d5a5 to d3be21a Compare December 3, 2015 21:24
@blowery
Copy link
Contributor Author

blowery commented Dec 3, 2015

Redid this on top of master now that #730 landed

@blowery
Copy link
Contributor Author

blowery commented Dec 6, 2015

Hmmmm... So switching Circle CI over to node 4.2.2 breaks the build, even if built with a clean cache. It appears to be breaking on contextify? Maybe jumping up to a current jsdom would help there. It's pretty disconcerting to see all the build errors.

@ehg
Copy link
Member

ehg commented Dec 7, 2015

Maybe jumping up to a current jsdom would help there. It's pretty disconcerting to see all the build errors.

@sirbrillig I think you mentioned the latest jsdom doesn't need contextify?

@ehg ehg force-pushed the try/node-4.4.2 branch 2 times, most recently from defde4b to a7e44e1 Compare December 7, 2015 15:37
@sirbrillig
Copy link
Member

Yup, that's correct! Relevant comment.

3.0.x will be the last release of jsdom to support Node.js. All future releases (starting with 4.0.0) will require io.js, whose new vm module will allow us to remove our contextify native-module dependency. (Given that I submitted the relevant patch to joyent/node 1.5 years ago, I'm very excited that we can finally use it!)

Also this:

This release relies on the newly-overhauled vm module of io.js to eliminate the Contextify native module dependency. jsdom should now be much easier to use and install, without requiring a C++ compiler toolchain!

@ehg
Copy link
Member

ehg commented Dec 7, 2015

So we'd have to get everyone to upgrade to node 4+ on their local machines… :)

@@ -3,7 +3,7 @@ require( 'lib/react-test-env-setup' )();
/**
* External Dependencies
*/
var sinon = require( 'sinon' ),
const sinon = require( 'sinon' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change need to be made? If we're changing things, I'd rather see this go to import syntax than to const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was mostly to quiet up eslint.

@gwwar
Copy link
Contributor

gwwar commented Dec 7, 2015

Don't forget to update the node engine version to our minimum supported version in package.json:

"engines": {
    "node": ">=4.2.3"
}

@blowery
Copy link
Contributor Author

blowery commented Dec 8, 2015

Don't forget to update the node engine version to our minimum supported version in package.json

Done. Interesting reading at http://www.marcusoft.net/2015/03/packagejson-and-engines-and-enginestrict.html. Looks like it's mostly advisory since we're the app.

@gwwar
Copy link
Contributor

gwwar commented Dec 8, 2015

Yup, it sadly only warns you if your package is installed as a dependency, but as a node developer it's still the first place I check for version compatibility.

@sirbrillig
Copy link
Member

A version check for Node in the Makefile might make sense, as suggested elsewhere by @jkudish. Something like this as a target:

node-version:
    @if [ "$(shell $(NODE) --version | sed 's/[^0-9]//g')" -lt 400 ]; then echo "Please upgrade your version of Node.js: https://nodejs.org/"; exit 1; fi

@blowery
Copy link
Contributor Author

blowery commented Dec 8, 2015

A version check for Node in the Makefile might make sense,

I added this a slightly different way, using a node script and the semver property in package. This way it could work on Windows too, and we have a single source of truth for the necessary node version.

@sirbrillig
Copy link
Member

using a node script and the semver property in package

That's way better! Awesome. 👍

@blowery
Copy link
Contributor Author

blowery commented Dec 8, 2015

Except semver isn't baked in... sigh.

@aduth
Copy link
Contributor

aduth commented Dec 8, 2015

I force-pushed a rebase to account for tests added in #550 which would have broken after the upgrade here (fixup'd into b81e2de).

I also fixed the version compare script to pull the semver dependency from the npm global root node_modules directory. The semver package is not bundled with Node, but is declared as a dependency of and maintained by the folks behind npm (9f8d852). This feels a bit hacky, but works well in my testing.

@aduth
Copy link
Contributor

aduth commented Dec 14, 2015

Should we add a project-wide .nvmrc ? Would that be useful?

Sounds useful, though it would appear that we'd need to update Make targets to use nvm exec if nvm is installed? Personally, I use n, so I wouldn't benefit from this.

@blowery
Copy link
Contributor Author

blowery commented Dec 15, 2015

Sounds useful, though it would appear that we'd need to update Make targets to use nvm exec if nvm is installed?

Nah, it just makes nvm use easier. No reason to force nvm exec into the Makefile.

@blowery blowery changed the title Framework: Move to Node 4.2.2 ** DO NOT MERGE ** Framework: Move to Node 4 Dec 15, 2015
@blowery
Copy link
Contributor Author

blowery commented Dec 15, 2015

Hrm, serving / and the CSS seems much slower now. I'm seeing the CSS rebuild on every request... Digging.

@blowery
Copy link
Contributor Author

blowery commented Dec 15, 2015

Hrm, serving / and the CSS seems much slower now. I'm seeing the CSS rebuild on every request...

This was due to the new node-version target. Made it order-only in 338e3e9 which prevents it from causing a rebuild on every request.

blowery and others added 9 commits December 15, 2015 15:24
Also fix the duped styles in follow-button.
The URL spec lets it resolve relative URLs without exploding.
I also turned off resource loading to prevent any accidental requests from going out when using JSDom.
Last, expose the history object for page.js to use.
Since `semver` is not default to node but is included in any npm
installation
This allows the dependency to run, but not foul the dep tree. With it as a normal dep, it would cause any target that depended upon it to re-run, every time it was invoked. This made a target like build-css rerun for every http request, which slowed things down considerably.

See https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html for more info on order-only deps
@blowery
Copy link
Contributor Author

blowery commented Dec 17, 2015

Just got this up and running, pretending to be a production node using my local setup, and it seems to work just fine. I think this is ready to go.

@ehg
Copy link
Member

ehg commented Dec 17, 2015

I think it's good to go too, works fine for me 👍

blowery added a commit that referenced this pull request Dec 17, 2015
@blowery blowery merged commit 66126f3 into master Dec 17, 2015
@blowery blowery deleted the try/node-4.4.2 branch December 17, 2015 19:40
@scruffian scruffian removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 17, 2015
blowery added a commit that referenced this pull request Dec 18, 2015
Somehow I broke this with the last commit on #1204 and didn't notice.

This re-instates the call to `check-node-version` to inform folks on old nodes that they need to upgrade
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.

6 participants