-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
} | ||
|
||
webpack(config, (err, stats) => { | ||
expect(err).toEqual(null) | ||
const modules = stats.toJson().modules | ||
const modules = stats.toJson({ source: true }).modules |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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
There was a problem hiding this 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?
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. |
Resolves #14