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: compute getPkgName only when used #4729

Merged
merged 4 commits into from Sep 11, 2021
Merged

fix: compute getPkgName only when used #4729

merged 4 commits into from Sep 11, 2021

Conversation

vwkd
Copy link
Contributor

@vwkd vwkd commented Aug 25, 2021

Description

Fixes #4698.

This computes getPkgName only when used within the OR operation, allowing for no package name if a libOptions.fileName is provided due to short circuiting. The check for libOptions isn't included anymore, because it's already present as the condition for when resolveLibFilename is called.

I'm unsure how to include tests as I'm unfamiliar with such a big project.

EDIT: Oh, I saw #4726 too late! Feel free to close this then.

EDIT 2: Thanks to @OneNail for the inspiration of the error message.

EDIT 3: I added tests for the cases covered by this change.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Shinigami92
Copy link
Member

Shinigami92 commented Aug 25, 2021

The other solution throws an error https://github.com/vitejs/vite/pull/4726/files#diff-aa53520bfd53e6c24220c44494457cc66370fd2bee513c15f9be7eb537a363e7R644

I personally like your solution therefore more, cause it does not throw an error, but do stuff silently 🚀/🤔


Edit: Damn 🙁 Tests failing 😢 @vwkd

@Shinigami92
Copy link
Member

Now it also throws an error 😢 So it is kinda the same as the other PR, and I don't prefer this PR instead of the other PR 🤷
So I'm for the solution that is just working (the other PR tests are green 👀 )

@vwkd
Copy link
Contributor Author

vwkd commented Aug 25, 2021

@Shinigami92 Thanks, I think I know why the CI failed. It's because packages/vite/src/node/__tests__/build.spec.ts still uses the old resolveLibFilename where the arguments changed.

I updated the tests and I hope the CI now passes. It's difficult for me to test locally, because I see many unrelated failures that I don't see on the CI.

EDIT: Also added two new tests for this bug.

@Shinigami92
Copy link
Member

[...] many unrelated failures that I don't see on the CI

I know you pain 😢

@Shinigami92 Shinigami92 added the p3-minor-bug An edge case that only affects very specific usage (priority) label Aug 25, 2021
Copy link
Member

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

🎉

@patak-dev patak-dev merged commit ce29273 into vitejs:main Sep 11, 2021
@vwkd vwkd deleted the fix-lib-name branch September 12, 2021 10:04
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't throw on missing name in package.json when fileName is specified in library mode
3 participants