feat(bundler-helper): add bundler-helper package#1708
Conversation
ff3988a to
252f66d
Compare
Coverage Report for CI Build 26090929246Coverage decreased (-0.4%) to 72.564%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
|
|
Re1: That increases the complexity of core, which is not necessary. Re2: That means we should improve the documentation, but not move it to core. Re3: Users who do not familiar with bundlers should not update bundler options, should they? IMO only advanced users / theme & plugin authors would try updating bundler options themselves, and they should be aware of the official ecosystem. |
Again: so moving this to core ensures there is no support mismatch in future. Avoiding possible future behavior mismatch is necessary. With a sub-export, we ensures our bundler helper is always up-to-date with current bundler.
Again: So having a easy reachable vuepress/bundler-helper is enough as a motivation. The following looks like bullshit💩: Detailsexamples in official docsexport default {
extendsBundlerOptions: (bundlerOptions, app) => {
// extends options of @vuepress/bundler-vite
if (app.options.bundler.name === '@vuepress/bundler-vite') {
bundlerOptions.vuePluginOptions ??= {}
bundlerOptions.vuePluginOptions.template ??= {}
bundlerOptions.vuePluginOptions.template.compilerOptions ??= {}
const isCustomElement =
bundlerOptions.vuePluginOptions.template.compilerOptions.isCustomElement
bundlerOptions.vuePluginOptions.template.compilerOptions.isCustomElement =
(tag) => {
if (isCustomElement?.(tag)) return true
if (tag === 'my-custom-element') return true
}
}
// extends options of @vuepress/bundler-webpack
if (app.options.bundler.name === '@vuepress/bundler-webpack') {
bundlerOptions.vue ??= {}
bundlerOptions.vue.compilerOptions ??= {}
const isCustomElement = bundlerOptions.vue.compilerOptions.isCustomElement
bundlerOptions.vue.compilerOptions.isCustomElement = (tag) => {
if (isCustomElement?.(tag)) return true
if (tag === 'my-custom-element') return true
}
}
// even more for the comming rspack
// new shit here
},
}If VuePress core inisit leveling up the developing difficulty like this, it is expected that no new active contributors appears in our ecosystem. We should not build high walls for developers and users. A lot of plugins WILL FAIL to run with vite/webpack with the default setting. I strongly inisit that our core should decrease the difficulty handling our bundler combinations with richer starter tools. The core SHOULD earse/lower the differences between bundlers just like how it's code is written. This should NOT be a ecosystem work. I try to ask a lot of project which supports VitePress to support VuePress, and a lot of anwser is No, besides the reason that we are in RC stage, a steedy understanding needs with our bundler system is the other major reason.
No, I've seen lots of reasonable needs comming from my theme users. E.g.:
UpdatedAnother major reason is that VuePress produces heavy/dirty bundelr config to make itself work. A careless override of any root config (e.g.: the whole At least the core are supposed to provide helpers like this: addViteConfig(bundlerOptions, app, {
// simplest option that is required
})
addWebpackConfig(bundlerOptions, app, {
// simplest option that is required
})
addRspackConfig(bundlerOptions, app, {
// simplest option that is required
})We are providing a documentation tool, not a devloping tool, so it's faire that we requires the core to care adjusting bundling behavior. |
This PR migrated bundler related functions from
@vuepress/helperto@vuepress/bundler-helper(a new package in core).We are going to have 3 bundlers now, so such helper is quite useful.
Also it's better to align the package with core.
Plus, the package solves sevel problems:
mergeViteConfigfunction is not available (could be a PR later).Code from official docs (Ref):
Now: