@rsdoctor/core 0.4.4 → 0.4.5
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/build-utils/build/index.d.ts +1 -0
- package/dist/build-utils/build/index.d.ts.map +1 -1
- package/dist/build-utils/build/index.js +3 -0
- package/dist/build-utils/build/loader/index.d.ts +2 -0
- package/dist/build-utils/build/loader/index.d.ts.map +1 -0
- package/dist/build-utils/build/loader/index.js +22 -0
- package/dist/build-utils/build/loader/probeLoader.d.ts +5 -0
- package/dist/build-utils/build/loader/probeLoader.d.ts.map +1 -0
- package/dist/build-utils/build/loader/probeLoader.js +76 -0
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +6 -0
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts.map +1 -0
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +81 -0
- package/dist/build-utils/build/utils/index.d.ts +1 -0
- package/dist/build-utils/build/utils/index.d.ts.map +1 -1
- package/dist/build-utils/build/utils/index.js +3 -1
- package/dist/build-utils/build/utils/loader.d.ts +1 -1
- package/dist/build-utils/build/utils/loader.d.ts.map +1 -1
- package/dist/build-utils/build/utils/loader.js +45 -19
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/build-utils/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/build-utils/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC"}
|
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var build_exports = {};
|
|
30
30
|
__export(build_exports, {
|
|
31
31
|
Chunks: () => Chunks,
|
|
32
|
+
Loader: () => Loader,
|
|
32
33
|
ModuleGraph: () => ModuleGraph,
|
|
33
34
|
Types: () => Types,
|
|
34
35
|
Utils: () => Utils
|
|
@@ -36,11 +37,13 @@ __export(build_exports, {
|
|
|
36
37
|
module.exports = __toCommonJS(build_exports);
|
|
37
38
|
var Chunks = __toESM(require("./chunks"));
|
|
38
39
|
var Utils = __toESM(require("./utils"));
|
|
40
|
+
var Loader = __toESM(require("./loader"));
|
|
39
41
|
var Types = __toESM(require("../../types"));
|
|
40
42
|
var ModuleGraph = __toESM(require("./module-graph"));
|
|
41
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
44
|
0 && (module.exports = {
|
|
43
45
|
Chunks,
|
|
46
|
+
Loader,
|
|
44
47
|
ModuleGraph,
|
|
45
48
|
Types,
|
|
46
49
|
Utils
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/build-utils/build/loader/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var loader_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(loader_exports);
|
|
18
|
+
__reExport(loader_exports, require("./probeLoaderPlugin"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./probeLoaderPlugin")
|
|
22
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Plugin } from '@rsdoctor/types';
|
|
2
|
+
import type { LoaderDefinitionFunction } from '@rspack/core';
|
|
3
|
+
export declare const loaderModule: Plugin.LoaderDefinition<Parameters<LoaderDefinitionFunction>, {}>;
|
|
4
|
+
export default loaderModule;
|
|
5
|
+
//# sourceMappingURL=probeLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probeLoader.d.ts","sourceRoot":"","sources":["../../../../src/build-utils/build/loader/probeLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAO,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAI7D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,gBAAgB,CAChD,UAAU,CAAC,wBAAwB,CAAC,EACpC,EAAE,CAwCH,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var probeLoader_exports = {};
|
|
30
|
+
__export(probeLoader_exports, {
|
|
31
|
+
default: () => probeLoader_default,
|
|
32
|
+
loaderModule: () => loaderModule
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(probeLoader_exports);
|
|
35
|
+
var import__ = require("../..");
|
|
36
|
+
var import_inner_plugins = require("../../../inner-plugins");
|
|
37
|
+
var import_lodash = require("lodash");
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
const loaderModule = function(...args) {
|
|
40
|
+
const time = Date.now();
|
|
41
|
+
const code = args[0];
|
|
42
|
+
const _options = this.getOptions();
|
|
43
|
+
const sdk = (0, import_inner_plugins.getSDK)(_options.builderName);
|
|
44
|
+
const loaderData = {
|
|
45
|
+
resource: {
|
|
46
|
+
path: this.resourcePath,
|
|
47
|
+
query: import__.Build.Utils.parseQuery(this.resourceQuery),
|
|
48
|
+
queryRaw: this.resourceQuery,
|
|
49
|
+
ext: import_path.default.extname(this.resourcePath).slice(1)
|
|
50
|
+
},
|
|
51
|
+
loaders: [
|
|
52
|
+
{
|
|
53
|
+
loader: _options.loader,
|
|
54
|
+
loaderIndex: this.loaderIndex,
|
|
55
|
+
path: _options.loader,
|
|
56
|
+
input: _options.type === "start" ? code : null,
|
|
57
|
+
result: _options.type === "end" ? code : null,
|
|
58
|
+
startAt: _options.type === "start" ? time : 0,
|
|
59
|
+
endAt: _options.type === "end" ? time : 0,
|
|
60
|
+
options: (0, import_lodash.omit)(_options.options, "type"),
|
|
61
|
+
isPitch: false,
|
|
62
|
+
sync: false,
|
|
63
|
+
errors: [],
|
|
64
|
+
pid: process.pid,
|
|
65
|
+
ppid: process.ppid
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
sdk.reportLoaderStartOrEnd(loaderData);
|
|
70
|
+
this.callback(null, ...args);
|
|
71
|
+
};
|
|
72
|
+
var probeLoader_default = loaderModule;
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
loaderModule
|
|
76
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probeLoaderPlugin.d.ts","sourceRoot":"","sources":["../../../../src/build-utils/build/loader/probeLoaderPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAUzC,qBAAa,iBAAiB;IAC5B,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY;IAoBnC,OAAO,CAAC,cAAc;CAqCvB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var probeLoaderPlugin_exports = {};
|
|
20
|
+
__export(probeLoaderPlugin_exports, {
|
|
21
|
+
ProbeLoaderPlugin: () => ProbeLoaderPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(probeLoaderPlugin_exports);
|
|
24
|
+
var import_common = require("@rsdoctor/utils/common");
|
|
25
|
+
var import__ = require("../..");
|
|
26
|
+
var import__2 = require("..");
|
|
27
|
+
const BuiltinLoaderName = "builtin:swc-loader";
|
|
28
|
+
const BuiltinLightingCssName = "builtin:lightningcss-loader";
|
|
29
|
+
const ESMLoaderFile = ".mjs";
|
|
30
|
+
class ProbeLoaderPlugin {
|
|
31
|
+
apply(compiler) {
|
|
32
|
+
compiler.hooks.beforeRun.tap(
|
|
33
|
+
{
|
|
34
|
+
name: "ProbeLoaderPlugin"
|
|
35
|
+
},
|
|
36
|
+
() => {
|
|
37
|
+
this.addProbeLoader(compiler);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
compiler.hooks.watchRun.tap(
|
|
41
|
+
{
|
|
42
|
+
name: "ProbeLoaderPlugin"
|
|
43
|
+
},
|
|
44
|
+
() => {
|
|
45
|
+
this.addProbeLoader(compiler);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
addProbeLoader(compiler) {
|
|
50
|
+
let rules = compiler.options.module.rules;
|
|
51
|
+
if (import_common.Loader.isVue(compiler)) {
|
|
52
|
+
compiler.options.module.rules = import__2.Utils.addProbeLoader2Rules(
|
|
53
|
+
rules,
|
|
54
|
+
compiler,
|
|
55
|
+
(r) => !!r.loader || typeof r === "string"
|
|
56
|
+
);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
rules = import__2.Utils.addProbeLoader2Rules(
|
|
60
|
+
rules,
|
|
61
|
+
compiler,
|
|
62
|
+
(r) => import__.Build.Utils.getLoaderNameMatch(r, BuiltinLoaderName, true)
|
|
63
|
+
);
|
|
64
|
+
rules = import__2.Utils.addProbeLoader2Rules(
|
|
65
|
+
rules,
|
|
66
|
+
compiler,
|
|
67
|
+
(r) => import__.Build.Utils.getLoaderNameMatch(r, BuiltinLightingCssName, true)
|
|
68
|
+
);
|
|
69
|
+
compiler.options.module.rules = import__2.Utils.addProbeLoader2Rules(
|
|
70
|
+
rules,
|
|
71
|
+
compiler,
|
|
72
|
+
(r) => {
|
|
73
|
+
return import__.Build.Utils.getLoaderNameMatch(r, ESMLoaderFile, false) || import__.Build.Utils.isESMLoader(r);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
ProbeLoaderPlugin
|
|
81
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/build-utils/build/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/build-utils/build/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC"}
|
|
@@ -18,9 +18,11 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
18
18
|
__reExport(utils_exports, require("./loader"), module.exports);
|
|
19
19
|
__reExport(utils_exports, require("./plugin"), module.exports);
|
|
20
20
|
__reExport(utils_exports, require("./parseBundle"), module.exports);
|
|
21
|
+
__reExport(utils_exports, require("../loader/probeLoader"), module.exports);
|
|
21
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
23
|
0 && (module.exports = {
|
|
23
24
|
...require("./loader"),
|
|
24
25
|
...require("./plugin"),
|
|
25
|
-
...require("./parseBundle")
|
|
26
|
+
...require("./parseBundle"),
|
|
27
|
+
...require("../loader/probeLoader")
|
|
26
28
|
});
|
|
@@ -14,7 +14,7 @@ export declare function extractLoaderName(loaderPath: string, cwd?: string): str
|
|
|
14
14
|
export declare function mapEachRules<T extends Plugin.BuildRuleSetRule>(rules: T[], callback: (rule: T) => T): T[];
|
|
15
15
|
export declare function isESMLoader(r: Plugin.BuildRuleSetRule): boolean;
|
|
16
16
|
export declare function getLoaderNameMatch(r: Plugin.BuildRuleSetRule, loaderName: string, strict?: boolean): boolean;
|
|
17
|
-
export declare function addProbeLoader2Rules<T extends Plugin.BuildRuleSetRule>(rules: T[],
|
|
17
|
+
export declare function addProbeLoader2Rules<T extends Plugin.BuildRuleSetRule>(rules: T[], compiler: Plugin.BaseCompiler, fn: (r: Plugin.BuildRuleSetRule) => boolean): T[];
|
|
18
18
|
export declare function createLoaderContextTrap(this: Plugin.LoaderContext<Common.PlainObject>, final: (err: Error | null | undefined, res: string | Buffer | null, sourceMap?: WebpackSourceMapInput) => void): Plugin.LoaderContext<Common.PlainObject<any>>;
|
|
19
19
|
export declare function parseQuery(query: string): {
|
|
20
20
|
[k: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/build-utils/build/utils/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAQ,cAAc,IAAI,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/build-utils/build/utils/loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAQ,cAAc,IAAI,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAW/E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAOA;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,GAAG,SAAgB,GAClB;IACD,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACzD,KAAK,EAAE,MAAM,CAAC,6BAA6B,CAAC;IAC5C,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;CACrB,CAiBA;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,MAAM,CAqBtE;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,gBAAgB,EAC5D,KAAK,EAAE,CAAC,EAAE,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GACvB,CAAC,EAAE,CAgFL;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,gBAAgB,WA2BrD;AAoCD,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,MAAM,CAAC,gBAAgB,EAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,UAAO,WAgBd;AACD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,gBAAgB,EACpE,KAAK,EAAE,CAAC,EAAE,EACV,QAAQ,EAAE,MAAM,CAAC,YAAY,EAC7B,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,gBAAgB,KAAK,OAAO,GAC1C,CAAC,EAAE,CA4EL;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,EAC9C,KAAK,EAAE,CACL,GAAG,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC7B,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC3B,SAAS,CAAC,EAAE,qBAAqB,KAC9B,IAAI,iDAsFV;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM;;EAMvC"}
|
|
@@ -44,6 +44,7 @@ var import_fs_extra = __toESM(require("fs-extra"));
|
|
|
44
44
|
var import_lodash = require("lodash");
|
|
45
45
|
var import_common = require("@rsdoctor/utils/common");
|
|
46
46
|
var import_graph = require("@rsdoctor/graph");
|
|
47
|
+
var import_logger = require("@rsdoctor/utils/logger");
|
|
47
48
|
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
|
48
49
|
function parsePathQueryFragment(str) {
|
|
49
50
|
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
@@ -160,6 +161,7 @@ function isESMLoader(r) {
|
|
|
160
161
|
try {
|
|
161
162
|
return import_fs_extra.default.readJsonSync(file, { encoding: "utf8" });
|
|
162
163
|
} catch (e) {
|
|
164
|
+
(0, import_logger.debug)(() => `isESMLoader function error:${e}`);
|
|
163
165
|
}
|
|
164
166
|
});
|
|
165
167
|
if (packageJsonData?.type === "module")
|
|
@@ -167,55 +169,79 @@ function isESMLoader(r) {
|
|
|
167
169
|
}
|
|
168
170
|
return false;
|
|
169
171
|
}
|
|
172
|
+
function appendProbeLoaders(compiler, loaderConfig) {
|
|
173
|
+
const _options = typeof loaderConfig === "object" ? typeof loaderConfig.options === "string" ? { options: loaderConfig.options } : loaderConfig.options : {};
|
|
174
|
+
const loaderPath = import_path.default.join(__dirname, "../loader/probeLoader.js");
|
|
175
|
+
const loader = typeof loaderConfig === "string" ? loaderConfig : typeof loaderConfig === "object" && loaderConfig.loader;
|
|
176
|
+
const createProbeLoader = (type) => ({
|
|
177
|
+
loader: loaderPath,
|
|
178
|
+
options: {
|
|
179
|
+
..._options,
|
|
180
|
+
loader,
|
|
181
|
+
ident: void 0,
|
|
182
|
+
type,
|
|
183
|
+
builderName: compiler.options.name
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return [
|
|
187
|
+
createProbeLoader("end"),
|
|
188
|
+
loaderConfig,
|
|
189
|
+
createProbeLoader("start")
|
|
190
|
+
];
|
|
191
|
+
}
|
|
170
192
|
function getLoaderNameMatch(r, loaderName, strict = true) {
|
|
171
193
|
if (!strict) {
|
|
172
194
|
return typeof r === "object" && typeof r?.loader === "string" && r.loader.includes(loaderName) || typeof r === "string" && r.includes(loaderName);
|
|
173
195
|
}
|
|
174
196
|
return typeof r === "object" && typeof r?.loader === "string" && r.loader === loaderName || typeof r === "string" && r === loaderName;
|
|
175
197
|
}
|
|
176
|
-
function addProbeLoader2Rules(rules,
|
|
198
|
+
function addProbeLoader2Rules(rules, compiler, fn) {
|
|
177
199
|
return rules.map((rule) => {
|
|
178
200
|
if (!rule || typeof rule === "string")
|
|
179
201
|
return rule;
|
|
180
|
-
if (fn(rule)) {
|
|
181
|
-
const
|
|
202
|
+
if (fn(rule) && !rule.use) {
|
|
203
|
+
const loaderConfig = {
|
|
204
|
+
loader: rule.loader ?? "",
|
|
205
|
+
options: rule.options,
|
|
206
|
+
ident: "ident" in rule && typeof rule.ident === "string" ? rule.ident : void 0
|
|
207
|
+
};
|
|
208
|
+
return {
|
|
182
209
|
...rule,
|
|
183
|
-
use:
|
|
184
|
-
{
|
|
185
|
-
loader: rule.loader,
|
|
186
|
-
options: rule.options
|
|
187
|
-
}
|
|
188
|
-
],
|
|
210
|
+
use: appendProbeLoaders(compiler, loaderConfig),
|
|
189
211
|
loader: void 0,
|
|
190
212
|
options: void 0
|
|
191
213
|
};
|
|
192
|
-
return appendRules(_rule, 0);
|
|
193
214
|
}
|
|
194
215
|
if (rule.use) {
|
|
195
216
|
if (Array.isArray(rule.use)) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
217
|
+
rule.use = rule.use.flatMap((loaderConfig) => {
|
|
218
|
+
if (typeof loaderConfig === "string" || typeof loaderConfig === "object" && loaderConfig && "loader" in loaderConfig) {
|
|
219
|
+
return fn(loaderConfig) ? appendProbeLoaders(compiler, loaderConfig) : [loaderConfig];
|
|
220
|
+
}
|
|
221
|
+
return [loaderConfig];
|
|
222
|
+
});
|
|
200
223
|
} else if (typeof rule.use === "object" && !Array.isArray(rule.use) && typeof rule.use !== "function") {
|
|
201
|
-
rule.use
|
|
224
|
+
if ("loader" in rule.use) {
|
|
225
|
+
rule.use = fn(rule.use) ? appendProbeLoaders(compiler, rule.use) : [rule.use];
|
|
226
|
+
}
|
|
227
|
+
} else if (typeof rule.use === "string") {
|
|
228
|
+
rule.use = fn(rule.use) ? appendProbeLoaders(compiler, { loader: rule.use }) : [
|
|
202
229
|
{
|
|
203
|
-
|
|
230
|
+
loader: rule.use
|
|
204
231
|
}
|
|
205
232
|
];
|
|
206
|
-
return appendRules(rule, 0);
|
|
207
233
|
}
|
|
208
234
|
}
|
|
209
235
|
if ("oneOf" in rule && rule.oneOf) {
|
|
210
236
|
return {
|
|
211
237
|
...rule,
|
|
212
|
-
oneOf: addProbeLoader2Rules(rule.oneOf,
|
|
238
|
+
oneOf: addProbeLoader2Rules(rule.oneOf, compiler, fn)
|
|
213
239
|
};
|
|
214
240
|
}
|
|
215
241
|
if ("rules" in rule && rule.rules) {
|
|
216
242
|
return {
|
|
217
243
|
...rule,
|
|
218
|
-
rules: addProbeLoader2Rules(rule.rules,
|
|
244
|
+
rules: addProbeLoader2Rules(rule.rules, compiler, fn)
|
|
219
245
|
};
|
|
220
246
|
}
|
|
221
247
|
return rule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"axios": "^1.7.
|
|
65
|
+
"axios": "^1.7.7",
|
|
66
66
|
"enhanced-resolve": "5.12.0",
|
|
67
67
|
"filesize": "^10.1.6",
|
|
68
68
|
"fs-extra": "^11.1.1",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"semver": "^7.6.3",
|
|
72
72
|
"source-map": "^0.7.4",
|
|
73
73
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
74
|
-
"@rsdoctor/graph": "0.4.
|
|
75
|
-
"@rsdoctor/sdk": "0.4.
|
|
76
|
-
"@rsdoctor/types": "0.4.
|
|
77
|
-
"@rsdoctor/utils": "0.4.
|
|
74
|
+
"@rsdoctor/graph": "0.4.5",
|
|
75
|
+
"@rsdoctor/sdk": "0.4.5",
|
|
76
|
+
"@rsdoctor/types": "0.4.5",
|
|
77
|
+
"@rsdoctor/utils": "0.4.5"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@rspack/core": "0.7.5",
|
|
81
81
|
"@types/fs-extra": "^11.0.4",
|
|
82
|
-
"@types/lodash": "^4.17.
|
|
82
|
+
"@types/lodash": "^4.17.9",
|
|
83
83
|
"@types/node": "^16",
|
|
84
84
|
"@types/node-fetch": "^2.6.11",
|
|
85
85
|
"@types/path-browserify": "1.0.3",
|