Skip to content

Conversation

@mildaniel
Copy link
Contributor

Description of changes:
npm 9 has removed the npm bin command which was used to find the local installation of esbuild.
This change switches the npm bin command to use npm root which should be backwards compatible.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mildaniel mildaniel requested a review from a team as a code owner November 17, 2022 23:05
Copy link
Contributor

@hnnasit hnnasit left a comment

Choose a reason for hiding this comment

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

LGTM

@mndeveci
Copy link
Contributor

Description of changes: npm 9 has removed the npm bin command which was used to find the local installation of esbuild. This change switches the npm bin command to use npm root which should be backwards compatible.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Just to confirm, npm bin doesn't work with npm v9, but npm root can work with earlier versions? So it won't break any existing customers, right?

@mildaniel
Copy link
Contributor Author

Description of changes: npm 9 has removed the npm bin command which was used to find the local installation of esbuild. This change switches the npm bin command to use npm root which should be backwards compatible.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Just to confirm, npm bin doesn't work with npm v9, but npm root can work with earlier versions? So it won't break any existing customers, right?

That's correct. npm reference


self.assertIsInstance(esbuild, SubprocessEsbuild)
self.assertEqual(esbuild.executable_search_paths, ["project/bin"])
self.assertEqual(esbuild.executable_search_paths, [str(Path("project/.bin"))])
Copy link
Contributor

Choose a reason for hiding this comment

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

I tested running npm root command, and actually the output is not project/.bin as npm bin command output. my npm version is 8.1.1

I think it will not make a difference in our case, but I am sharing that with you so may be I am missing any thing

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that there are some discrepancies, do we have integration tests that will catch any of these possible errors? Or these differences are just fine since all integration tests have passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case it shouldn't make a difference. npm bin would return the path to the binary directory itself which we mock and then later assert. npm root returns the path to the active node_modules, which should have a .bin directory within it. In this case we have to append that directory ourselves so that tests should essentially be equivalent.

Our integration test cases should already cover this case, we just need to run them using npm 9 in our test jobs.

try:
npm_bin_path = subprocess_npm.run(["bin"], cwd=scratch_dir)
npm_bin_path_root = subprocess_npm.run(["root"], cwd=scratch_dir)
npm_bin_path = str(Path(npm_bin_path_root, ".bin"))
Copy link
Contributor

Choose a reason for hiding this comment

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

how can we make sure the npm root command is available in all supported npm versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked in the documentation which versions this command is supported in https://docs.npmjs.com/cli/v8/commands/npm-root. Should be all the same versions as npm bin + npm 9.

Copy link
Contributor

@moelasmar moelasmar left a comment

Choose a reason for hiding this comment

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

should we update our Appveyor jobs to run the nodejs build test cases in different versions

@mildaniel
Copy link
Contributor Author

should we update our Appveyor jobs to run the nodejs build test cases in different versions

I was planning on doing this as a follow-up item.

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.

4 participants