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

refactor(css): make getEmptyChunkReplacer for unit test #14528

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Oct 3, 2023

Description

Refactor the css plugin code a bit to allow unit testing the remove css chunks part.
Done as a separate PR to get an initial snapshot, as suggested here: #14517 (review)

Additional context

Already added the unit tests which show the invalid code.


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 PR Title 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.

…t tested

Also refactor replacer code into `getEmptyChunkReplacer` function.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the chore/refactor-css-removal-as-function-for-testing branch from ed7bf3b to e791692 Compare October 3, 2023 23:31
@susnux susnux requested a review from bluwy October 3, 2023 23:32
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

A few more nits. Thanks for the changes!

packages/vite/src/node/plugins/css.ts Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/css.ts Outdated Show resolved Hide resolved
packages/vite/src/node/__tests__/plugins/css.spec.ts Outdated Show resolved Hide resolved
packages/vite/src/node/__tests__/plugins/css.spec.ts Outdated Show resolved Hide resolved
packages/vite/src/node/__tests__/plugins/css.spec.ts Outdated Show resolved Hide resolved
@bluwy bluwy changed the title refactor(css): make removePureCssChunks a function so it can be unit tested refactor(css): make getEmptyChunkReplacer for unit test Oct 9, 2023
@bluwy bluwy added the p1-chore Doesn't change code behavior (priority) label Oct 9, 2023
@susnux
Copy link
Contributor Author

susnux commented Oct 10, 2023

@bluwy Thank you for taking care! I was a bit short on time.

@patak-dev patak-dev merged commit 18900fd into vitejs:main Oct 10, 2023
9 checks passed
@bluwy
Copy link
Member

bluwy commented Oct 10, 2023

No problem!

@susnux susnux deleted the chore/refactor-css-removal-as-function-for-testing branch October 17, 2023 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1-chore Doesn't change code behavior (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants