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

fix: use path.join and __dirname for require package.json #1936

Merged
merged 1 commit into from
May 17, 2022

Conversation

ddelgrosso1
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1934 🦕

@ddelgrosso1 ddelgrosso1 requested review from a team as code owners May 17, 2022 12:30
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: storage Issues related to the googleapis/nodejs-storage API. labels May 17, 2022
@shaffeeullah shaffeeullah added the owlbot:run Add this label to trigger the Owlbot post processor. label May 17, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 17, 2022
@shaffeeullah shaffeeullah merged commit b868762 into googleapis:main May 17, 2022
@timdp
Copy link

timdp commented May 17, 2022

@ddelgrosso1 @shaffeeullah This is unnecessary. require() is always relative to the file itself.

Additionally, I don't think it has anything to do with #1934, which it's supposed to close. The issue there is that the import is conditional (through a try).

@faradaytrs
Copy link

@timdp You are right because it didn't fix the problem, now it immediately fails in runtime.

@timdp
Copy link

timdp commented May 18, 2022

It would do, yes. In the case of esbuild, I imagine it leaves the require() untouched and then tries to find package.json relative to the working directory of the bundle rather than the source file. Both are invalid.

Like I said on the original report, I would attempt to avoid the fallthrough altogether by making sure the source file is always at the same depth, whether or not it's gone through a build step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could not resolve "../package.json" on v5.20.1
4 participants