@rsdoctor/core 2.0.0-alpha.2 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/26.js +48 -37
- package/dist/630.js +17 -6
- package/dist/build-utils/build/server.d.ts +1 -2
- package/dist/index.js +288 -105
- package/dist/inner-plugins/plugins/errors.d.ts +1 -0
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/summary.d.ts +3 -2
- package/dist/inner-plugins/utils/sdk.d.ts +2 -1
- package/dist/rspack-plugin/multiple.d.ts +5 -3
- package/dist/rspack-plugin/plugin.d.ts +43 -17
- package/dist/rspack-plugin/session.d.ts +20 -0
- package/dist/sdk/multiple/controller.d.ts +13 -2
- package/dist/sdk/multiple/primary.d.ts +12 -4
- package/package.json +8 -9
package/dist/26.js
CHANGED
|
@@ -5,7 +5,7 @@ import fs_extra from "fs-extra";
|
|
|
5
5
|
import fs_0 from "fs";
|
|
6
6
|
import path_0, { dirname, isAbsolute, resolve as external_path_resolve } from "path";
|
|
7
7
|
import node_fs from "node:fs";
|
|
8
|
-
import connect from "connect";
|
|
8
|
+
import { connect } from "connect-next";
|
|
9
9
|
import http from "http";
|
|
10
10
|
import os from "os";
|
|
11
11
|
import "get-port";
|
|
@@ -23983,8 +23983,8 @@ async function reportLoader(ctx, start, startHRTime, isPitch, sync, code, err, r
|
|
|
23983
23983
|
sourcesContent: data.sourcesContent,
|
|
23984
23984
|
mappings: data.mappings,
|
|
23985
23985
|
file: loaderData[0].resource.path
|
|
23986
|
-
}, sdk = getSDK(
|
|
23987
|
-
return sdk?.reportLoader
|
|
23986
|
+
}, compilation = ctx._compilation, sdk = getSDK(compilation?.compiler?.compilerPath || compilation?.name);
|
|
23987
|
+
return sdk?.reportLoader ? (sdk.reportLoader(loaderData), sdk.reportSourceMap(sourceMapData)) : await Promise.all([
|
|
23988
23988
|
Fetch.postJSON(`${host}${SDK.ServerAPI.API.ReportLoader}`, loaderData, 8888).catch((err)=>{
|
|
23989
23989
|
rsdoctorLogger.debug(`${err.message}`, '[RspackPlugin.ReportLoader][error]');
|
|
23990
23990
|
}),
|
|
@@ -24070,7 +24070,16 @@ function getDefaultOutput() {
|
|
|
24070
24070
|
compressData: void 0
|
|
24071
24071
|
};
|
|
24072
24072
|
}
|
|
24073
|
-
|
|
24073
|
+
let normalizeReportType = (reportCodeType, mode)=>{
|
|
24074
|
+
let convertedReportCodeType = 'object' == typeof reportCodeType ? function(reportCodeType) {
|
|
24075
|
+
if (reportCodeType) {
|
|
24076
|
+
if (reportCodeType.noCode) return 'noCode';
|
|
24077
|
+
else if (reportCodeType.noAssetsAndModuleSource) return 'noAssetsAndModuleSource';
|
|
24078
|
+
else if (reportCodeType.noModuleSource) return 'noModuleSource';
|
|
24079
|
+
}
|
|
24080
|
+
}(reportCodeType) : reportCodeType;
|
|
24081
|
+
return 'noCode' === convertedReportCodeType || mode === SDK.IMode[SDK.IMode.brief] ? SDK.ToDataType.NoCode : mode === SDK.IMode[SDK.IMode.lite] || 'noAssetsAndModuleSource' === convertedReportCodeType ? SDK.ToDataType.NoSourceAndAssets : 'noModuleSource' === convertedReportCodeType ? SDK.ToDataType.NoSource : SDK.ToDataType.Normal;
|
|
24082
|
+
}, normalizeRspackUserOptions = function(config = {}) {
|
|
24074
24083
|
var mode, mode1, finalMode, value, value1;
|
|
24075
24084
|
let gzipLevel, finalBrief, finalNormalOptions, userOutput = config.output, defaultOutput = getDefaultOutput(), outputConfig = 'json' === process.env.RSDOCTOR_OUTPUT ? {
|
|
24076
24085
|
reportDir: userOutput?.reportDir,
|
|
@@ -24083,7 +24092,7 @@ function normalizeUserConfig(config = {}) {
|
|
|
24083
24092
|
}
|
|
24084
24093
|
} : userOutput ?? defaultOutput, { linter = {}, features = {}, loaderInterceptorOptions = {}, disableClientServer: userDisableClientServer = !1, sdkInstance, innerClientPath = '', output = outputConfig, supports: userSupports = {}, port, server: userServer = {}, printLog = {
|
|
24085
24094
|
serverUrls: !0
|
|
24086
|
-
}, mode: mode2, brief } = {
|
|
24095
|
+
}, mode: mode2, brief, multiCompiler = !0 } = {
|
|
24087
24096
|
...config,
|
|
24088
24097
|
output: outputConfig
|
|
24089
24098
|
}, supports = {
|
|
@@ -24099,7 +24108,7 @@ function normalizeUserConfig(config = {}) {
|
|
|
24099
24108
|
let server = {
|
|
24100
24109
|
...userServer
|
|
24101
24110
|
};
|
|
24102
|
-
assert(void 0 === server.port || 'number' == typeof server.port), void 0 === server.port && void 0 !== port && (server.port = port);
|
|
24111
|
+
assert(void 0 === server.port || 'number' == typeof server.port), assert('boolean' == typeof multiCompiler || 'object' == typeof multiCompiler && null !== multiCompiler), void 0 === server.port && void 0 !== port && (server.port = port);
|
|
24103
24112
|
let finalMode1 = ('mode' in output && 'string' == typeof (mode = output.mode) && [
|
|
24104
24113
|
'brief',
|
|
24105
24114
|
'normal',
|
|
@@ -24176,20 +24185,14 @@ function normalizeUserConfig(config = {}) {
|
|
|
24176
24185
|
supports,
|
|
24177
24186
|
port,
|
|
24178
24187
|
server,
|
|
24179
|
-
printLog
|
|
24188
|
+
printLog,
|
|
24189
|
+
multiCompiler: {
|
|
24190
|
+
enabled: !1 !== multiCompiler,
|
|
24191
|
+
group: 'object' == typeof multiCompiler ? multiCompiler.group : void 0
|
|
24192
|
+
}
|
|
24180
24193
|
};
|
|
24181
24194
|
return void 0 !== output.compressData && rsdoctorLogger.info(external_rslog_color.yellow("The 'compressData' configuration will be deprecated in a future version.")), res;
|
|
24182
|
-
}
|
|
24183
|
-
let normalizeReportType = (reportCodeType, mode)=>{
|
|
24184
|
-
let convertedReportCodeType = 'object' == typeof reportCodeType ? function(reportCodeType) {
|
|
24185
|
-
if (reportCodeType) {
|
|
24186
|
-
if (reportCodeType.noCode) return 'noCode';
|
|
24187
|
-
else if (reportCodeType.noAssetsAndModuleSource) return 'noAssetsAndModuleSource';
|
|
24188
|
-
else if (reportCodeType.noModuleSource) return 'noModuleSource';
|
|
24189
|
-
}
|
|
24190
|
-
}(reportCodeType) : reportCodeType;
|
|
24191
|
-
return 'noCode' === convertedReportCodeType || mode === SDK.IMode[SDK.IMode.brief] ? SDK.ToDataType.NoCode : mode === SDK.IMode[SDK.IMode.lite] || 'noAssetsAndModuleSource' === convertedReportCodeType ? SDK.ToDataType.NoSourceAndAssets : 'noModuleSource' === convertedReportCodeType ? SDK.ToDataType.NoSource : SDK.ToDataType.Normal;
|
|
24192
|
-
}, normalizeRspackUserOptions = normalizeUserConfig, execAsync = promisify(external_node_child_process_exec), supportedChromiumBrowsers = [
|
|
24195
|
+
}, execAsync = promisify(external_node_child_process_exec), supportedChromiumBrowsers = [
|
|
24193
24196
|
'Google Chrome Canary',
|
|
24194
24197
|
'Google Chrome Dev',
|
|
24195
24198
|
'Google Chrome Beta',
|
|
@@ -24322,7 +24325,9 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
24322
24325
|
apply(compiler) {
|
|
24323
24326
|
logger_time('InternalLoaderPlugin.apply');
|
|
24324
24327
|
try {
|
|
24325
|
-
compiler.
|
|
24328
|
+
compiler.isChild() ? this.sdk.addClientRoutes([
|
|
24329
|
+
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
24330
|
+
]) : compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler)), compiler.hooks.compilation.tap(this.tapPreOptions, (compilation)=>this.compilation(compiler, compilation));
|
|
24326
24331
|
} finally{
|
|
24327
24332
|
logger_timeEnd('InternalLoaderPlugin.apply');
|
|
24328
24333
|
}
|
|
@@ -24330,7 +24335,7 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
24330
24335
|
compilation(compiler, compilation) {
|
|
24331
24336
|
logger_time('InternalLoaderPlugin.compilation');
|
|
24332
24337
|
try {
|
|
24333
|
-
if (compiler.
|
|
24338
|
+
if (compilation.compiler && compilation.compiler !== compiler) return;
|
|
24334
24339
|
let wrapper = (callback)=>(loaderContext, module)=>{
|
|
24335
24340
|
let originLoaders = (module?.loaders || loaderContext?.loaders || []).map((loader)=>{
|
|
24336
24341
|
let rawOptions = loader.options, opts = 'object' == typeof rawOptions && null !== rawOptions ? rawOptions : {};
|
|
@@ -24406,7 +24411,6 @@ class InternalLoaderPlugin extends InternalBasePlugin {
|
|
|
24406
24411
|
super(...args), this.name = 'loader', this.internalLoaderPath = loader_require.resolve('@rsdoctor/core/proxy-loader'), this.afterPlugins = (compiler)=>{
|
|
24407
24412
|
logger_time('InternalLoaderPlugin.afterPlugins');
|
|
24408
24413
|
try {
|
|
24409
|
-
if (compiler.isChild()) return;
|
|
24410
24414
|
compiler.options.module.rules = this.getInterceptRules(compiler, compiler.options.module.rules), this.sdk.addClientRoutes([
|
|
24411
24415
|
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
24412
24416
|
]);
|
|
@@ -24420,7 +24424,7 @@ class InternalPluginsPlugin extends InternalBasePlugin {
|
|
|
24420
24424
|
apply(compiler) {
|
|
24421
24425
|
logger_time('InternalPluginsPlugin.apply');
|
|
24422
24426
|
try {
|
|
24423
|
-
compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler)), compiler.hooks.compilation.tap(this.tapPostOptions, this.compilation);
|
|
24427
|
+
compiler.isChild() ? this.afterPlugins(compiler) : compiler.hooks.afterPlugins.tap(this.tapPostOptions, this.afterPlugins.bind(this, compiler)), compiler.hooks.compilation.tap(this.tapPostOptions, (compilation)=>this.compilation(compiler, compilation));
|
|
24424
24428
|
} finally{
|
|
24425
24429
|
logger_timeEnd('InternalPluginsPlugin.apply');
|
|
24426
24430
|
}
|
|
@@ -24429,17 +24433,16 @@ class InternalPluginsPlugin extends InternalBasePlugin {
|
|
|
24429
24433
|
super(...args), this.name = 'plugins', this.afterPlugins = (compiler)=>{
|
|
24430
24434
|
logger_time('InternalPluginsPlugin.afterPlugins');
|
|
24431
24435
|
try {
|
|
24432
|
-
if (compiler.isChild()) return;
|
|
24433
24436
|
interceptCompilerHooks(compiler, (name, hook)=>interceptPluginHook(this.sdk, name, hook)), this.sdk.addClientRoutes([
|
|
24434
24437
|
Manifest.RsdoctorManifestClientRoutes.Plugins
|
|
24435
24438
|
]);
|
|
24436
24439
|
} finally{
|
|
24437
24440
|
logger_timeEnd('InternalPluginsPlugin.afterPlugins');
|
|
24438
24441
|
}
|
|
24439
|
-
}, this.compilation = (compilation)=>{
|
|
24442
|
+
}, this.compilation = (compiler, compilation)=>{
|
|
24440
24443
|
logger_time('InternalPluginsPlugin.compilation');
|
|
24441
24444
|
try {
|
|
24442
|
-
if (compilation.compiler.
|
|
24445
|
+
if (compilation.compiler && compilation.compiler !== compiler) return;
|
|
24443
24446
|
interceptCompilationHooks(compilation, (name, hook)=>interceptPluginHook(this.sdk, name, hook));
|
|
24444
24447
|
} finally{
|
|
24445
24448
|
logger_timeEnd('InternalPluginsPlugin.compilation');
|
|
@@ -24451,7 +24454,7 @@ class InternalErrorReporterPlugin extends InternalBasePlugin {
|
|
|
24451
24454
|
apply(compiler) {
|
|
24452
24455
|
logger_time('InternalErrorReporterPlugin.apply');
|
|
24453
24456
|
try {
|
|
24454
|
-
compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
24457
|
+
compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.afterCompile) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
24455
24458
|
} finally{
|
|
24456
24459
|
logger_timeEnd('InternalErrorReporterPlugin.apply');
|
|
24457
24460
|
}
|
|
@@ -24500,6 +24503,11 @@ class InternalErrorReporterPlugin extends InternalBasePlugin {
|
|
|
24500
24503
|
} finally{
|
|
24501
24504
|
logger_timeEnd('InternalErrorReporterPlugin.done');
|
|
24502
24505
|
}
|
|
24506
|
+
}, this.afterCompile = async (compilation)=>{
|
|
24507
|
+
await Promise.all([
|
|
24508
|
+
this.reportErrors(compilation.errors || []),
|
|
24509
|
+
this.reportWarnings(compilation.warnings || [])
|
|
24510
|
+
]);
|
|
24503
24511
|
};
|
|
24504
24512
|
}
|
|
24505
24513
|
}
|
|
@@ -24507,7 +24515,7 @@ class InternalSummaryPlugin extends InternalBasePlugin {
|
|
|
24507
24515
|
apply(compiler) {
|
|
24508
24516
|
logger_time('InternalSummaryPlugin.apply');
|
|
24509
24517
|
try {
|
|
24510
|
-
compiler.hooks.beforeCompile.tapPromise(this.tapPostOptions, this.beforeCompile), compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.afterCompile), compiler.hooks.done.tapPromise(this.tapPostOptions, this.done.bind(this, compiler));
|
|
24518
|
+
compiler.hooks.beforeCompile.tapPromise(this.tapPostOptions, this.beforeCompile.bind(this, compiler)), compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.afterCompile.bind(this, compiler)), compiler.isChild() || compiler.hooks.done.tapPromise(this.tapPostOptions, this.done.bind(this, compiler));
|
|
24511
24519
|
} finally{
|
|
24512
24520
|
logger_timeEnd('InternalSummaryPlugin.apply');
|
|
24513
24521
|
}
|
|
@@ -24534,20 +24542,20 @@ class InternalSummaryPlugin extends InternalBasePlugin {
|
|
|
24534
24542
|
});
|
|
24535
24543
|
}
|
|
24536
24544
|
constructor(...args){
|
|
24537
|
-
super(...args), this.name = 'summary', this.times = new Map(), this.preTimes = new Map(), this.postTimes = new Map(), this.beforeCompile = async ()=>{
|
|
24545
|
+
super(...args), this.name = 'summary', this.times = new Map(), this.preTimes = new Map(), this.postTimes = new Map(), this.createdAt = Date.now(), this.beforeCompile = async (compiler)=>{
|
|
24538
24546
|
logger_time('InternalSummaryPlugin.beforeCompile');
|
|
24539
24547
|
try {
|
|
24540
24548
|
if (!this.times.has(Summary.SummaryCostsDataName.Bootstrap)) {
|
|
24541
|
-
let
|
|
24549
|
+
let startAt = compiler.isChild() ? this.createdAt : Date.now() - Math.floor(1000 * process.uptime());
|
|
24542
24550
|
this.report(Summary.SummaryCostsDataName.Bootstrap, startAt), this.mark(Summary.SummaryCostsDataName.Bootstrap, 'post');
|
|
24543
24551
|
}
|
|
24544
24552
|
} finally{
|
|
24545
24553
|
logger_timeEnd('InternalSummaryPlugin.beforeCompile');
|
|
24546
24554
|
}
|
|
24547
|
-
}, this.afterCompile = async (compilation)=>{
|
|
24555
|
+
}, this.afterCompile = async (compiler, compilation)=>{
|
|
24548
24556
|
logger_time('InternalSummaryPlugin.afterCompile');
|
|
24549
24557
|
try {
|
|
24550
|
-
if (!this.times.has(Summary.SummaryCostsDataName.Compile) && !compilation.compiler.
|
|
24558
|
+
if (!this.times.has(Summary.SummaryCostsDataName.Compile) && (!compilation.compiler || compilation.compiler === compiler)) {
|
|
24551
24559
|
let start = this.postTimes.get(Summary.SummaryCostsDataName.Bootstrap);
|
|
24552
24560
|
this.report(Summary.SummaryCostsDataName.Compile, start), this.mark(Summary.SummaryCostsDataName.Compile, 'post');
|
|
24553
24561
|
}
|
|
@@ -24582,7 +24590,9 @@ class InternalBundlePlugin extends InternalBasePlugin {
|
|
|
24582
24590
|
apply(compiler) {
|
|
24583
24591
|
logger_time('InternalBundlePlugin.apply');
|
|
24584
24592
|
try {
|
|
24585
|
-
this.scheduler.ensureModulesChunksGraphApplied(compiler), this.changeDevtoolModuleFilename(compiler), compiler.hooks.compilation.tap(this.tapPostOptions,
|
|
24593
|
+
this.scheduler.ensureModulesChunksGraphApplied(compiler), this.changeDevtoolModuleFilename(compiler), compiler.hooks.compilation.tap(this.tapPostOptions, (compilation)=>{
|
|
24594
|
+
compilation.compiler && compilation.compiler !== compiler || this.thisCompilation(compilation);
|
|
24595
|
+
}), compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.done.bind(this)) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done.bind(this));
|
|
24586
24596
|
} finally{
|
|
24587
24597
|
logger_timeEnd('InternalBundlePlugin.apply');
|
|
24588
24598
|
}
|
|
@@ -24636,8 +24646,8 @@ async function collectSourceMaps(map, assetLinesCodeList, _compilation, _this, s
|
|
|
24636
24646
|
let sourceMapDir1, consumer = await new SourceMapConsumer(map);
|
|
24637
24647
|
sourceMapPath ? sourceMapDir1 = dirname(sourceMapPath) : _compilation.options.output?.path && (sourceMapDir1 = 'string' == typeof _compilation.options.output.path ? _compilation.options.output.path : void 0);
|
|
24638
24648
|
let sourceRoot1 = map.sourceRoot, getRealSourcePath = (context = _this.sdk.root || process.cwd(), cache = _this._realSourcePathCache, sourceMapDir = sourceMapDir1, sourceRoot = sourceRoot1 ?? void 0, cache = cache || new Map(), (source, sourceMapFilenameRegex)=>{
|
|
24649
|
+
let resolved;
|
|
24639
24650
|
if (cache.has(source)) return cache.get(source);
|
|
24640
|
-
let resolved = UNASSIGNED;
|
|
24641
24651
|
if (source.startsWith('file://')) resolved = external_path_resolve(context, source.replace(/^file:\/\//, ''));
|
|
24642
24652
|
else if (source.startsWith('webpack://')) if (sourceMapFilenameRegex) {
|
|
24643
24653
|
let match = source.match(sourceMapFilenameRegex), filePath = match?.[1], baseDir = namespace && source.startsWith(`webpack://${namespace}`) || namespace && source.startsWith(`file://${namespace}`) ? process.cwd() : context;
|
|
@@ -24773,6 +24783,7 @@ let hasConsole = !1, ensureModulesChunksGraphFn = (compiler, _this)=>{
|
|
|
24773
24783
|
chunkGraph: !1,
|
|
24774
24784
|
moduleGraph: !1
|
|
24775
24785
|
}, rsdoctorLogger.debug('[RspackNativePlugin] Apply hooks'), compiler.hooks.compilation.tap('RsdoctorRspackPlugin', (compilation)=>{
|
|
24786
|
+
if (compilation.compiler && compilation.compiler !== compiler) return;
|
|
24776
24787
|
state.chunkGraph = !1, state.moduleGraph = !1;
|
|
24777
24788
|
let hooks = RsdoctorRspackPlugin.getCompilationHooks(compilation), cached = {}, dependOn = {
|
|
24778
24789
|
chunkGraphData: [],
|
|
@@ -24924,13 +24935,13 @@ let hasConsole = !1, ensureModulesChunksGraphFn = (compiler, _this)=>{
|
|
|
24924
24935
|
rsdoctorLogger.debug('[RspackNativePlugin] Called assets hook'), tryConsumeData('assetPatchData', rawAssetPatch);
|
|
24925
24936
|
});
|
|
24926
24937
|
}), state);
|
|
24927
|
-
_this._realSourcePathCache || (_this._realSourcePathCache = new Map()), compiler.hooks.done.tapPromise(internalPluginTapPreOptions('moduleGraph'), async ()=>{
|
|
24938
|
+
_this._realSourcePathCache || (_this._realSourcePathCache = new Map()), ('function' == typeof compiler.isChild && compiler.isChild() ? compiler.hooks.afterCompile : compiler.hooks.done).tapPromise(internalPluginTapPreOptions('moduleGraph'), async ()=>{
|
|
24928
24939
|
await doneHandler(_this, compiler, nativeGraphState);
|
|
24929
24940
|
}), compiler.hooks.compilation.tap({
|
|
24930
24941
|
...pluginTapPostOptions,
|
|
24931
24942
|
name: 'RsdoctorSourceMapCollector'
|
|
24932
24943
|
}, (compilation)=>{
|
|
24933
|
-
compilation.hooks.processAssets && compilation.hooks.processAssets.tapPromise({
|
|
24944
|
+
(!compilation.compiler || compilation.compiler === compiler) && compilation.hooks.processAssets && compilation.hooks.processAssets.tapPromise({
|
|
24934
24945
|
name: 'RsdoctorSourceMapCollector',
|
|
24935
24946
|
stage: 2400
|
|
24936
24947
|
}, async ()=>{
|
|
@@ -26074,7 +26085,7 @@ class InternalRulesPlugin extends InternalBasePlugin {
|
|
|
26074
26085
|
apply(compiler) {
|
|
26075
26086
|
logger_time('InternalRulesPlugin.apply');
|
|
26076
26087
|
try {
|
|
26077
|
-
compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
26088
|
+
compiler.isChild() ? compiler.hooks.afterCompile.tapPromise(this.tapPreOptions, this.lint.bind(this)) : compiler.hooks.done.tapPromise(this.tapPreOptions, this.done);
|
|
26078
26089
|
} finally{
|
|
26079
26090
|
logger_timeEnd('InternalRulesPlugin.apply');
|
|
26080
26091
|
}
|
|
@@ -26160,4 +26171,4 @@ class InternalResolverPlugin extends InternalBasePlugin {
|
|
|
26160
26171
|
};
|
|
26161
26172
|
}
|
|
26162
26173
|
}
|
|
26163
|
-
export { DevToolError, FileSharding, InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, Linter as LinterType, ProbeLoaderPlugin, createServer, defaultHost, defaultPort, defineRule, ensureModulesChunksGraphFn, fs_extra, getCPUInfo, getMemoryInfo, getNodeVersion, getNpmVersion, getOriginLoaderModule, getPnpmVersion, getPortSync, getRspackNativePlugin, getYarnVersion, handleBriefModeReport, linter_Linter as Linter, normalizeRspackUserOptions,
|
|
26174
|
+
export { DevToolError, FileSharding, InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, Linter as LinterType, ProbeLoaderPlugin, createServer, defaultHost, defaultPort, defineRule, ensureModulesChunksGraphFn, fs_extra, getCPUInfo, getMemoryInfo, getNodeVersion, getNpmVersion, getOriginLoaderModule, getPnpmVersion, getPortSync, getRspackNativePlugin, getYarnVersion, handleBriefModeReport, linter_Linter as Linter, normalizeRspackUserOptions, processCompilerConfig, reportLoader, rule_Rule as LinterRule, rules_rules as rules, shouldSkipLoader };
|
package/dist/630.js
CHANGED
|
@@ -1225,18 +1225,29 @@ function getModuleLocation(node) {
|
|
|
1225
1225
|
};
|
|
1226
1226
|
}
|
|
1227
1227
|
function setSDK(t) {
|
|
1228
|
-
|
|
1228
|
+
registerSDK(t, !0);
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1230
|
+
function registerSDK(t, asDefault = !1) {
|
|
1231
|
+
globalThis.__rsdoctor_sdks__ || (globalThis.__rsdoctor_sdks__ = []);
|
|
1232
|
+
let sameNameIndex = globalThis.__rsdoctor_sdks__.findIndex((sdk)=>sdk.name === t.name);
|
|
1233
|
+
sameNameIndex >= 0 ? globalThis.__rsdoctor_sdks__[sameNameIndex] = t : globalThis.__rsdoctor_sdks__.includes(t) || globalThis.__rsdoctor_sdks__.push(t), asDefault && (globalThis.__rsdoctor_sdk__ = t);
|
|
1234
|
+
}
|
|
1235
|
+
function findMatchingSDK(sdks, compilerId) {
|
|
1236
|
+
let exactMatch = sdks.find((item)=>item.name === compilerId || 'compilerPath' in item && item.compilerPath === compilerId);
|
|
1237
|
+
if (exactMatch) return exactMatch;
|
|
1238
|
+
let compilerName = compilerId.split('|', 1)[0];
|
|
1239
|
+
if (compilerName && compilerName !== compilerId) return sdks.find((item)=>item.name === compilerName);
|
|
1240
|
+
}
|
|
1241
|
+
function getSDK(compilerId) {
|
|
1231
1242
|
let sdks = globalThis.__rsdoctor_sdks__ || [], sdk = globalThis.__rsdoctor_sdk__;
|
|
1232
|
-
if (
|
|
1243
|
+
if (compilerId && (sdk = findMatchingSDK(sdks, compilerId) || sdk), sdk && compilerId && 'parent' in sdk) {
|
|
1233
1244
|
let parent = sdk.parent;
|
|
1234
|
-
return parent
|
|
1245
|
+
return parent && findMatchingSDK(parent.slaves, compilerId) || sdk;
|
|
1235
1246
|
}
|
|
1236
1247
|
return sdk;
|
|
1237
1248
|
}
|
|
1238
1249
|
export default function(...args) {
|
|
1239
|
-
let time = Date.now(), code = args[0], _options = this.getOptions(), sdk = getSDK(_options.builderName), loaderData = {
|
|
1250
|
+
let time = Date.now(), code = args[0], _options = this.getOptions(), compilation = this._compilation, sdk = getSDK(compilation?.compiler?.compilerPath || _options.builderName), loaderData = {
|
|
1240
1251
|
resource: {
|
|
1241
1252
|
path: this._module?.layer ? `${this.resourcePath}[${this._module.layer}]` : this.resourcePath,
|
|
1242
1253
|
query: parseQuery(this.resourceQuery),
|
|
@@ -1266,4 +1277,4 @@ export default function(...args) {
|
|
|
1266
1277
|
};
|
|
1267
1278
|
sdk?.reportLoaderStartOrEnd(loaderData), this.callback(null, ...args);
|
|
1268
1279
|
};
|
|
1269
|
-
export { addProbeLoader2Rules, color, createLoaderContextTrap, extractLoaderName, filesize, getDocument, getLoaderNameMatch, getSDK, interceptCompilationHooks, interceptCompilerHooks, isESMLoader, loadLoaderModule, logger_time, mapEachRules, parseBundle, parseQuery, parser, rsdoctorLogger as logger, setSDK, stringify, timeEnd };
|
|
1280
|
+
export { addProbeLoader2Rules, color, createLoaderContextTrap, extractLoaderName, filesize, getDocument, getLoaderNameMatch, getSDK, interceptCompilationHooks, interceptCompilerHooks, isESMLoader, loadLoaderModule, logger_time, mapEachRules, parseBundle, parseQuery, parser, registerSDK, rsdoctorLogger as logger, setSDK, stringify, timeEnd };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import connect from 'connect';
|
|
2
1
|
import http from 'http';
|
|
3
2
|
import { Thirdparty } from '@rsdoctor/shared/types';
|
|
4
3
|
export declare const defaultHost = "127.0.0.1";
|
|
@@ -6,7 +5,7 @@ export declare const defaultPort: number;
|
|
|
6
5
|
export declare function getPort(expectPort: number, host?: string): Promise<number>;
|
|
7
6
|
export declare const createGetPortSyncFunctionString: (expectPort: number, host?: string) => string;
|
|
8
7
|
export declare function getPortSync(expectPort: number, host?: string): number | never;
|
|
9
|
-
export declare function createApp(): connect.Server;
|
|
8
|
+
export declare function createApp(): Thirdparty.connect.Server;
|
|
10
9
|
export declare function createServer(port: number, host?: string): Promise<{
|
|
11
10
|
app: Thirdparty.connect.Server;
|
|
12
11
|
server: http.Server;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import node_fs, { existsSync } from "node:fs";
|
|
1
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
2
|
+
import node_fs from "node:fs";
|
|
5
3
|
import fs_extra from "fs-extra";
|
|
6
4
|
import path_0 from "path";
|
|
7
5
|
import { createRequire } from "module";
|
|
@@ -26,10 +24,18 @@ import raw_body from "raw-body";
|
|
|
26
24
|
import { createBrotliDecompress, createGunzip, createInflate } from "node:zlib";
|
|
27
25
|
import node_process from "node:process";
|
|
28
26
|
import { AsyncSeriesHook } from "@rspack/lite-tapable";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
27
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
28
|
+
import { setSDK, logger as rsdoctorLogger, logger_time, timeEnd, color, stringify, registerSDK } from "./630.js";
|
|
29
|
+
import { InternalResolverPlugin, getYarnVersion, InternalPluginsPlugin, getRspackNativePlugin, InternalSummaryPlugin, ensureModulesChunksGraphFn, getNpmVersion, InternalBundlePlugin, getNodeVersion, fs_extra as external_fs_extra_fs_extra, handleBriefModeReport, processCompilerConfig, InternalLoaderPlugin, getCPUInfo, defaultPort, getPnpmVersion, FileSharding, createServer, getMemoryInfo, normalizeRspackUserOptions, defaultHost, InternalErrorReporterPlugin, getPortSync, InternalRulesPlugin, DevToolError, ProbeLoaderPlugin } from "./26.js";
|
|
31
30
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
32
|
-
var date, __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url))
|
|
31
|
+
var date, __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
32
|
+
let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
33
|
+
__webpack_require__.add({
|
|
34
|
+
"launch-editor" (module) {
|
|
35
|
+
module.exports = __rspack_createRequire_require("launch-editor");
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
var apis_namespaceObject = {};
|
|
33
39
|
__webpack_require__.r(apis_namespaceObject), __webpack_require__.d(apis_namespaceObject, {
|
|
34
40
|
AlertsAPI: ()=>AlertsAPI,
|
|
35
41
|
BundleDiffAPI: ()=>BundleDiffAPI,
|
|
@@ -1002,7 +1008,7 @@ class RsdoctorServer {
|
|
|
1002
1008
|
return;
|
|
1003
1009
|
}
|
|
1004
1010
|
try {
|
|
1005
|
-
let launch =
|
|
1011
|
+
let launch = __webpack_require__("launch-editor"), responded = !1, safeEnd = (code, body)=>{
|
|
1006
1012
|
responded || (responded = !0, res.statusCode = code, res.end(body));
|
|
1007
1013
|
};
|
|
1008
1014
|
launch(file, editor, (_fileName, errorMessage)=>{
|
|
@@ -1532,157 +1538,268 @@ class RsdoctorSlaveServer extends RsdoctorServer {
|
|
|
1532
1538
|
}
|
|
1533
1539
|
let primary_id = 1;
|
|
1534
1540
|
class RsdoctorPrimarySDK extends RsdoctorSDK {
|
|
1535
|
-
constructor({ name, stage, controller, extraConfig, type }){
|
|
1541
|
+
constructor({ name, displayName, compilerPath, parentCompilerPath, isChild, stage, controller, extraConfig, type }){
|
|
1536
1542
|
super({
|
|
1537
1543
|
name,
|
|
1538
1544
|
root: controller.root,
|
|
1539
1545
|
config: extraConfig
|
|
1540
|
-
});
|
|
1546
|
+
}), this.reportFileName = '';
|
|
1541
1547
|
let lastSdk = controller.getLastSdk(), port = lastSdk ? lastSdk.server.port + 1 : extraConfig?.server?.port ?? this.server.port;
|
|
1542
|
-
this.id = primary_id++, this.stage = 'number' == typeof stage ? stage : 1, this.extraConfig = extraConfig, this.parent = controller, this.server = new RsdoctorSlaveServer(this, port, {
|
|
1548
|
+
this.id = primary_id++, this.stage = 'number' == typeof stage ? stage : 1, this.displayName = displayName || name, this.compilerPath = compilerPath || '', this.parentCompilerPath = parentCompilerPath, this.isChild = !!isChild, this.extraConfig = extraConfig, this.parent = controller, lastSdk && (this.server = new RsdoctorSlaveServer(this, port, {
|
|
1543
1549
|
cors: extraConfig?.server?.cors
|
|
1544
|
-
}), this.type = type, this.setName(name)
|
|
1545
|
-
}
|
|
1546
|
-
clearSwitch() {
|
|
1547
|
-
this.uploadPieces = new Promise((resolve)=>{
|
|
1548
|
-
this.finishUploadPieceSwitch = resolve;
|
|
1549
|
-
});
|
|
1550
|
+
})), this.type = type, this.setName(name);
|
|
1550
1551
|
}
|
|
1551
1552
|
get isMaster() {
|
|
1552
1553
|
return this.parent.master === this;
|
|
1553
1554
|
}
|
|
1554
1555
|
async writePieces() {
|
|
1555
|
-
|
|
1556
|
-
this.setOutputDir(isMaster ? outputDir : path_0.join(parent.master.outputDir, '.slaves', name.replace(/\s+/g, '-'))), await super.writePieces(this.getStoreData()), finishUploadPieceSwitch?.();
|
|
1556
|
+
this.setOutputDir(this.parent.getCompilerOutputDir(this)), await super.writePieces(this.getStoreData());
|
|
1557
1557
|
}
|
|
1558
1558
|
async writeManifest() {
|
|
1559
|
-
let { parent, cloudData
|
|
1560
|
-
|
|
1559
|
+
let { parent, cloudData } = this;
|
|
1560
|
+
cloudData && parent.isMultiple && (cloudData.name = this.name, cloudData.series = parent.getSeriesData());
|
|
1561
1561
|
let result = await super.writeManifest();
|
|
1562
|
-
return
|
|
1562
|
+
return await parent.refreshManifestSeries(), result;
|
|
1563
|
+
}
|
|
1564
|
+
async refreshManifestSeries() {
|
|
1565
|
+
this.parent.isMultiple && this.cloudData && this.diskManifestPath && (this.cloudData.name = this.name, this.cloudData.series = this.parent.getSeriesData(), await super.writeManifest());
|
|
1563
1566
|
}
|
|
1564
1567
|
getSeriesData(serverUrl = !1) {
|
|
1565
1568
|
return this.parent.getSeriesData(serverUrl);
|
|
1566
1569
|
}
|
|
1567
1570
|
setName(name) {
|
|
1568
|
-
|
|
1571
|
+
let baseName = name || `compiler-${this.id}`;
|
|
1572
|
+
if (!this.parent.hasName(baseName, this)) {
|
|
1573
|
+
this._name = baseName;
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
let suffix = 2;
|
|
1577
|
+
for(; this.parent.hasName(`${baseName}-${suffix}`, this);)suffix += 1;
|
|
1578
|
+
this._name = `${baseName}-${suffix}`;
|
|
1569
1579
|
}
|
|
1570
1580
|
getManifestData() {
|
|
1571
1581
|
let data = super.getManifestData();
|
|
1572
|
-
return data.name = this.name, data.series = this.getSeriesData(!0), data;
|
|
1582
|
+
return this.parent.isMultiple && (data.name = this.name, data.series = this.getSeriesData(!0)), data;
|
|
1583
|
+
}
|
|
1584
|
+
addRsdoctorDataToHTML(storeData, htmlContent) {
|
|
1585
|
+
let result = super.addRsdoctorDataToHTML(storeData, htmlContent);
|
|
1586
|
+
if (!this.parent.isMultiple) return result;
|
|
1587
|
+
let metadata = `<script>window.${Constants.WINDOW_RSDOCTOR_TAG}.name=${JSON.stringify(this.name)};window.${Constants.WINDOW_RSDOCTOR_TAG}.series=${JSON.stringify(this.parent.getBriefSeriesData(this))}</script>`;
|
|
1588
|
+
return result.replace('</body>', `${metadata}</body>`);
|
|
1573
1589
|
}
|
|
1574
1590
|
}
|
|
1575
1591
|
class RsdoctorSDKController {
|
|
1576
1592
|
constructor(root = process.cwd()){
|
|
1577
|
-
this.slaves = [], this.root = '', this.root = root;
|
|
1593
|
+
this.slaves = [], this.activeSlaves = new Set(), this.outputDir = '', this.refreshManifestTask = Promise.resolve(), this.root = '', this.root = root;
|
|
1578
1594
|
}
|
|
1579
1595
|
get master() {
|
|
1580
|
-
return this.
|
|
1596
|
+
return this.getActiveSlaves()[0];
|
|
1597
|
+
}
|
|
1598
|
+
get isMultiple() {
|
|
1599
|
+
return this.activeSlaves.size > 1;
|
|
1581
1600
|
}
|
|
1582
1601
|
getLastSdk() {
|
|
1583
1602
|
return this.slaves[this.slaves.length - 1];
|
|
1584
1603
|
}
|
|
1585
|
-
hasName(name) {
|
|
1586
|
-
return !!this.slaves.find((item)=>item.name === name);
|
|
1604
|
+
hasName(name, exclude) {
|
|
1605
|
+
return !!this.slaves.find((item)=>item !== exclude && item.name === name);
|
|
1606
|
+
}
|
|
1607
|
+
registerSlave(slave) {
|
|
1608
|
+
this.activeSlaves.add(slave);
|
|
1609
|
+
}
|
|
1610
|
+
setOutputDir(slave, outputDir) {
|
|
1611
|
+
slave === this.master && slave !== this.outputOwner && (this.outputDir = outputDir, this.outputOwner = slave, slave.setOutputDir(outputDir));
|
|
1612
|
+
}
|
|
1613
|
+
getCompilerOutputDir(slave) {
|
|
1614
|
+
if (slave === this.master) return this.outputDir || slave.outputDir;
|
|
1615
|
+
let rootOutputDir = this.outputDir || this.master?.outputDir || slave.outputDir;
|
|
1616
|
+
if (slave.isChild) return node_path.join(rootOutputDir, '.slaves', slave.name.replace(/\s+/g, '-'));
|
|
1617
|
+
let name = slave.name.replace(/[^a-zA-Z0-9_$-]+/g, '-').replace(/^-+|-+$/g, '') || `compiler-${slave.id}`;
|
|
1618
|
+
return node_path.join(rootOutputDir, 'compilers', name);
|
|
1587
1619
|
}
|
|
1588
1620
|
getSeriesData(serverUrl = !1) {
|
|
1589
|
-
return this.
|
|
1621
|
+
return this.getActiveSlaves().map((item)=>{
|
|
1590
1622
|
let data = {
|
|
1591
1623
|
name: item.name,
|
|
1592
|
-
|
|
1593
|
-
|
|
1624
|
+
displayName: item.displayName,
|
|
1625
|
+
path: item.reportFileName ? node_path.join(this.getCompilerOutputDir(item), item.reportFileName) : item.diskManifestPath || node_path.resolve(this.getCompilerOutputDir(item), Constants.RsdoctorOutputManifest),
|
|
1626
|
+
stage: item.stage,
|
|
1627
|
+
compilerPath: item.compilerPath,
|
|
1628
|
+
parentCompilerPath: item.parentCompilerPath,
|
|
1629
|
+
isChild: item.isChild
|
|
1594
1630
|
};
|
|
1595
1631
|
return serverUrl && (data.origin = item.server.origin), data;
|
|
1596
1632
|
});
|
|
1597
1633
|
}
|
|
1598
|
-
|
|
1634
|
+
getBriefSeriesData(current) {
|
|
1635
|
+
let currentOutputDir = this.getCompilerOutputDir(current);
|
|
1636
|
+
return this.getActiveSlaves().map((item)=>({
|
|
1637
|
+
name: item.name,
|
|
1638
|
+
path: node_path.relative(currentOutputDir, node_path.join(this.getCompilerOutputDir(item), item.reportFileName || 'rsdoctor-report.html')).split(node_path.sep).map((segment)=>encodeURIComponent(segment)).join('/'),
|
|
1639
|
+
stage: item.stage
|
|
1640
|
+
}));
|
|
1641
|
+
}
|
|
1642
|
+
createSlave({ name, displayName, compilerPath, parentCompilerPath, isChild, stage, extraConfig, type }) {
|
|
1599
1643
|
let slave = new RsdoctorPrimarySDK({
|
|
1600
1644
|
name,
|
|
1601
|
-
|
|
1645
|
+
displayName,
|
|
1646
|
+
compilerPath,
|
|
1647
|
+
parentCompilerPath,
|
|
1648
|
+
isChild,
|
|
1649
|
+
stage: 'number' == typeof stage ? stage : this.slaves.length,
|
|
1602
1650
|
controller: this,
|
|
1603
1651
|
extraConfig,
|
|
1604
1652
|
type
|
|
1605
1653
|
});
|
|
1606
1654
|
return this.slaves.push(slave), this.slaves.sort((a, b)=>a.stage - b.stage), slave;
|
|
1607
1655
|
}
|
|
1656
|
+
refreshManifestSeries() {
|
|
1657
|
+
return this.isMultiple ? (this.refreshManifestTask = this.refreshManifestTask.then(async ()=>{
|
|
1658
|
+
for (let slave of this.getActiveSlaves())await slave.refreshManifestSeries();
|
|
1659
|
+
}), this.refreshManifestTask) : Promise.resolve();
|
|
1660
|
+
}
|
|
1661
|
+
getActiveSlaves() {
|
|
1662
|
+
return this.slaves.filter((item)=>this.activeSlaves.has(item));
|
|
1663
|
+
}
|
|
1608
1664
|
}
|
|
1609
|
-
|
|
1665
|
+
var package_namespaceObject = JSON.parse('{"name":"@rsdoctor/core","version":"2.0.0-beta.0","repository":{"type":"git","url":"https://github.com/web-infra-dev/rsdoctor","directory":"packages/core"},"license":"MIT","engines":{"node":">=22.18.0"},"main":"dist/index.js","types":"dist/index.d.ts","files":["dist","static"],"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./proxy-loader":{"types":"./dist/proxy-loader.d.ts","default":"./dist/proxy-loader.js"}},"typesVersions":{"*":{".":["./dist/index.d.ts"],"proxy-loader":["./dist/proxy-loader.d.ts"]}},"scripts":{"dev":"npm run start","build":"rslib build","start":"rslib build -w","test":"rstest run"},"dependencies":{"@babel/code-frame":"7.26.2","@rspack/lite-tapable":"catalog:","@rsdoctor/shared":"workspace:*","@types/estree":"catalog:","acorn":"^8.10.0","acorn-import-attributes":"^1.9.5","acorn-walk":"8.3.5","browserslist-load-config":"^1.0.3","caniuse-lite":"^1.0.30001809","connect-next":"catalog:","envinfo":"7.21.0","fs-extra":"catalog:","get-port":"5.1.1","lines-and-columns":"2.0.4","open":"^11.0.0","raw-body":"3.0.2","rslog":"^2.1.3","semver":"^7.8.5","source-map":"catalog:","@rsdoctor/client":"workspace:*","cors":"2.8.6","launch-editor":"^2.14.1","sirv":"catalog:","ws":"8.21.3"},"devDependencies":{"@rsbuild/plugin-check-syntax":"catalog:","@rspack/core":"catalog:","@scripts/test-helper":"workspace:*","@types/babel__code-frame":"7.27.0","@types/envinfo":"7.8.4","@types/fs-extra":"catalog:","@types/node":"catalog:","@types/semver":"^7.8.0","babel-loader":"10.1.1","filesize":"catalog:","json-stream-stringify":"3.0.1","string-loader":"0.0.1","ts-loader":"^9.6.2","tslib":"catalog:","typescript":"catalog:","@types/cors":"2.8.19","@types/ws":"^8.18.1"},"peerDependencies":{"@rspack/core":"^2.0.0"},"peerDependenciesMeta":{"@rspack/core":{"optional":true}},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}');
|
|
1666
|
+
let pluginTapName = 'RsdoctorRspackPlugin', pluginTapPostOptions = {
|
|
1610
1667
|
name: pluginTapName,
|
|
1611
1668
|
stage: 999
|
|
1612
|
-
}, hasGreeted = !1;
|
|
1669
|
+
}, pendingSessions = new Map(), hasGreeted = !1;
|
|
1670
|
+
class RsdoctorCompilerContext {
|
|
1671
|
+
constructor(sdk, options){
|
|
1672
|
+
this.sdk = sdk, this.options = options, this.name = pluginTapName, this.isRsdoctorPlugin = !0, this.modulesGraph = new ModuleGraph(), this.applied = !1;
|
|
1673
|
+
}
|
|
1674
|
+
apply() {}
|
|
1675
|
+
ensureModulesChunksGraphApplied(compiler) {
|
|
1676
|
+
ensureModulesChunksGraphFn(compiler, this);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1613
1679
|
class RsdoctorRspackPlugin {
|
|
1614
1680
|
constructor(options){
|
|
1615
|
-
this.name = pluginTapName, this.
|
|
1681
|
+
if (this.name = pluginTapName, this.isRsdoctorPlugin = !0, this.compilerContexts = new WeakMap(), this.childPlugins = new Map(), this.appliedCompilerCount = 0, this.afterPlugins = (compiler, context = this.getCompilerContext(compiler))=>{
|
|
1616
1682
|
logger_time('RsdoctorRspackPlugin.afterPlugins');
|
|
1617
1683
|
try {
|
|
1618
|
-
this.getRspackConfig(compiler);
|
|
1684
|
+
this.getRspackConfig(compiler, context);
|
|
1619
1685
|
} finally{
|
|
1620
1686
|
timeEnd('RsdoctorRspackPlugin.afterPlugins');
|
|
1621
1687
|
}
|
|
1622
|
-
}, this.done = async (compiler)=>{
|
|
1688
|
+
}, this.done = async (compiler, context = this.getCompilerContext(compiler))=>{
|
|
1623
1689
|
logger_time('RsdoctorRspackPlugin.done');
|
|
1624
1690
|
try {
|
|
1625
|
-
rsdoctorLogger.debug('[RsdoctorRspackPlugin] bootstrap(start) in done()'), await
|
|
1691
|
+
rsdoctorLogger.debug('[RsdoctorRspackPlugin] bootstrap(start) in done()'), await context.bootstrapTask, rsdoctorLogger.debug('[RsdoctorRspackPlugin] bootstrap(end) in done()'), context.sdk.addClientRoutes([
|
|
1626
1692
|
Manifest.RsdoctorManifestClientRoutes.Overall
|
|
1627
|
-
]),
|
|
1693
|
+
]), context.sdk instanceof RsdoctorPrimarySDK ? context.sdk.setOutputDir(context.sdk.parent.getCompilerOutputDir(context.sdk)) : context.sdk.setOutputDir(this.getOutputDir(compiler)), await context.sdk.writeStore();
|
|
1694
|
+
let isPrimaryCompiler = !(context.sdk instanceof RsdoctorPrimarySDK) || context.sdk.isMaster;
|
|
1695
|
+
!this.options.disableClientServer && isPrimaryCompiler && (this.options.output.mode === SDK.IMode[SDK.IMode.brief] ? await handleBriefModeReport(context.sdk, this.options, this.options.disableClientServer) : await context.sdk.server.openClientPage('homepage')), this.shouldDisposeSDK() && await context.sdk.dispose();
|
|
1628
1696
|
} finally{
|
|
1629
1697
|
timeEnd('RsdoctorRspackPlugin.done');
|
|
1630
1698
|
}
|
|
1631
|
-
}, this.
|
|
1699
|
+
}, this.childDone = async (compiler, context)=>{
|
|
1700
|
+
await context.bootstrapTask, context.sdk.addClientRoutes([
|
|
1701
|
+
Manifest.RsdoctorManifestClientRoutes.Overall
|
|
1702
|
+
]), context.sdk instanceof RsdoctorPrimarySDK ? context.sdk.setOutputDir(context.sdk.parent.getCompilerOutputDir(context.sdk)) : context.sdk.setOutputDir(this.getOutputDir(compiler)), await context.sdk.writeStore(), this.shouldDisposeSDK() && await context.sdk.dispose();
|
|
1703
|
+
}, this.childOptions = {
|
|
1704
|
+
...options,
|
|
1632
1705
|
supports: {
|
|
1633
1706
|
...options?.supports
|
|
1634
1707
|
}
|
|
1635
|
-
}))
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1708
|
+
}, this.options = normalizeRspackUserOptions(this.childOptions), this.outsideInstance = !!this.options.sdkInstance, this.defaultName = options?.name || pluginTapName, this.defaultStage = options?.stage, this.options.sdkInstance) {
|
|
1709
|
+
this.options.sdkInstance instanceof RsdoctorPrimarySDK && (this.controller = this.options.sdkInstance.parent), this.primaryContext = new RsdoctorCompilerContext(this.options.sdkInstance, this.options);
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
this.sessionLease = function(options) {
|
|
1713
|
+
if (!options.multiCompiler.enabled) return {
|
|
1714
|
+
controller: new RsdoctorSDKController(),
|
|
1715
|
+
release () {}
|
|
1716
|
+
};
|
|
1717
|
+
let key = function(options) {
|
|
1718
|
+
let root = process.cwd(), { group } = options.multiCompiler;
|
|
1719
|
+
return group ? [
|
|
1720
|
+
'group',
|
|
1721
|
+
root,
|
|
1722
|
+
group
|
|
1723
|
+
].join('\0') : [
|
|
1724
|
+
'auto',
|
|
1725
|
+
root,
|
|
1726
|
+
options.output.mode,
|
|
1727
|
+
options.output.reportDir,
|
|
1728
|
+
options.server.port ?? options.port ?? ''
|
|
1729
|
+
].join('\0');
|
|
1730
|
+
}(options), session = pendingSessions.get(key);
|
|
1731
|
+
if (!session) {
|
|
1732
|
+
let controller = new RsdoctorSDKController(), timer = setTimeout(()=>{
|
|
1733
|
+
pendingSessions.get(key)?.controller === controller && pendingSessions.delete(key);
|
|
1734
|
+
}, 0);
|
|
1735
|
+
timer.unref?.(), session = {
|
|
1736
|
+
controller,
|
|
1737
|
+
timer
|
|
1738
|
+
}, pendingSessions.set(key, session);
|
|
1651
1739
|
}
|
|
1652
|
-
|
|
1740
|
+
let { controller } = session;
|
|
1741
|
+
return {
|
|
1742
|
+
controller,
|
|
1743
|
+
release () {
|
|
1744
|
+
let current = pendingSessions.get(key);
|
|
1745
|
+
current?.controller === controller && (clearTimeout(current.timer), pendingSessions.delete(key));
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
}(this.options), this.controller = this.sessionLease.controller, this.primaryContext = this.createCompilerContext(this.defaultStage);
|
|
1749
|
+
}
|
|
1750
|
+
get sdk() {
|
|
1751
|
+
return this.primaryContext.sdk;
|
|
1752
|
+
}
|
|
1753
|
+
get modulesGraph() {
|
|
1754
|
+
return this.primaryContext.modulesGraph;
|
|
1755
|
+
}
|
|
1756
|
+
get _bootstrapTask() {
|
|
1757
|
+
return this.primaryContext.bootstrapTask;
|
|
1758
|
+
}
|
|
1759
|
+
getCompilerSDK(name) {
|
|
1760
|
+
return this.sdk.name === name ? this.sdk : this.sdk instanceof RsdoctorPrimarySDK ? this.sdk.parent.slaves.find((sdk)=>sdk.name === name) : void 0;
|
|
1653
1761
|
}
|
|
1654
1762
|
apply(compiler) {
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1763
|
+
let context = this.getCompilerContext(compiler);
|
|
1764
|
+
if (!context.applied) {
|
|
1765
|
+
context.applied = !0, logger_time('RsdoctorRspackPlugin.apply');
|
|
1766
|
+
try {
|
|
1767
|
+
hasGreeted || compiler.isChild() || (hasGreeted = !0, rsdoctorLogger.greet(`
|
|
1768
|
+
\nRsdoctor v${package_namespaceObject.version}\n`)), this.releasePendingSessionOnRun(compiler), context.bootstrapTask || (context.bootstrapTask = context.sdk.bootstrap());
|
|
1769
|
+
let compilerName = compiler.name || compiler.options.name || (1 === this.appliedCompilerCount ? this.defaultName : `${this.defaultName}-${this.appliedCompilerCount}`);
|
|
1770
|
+
compiler.isChild() || context.sdk.setName(compilerName), context.sdk instanceof RsdoctorPrimarySDK && (compiler.isChild() || (context.sdk.displayName = compiler.name || compiler.options.name || (1 === this.appliedCompilerCount ? 'Main compiler' : compilerName)), 'dependencies' in compiler.options && (context.sdk.dependencies = compiler.options.dependencies), context.sdk.parent.registerSlave(context.sdk), context.sdk.parent.setOutputDir(context.sdk, this.getOutputDir(compiler)), this.options.output.mode === SDK.IMode[SDK.IMode.brief] && (context.sdk.reportFileName = this.getBriefReportFileName())), compiler.isChild() ? registerSDK(context.sdk) : setSDK(context.sdk), this.applyChildCompilerSupport(compiler, context), compiler.isChild() ? (this.getRspackConfig(compiler, context), compiler.hooks.afterCompile.tapPromise({
|
|
1771
|
+
...pluginTapPostOptions,
|
|
1772
|
+
stage: pluginTapPostOptions.stage + 100
|
|
1773
|
+
}, ()=>this.childDone(compiler, context))) : (compiler.hooks.afterPlugins.tap(pluginTapPostOptions, ()=>this.afterPlugins(compiler, context)), compiler.hooks.done.tapPromise({
|
|
1774
|
+
...pluginTapPostOptions,
|
|
1775
|
+
stage: pluginTapPostOptions.stage + 100
|
|
1776
|
+
}, ()=>this.done(compiler, context))), new InternalSummaryPlugin(context).apply(compiler), this.options.features.loader && (compiler.isChild() || new ProbeLoaderPlugin().apply(compiler), context.sdk.addClientRoutes([
|
|
1777
|
+
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
1778
|
+
]), Loader.isVue(compiler) || new InternalLoaderPlugin(context).apply(compiler)), this.options.features.plugins && new InternalPluginsPlugin(context).apply(compiler), this.options.features.bundle && new InternalBundlePlugin(context).apply(compiler), this.options.features.resolver && new InternalResolverPlugin(context).apply(compiler), new InternalRulesPlugin(context).apply(compiler), new InternalErrorReporterPlugin(context).apply(compiler);
|
|
1779
|
+
let RsdoctorRspackNativePlugin = getRspackNativePlugin(compiler);
|
|
1780
|
+
rsdoctorLogger.debug('[RspackNativePlugin] Enabled'), new RsdoctorRspackNativePlugin({
|
|
1781
|
+
moduleGraphFeatures: !0,
|
|
1782
|
+
chunkGraphFeatures: !0,
|
|
1783
|
+
sourceMapFeatures: {
|
|
1784
|
+
cheap: !1,
|
|
1785
|
+
module: !1
|
|
1786
|
+
}
|
|
1787
|
+
}).apply(compiler);
|
|
1788
|
+
} finally{
|
|
1789
|
+
timeEnd('RsdoctorRspackPlugin.apply');
|
|
1790
|
+
}
|
|
1675
1791
|
}
|
|
1676
1792
|
}
|
|
1677
1793
|
ensureModulesChunksGraphApplied(compiler) {
|
|
1678
|
-
|
|
1794
|
+
this.getCompilerContext(compiler).ensureModulesChunksGraphApplied(compiler);
|
|
1679
1795
|
}
|
|
1680
|
-
getRspackConfig(compiler) {
|
|
1796
|
+
getRspackConfig(compiler, context = this.getCompilerContext(compiler)) {
|
|
1681
1797
|
logger_time('RsdoctorRspackPlugin.getRspackConfig');
|
|
1682
1798
|
try {
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1799
|
+
let configuration = processCompilerConfig(compiler.options);
|
|
1800
|
+
compiler.isChild() && compiler.name && (configuration.name = compiler.name);
|
|
1801
|
+
let { rspackVersion } = compiler.rspack;
|
|
1802
|
+
context.sdk.reportConfiguration({
|
|
1686
1803
|
name: 'rspack',
|
|
1687
1804
|
version: rspackVersion || 'unknown',
|
|
1688
1805
|
config: configuration,
|
|
@@ -1692,32 +1809,98 @@ class RsdoctorRspackPlugin {
|
|
|
1692
1809
|
timeEnd('RsdoctorRspackPlugin.getRspackConfig');
|
|
1693
1810
|
}
|
|
1694
1811
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
let controller = new RsdoctorSDKController();
|
|
1701
|
-
return globalController = controller, controller;
|
|
1702
|
-
})(), normallizedOptions = normalizeUserConfig(options), instance = controller.createSlave({
|
|
1703
|
-
name: options.name || 'Builder',
|
|
1704
|
-
stage: options.stage,
|
|
1812
|
+
createCompilerContext(stage) {
|
|
1813
|
+
let controller = this.controller, { output, innerClientPath, printLog, server, features } = this.options;
|
|
1814
|
+
return new RsdoctorCompilerContext(controller.createSlave({
|
|
1815
|
+
name: this.defaultName,
|
|
1816
|
+
stage,
|
|
1705
1817
|
extraConfig: {
|
|
1706
|
-
innerClientPath
|
|
1707
|
-
printLog
|
|
1708
|
-
server
|
|
1709
|
-
mode:
|
|
1710
|
-
brief:
|
|
1818
|
+
innerClientPath,
|
|
1819
|
+
printLog,
|
|
1820
|
+
server,
|
|
1821
|
+
mode: output.mode || void 0,
|
|
1822
|
+
brief: output.mode === SDK.IMode[SDK.IMode.brief] && output.options || void 0,
|
|
1823
|
+
features: {
|
|
1824
|
+
treeShaking: features.treeShaking
|
|
1825
|
+
}
|
|
1711
1826
|
},
|
|
1712
|
-
type:
|
|
1827
|
+
type: output.reportCodeType
|
|
1828
|
+
}), this.options);
|
|
1829
|
+
}
|
|
1830
|
+
getCompilerContext(compiler) {
|
|
1831
|
+
let context, existing = this.compilerContexts.get(compiler);
|
|
1832
|
+
if (existing) return existing;
|
|
1833
|
+
if (0 === this.appliedCompilerCount) context = this.primaryContext;
|
|
1834
|
+
else {
|
|
1835
|
+
if (!this.controller) throw Error('[RsdoctorRspackPlugin] A fixed sdkInstance cannot be shared by multiple compilers. Create one plugin instance per compiler with a separate sdkInstance.');
|
|
1836
|
+
if (!this.options.multiCompiler.enabled) throw Error('[RsdoctorRspackPlugin] This plugin instance was applied to multiple compilers while multiCompiler is disabled.');
|
|
1837
|
+
context = this.createCompilerContext();
|
|
1838
|
+
}
|
|
1839
|
+
return this.appliedCompilerCount += 1, this.compilerContexts.set(compiler, context), context;
|
|
1840
|
+
}
|
|
1841
|
+
getOutputDir(compiler) {
|
|
1842
|
+
return node_path.resolve(this.options.output.reportDir || compiler.options.output?.path || compiler.outputPath, this.options.output.mode === SDK.IMode[SDK.IMode.brief] ? '' : `./${Constants.RsdoctorOutputFolder}`);
|
|
1843
|
+
}
|
|
1844
|
+
getBriefReportFileName() {
|
|
1845
|
+
let options = this.options.output.options;
|
|
1846
|
+
return options.type?.includes('html') ? options.htmlOptions?.reportHtmlName || 'rsdoctor-report.html' : options.jsonOptions?.fileName || 'rsdoctor-data.json';
|
|
1847
|
+
}
|
|
1848
|
+
applyChildCompilerSupport(compiler, context) {
|
|
1849
|
+
compiler.hooks.thisCompilation.tap({
|
|
1850
|
+
name: `${pluginTapName}:childCompiler`,
|
|
1851
|
+
stage: -999
|
|
1852
|
+
}, (compilation)=>{
|
|
1853
|
+
compilation.hooks.childCompiler.tap(`${pluginTapName}:childCompiler`, (childCompiler, compilerName, compilerIndex)=>{
|
|
1854
|
+
this.registerChildCompiler(compiler, childCompiler, compilerName, compilerIndex, context);
|
|
1855
|
+
});
|
|
1713
1856
|
});
|
|
1714
|
-
super({
|
|
1715
|
-
...options,
|
|
1716
|
-
sdkInstance: instance
|
|
1717
|
-
}), this.controller = controller;
|
|
1718
1857
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1858
|
+
registerChildCompiler(parentCompiler, childCompiler, compilerName, compilerIndex, parentContext) {
|
|
1859
|
+
if (!(parentContext.sdk instanceof RsdoctorPrimarySDK)) return;
|
|
1860
|
+
let parentSDK = parentContext.sdk, controller = parentSDK.parent, compilerPath = childCompiler.compilerPath || `${parentCompiler.compilerPath}${compilerName}|${compilerIndex}|`, childKey = `${parentSDK.id}:${compilerPath}`, registeredChild = this.childPlugins.get(childKey);
|
|
1861
|
+
if (registeredChild?.compiler === childCompiler) return;
|
|
1862
|
+
controller.setOutputDir(parentSDK, this.getOutputDir(parentCompiler));
|
|
1863
|
+
let childSDK = (()=>{
|
|
1864
|
+
if (registeredChild) return registeredChild.sdk;
|
|
1865
|
+
let safeCompilerPath = compilerPath.replace(/[^a-zA-Z0-9._-]+/g, '-') || `${compilerName}-${compilerIndex}`, displayName = childCompiler.name || compilerName || `Child compiler ${compilerIndex}`, sdk = controller.createSlave({
|
|
1866
|
+
name: `child-${safeCompilerPath}`,
|
|
1867
|
+
displayName,
|
|
1868
|
+
compilerPath,
|
|
1869
|
+
parentCompilerPath: parentCompiler.compilerPath || '',
|
|
1870
|
+
isChild: !0,
|
|
1871
|
+
stage: parentSDK.stage + (controller.slaves.length + 1) / 1000,
|
|
1872
|
+
extraConfig: parentSDK.extraConfig,
|
|
1873
|
+
type: parentSDK.type
|
|
1874
|
+
});
|
|
1875
|
+
return sdk.dependencies = [
|
|
1876
|
+
parentSDK.name
|
|
1877
|
+
], sdk;
|
|
1878
|
+
})();
|
|
1879
|
+
this.removeInheritedRsdoctorTaps(childCompiler);
|
|
1880
|
+
let childPlugin = new RsdoctorRspackPlugin({
|
|
1881
|
+
...this.childOptions,
|
|
1882
|
+
sdkInstance: childSDK
|
|
1883
|
+
});
|
|
1884
|
+
this.childPlugins.set(childKey, {
|
|
1885
|
+
compiler: childCompiler,
|
|
1886
|
+
sdk: childSDK
|
|
1887
|
+
}), childPlugin.apply(childCompiler);
|
|
1888
|
+
}
|
|
1889
|
+
removeInheritedRsdoctorTaps(compiler) {
|
|
1890
|
+
for (let hook of Object.values(compiler.hooks))Array.isArray(hook.taps) && (hook.taps = hook.taps.filter((tap)=>tap.name !== pluginTapName && !tap.name.startsWith(`${pluginTapName}:`)));
|
|
1891
|
+
}
|
|
1892
|
+
shouldDisposeSDK() {
|
|
1893
|
+
return this.options.disableClientServer || this.options.output.mode === SDK.IMode[SDK.IMode.brief] && Array.isArray(this.options.output.options?.type) && 1 === this.options.output.options.type.length && 'json' === this.options.output.options.type[0];
|
|
1894
|
+
}
|
|
1895
|
+
releasePendingSessionOnRun(compiler) {
|
|
1896
|
+
if (!this.sessionLease) return;
|
|
1897
|
+
let release = this.sessionLease.release;
|
|
1898
|
+
compiler.hooks.beforeRun.tap(pluginTapName, release), compiler.hooks.watchRun.tap(pluginTapName, release);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
class RsdoctorRspackMultiplePlugin extends RsdoctorRspackPlugin {
|
|
1902
|
+
constructor(options = {}){
|
|
1903
|
+
super(options);
|
|
1721
1904
|
}
|
|
1722
1905
|
}
|
|
1723
1906
|
export { Linter, LinterRule, LinterType, defineRule, rules } from "./26.js";
|
|
@@ -5,6 +5,7 @@ export declare class InternalErrorReporterPlugin<T extends Plugin.BaseCompiler>
|
|
|
5
5
|
readonly name = "error-reporter";
|
|
6
6
|
apply(compiler: T): void;
|
|
7
7
|
done: (stats: Plugin.BaseStats) => Promise<void>;
|
|
8
|
+
afterCompile: (compilation: Plugin.BaseCompilation) => Promise<void>;
|
|
8
9
|
handleBundlerError(err: Plugin.BuildError, category: Rule.RuleMessageCategory, level: keyof typeof Err.ErrorLevel): DevToolError;
|
|
9
10
|
reportWarnings(warnings: Plugin.BuildError[]): Promise<void>;
|
|
10
11
|
reportErrors(errors: Plugin.BuildWarning[]): Promise<void>;
|
|
@@ -4,5 +4,5 @@ export declare class InternalPluginsPlugin<T extends Plugin.BaseCompiler> extend
|
|
|
4
4
|
readonly name = "plugins";
|
|
5
5
|
apply(compiler: Plugin.BaseCompiler): void;
|
|
6
6
|
afterPlugins: (compiler: Plugin.BaseCompiler) => void;
|
|
7
|
-
compilation: (compilation: Plugin.BaseCompilation) => void;
|
|
7
|
+
compilation: (compiler: Plugin.BaseCompiler, compilation: Plugin.BaseCompilation) => void;
|
|
8
8
|
}
|
|
@@ -5,10 +5,11 @@ export declare class InternalSummaryPlugin<T extends Plugin.BaseCompiler> extend
|
|
|
5
5
|
private times;
|
|
6
6
|
private preTimes;
|
|
7
7
|
private postTimes;
|
|
8
|
+
private readonly createdAt;
|
|
8
9
|
apply(compiler: T): void;
|
|
9
10
|
private mark;
|
|
10
|
-
beforeCompile: () => Promise<void>;
|
|
11
|
-
afterCompile: (compilation: Plugin.BaseCompilation) => Promise<void>;
|
|
11
|
+
beforeCompile: (compiler: T) => Promise<void>;
|
|
12
|
+
afterCompile: (compiler: T, compilation: Plugin.BaseCompilation) => Promise<void>;
|
|
12
13
|
done: (compiler: T) => Promise<void>;
|
|
13
14
|
private report;
|
|
14
15
|
}
|
|
@@ -4,4 +4,5 @@ declare global {
|
|
|
4
4
|
var __rsdoctor_sdk__: SDK.RsdoctorBuilderSDKInstance | undefined;
|
|
5
5
|
}
|
|
6
6
|
export declare function setSDK(t: SDK.RsdoctorBuilderSDKInstance): void;
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function registerSDK(t: SDK.RsdoctorBuilderSDKInstance, asDefault?: boolean): void;
|
|
8
|
+
export declare function getSDK(compilerId?: string): SDK.RsdoctorBuilderSDKInstance | undefined;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { Linter } from '@rsdoctor/shared/types';
|
|
1
2
|
import type { RsdoctorMultiplePluginOptions } from '../types/index.js';
|
|
2
|
-
import { type Linter, type Plugin } from '@rsdoctor/shared/types';
|
|
3
3
|
import { RsdoctorRspackPlugin } from './plugin.js';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use {@link RsdoctorRspackPlugin}. Multi-compiler builds are now
|
|
6
|
+
* detected and isolated automatically.
|
|
7
|
+
*/
|
|
4
8
|
export declare class RsdoctorRspackMultiplePlugin<Rules extends Linter.ExtendRuleData[]> extends RsdoctorRspackPlugin<Rules> {
|
|
5
|
-
private controller;
|
|
6
9
|
constructor(options?: RsdoctorMultiplePluginOptions<Rules>);
|
|
7
|
-
apply(compiler: Plugin.BaseCompilerType<'rspack'>): void;
|
|
8
10
|
}
|
|
@@ -1,25 +1,51 @@
|
|
|
1
|
-
import type { RsdoctorRspackPluginInstance, RsdoctorRspackPluginOptions, RsdoctorRspackPluginOptionsNormalized } from '../types/index.js';
|
|
2
1
|
import { RsdoctorPrimarySDK } from '../sdk/index.js';
|
|
2
|
+
import type { RsdoctorRspackPluginInstance, RsdoctorRspackPluginOptions, RsdoctorRspackPluginOptionsNormalized } from '../types/index.js';
|
|
3
3
|
import { Linter, Plugin, SDK } from '@rsdoctor/shared/types';
|
|
4
|
+
declare class RsdoctorCompilerContext implements RsdoctorRspackPluginInstance<Linter.ExtendRuleData[]> {
|
|
5
|
+
readonly sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
6
|
+
readonly options: RsdoctorRspackPluginOptionsNormalized<Linter.ExtendRuleData[]>;
|
|
7
|
+
readonly name = "RsdoctorRspackPlugin";
|
|
8
|
+
readonly isRsdoctorPlugin = true;
|
|
9
|
+
readonly modulesGraph: SDK.ModuleGraphInstance;
|
|
10
|
+
bootstrapTask?: Promise<unknown>;
|
|
11
|
+
applied: boolean;
|
|
12
|
+
constructor(sdk: SDK.RsdoctorBuilderSDKInstance, options: RsdoctorRspackPluginOptionsNormalized<Linter.ExtendRuleData[]>);
|
|
13
|
+
apply(): void;
|
|
14
|
+
ensureModulesChunksGraphApplied(compiler: Plugin.BaseCompilerType<'rspack'>): void;
|
|
15
|
+
}
|
|
4
16
|
export declare class RsdoctorRspackPlugin<Rules extends Linter.ExtendRuleData[]> implements RsdoctorRspackPluginInstance<Rules> {
|
|
5
17
|
readonly name = "RsdoctorRspackPlugin";
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
readonly isRsdoctorPlugin = true;
|
|
19
|
+
readonly options: RsdoctorRspackPluginOptionsNormalized<Rules>;
|
|
20
|
+
readonly outsideInstance: boolean;
|
|
21
|
+
private readonly childOptions;
|
|
22
|
+
private readonly defaultName;
|
|
23
|
+
private readonly defaultStage?;
|
|
24
|
+
private readonly controller?;
|
|
25
|
+
private readonly sessionLease?;
|
|
26
|
+
private readonly primaryContext;
|
|
27
|
+
private readonly compilerContexts;
|
|
28
|
+
private readonly childPlugins;
|
|
29
|
+
private appliedCompilerCount;
|
|
13
30
|
constructor(options?: RsdoctorRspackPluginOptions<Rules>);
|
|
31
|
+
get sdk(): SDK.RsdoctorBuilderSDKInstance;
|
|
32
|
+
get modulesGraph(): SDK.ModuleGraphInstance;
|
|
33
|
+
get _bootstrapTask(): Promise<unknown>;
|
|
34
|
+
getCompilerSDK(name: string): SDK.RsdoctorBuilderSDKInstance | RsdoctorPrimarySDK | undefined;
|
|
14
35
|
apply(compiler: unknown): unknown;
|
|
15
|
-
/**
|
|
16
|
-
* @description Generate ModuleGraph and ChunkGraph from the Rspack native plugin.
|
|
17
|
-
* @param {Compiler} compiler
|
|
18
|
-
* @return {*}
|
|
19
|
-
* @memberof RsdoctorRspackPlugin
|
|
20
|
-
*/
|
|
21
36
|
ensureModulesChunksGraphApplied(compiler: Plugin.BaseCompilerType<'rspack'>): void;
|
|
22
|
-
afterPlugins: (compiler: Plugin.BaseCompilerType<'rspack'
|
|
23
|
-
done: (compiler: Plugin.BaseCompilerType<'rspack'
|
|
24
|
-
getRspackConfig(compiler: Plugin.BaseCompilerType<'rspack'
|
|
37
|
+
afterPlugins: (compiler: Plugin.BaseCompilerType<'rspack'>, context?: RsdoctorCompilerContext) => void;
|
|
38
|
+
done: (compiler: Plugin.BaseCompilerType<'rspack'>, context?: RsdoctorCompilerContext) => Promise<void>;
|
|
39
|
+
getRspackConfig(compiler: Plugin.BaseCompilerType<'rspack'>, context?: RsdoctorCompilerContext): void;
|
|
40
|
+
private createCompilerContext;
|
|
41
|
+
private getCompilerContext;
|
|
42
|
+
private getOutputDir;
|
|
43
|
+
private getBriefReportFileName;
|
|
44
|
+
private applyChildCompilerSupport;
|
|
45
|
+
private registerChildCompiler;
|
|
46
|
+
private removeInheritedRsdoctorTaps;
|
|
47
|
+
private childDone;
|
|
48
|
+
private shouldDisposeSDK;
|
|
49
|
+
private releasePendingSessionOnRun;
|
|
25
50
|
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RsdoctorSDKController } from '../sdk/index.js';
|
|
2
|
+
export interface RsdoctorBuildSessionOptions {
|
|
3
|
+
multiCompiler: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
group?: string;
|
|
6
|
+
};
|
|
7
|
+
output: {
|
|
8
|
+
mode: string;
|
|
9
|
+
reportDir: string;
|
|
10
|
+
};
|
|
11
|
+
server: {
|
|
12
|
+
port?: number;
|
|
13
|
+
};
|
|
14
|
+
port?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RsdoctorBuildSessionLease {
|
|
17
|
+
controller: RsdoctorSDKController;
|
|
18
|
+
release(): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function acquireBuildSession(options: RsdoctorBuildSessionOptions): RsdoctorBuildSessionLease;
|
|
@@ -2,11 +2,22 @@ import { Manifest } from '@rsdoctor/shared/types';
|
|
|
2
2
|
import { RsdoctorPrimarySDK } from './primary.js';
|
|
3
3
|
export declare class RsdoctorSDKController {
|
|
4
4
|
readonly slaves: RsdoctorPrimarySDK[];
|
|
5
|
+
private readonly activeSlaves;
|
|
6
|
+
private outputDir;
|
|
7
|
+
private outputOwner?;
|
|
8
|
+
private refreshManifestTask;
|
|
5
9
|
root: string;
|
|
6
10
|
constructor(root?: string);
|
|
7
11
|
get master(): RsdoctorPrimarySDK;
|
|
12
|
+
get isMultiple(): boolean;
|
|
8
13
|
getLastSdk(): RsdoctorPrimarySDK;
|
|
9
|
-
hasName(name: string): boolean;
|
|
14
|
+
hasName(name: string, exclude?: RsdoctorPrimarySDK): boolean;
|
|
15
|
+
registerSlave(slave: RsdoctorPrimarySDK): void;
|
|
16
|
+
setOutputDir(slave: RsdoctorPrimarySDK, outputDir: string): void;
|
|
17
|
+
getCompilerOutputDir(slave: RsdoctorPrimarySDK): string;
|
|
10
18
|
getSeriesData(serverUrl?: boolean): Manifest.RsdoctorManifestSeriesData[];
|
|
11
|
-
|
|
19
|
+
getBriefSeriesData(current: RsdoctorPrimarySDK): Manifest.RsdoctorManifestSeriesData[];
|
|
20
|
+
createSlave({ name, displayName, compilerPath, parentCompilerPath, isChild, stage, extraConfig, type, }: Omit<ConstructorParameters<typeof RsdoctorPrimarySDK>[0], 'controller'>): RsdoctorPrimarySDK;
|
|
21
|
+
refreshManifestSeries(): Promise<void>;
|
|
22
|
+
private getActiveSlaves;
|
|
12
23
|
}
|
|
@@ -3,6 +3,10 @@ import { RsdoctorSDK } from '../sdk/index.js';
|
|
|
3
3
|
import type { RsdoctorSDKController } from './controller.js';
|
|
4
4
|
interface RsdoctorSlaveSDKOptions {
|
|
5
5
|
name: string;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
compilerPath?: string;
|
|
8
|
+
parentCompilerPath?: string;
|
|
9
|
+
isChild?: boolean;
|
|
6
10
|
/**
|
|
7
11
|
* use to sort for display in the client page.
|
|
8
12
|
* the smaller the front.
|
|
@@ -17,16 +21,20 @@ export declare class RsdoctorPrimarySDK extends RsdoctorSDK implements SDK.Rsdoc
|
|
|
17
21
|
id: number;
|
|
18
22
|
parent: RsdoctorSDKController;
|
|
19
23
|
readonly stage: number;
|
|
24
|
+
displayName: string;
|
|
25
|
+
readonly compilerPath: string;
|
|
26
|
+
readonly parentCompilerPath?: string;
|
|
27
|
+
readonly isChild: boolean;
|
|
20
28
|
dependencies: Array<string> | undefined;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
constructor({ name, stage, controller, extraConfig, type, }: RsdoctorSlaveSDKOptions);
|
|
24
|
-
private clearSwitch;
|
|
29
|
+
reportFileName: string;
|
|
30
|
+
constructor({ name, displayName, compilerPath, parentCompilerPath, isChild, stage, controller, extraConfig, type, }: RsdoctorSlaveSDKOptions);
|
|
25
31
|
get isMaster(): boolean;
|
|
26
32
|
protected writePieces(): Promise<void>;
|
|
27
33
|
protected writeManifest(): Promise<string>;
|
|
34
|
+
refreshManifestSeries(): Promise<void>;
|
|
28
35
|
getSeriesData(serverUrl?: boolean): Manifest.RsdoctorManifestSeriesData[];
|
|
29
36
|
setName(name: string): void;
|
|
30
37
|
getManifestData(): Manifest.RsdoctorManifestWithShardingFiles;
|
|
38
|
+
addRsdoctorDataToHTML(storeData: SDK.BuilderStoreData, htmlContent: string): string;
|
|
31
39
|
}
|
|
32
40
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"acorn-import-attributes": "^1.9.5",
|
|
46
46
|
"acorn-walk": "8.3.5",
|
|
47
47
|
"browserslist-load-config": "^1.0.3",
|
|
48
|
-
"caniuse-lite": "^1.0.
|
|
49
|
-
"connect": "
|
|
48
|
+
"caniuse-lite": "^1.0.30001809",
|
|
49
|
+
"connect-next": "4.0.3",
|
|
50
50
|
"envinfo": "7.21.0",
|
|
51
51
|
"fs-extra": "^11.1.1",
|
|
52
52
|
"get-port": "5.1.1",
|
|
@@ -59,19 +59,18 @@
|
|
|
59
59
|
"cors": "2.8.6",
|
|
60
60
|
"launch-editor": "^2.14.1",
|
|
61
61
|
"sirv": "3.0.2",
|
|
62
|
-
"ws": "8.21.
|
|
63
|
-
"@rsdoctor/shared": "2.0.0-
|
|
64
|
-
"@rsdoctor/client": "2.0.0-
|
|
62
|
+
"ws": "8.21.3",
|
|
63
|
+
"@rsdoctor/shared": "2.0.0-beta.0",
|
|
64
|
+
"@rsdoctor/client": "2.0.0-beta.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@rsbuild/plugin-check-syntax": "^1.6.1",
|
|
68
|
-
"@rspack/core": "^2.1.
|
|
68
|
+
"@rspack/core": "^2.1.8",
|
|
69
69
|
"@types/babel__code-frame": "7.27.0",
|
|
70
|
-
"@types/connect": "3.4.38",
|
|
71
70
|
"@types/envinfo": "7.8.4",
|
|
72
71
|
"@types/fs-extra": "^11.0.4",
|
|
73
72
|
"@types/node": "^24.12.3",
|
|
74
|
-
"@types/semver": "^7.
|
|
73
|
+
"@types/semver": "^7.8.0",
|
|
75
74
|
"babel-loader": "10.1.1",
|
|
76
75
|
"filesize": "^11.0.22",
|
|
77
76
|
"json-stream-stringify": "3.0.1",
|