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 marked this pull request as draft Jun 1, 2021
@gobeli gobeli force-pushed the gobeli:main branch from 1ce0557 to 244835d Jun 2, 2021
@gobeli
Copy link
Contributor Author

@gobeli gobeli commented Jun 2, 2021

Changed the existing lib tests within the playground package

@Shinigami92
Copy link
Member

@Shinigami92 Shinigami92 commented Jun 2, 2021

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 requested a review from patak-js Jun 2, 2021
@gobeli
Copy link
Contributor Author

@gobeli 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

@Shinigami92 Shinigami92 commented Jun 2, 2021

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 gobeli commented Jun 2, 2021

Ok, I gave it a shot with the unit tests

@Shinigami92
Copy link
Member

@Shinigami92 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 marked this pull request as ready for review Jun 2, 2021
@Shinigami92 Shinigami92 requested a review from patak-js Jun 14, 2021
Copy link
Member

@Shinigami92 Shinigami92 left a comment

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

@gobeli gobeli force-pushed the gobeli:main branch from 0babbc7 to 36fabe7 Jun 14, 2021
@gobeli
Copy link
Contributor Author

@gobeli gobeli commented Jun 14, 2021

Yeah, it should be fixed now

@antfu antfu dismissed patak-js’s stale review Jun 26, 2021

Resolved

packages/vite/src/node/build.ts Outdated Show resolved Hide resolved
packages/vite/src/node/build.ts Outdated Show resolved Hide resolved
@gobeli gobeli dismissed stale reviews from antfu and Shinigami92 via 7ed0f5d Jun 29, 2021
@gobeli gobeli force-pushed the gobeli:main branch from 36fabe7 to 7ed0f5d Jun 29, 2021
@patak-js patak-js requested a review from antfu Jun 29, 2021
@patak-js patak-js requested a review from Shinigami92 Jul 14, 2021
@patak-js patak-js 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-js patak-js merged commit 772b2f7 into vitejs:main Jul 14, 2021
6 checks passed
6 checks passed
@github-actions
Build&Test: node-12, ubuntu-latest
Details
@github-actions
Build&Test: node-14, ubuntu-latest
Details
@github-actions
Build&Test: node-16, ubuntu-latest
Details
@github-actions
Build&Test: node-14, macos-latest
Details
@github-actions
Build&Test: node-14, windows-latest
Details
@github-actions
Lint: node-14, ubuntu-latest
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants