Skip to content

refactor: update svgprep plugin for webpack 5 #1859

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

Merged
merged 2 commits into from
Oct 13, 2021

Conversation

damianstasik
Copy link
Contributor

@damianstasik damianstasik commented Oct 13, 2021

New Pull Request Checklist

Issue Description

This PR updates the SVG Prep plugin for webpack 5 as the current version throws the following warning:

(node:95614) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
	Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
	Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.

Related issue: #1859

Approach

  1. The plugin now uses the recommended processAssets hook instead of emit.
  2. Replaced tapAsync with tapPromise to simplify the code with async/await.
  3. There is now an additional hook that wraps the previous one, it is required to have access to the current compilation process.
  4. Replaced !!name.match(/\.svg$/) with name.endsWith('.svg') to make it easier to understand how the array is filtered.
  5. Used compilation.emitAsset instead of just putting new objects into compilation.assets which was the old way (pre-webpack 5) of emitting new assets.
  6. The emitted source is now wrapped with RawSource to let webpack-sources handle the final format (which usually is an object with source and size properties).

TODOs before merging

  • A changelog entry is created automatically using the pull request title (do not manually add a changelog entry)

@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 13, 2021

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@mtrezza
Copy link
Member

mtrezza commented Oct 13, 2021

It builds fine, please again let me know when this is ready for review.

@damianstasik
Copy link
Contributor Author

@mtrezza It is ready 👍

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

Looks good! Another annoying deprecation message less is candy for the eye!

@mtrezza mtrezza merged commit 0e7f613 into parse-community:alpha Oct 13, 2021
@parseplatformorg
Copy link
Contributor

🎉 This pull request has been released in version 3.3.0-alpha.5

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Oct 15, 2021
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.3.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 1, 2021
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants