-
Notifications
You must be signed in to change notification settings - Fork 916
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
feat: support experimental inline match resource #2046
feat: support experimental inline match resource #2046
Conversation
@sodatea Hi, I haven't finished the final touch yet. But I have some questions about how this new feature will be integrated into the codebase. |
I'm okay with configuring it in both the plugin and loader.
I think automatic detection is better. |
@sodatea |
src/index.ts
Outdated
} = loaderContext | ||
|
||
const webpackVersion = _compiler?.webpack?.version | ||
const isWebpack5 = webpackVersion && webpackVersion[0] > '4' |
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.
webpackVersion[0] > '4' is dangerous when webpackVersion > 10.x.y, I thinks direct equal test should be better
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.
This is copied from the original implementation. I changed it to a relatively better one.
8eb7ae2
to
42e4747
Compare
feat: finish inline match resource chore: cleanup chore: cleanup feat: add experimental css support feat: dispatch plugin dynammically feat: support option `experimentalInlineMatchResource` chore: enable test on CI chore: disable sourceMap generation ] docs: add option doc docs: correct version fix: fix lang matching feat: use a relatively better version test fix: fix incorrect match with `experiments.css` enabled fix: more accurate when matching styles feat: optimize for `Rule.loader` fix: import
42e4747
to
fc9b73d
Compare
@sodatea Hi, CI workflow has been fixed. Would you please take a look again? :) |
src/util.ts
Outdated
resourcePath: string, | ||
resourceQuery?: string, | ||
lang?: string, | ||
additionalLoaders?: string[] |
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.
I don't see any usage of this parameter. What's it reserved for?
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.
This is not related. I will remove this.
pitcher, | ||
...rules.filter((rule) => !vueLoaderRules.includes(rule)), | ||
templateCompilerRule, | ||
...clonedRules, |
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.
I thought the intention of using inline match resource was to get rid of cloning rules. Can we remove it here?
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.
I think what blocks us from removing this currently is the lang
query for us. templateCompilerRule
seems depending on the result from the remaining rules. But I will try this in the future PR. Ideally, we could get rid of the VueLoaderPlugin
in the future.
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.
Oh, I see. Supporting template pre-processors is a bit challenging. We can implement that later. Thanks!
This PR leverages inline match resource, a new technique provided by Webpack@5
to process modules, which allows loader developers to write more ergonomic code
and make the code easier to maintain. From now on, you can enable
options.experimentalInlineMatchResource
ofvue-loader
to give it a try.Other minor changes:
VueLoaderPlugin
dynamically to decouple webpack and support webpack-like plugin systems.experiments.css
supportNote:
The ideal solution with inline match resource is to get rid of the
VueLoaderPlugin
completely,I will try to optimize this in the future.