@rsdoctor/rspack-plugin 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.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAEL,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAcvB,OAAO,KAAK,EACV,4BAA4B,EAC5B,+BAA+B,EAC/B,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,MAAM,EAEN,MAAM,EAEP,MAAM,iBAAiB,CAAC;AAQzB,qBAAa,oBAAoB,CAAC,KAAK,SAAS,MAAM,CAAC,cAAc,EAAE,CACrE,YAAW,4BAA4B,CAAC,KAAK,CAAC;IAE9C,SAAgB,IAAI,0BAAiB;IAErC,SAAgB,GAAG,EAAE,kBAAkB,GAAG,gBAAgB,CAAC;IAE3D,SAAgB,gBAAgB,EAAE,OAAO,CAAC;IAEnC,cAAc,EAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzC,SAAS,CAAC,eAAe,UAAS;IAE3B,YAAY,EAAE,WAAW,CAAC;IAE1B,OAAO,EAAE,+BAA+B,CAAC,KAAK,CAAC,CAAC;IAEhD,eAAe,EAAE,OAAO,CAAC;gBAEpB,OAAO,CAAC,EAAE,2BAA2B,CAAC,KAAK,CAAC;IAiCxD,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO;IAyDjC;;;;;OAKG;IACI,+BAA+B,CACpC,QAAQ,EAAE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;IAKtC,IAAI,aACC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAC1C,OAAO,CAAC,IAAI,CAAC,CA6Cd;IAEK,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,g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_exports);
34
34
  var import_graph = require("@rsdoctor/graph");
35
35
  var import_sdk = require("@rsdoctor/sdk");
36
36
  var import_plugins = require("@rsdoctor/core/plugins");
37
+ var import_build_utils = require("@rsdoctor/core/build-utils");
37
38
  var import_types = require("@rsdoctor/types");
38
39
  var import_path = __toESM(require("path"));
39
40
  var import_constants = require("./constants");
40
41
  var import_lodash = require("lodash");
41
- var import_probeLoaderPlugin = require("./probeLoaderPlugin");
42
42
  var import_common = require("@rsdoctor/utils/common");
43
43
  var import_logger = require("@rsdoctor/utils/logger");
44
44
  class RsdoctorRspackPlugin {
@@ -128,11 +128,16 @@ class RsdoctorRspackPlugin {
128
128
  new import_plugins.InternalSummaryPlugin(this).apply(
129
129
  compiler
130
130
  );
131
- if (this.options.features.loader && !import_common.Loader.isVue(compiler)) {
132
- new import_probeLoaderPlugin.ProbeLoaderPlugin().apply(compiler);
133
- new import_plugins.InternalLoaderPlugin(this).apply(
134
- compiler
135
- );
131
+ if (this.options.features.loader) {
132
+ new import_build_utils.Loader.ProbeLoaderPlugin().apply(compiler);
133
+ this.sdk.addClientRoutes([
134
+ import_types.Manifest.RsdoctorManifestClientRoutes.WebpackLoaders
135
+ ]);
136
+ if (!import_common.Loader.isVue(compiler)) {
137
+ new import_plugins.InternalLoaderPlugin(this).apply(
138
+ compiler
139
+ );
140
+ }
136
141
  }
137
142
  if (this.options.features.plugins) {
138
143
  new import_plugins.InternalPluginsPlugin(this).apply(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/rspack-plugin",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -14,15 +14,15 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "lodash": "^4.17.21",
17
- "@rsdoctor/core": "0.4.4",
18
- "@rsdoctor/graph": "0.4.4",
19
- "@rsdoctor/sdk": "0.4.4",
20
- "@rsdoctor/utils": "0.4.4",
21
- "@rsdoctor/types": "0.4.4"
17
+ "@rsdoctor/core": "0.4.5",
18
+ "@rsdoctor/graph": "0.4.5",
19
+ "@rsdoctor/sdk": "0.4.5",
20
+ "@rsdoctor/utils": "0.4.5",
21
+ "@rsdoctor/types": "0.4.5"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@rspack/core": "0.7.5",
25
- "@types/lodash": "^4.17.7",
25
+ "@types/lodash": "^4.17.9",
26
26
  "@types/node": "^16",
27
27
  "@types/tapable": "2.2.7",
28
28
  "tslib": "2.7.0",
@@ -1,5 +0,0 @@
1
- import { Plugin } from '@rsdoctor/types';
2
- import type { LoaderDefinitionFunction } from '@rspack/core';
3
- declare const loaderModule: Plugin.LoaderDefinition<Parameters<LoaderDefinitionFunction>, {}>;
4
- export default loaderModule;
5
- //# sourceMappingURL=probeLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"probeLoader.d.ts","sourceRoot":"","sources":["../src/probeLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAO,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAI7D,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,gBAAgB,CACzC,UAAU,CAAC,wBAAwB,CAAC,EACpC,EAAE,CAwCH,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,71 +0,0 @@
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
- });
33
- module.exports = __toCommonJS(probeLoader_exports);
34
- var import_plugins = require("@rsdoctor/core/plugins");
35
- var import_core = require("@rsdoctor/core");
36
- var import_lodash = require("lodash");
37
- var import_path = __toESM(require("path"));
38
- const loaderModule = function(...args) {
39
- const time = Date.now();
40
- const code = args[0];
41
- const _options = this.getOptions();
42
- const sdk = (0, import_plugins.getSDK)(_options.builderName);
43
- const loaderData = {
44
- resource: {
45
- path: this.resourcePath,
46
- query: import_core.Build.Utils.parseQuery(this.resourceQuery),
47
- queryRaw: this.resourceQuery,
48
- ext: import_path.default.extname(this.resourcePath).slice(1)
49
- },
50
- loaders: [
51
- {
52
- loader: _options.loader,
53
- loaderIndex: this.loaderIndex,
54
- path: _options.loader,
55
- input: _options.type === "start" ? code : null,
56
- result: _options.type === "end" ? code : null,
57
- startAt: _options.type === "start" ? time : 0,
58
- endAt: _options.type === "end" ? time : 0,
59
- options: (0, import_lodash.omit)(_options.options, "type"),
60
- isPitch: false,
61
- sync: false,
62
- errors: [],
63
- pid: process.pid,
64
- ppid: process.ppid
65
- }
66
- ]
67
- };
68
- sdk.reportLoaderStartOrEnd(loaderData);
69
- this.callback(null, ...args);
70
- };
71
- var probeLoader_default = loaderModule;
@@ -1,6 +0,0 @@
1
- import { Plugin } from '@rsdoctor/types';
2
- export declare class ProbeLoaderPlugin {
3
- apply(compiler: Plugin.BaseCompiler): void;
4
- private addProbeLoader;
5
- }
6
- //# sourceMappingURL=probeLoaderPlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"probeLoaderPlugin.d.ts","sourceRoot":"","sources":["../src/probeLoaderPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAOzC,qBAAa,iBAAiB;IAC5B,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY;IAoBnC,OAAO,CAAC,cAAc;CA+CvB"}
@@ -1,100 +0,0 @@
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 probeLoaderPlugin_exports = {};
30
- __export(probeLoaderPlugin_exports, {
31
- ProbeLoaderPlugin: () => ProbeLoaderPlugin
32
- });
33
- module.exports = __toCommonJS(probeLoaderPlugin_exports);
34
- var import_build_utils = require("@rsdoctor/core/build-utils");
35
- var import_path = __toESM(require("path"));
36
- var import_core = require("@rsdoctor/core");
37
- const BuiltinLoaderName = "builtin:swc-loader";
38
- const ESMLoaderFile = ".mjs";
39
- class ProbeLoaderPlugin {
40
- apply(compiler) {
41
- compiler.hooks.beforeRun.tap(
42
- {
43
- name: "ProbeLoaderPlugin"
44
- },
45
- () => {
46
- this.addProbeLoader(compiler);
47
- }
48
- );
49
- compiler.hooks.watchRun.tap(
50
- {
51
- name: "ProbeLoaderPlugin"
52
- },
53
- () => {
54
- this.addProbeLoader(compiler);
55
- }
56
- );
57
- }
58
- addProbeLoader(compiler) {
59
- const rules = compiler.options.module.rules;
60
- const appendRule = (rule, index) => {
61
- if ("use" in rule && Array.isArray(rule.use)) {
62
- const _builtinRule = rule.use[index];
63
- const _options = typeof _builtinRule.options === "string" ? {} : { ..._builtinRule };
64
- rule.use.splice(index, 0, {
65
- loader: import_path.default.join(__dirname, "./probeLoader.js"),
66
- options: {
67
- ..._options,
68
- type: "end",
69
- builderName: compiler.options.name
70
- }
71
- });
72
- rule.use.splice(index + 2, 0, {
73
- loader: import_path.default.join(__dirname, "./probeLoader.js"),
74
- options: {
75
- ..._options,
76
- type: "start",
77
- builderName: compiler.options.name
78
- }
79
- });
80
- }
81
- return rule;
82
- };
83
- compiler.options.module.rules = import_build_utils.Utils.addProbeLoader2Rules(
84
- rules,
85
- appendRule,
86
- (r) => import_core.Build.Utils.getLoaderNameMatch(r, BuiltinLoaderName, true)
87
- );
88
- compiler.options.module.rules = import_build_utils.Utils.addProbeLoader2Rules(
89
- rules,
90
- appendRule,
91
- (r) => {
92
- return import_core.Build.Utils.getLoaderNameMatch(r, ESMLoaderFile, false) || import_core.Build.Utils.isESMLoader(r);
93
- }
94
- );
95
- }
96
- }
97
- // Annotate the CommonJS export names for ESM import in node:
98
- 0 && (module.exports = {
99
- ProbeLoaderPlugin
100
- });