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

Make webpack autoupload plugin compatible with webpack 5 #434

Merged
merged 3 commits into from
Feb 22, 2021

Conversation

anthmatic
Copy link
Contributor

@anthmatic anthmatic commented Jan 26, 2021

Description and Context

Between webpack v4 > v5, a couple of breaking changes were released that affected this plugin:

  • data was removed from assets, specifically emitted and existsAt
  • In v4, files were always emitted on the first compile, in v5 they're only emitted if they've changed

This pr:

  • removes the dependency on existsAt and builds the filepath manually
  • checks for the presence of emittted or compares an asset against the emittedAssets set
  • keeps track of the first compile to ensure that we continue to upload correctly

Fixes #408

Copy link
Contributor

@miketalley miketalley left a comment

Choose a reason for hiding this comment

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

Code looks good and it works in testing with webpack versions 4 and 5!

The only thing was the upload of all assets output by the webpack build when a single file changes (as we discussed). LMK how I can help with testing this more if needed!

@anthmatic anthmatic requested a review from miketalley February 17, 2021 16:28
@anthmatic
Copy link
Contributor Author

After some testing (thanks @miketalley!) I reworked the logic here to make sure that we're only uploading emitted assets and also ensure that the first compile uploads all files consistently. I updated the PR description as well.

FYI I'm planning to get this out in a new release, but from this new repo https://github.com/HubSpot/webpack-cms-plugins

@anthmatic anthmatic merged commit 51ff565 into master Feb 22, 2021
@anthmatic anthmatic deleted the fix/webpack5-compat branch February 22, 2021 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HubSpot Webpack Upload Plugin Doesn't work with Webpack v5
3 participants