Skip to content

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

Closed
wants to merge 0 commits into from

Conversation

18566246732
Copy link

No description provided.

Copy link
Member

@haoqunjiang haoqunjiang left a 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'),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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) {
Copy link
Member

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();
Copy link
Member

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()
Copy link
Member

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.

@haoqunjiang
Copy link
Member

😰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?

@18566246732
Copy link
Author

okay, no problem, I'll make a new pr

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.

2 participants