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

Switch to npm #10948

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Switch to npm #10948

wants to merge 5 commits into from

Conversation

ryanhamley
Copy link
Contributor

Launch Checklist

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog></changelog>

@ryanhamley ryanhamley marked this pull request as ready for review August 19, 2021 18:57
@@ -25,7 +21,7 @@ git clone git@github.com:mapbox/mapbox-gl-js.git

Install node module dependencies
```bash
yarn install
npm install
Copy link
Contributor

Choose a reason for hiding this comment

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

What minimum version of NPM is needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

An appropriate version of npm gets installed whenever a version of node is installed, nobody generally has to think about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Node 14, which we specify elsewhere, installs npm 6 by default (so does Node 10 and 12). It looks like Node 16 will install npm 7 by default when that becomes available. See nodejs/node#37689.

Copy link
Contributor

@arindam1993 arindam1993 left a comment

Choose a reason for hiding this comment

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

looks good to me, I'm so in for this.

@SnailBones SnailBones added the skip changelog Used for PRs that do not need a changelog entry label Aug 19, 2021
@SnailBones
Copy link
Contributor

Switching from yarn to npm means different commands for everyone building gl-js from source.

Can we get a review from the following teams? @mapbox/docs @mapbox/studio @mapbox/gl-native

- v4-yarn-{{ checksum "yarn.lock" }}
- run: yarn
- v4-npm-{{ checksum "package-lock.json" }}
- run: npm install
Copy link
Contributor

Choose a reason for hiding this comment

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

Should npm ci be used instead? This will guarantee consistency with the package-lock.json, and will error if there is a mismatch between the package.json and package-lock.json.

@jingsam
Copy link
Contributor

jingsam commented Aug 20, 2021

This is a big step for the third contributors. Would you explain why we need switch from yarn to npm?

@ryanhamley
Copy link
Contributor Author

We ran into an issue where installing a new dependency caused yarn to rewrite the entire yarn.lock file. This change also brings GL JS into line with most other Mapbox projects that use npm, so we won't run into issues with people using npm instead of yarn. Removing yarn also means one less thing for people to install to begin working with GL JS. The specific reasons that GL JS chose yarn years ago aren't big differentiators anymore so it feels like a good time to make this switch. For most use cases, it should be just changing yarn run <command> to npm run <command>. @jingsam is there a specific way that this would negatively impact your project that we might not be thinking of?

@mourner
Copy link
Member

mourner commented Aug 20, 2021

Let's not rush this through — we should take time to fully evaluate the impact, settle on the right NPM version (v7 has a different lock format), utilize npm ci where necessary, make sure all commands are working as expected, and measure performance for cold and hot installs.

@jingsam
Copy link
Contributor

jingsam commented Aug 20, 2021

@ryanhamley Earlier mapbox open source projects are using yarn instead of npm. We follow this convention for years. we are satisfied for its performance and deterministic. We don't know whether npm v5 is a good choice. Even though npm v5 has released for years, majorities choose yarn. So I agree with @mourner . We would better to fully evaluate the impact first. I guess npm also can not guarantee that it will not rewrite the entire lock file when we installing or updating a package.

@mourner mourner marked this pull request as draft October 25, 2021 16:35
@asheemmamoowala asheemmamoowala linked an issue Oct 27, 2021 that may be closed by this pull request
@ryanhamley
Copy link
Contributor Author

Closing this for now since there was no clear consensus

@ryanhamley ryanhamley closed this Jan 6, 2022
@mourner
Copy link
Member

mourner commented Jan 28, 2022

Closing this for now since there was no clear consensus

@ryanhamley Let's rivisit this. I think there was consensus that we should evaluate switching to NPM, especially given that Yarn v1 is not very actively maintained, v2+ have low adoption, and that NPM has fixed most of its flaws in recent years, including fully deterministic builds with v7+ lockfile. It just needed more steps before a potential switch — e.g. consider potential upgrade to Node v16 LTS that comes with NPM v8 (or manually installing it with Node v14), measure cold and hot install time vs Yarn, etc.

@ryanhamley ryanhamley reopened this Jan 28, 2022
@avpeery avpeery added skip changelog Used for PRs that do not need a changelog entry and removed skip changelog Used for PRs that do not need a changelog entry labels Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Used for PRs that do not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

npm install breaks tests
8 participants