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

Chore: Support Webpack 5 #15

Merged
merged 5 commits into from
Mar 10, 2023
Merged

Chore: Support Webpack 5 #15

merged 5 commits into from
Mar 10, 2023

Conversation

chawes13
Copy link
Contributor

@chawes13 chawes13 commented Mar 9, 2023

Resolves #14

@chawes13 chawes13 requested a review from mwislek March 9, 2023 15:08
}

webpack(config, (err, stats) => {
expect(err).toEqual(null)
const modules = stats.toJson().modules
const modules = stats.toJson({ source: true }).modules
Copy link
Contributor Author

Choose a reason for hiding this comment

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

expect(modules.length).toEqual(4)
const indexFileContent = modules.pop().source
const indexFileContent = modules.find((module) => module.name.includes('.index.js')).source
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Webpack 5 returns the .index file as the first file. Instead of switching this to .shift, I thought it would be more future proof to actually find the file.

const config = {
mode: 'production',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Webpack recommends always adding mode

https://webpack.js.org/migrate/5/#make-sure-to-use-mode

Copy link

@mwislek mwislek left a comment

Choose a reason for hiding this comment

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

Nicely done sir! This looks rather complicated, having to essentially recreate the Webpack environment for tests.

I didn't test this but I can if you'd like. It should be fairly straightforward using yarn link. Did you notice the Travis errors?

@chawes13
Copy link
Contributor Author

I've pulled it into a client project with webpack 5 and you're using it on another project with that same setup, so I'd say it works! The tests passed for me locally so let me look at why Travis is complaining.

@chawes13 chawes13 merged commit 983e08f into master Mar 10, 2023
@chawes13 chawes13 deleted the chore/upgrade-to-webpack-5 branch March 10, 2023 16:41
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.

Add support for webpack 5
2 participants