-
Notifications
You must be signed in to change notification settings - Fork 918
feat: rewrite VueLoaderPlugin to support webpack5 #1607
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
Conversation
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.
Thanks for the PR!
Despite the big refactor, I don't feel like shipping a new major version merely for webpack 5 support at the moment, because that means we need to keep two branches and ship two new versions every time we update the code on the loader side, which increases our maintenance burden.
Would you please move the new implementation into a new file named as plugin-webpack5.js
and keep the old plugin as plugin-webpack4.js
, and then do differential loading in the plugin.js
based on the webpack version? This way we can support two webpack versions in one codebase.
lib/plugin.js
Outdated
|
||
// global pitcher (responsible for injecting template compiler loader & CSS | ||
// post loader) | ||
const pitcher = { | ||
loader: require.resolve('./loaders/pitcher'), | ||
loader: require.resolve('vue-loader/lib/loaders/pitcher'), |
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.
loader: require.resolve('vue-loader/lib/loaders/pitcher'), | |
loader: require.resolve('./loaders/pitcher'), |
lib/plugin.js
Outdated
normalized.resource && | ||
normalized.resource(fakeFile) | ||
) | ||
function cloneRule (rawRule, ruleSetCompiler, refs) { |
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.
There's only one instance of ruleSetCompiler
in this module so no need to pass it around.
lib/plugin.js
Outdated
|
||
const conditions = rules[0].rules | ||
.map(rule => rule.conditions) | ||
.flat(); |
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.
.flat
is only supported in Node.js v11+, so don't use it.
lib/plugin.js
Outdated
.filter(effect => effect.type === 'use') | ||
.map(effect => effect.value) | ||
) | ||
.flat() |
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.
Don't use .flat
, for compatibility concerns.
😰I'm so sorry I seemed to have messed things up by accidentally force pushing to your fork. Could you open a new pull request, please? |
okay, no problem, I'll make a new pr |
No description provided.