@lynx-js/rspeedy
Version:
A webpack/rspack-based frontend toolchain for Lynx
60 lines (59 loc) • 3.02 kB
JavaScript
export const __webpack_ids__ = [
"src_plugins_rsdoctor_plugin_ts"
];
export const __webpack_modules__ = {
"./src/plugins/rsdoctor.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
pluginRsdoctor: ()=>pluginRsdoctor
});
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
var _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/is-ci.ts");
function pluginRsdoctor(options) {
return {
name: 'lynx:rsbuild:rsdoctor',
remove: [
'rsbuild:rsdoctor'
],
setup (api) {
if ('true' !== process.env['RSDOCTOR']) return;
api.onBeforeCreateCompiler(async ({ bundlerConfigs })=>{
const { RsdoctorRspackPlugin } = await import("@rsdoctor/rspack-plugin");
for (const config of bundlerConfigs){
const pluginName = 'RsdoctorRspackPlugin';
const registered = config.plugins?.some((plugin)=>'object' == typeof plugin && plugin?.['isRsdoctorPlugin'] === true || plugin?.constructor?.name === pluginName);
if (registered) continue;
config.plugins ??= [];
const defaultOptions = {
disableClientServer: (0, _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_1__.y)(),
supports: {
banner: true
},
linter: {
rules: {
'ecma-version-check': options?.linter?.rules?.['ecma-version-check'] ?? [
'Warn',
{
ecmaVersion: 2019
}
]
}
}
};
config.plugins.push(new RsdoctorRspackPlugin((0, _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.mergeRsbuildConfig)(defaultOptions, options)));
}
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.info("Rsdoctor is enabled.");
});
}
};
}
},
"./src/utils/is-ci.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.d(__webpack_exports__, {
y: ()=>isCI
});
function isCI() {
return !!process.env['CI'] && 'false' !== process.env['CI'];
}
}
};