Skip to content

fix(v15): loaders for styles are not deduplicated when experiments.css is true#2071

Open
xc2 wants to merge 1 commit into
vuejs:masterfrom
xc2:fix-duplicate-style-loaders
Open

fix(v15): loaders for styles are not deduplicated when experiments.css is true#2071
xc2 wants to merge 1 commit into
vuejs:masterfrom
xc2:fix-duplicate-style-loaders

Conversation

@xc2
Copy link
Copy Markdown

@xc2 xc2 commented Apr 15, 2024

related web-infra-dev/rsbuild#2093

cause:

genRequest who does the deduplicating is not called for the branch for experiments.css === true

if (isWebpack5 && this._compiler.options.experiments && this._compiler.options.experiments.css) {
// If user enables `experiments.css`, then we are trying to emit css code directly.
// Although we can target requests like `xxx.vue?type=style` to match `type: "css"`,
// it will make the plugin a mess.
if (!options.experimentalInlineMatchResource) {
this.emitError(
new Error(
'`experimentalInlineMatchResource` should be enabled if `experiments.css` enabled currently'
)
)
return ''
}
if (query.inline || query.module) {
this.emitError(
new Error(
'`inline` or `module` is currently not supported with `experiments.css` enabled'
)
)
return ''
}
const loaderString = [stylePostLoaderPath, ...loaders]
.map((loader) => {
return typeof loader === 'string' ? loader : loader.request
})
.join('!')
const styleRequest = loaderUtils.stringifyRequest(
this,
`${this.resourcePath}${query.lang ? `.${query.lang}` : ''}${
this.resourceQuery
}!=!-!${loaderString}!${this.resourcePath + this.resourceQuery}`
)
return `@import ${styleRequest};`
}

@xc2 xc2 changed the title fix: loaders for styles are not deduplicated when experiments.css is true fix(v15): loaders for styles are not deduplicated when experiments.css is true Apr 15, 2024
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.

1 participant