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

feat: enable usage of function as library fileName, close #3585 #3625

Merged
merged 5 commits into from Jul 14, 2021

Conversation

gobeli
Copy link
Contributor

@gobeli gobeli commented Jun 1, 2021

Description

This PR would enable users of the library mode to use a function to define the output filename. (As discussed in #3585)

I didn't see existing tests in this area, but maybe I missed it, glad to add some if required.


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 Shinigami92 added p2-nice-to-have Not breaking anything but nice to have (priority) needs test labels Jun 1, 2021
@Shinigami92 Shinigami92 marked this pull request as draft June 1, 2021 14:41
@gobeli
Copy link
Contributor Author

gobeli commented Jun 2, 2021

Changed the existing lib tests within the playground package

@Shinigami92
Copy link
Member

Changed the existing lib tests within the playground package

I just wonder: don't we have a test only for fileName: string?
May I ask you to cover all three possibilities. 🙂
This would prevent regression in the future and stabilize this feature 🙂

Shinigami92
Shinigami92 previously approved these changes Jun 2, 2021
@gobeli
Copy link
Contributor Author

gobeli commented Jun 2, 2021

I just wonder: don't we have a test only for fileName: string?
May I ask you to cover all three possibilities.
This would prevent regression in the future and stabilize this feature

Yeah would be a good idea, I didn't get it to work without creating multiple playgrounds though 🤔
Would that be a problem? Or do you have any pointers on how to do it without creating more playgrounds?

@Shinigami92
Copy link
Member

Maybe you can extract the logic and create a unit-test for it 🤔
You can orient yourself on the __tests__ folder in packages/vite/src/node/__tests__ and create one for client
Then the playground test is enough for the integration test and then the unit test covers the rest 🙂

@gobeli
Copy link
Contributor Author

gobeli commented Jun 2, 2021

Ok, I gave it a shot with the unit tests

@Shinigami92
Copy link
Member

Shinigami92 commented Jun 2, 2021

I think we need a "exclude": ["**/__tests__"] in .../client/tsconfig.json like in .../node/tsconfig.json

Also I don't see the running test in the checks 🤔
I see some for src/node

These unit tests are only in test-serve. @patak-js Do you know a bit more about this and how we configure them for src/client?

Nevermind 🤦 I mixed some PRs, sorry

Test run successfully here: https://github.com/vitejs/vite/pull/3625/checks?check_run_id=2727359038#step:10:32

Shinigami92
Shinigami92 previously approved these changes Jun 2, 2021
@Shinigami92 Shinigami92 marked this pull request as ready for review June 2, 2021 12:34
packages/vite/src/node/build.ts Outdated Show resolved Hide resolved
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.

Okay, seems we need a non-null assertion at the calling location

@gobeli
Copy link
Contributor Author

gobeli commented Jun 14, 2021

Yeah, it should be fixed now

Shinigami92
Shinigami92 previously approved these changes Jun 14, 2021
antfu
antfu previously approved these changes Jun 26, 2021
packages/vite/src/node/build.ts Outdated Show resolved Hide resolved
packages/vite/src/node/build.ts Outdated Show resolved Hide resolved
@patak-dev patak-dev requested a review from antfu June 29, 2021 18:32
@patak-dev patak-dev changed the title feat(vite): enable usage of function as library fileName (#3585) feat: enable usage of function as library fileName, close #3585 Jul 14, 2021
@patak-dev patak-dev merged commit 772b2f7 into vitejs:main Jul 14, 2021
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
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants