Skip to content

Framework: Pin nvmrc to specific current LTS#22236

Merged
aduth merged 2 commits intomasterfrom
update/pin-nvmrc-lts
May 11, 2020
Merged

Framework: Pin nvmrc to specific current LTS#22236
aduth merged 2 commits intomasterfrom
update/pin-nvmrc-lts

Conversation

@aduth
Copy link
Member

@aduth aduth commented May 8, 2020

Related Slack discussion (link requires registration): https://wordpress.slack.com/archives/C02QB2JS7/p1588794429373800

This pull request seeks to update .nvmrc to designate the actual current LTS version. This is intended to future-proof builds which occur when checking out an older version of the branch. Notably, this is an issue today when checking out old versions of Gutenberg, where we had used an older version of the node-sass dependency which only works in e.g. Node 10 or earlier. If, at the time, .nvmrc had specified 10 as the Node version of the project, it would not be as much an issue†. With these changes, we can at least try to correct this problem moving forward.

Note that the primary downside here is that we will need to manually update this value over time, as the LTS changes. Based on the release schedule, this should be expected to occur once every year (each October).

Testing Instructions:

Running nvm install should install Node v12.16.3:

nvm install --latest-npm && nvm use

Follow-up tasks:

† This only really helps if one knows to run nvm install && nvm use after checking out an older branch / commit. Ideally we can make this more seamless, or at least more noisy as part of checks prior to any actions we expect to depend on this behavior.

Example ideas:

@aduth aduth added the Framework Issues related to broader framework topics, especially as it relates to javascript label May 8, 2020
@github-actions
Copy link

github-actions bot commented May 8, 2020

Size Change: +311 B (0%)

Total Size: 824 kB

Filename Size Change
build/block-directory/index.js 6.61 kB +4 B (0%)
build/block-editor/index.js 102 kB +108 B (0%)
build/block-library/editor-rtl.css 7.12 kB -3 B (0%)
build/block-library/editor.css 7.12 kB -3 B (0%)
build/block-library/index.js 115 kB -134 B (0%)
build/block-library/style-rtl.css 7.38 kB +44 B (0%)
build/block-library/style.css 7.38 kB +44 B (0%)
build/components/index.js 180 kB +251 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.02 kB 0 B
build/annotations/index.js 3.62 kB 0 B
build/api-fetch/index.js 4.08 kB 0 B
build/autop/index.js 2.82 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 761 B 0 B
build/block-editor/style-rtl.css 10.3 kB 0 B
build/block-editor/style.css 10.3 kB 0 B
build/block-library/theme-rtl.css 683 B 0 B
build/block-library/theme.css 685 B 0 B
build/block-serialization-default-parser/index.js 1.88 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 48.1 kB 0 B
build/components/style-rtl.css 17 kB 0 B
build/components/style.css 16.9 kB 0 B
build/compose/index.js 6.66 kB 0 B
build/core-data/index.js 11.4 kB 0 B
build/data-controls/index.js 1.29 kB 0 B
build/data/index.js 8.45 kB 0 B
build/date/index.js 5.47 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 3.1 kB 0 B
build/edit-navigation/index.js 4.41 kB 0 B
build/edit-navigation/style-rtl.css 618 B 0 B
build/edit-navigation/style.css 617 B 0 B
build/edit-post/index.js 28 kB 0 B
build/edit-post/style-rtl.css 12.2 kB 0 B
build/edit-post/style.css 12.2 kB 0 B
build/edit-site/index.js 12.1 kB 0 B
build/edit-site/style-rtl.css 5.22 kB 0 B
build/edit-site/style.css 5.22 kB 0 B
build/edit-widgets/index.js 8.37 kB 0 B
build/edit-widgets/style-rtl.css 4.69 kB 0 B
build/edit-widgets/style.css 4.69 kB 0 B
build/editor/editor-styles-rtl.css 425 B 0 B
build/editor/editor-styles.css 428 B 0 B
build/editor/index.js 44.3 kB 0 B
build/editor/style-rtl.css 5.07 kB 0 B
build/editor/style.css 5.08 kB 0 B
build/element/index.js 4.65 kB 0 B
build/escape-html/index.js 734 B 0 B
build/format-library/index.js 7.63 kB 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 2.14 kB 0 B
build/html-entities/index.js 622 B 0 B
build/i18n/index.js 3.56 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keyboard-shortcuts/index.js 2.51 kB 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.12 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 5.29 kB 0 B
build/notices/index.js 1.79 kB 0 B
build/nux/index.js 3.4 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/plugins/index.js 2.56 kB 0 B
build/primitives/index.js 1.5 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/rich-text/index.js 14.8 kB 0 B
build/server-side-render/index.js 2.68 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.28 kB 0 B
build/url/index.js 4.02 kB 0 B
build/viewport/index.js 1.84 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

