Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

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

Merged
shaffeeullah merged 1 commit intogoogleapis:mainfrom
ddelgrosso1:fix-es-build
May 17, 2022
Merged

fix: use path.join and __dirname for require package.json#1936
shaffeeullah merged 1 commit intogoogleapis:mainfrom
ddelgrosso1:fix-es-build

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 a review from a team as a code owner May 17, 2022 12:30
@ddelgrosso1 ddelgrosso1 requested a review from a team 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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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