Copy link
Contributor

@chrisvanpatten chrisvanpatten left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

I also did some quick digging to compare this with tying to a specific LTS "codename" (e.g. lts/erbium) and it turns out internally nvm converts those names to the version number anyway, so there's no practical difference. If anything, this is clearer because the codenames aren't often used.

@chrisvanpatten
Copy link
Contributor

chrisvanpatten commented May 8, 2020

One thought: is it worth documenting that this is expected to reflect the latest LTS release? Unfortunately it doesn't look like .nvmrc can accept comments, but it probably wouldn't hurt to make it explicit somewhere.

@aduth
Copy link
Member Author

aduth commented May 8, 2020

One thought: is it worth documenting that this is expected to reflect the latest LTS release? Unfortunately it doesn't look like .nvmrc can accept comments, but it probably wouldn't hurt to make it explicit somewhere.

It would be nice if we could include a comment in the file, yeah. I dug a bit into the documentation and source code, and can't seem to find any indication of a syntax for supporting comments.

Where do you imagine it might make sense to document this otherwise? We do already have the expectation outlined in the "Getting Started" guide, but this is just the general expectation, not anything about .nvmrc and how it's managed:

The first step is to install the latest active LTS release of Node, along with the latest version of NPM.

https://github.com/WordPress/gutenberg/blob/master/docs/contributors/getting-started.md

@chrisvanpatten
Copy link
Contributor

How about something like this:

Gutenberg is built using the latest active LTS release of Node, along with the latest version of NPM.

The easiest way to install and manage node and NPM (on macOS, Linux, or Windows 10 with the Linux Subsystem) is by using nvm. Once nvm is installed, you can install the correct version of Node by running nvm install --latest-npm in the Gutenberg directory.

This also makes it easier to build older versions of Gutenberg while ensuring you have the same version of node which was used at that time. Gutenberg's .nvmrc file is regularly updated to the current available LTS release, so nvm install on an older branch will use whichever LTS version was active at that time.

@aduth
Copy link
Member Author

aduth commented May 8, 2020

It reads nicely to me. My only hesitation is that this document is the entry point for new contributors, and is already pretty over-encumbered with information. While it's all certainly useful, some of it isn't particularly relevant for a new contributor's first steps (e.g. working in old branches).

@chrisvanpatten
Copy link
Contributor

chrisvanpatten commented May 8, 2020

@aduth Maybe if it were formatted more like this:


Gutenberg is built using the latest active LTS release of Node, along with the latest version of NPM.

The easiest way to install and manage node and NPM (on macOS, Linux, or Windows 10 with the Linux Subsystem) is by using nvm. Once nvm is installed, you can install the correct version of Node by running nvm install --latest-npm in the Gutenberg directory.

Note: If you find yourself needing to build older versions of Gutenberg, nvm makes that process easier too. Because Gutenberg's .nvmrc file is regularly updated to the current available LTS release, running nvm install on an older branch will install whichever LTS version was active at that time.

...


I also simplified the language a bit to reflect that this is intended for new contributors.

@whyisjake
Copy link
Member

Related: #22120 and #22121.

@whyisjake
Copy link
Member

Also related: https://core.trac.wordpress.org/ticket/50094

@aduth aduth requested a review from ajitbohra as a code owner May 11, 2020 18:54
@aduth
Copy link
Member Author

aduth commented May 11, 2020

@aduth Maybe if it were formatted more like this:

Thanks @chrisvanpatten . It seems like a nice balance of information. I think it also does a good job to consolidate / highlight the expected versions of Node/NPM in that introductory sentence.

Separately, something about the existing "Python requirement" paragraph stands out to me as disjointed. I don't think it's directly related to what's being modified here, so maybe consider as a separate task.

@aduth aduth merged commit f073d76 into master May 11, 2020
@aduth aduth deleted the update/pin-nvmrc-lts branch May 11, 2020 20:35
@github-actions github-actions bot added this to the Gutenberg 8.2 milestone May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Framework Issues related to broader framework topics, especially as it relates to javascript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants