@rsdoctor/core 2.0.0-alpha.1 → 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.
Files changed (177) hide show
  1. package/dist/26.js +26174 -0
  2. package/dist/630.js +1280 -0
  3. package/dist/630.js.LICENSE.txt +7 -0
  4. package/dist/build-utils/build/chunks/assetsModules.d.ts +7 -1
  5. package/dist/build-utils/build/loader/probeLoader.d.ts +7 -2
  6. package/dist/build-utils/build/server.d.ts +1 -2
  7. package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
  8. package/dist/index.d.ts +5 -5
  9. package/dist/index.js +1908 -7
  10. package/dist/inner-plugins/constants.d.ts +1 -1
  11. package/dist/inner-plugins/plugins/base.d.ts +2 -2
  12. package/dist/inner-plugins/plugins/errors.d.ts +1 -0
  13. package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
  14. package/dist/inner-plugins/plugins/summary.d.ts +3 -2
  15. package/dist/inner-plugins/utils/sdk.d.ts +2 -1
  16. package/dist/logger.d.ts +2 -2
  17. package/dist/probe-loader.js +2 -0
  18. package/dist/proxy-loader.d.ts +1 -0
  19. package/dist/proxy-loader.js +48 -0
  20. package/dist/rslib-runtime.js +28 -0
  21. package/dist/rspack-plugin/constants.d.ts +1 -1
  22. package/dist/rspack-plugin/multiple.d.ts +5 -3
  23. package/dist/rspack-plugin/plugin.d.ts +43 -17
  24. package/dist/rspack-plugin/session.d.ts +20 -0
  25. package/dist/rules/rules/ecma-version-check/htmlParserStub.d.ts +3 -0
  26. package/dist/rules/rules/ecma-version-check/types.d.ts +13 -2
  27. package/dist/sdk/multiple/controller.d.ts +13 -2
  28. package/dist/sdk/multiple/primary.d.ts +12 -4
  29. package/dist/sdk/server/apis/base.d.ts +1 -1
  30. package/dist/sdk/server/socket/api.d.ts +1 -1
  31. package/dist/sdk/utils/date.d.ts +1 -0
  32. package/dist/types/loader.d.ts +1 -1
  33. package/package.json +23 -117
  34. package/dist/build-utils/build/chunks/assetsModules.js +0 -9
  35. package/dist/build-utils/build/chunks/index.js +0 -3
  36. package/dist/build-utils/build/chunks/rspack/transform.js +0 -44
  37. package/dist/build-utils/build/envinfo.js +0 -60
  38. package/dist/build-utils/build/file/cache.js +0 -24
  39. package/dist/build-utils/build/file/index.js +0 -5
  40. package/dist/build-utils/build/file/sharding.js +0 -38
  41. package/dist/build-utils/build/index.js +0 -12
  42. package/dist/build-utils/build/json.js +0 -67
  43. package/dist/build-utils/build/loader/index.js +0 -3
  44. package/dist/build-utils/build/loader/probeLoader.js +0 -44
  45. package/dist/build-utils/build/loader/probeLoaderPlugin.js +0 -32
  46. package/dist/build-utils/build/module-graph/index.js +0 -2
  47. package/dist/build-utils/build/module-graph/parser.js +0 -13
  48. package/dist/build-utils/build/module-graph/rspack/transform.js +0 -111
  49. package/dist/build-utils/build/module-graph/utils.js +0 -60
  50. package/dist/build-utils/build/process.js +0 -18
  51. package/dist/build-utils/build/server.js +0 -107
  52. package/dist/build-utils/build/utils/index.js +0 -4
  53. package/dist/build-utils/build/utils/loader.js +0 -267
  54. package/dist/build-utils/build/utils/parseBundle.js +0 -238
  55. package/dist/build-utils/build/utils/plugin.js +0 -21
  56. package/dist/build-utils/index.js +0 -13
  57. package/dist/collection.d.ts +0 -1
  58. package/dist/collection.js +0 -2
  59. package/dist/common/file.js +0 -8
  60. package/dist/common/global-config.js +0 -33
  61. package/dist/common/index.d.ts +0 -4
  62. package/dist/common/index.js +0 -6
  63. package/dist/common-browser.d.ts +0 -1
  64. package/dist/common-browser.js +0 -2
  65. package/dist/error/error.js +0 -143
  66. package/dist/error/index.js +0 -3
  67. package/dist/error/transform.js +0 -138
  68. package/dist/error/utils.js +0 -23
  69. package/dist/graph/index.d.ts +0 -1
  70. package/dist/graph/index.js +0 -2
  71. package/dist/inner-plugins/constants.js +0 -19
  72. package/dist/inner-plugins/index.js +0 -3
  73. package/dist/inner-plugins/loaders/proxy.js +0 -65
  74. package/dist/inner-plugins/plugins/base.js +0 -20
  75. package/dist/inner-plugins/plugins/bundle.js +0 -63
  76. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +0 -74
  77. package/dist/inner-plugins/plugins/errors.js +0 -65
  78. package/dist/inner-plugins/plugins/index.js +0 -11
  79. package/dist/inner-plugins/plugins/loader.js +0 -108
  80. package/dist/inner-plugins/plugins/plugins.js +0 -40
  81. package/dist/inner-plugins/plugins/progress.js +0 -35
  82. package/dist/inner-plugins/plugins/resolver.js +0 -57
  83. package/dist/inner-plugins/plugins/rspack.js +0 -99
  84. package/dist/inner-plugins/plugins/rules.js +0 -64
  85. package/dist/inner-plugins/plugins/sourcemapTool.js +0 -230
  86. package/dist/inner-plugins/plugins/summary.js +0 -92
  87. package/dist/inner-plugins/utils/circleDetect.js +0 -16
  88. package/dist/inner-plugins/utils/config.js +0 -141
  89. package/dist/inner-plugins/utils/index.js +0 -8
  90. package/dist/inner-plugins/utils/loader.js +0 -134
  91. package/dist/inner-plugins/utils/normalize-config.js +0 -77
  92. package/dist/inner-plugins/utils/openBrowser.js +0 -55
  93. package/dist/inner-plugins/utils/plugin-common.js +0 -94
  94. package/dist/inner-plugins/utils/plugin.js +0 -70
  95. package/dist/inner-plugins/utils/sdk.js +0 -19
  96. package/dist/logger.js +0 -51
  97. package/dist/rspack-plugin/constants.js +0 -23
  98. package/dist/rspack-plugin/index.js +0 -3
  99. package/dist/rspack-plugin/multiple.js +0 -39
  100. package/dist/rspack-plugin/plugin.js +0 -133
  101. package/dist/rule-utils/document/document.js +0 -46
  102. package/dist/rule-utils/document/index.js +0 -4
  103. package/dist/rule-utils/document/server.js +0 -13
  104. package/dist/rule-utils/document/types.js +0 -1
  105. package/dist/rule-utils/index.js +0 -3
  106. package/dist/rule-utils/parser/asserts.js +0 -105
  107. package/dist/rule-utils/parser/index.js +0 -5
  108. package/dist/rule-utils/parser/parser.js +0 -24
  109. package/dist/rule-utils/parser/types.js +0 -8
  110. package/dist/rule-utils/parser/utils.js +0 -106
  111. package/dist/rules/index.js +0 -4
  112. package/dist/rules/linter.js +0 -36
  113. package/dist/rules/rule.js +0 -101
  114. package/dist/rules/rules/cjs-require/index.js +0 -50
  115. package/dist/rules/rules/cjs-require/types.js +0 -1
  116. package/dist/rules/rules/cross-chunks-package/index.js +0 -41
  117. package/dist/rules/rules/cross-chunks-package/types.js +0 -1
  118. package/dist/rules/rules/cross-chunks-package/utils.js +0 -7
  119. package/dist/rules/rules/default-import-check/index.js +0 -83
  120. package/dist/rules/rules/default-import-check/types.js +0 -1
  121. package/dist/rules/rules/default-import-check/utils.js +0 -52
  122. package/dist/rules/rules/duplicate-package/index.js +0 -39
  123. package/dist/rules/rules/duplicate-package/types.js +0 -24
  124. package/dist/rules/rules/duplicate-package/utils.js +0 -38
  125. package/dist/rules/rules/ecma-version-check/index.js +0 -53
  126. package/dist/rules/rules/ecma-version-check/types.js +0 -1
  127. package/dist/rules/rules/ecma-version-check/utils.js +0 -6
  128. package/dist/rules/rules/esm-resolved-to-cjs/index.js +0 -193
  129. package/dist/rules/rules/esm-resolved-to-cjs/types.js +0 -1
  130. package/dist/rules/rules/index.js +0 -22
  131. package/dist/rules/rules/loader-performance-optimization/index.js +0 -86
  132. package/dist/rules/rules/loader-performance-optimization/types.js +0 -1
  133. package/dist/rules/rules/loader-performance-optimization/utils.js +0 -10
  134. package/dist/rules/rules/module-mixed-chunks/index.js +0 -52
  135. package/dist/rules/rules/module-mixed-chunks/types.js +0 -1
  136. package/dist/rules/rules/side-effects-only-imports/index.js +0 -81
  137. package/dist/rules/rules/side-effects-only-imports/types.js +0 -1
  138. package/dist/rules/utils.js +0 -10
  139. package/dist/sdk/index.js +0 -3
  140. package/dist/sdk/multiple/controller.js +0 -42
  141. package/dist/sdk/multiple/index.js +0 -3
  142. package/dist/sdk/multiple/primary.js +0 -64
  143. package/dist/sdk/multiple/server.js +0 -14
  144. package/dist/sdk/sdk/core.js +0 -163
  145. package/dist/sdk/sdk/index.js +0 -435
  146. package/dist/sdk/sdk/types.js +0 -1
  147. package/dist/sdk/server/apis/alerts.js +0 -30
  148. package/dist/sdk/server/apis/base.js +0 -22
  149. package/dist/sdk/server/apis/bundle-diff.js +0 -51
  150. package/dist/sdk/server/apis/data.js +0 -44
  151. package/dist/sdk/server/apis/fs.js +0 -28
  152. package/dist/sdk/server/apis/graph.js +0 -116
  153. package/dist/sdk/server/apis/index.js +0 -11
  154. package/dist/sdk/server/apis/loader.js +0 -120
  155. package/dist/sdk/server/apis/plugin.js +0 -39
  156. package/dist/sdk/server/apis/project.js +0 -59
  157. package/dist/sdk/server/apis/renderer.js +0 -33
  158. package/dist/sdk/server/apis/resolver.js +0 -38
  159. package/dist/sdk/server/client.js +0 -8
  160. package/dist/sdk/server/fakeServer.js +0 -12
  161. package/dist/sdk/server/index.js +0 -292
  162. package/dist/sdk/server/json-body.js +0 -150
  163. package/dist/sdk/server/router.js +0 -83
  164. package/dist/sdk/server/security.js +0 -47
  165. package/dist/sdk/server/socket/api.js +0 -22
  166. package/dist/sdk/server/socket/index.js +0 -166
  167. package/dist/sdk/server/utils.js +0 -19
  168. package/dist/sdk/utils/base.js +0 -22
  169. package/dist/sdk/utils/constant.js +0 -4
  170. package/dist/sdk/utils/index.js +0 -4
  171. package/dist/sdk/utils/openBrowser.js +0 -53
  172. package/dist/sdk/utils/upload.js +0 -6
  173. package/dist/sdk.js +0 -2
  174. package/dist/types/index.js +0 -4
  175. package/dist/types/loader.js +0 -1
  176. package/dist/types/plugin.js +0 -1
  177. package/dist/types/rules.js +0 -1
@@ -1,70 +0,0 @@
1
- import "node:module";
2
- import { DevToolError } from "../../error/index.js";
3
- function reportPluginData(sdk, hook, tapName, start, type, _res, err) {
4
- const end = Date.now();
5
- sdk.reportPlugin({
6
- [hook]: [
7
- {
8
- tapName,
9
- costs: end - start,
10
- startAt: start,
11
- endAt: end,
12
- type,
13
- result: null,
14
- error: err ? [
15
- new DevToolError(`${tapName} ${hook} Error`, err.message, {
16
- controller: {
17
- noStack: false,
18
- noColor: true
19
- },
20
- stack: err.stack
21
- })
22
- ] : []
23
- }
24
- ]
25
- });
26
- }
27
- function interceptPluginHook(sdk, name, hook) {
28
- if (!hook?.intercept) return;
29
- hook.intercept({
30
- register (tap) {
31
- const o = tap.fn;
32
- if ('sync' === tap.type) tap.fn = function(...args) {
33
- const start = Date.now();
34
- try {
35
- const res = o.apply(this, args);
36
- reportPluginData(sdk, name, tap.name, start, tap.type, res);
37
- return res;
38
- } catch (error) {
39
- reportPluginData(sdk, name, tap.name, start, tap.type, null, error);
40
- throw error;
41
- }
42
- };
43
- else if ('async' === tap.type) tap.fn = async function(...args) {
44
- const start = Date.now();
45
- try {
46
- const res = await o.apply(this, args);
47
- reportPluginData(sdk, name, tap.name, start, tap.type, res);
48
- return res;
49
- } catch (error) {
50
- reportPluginData(sdk, name, tap.name, start, tap.type, null, error);
51
- throw error;
52
- }
53
- };
54
- else if ('promise' === tap.type) tap.fn = function(...args) {
55
- const start = Date.now();
56
- const isChild = args?.[0]?.compiler?.isChild();
57
- return o.apply(this, args).then((res)=>{
58
- if (isChild) return res;
59
- reportPluginData(sdk, name, tap.name, start, tap.type, res);
60
- return res;
61
- }).catch((error)=>{
62
- reportPluginData(sdk, name, tap.name, start, tap.type, null, error);
63
- throw error;
64
- });
65
- };
66
- return tap;
67
- }
68
- });
69
- }
70
- export { interceptPluginHook, reportPluginData };
@@ -1,19 +0,0 @@
1
- import "node:module";
2
- const globalKey = '__rsdoctor_sdks__';
3
- function setSDK(t) {
4
- if (!globalThis.__rsdoctor_sdks__) globalThis.__rsdoctor_sdks__ = [];
5
- globalThis.__rsdoctor_sdks__.push(t);
6
- globalThis.__rsdoctor_sdk__ = t;
7
- }
8
- function getSDK(builderName) {
9
- const sdks = globalThis[globalKey] || [];
10
- let sdk = globalThis['__rsdoctor_sdk__'];
11
- if (sdk && sdk.name !== builderName) sdk = builderName ? sdks.find((s)=>s.name === builderName) || sdk : sdk;
12
- if (sdk && builderName && 'parent' in sdk) {
13
- const parent = sdk.parent;
14
- const slaveSDK = parent?.slaves.find((_sdk)=>_sdk.name === builderName);
15
- return slaveSDK || sdk;
16
- }
17
- return sdk;
18
- }
19
- export { getSDK, setSDK };
package/dist/logger.js DELETED
@@ -1,51 +0,0 @@
1
- import "node:module";
2
- import picocolors from "picocolors";
3
- import { createLogger, logger } from "rslog";
4
- import { Constants } from "@rsdoctor/shared/types";
5
- function debug(getMsg, prefix = '') {
6
- if (!process.env.DEBUG) return;
7
- logger.level = 'verbose';
8
- logger.debug(`${prefix} ${getMsg()}`);
9
- }
10
- const rsdoctorLogger = createLogger();
11
- rsdoctorLogger.override({
12
- log: (message)=>{
13
- console.log(`${picocolors.green('[RSDOCTOR LOG]')} ${message}`);
14
- },
15
- info: (message)=>{
16
- console.log(`${picocolors.yellow('[RSDOCTOR INFO]')} ${message}`);
17
- },
18
- warn: (message)=>{
19
- console.warn(`${picocolors.yellow('[RSDOCTOR WARN]')} ${message}`);
20
- },
21
- start: (message)=>{
22
- console.log(`${picocolors.green('[RSDOCTOR START]')} ${message}`);
23
- },
24
- ready: (message)=>{
25
- console.log(`${picocolors.green('[RSDOCTOR READY]')} ${message}`);
26
- },
27
- error: (message)=>{
28
- console.error(`${picocolors.red('[RSDOCTOR ERROR]')} ${message}`);
29
- },
30
- success: (message)=>{
31
- console.error(`${picocolors.green('[RSDOCTOR SUCCESS]')} ${message}`);
32
- },
33
- debug: (message)=>{
34
- if (process.env.DEBUG) console.log(`${picocolors.blue('[RSDOCTOR DEBUG]')} ${message}`);
35
- }
36
- });
37
- const _timers = new Map();
38
- function time(label) {
39
- if (process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey) return;
40
- if (_timers.has(label)) return;
41
- _timers.set(label, Date.now());
42
- }
43
- function timeEnd(label) {
44
- if (process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey) return;
45
- const start = _timers.get(label);
46
- if (null == start) return void logger.debug(`Timer '${label}' does not exist.`);
47
- const duration = Date.now() - start;
48
- logger.debug(`Timer '${label}' ended: ${duration}ms`);
49
- _timers.delete(label);
50
- }
51
- export { debug, picocolors as chalk, rsdoctorLogger as logger, time, timeEnd };
@@ -1,23 +0,0 @@
1
- import "node:module";
2
- import { createRequire } from "node:module";
3
- const constants_require = createRequire(import.meta.url);
4
- const packageJson = constants_require('../../package.json');
5
- const pluginTapName = 'RsdoctorRspackPlugin';
6
- const pluginTapPostOptions = {
7
- name: pluginTapName,
8
- stage: 999
9
- };
10
- const pluginTapPreOptions = {
11
- name: pluginTapName,
12
- stage: -999
13
- };
14
- const internalPluginTapPreOptions = (namespace)=>({
15
- name: `${pluginTapName}:${namespace}`,
16
- stage: -998
17
- });
18
- const internalPluginTapPostOptions = (namespace)=>({
19
- name: `${pluginTapName}:${namespace}`,
20
- stage: 1000
21
- });
22
- const pkg = packageJson;
23
- export { internalPluginTapPostOptions, internalPluginTapPreOptions, pkg, pluginTapName, pluginTapPostOptions, pluginTapPreOptions };
@@ -1,3 +0,0 @@
1
- import "node:module";
2
- export * from "./plugin.js";
3
- export * from "./multiple.js";
@@ -1,39 +0,0 @@
1
- import "node:module";
2
- import { RsdoctorSDKController } from "../sdk.js";
3
- import { SDK } from "@rsdoctor/shared/types";
4
- import { normalizeUserConfig } from "../inner-plugins/index.js";
5
- import { RsdoctorRspackPlugin } from "./plugin.js";
6
- let globalController;
7
- class RsdoctorRspackMultiplePlugin extends RsdoctorRspackPlugin {
8
- apply(compiler) {
9
- if ('dependencies' in compiler.options) this.sdk.dependencies = compiler.options.dependencies;
10
- super.apply(compiler);
11
- }
12
- constructor(options = {}){
13
- const controller = (()=>{
14
- if (globalController) return globalController;
15
- const controller = new RsdoctorSDKController();
16
- globalController = controller;
17
- return controller;
18
- })();
19
- const normallizedOptions = normalizeUserConfig(options);
20
- const instance = controller.createSlave({
21
- name: options.name || 'Builder',
22
- stage: options.stage,
23
- extraConfig: {
24
- innerClientPath: normallizedOptions.innerClientPath,
25
- printLog: normallizedOptions.printLog,
26
- server: normallizedOptions.server,
27
- mode: normallizedOptions.output.mode ? normallizedOptions.output.mode : void 0,
28
- brief: normallizedOptions.output.mode === SDK.IMode[SDK.IMode.brief] ? normallizedOptions.output.options || void 0 : void 0
29
- },
30
- type: normallizedOptions.output.reportCodeType
31
- });
32
- super({
33
- ...options,
34
- sdkInstance: instance
35
- });
36
- this.controller = controller;
37
- }
38
- }
39
- export { RsdoctorRspackMultiplePlugin };
@@ -1,133 +0,0 @@
1
- import "node:module";
2
- import { Loader } from "../build-utils/index.js";
3
- import { InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, ensureModulesChunksGraphFn, handleBriefModeReport, normalizeRspackUserOptions, processCompilerConfig, setSDK } from "../inner-plugins/index.js";
4
- import { RsdoctorSDK, findRoot } from "../sdk.js";
5
- import { Constants, Manifest, SDK } from "@rsdoctor/shared/types";
6
- import path from "path";
7
- import { pkg, pluginTapName, pluginTapPostOptions } from "./constants.js";
8
- import { ModuleGraph } from "../graph/index.js";
9
- import { Loader as index_js_Loader } from "../common/index.js";
10
- import { logger, time, timeEnd } from "../logger.js";
11
- import { getRspackNativePlugin } from "../inner-plugins/plugins/rspack.js";
12
- let hasGreeted = false;
13
- class RsdoctorRspackPlugin {
14
- apply(compiler) {
15
- time('RsdoctorRspackPlugin.apply');
16
- try {
17
- if (!hasGreeted && !compiler.isChild()) {
18
- hasGreeted = true;
19
- logger.greet(`
20
- \nRsdoctor v${pkg.version}\n`);
21
- }
22
- if (!this._bootstrapTask) this._bootstrapTask = this.sdk.bootstrap();
23
- if (compiler.options.name) this.sdk.setName(compiler.options.name);
24
- setSDK(this.sdk);
25
- compiler.hooks.afterPlugins.tap(pluginTapPostOptions, this.afterPlugins.bind(this, compiler));
26
- compiler.hooks.done.tapPromise({
27
- ...pluginTapPostOptions,
28
- stage: pluginTapPostOptions.stage + 100
29
- }, this.done.bind(this, compiler));
30
- new InternalSummaryPlugin(this).apply(compiler);
31
- if (this.options.features.loader) {
32
- new Loader.ProbeLoaderPlugin().apply(compiler);
33
- this.sdk.addClientRoutes([
34
- Manifest.RsdoctorManifestClientRoutes.Loaders
35
- ]);
36
- if (!index_js_Loader.isVue(compiler)) new InternalLoaderPlugin(this).apply(compiler);
37
- }
38
- if (this.options.features.plugins) new InternalPluginsPlugin(this).apply(compiler);
39
- if (this.options.features.bundle) new InternalBundlePlugin(this).apply(compiler);
40
- if (this.options.features.resolver) new InternalResolverPlugin(this).apply(compiler);
41
- new InternalRulesPlugin(this).apply(compiler);
42
- new InternalErrorReporterPlugin(this).apply(compiler);
43
- const RsdoctorRspackNativePlugin = getRspackNativePlugin(compiler);
44
- logger.debug('[RspackNativePlugin] Enabled');
45
- new RsdoctorRspackNativePlugin({
46
- moduleGraphFeatures: true,
47
- chunkGraphFeatures: true,
48
- sourceMapFeatures: {
49
- cheap: false,
50
- module: false
51
- }
52
- }).apply(compiler);
53
- } finally{
54
- timeEnd('RsdoctorRspackPlugin.apply');
55
- }
56
- }
57
- ensureModulesChunksGraphApplied(compiler) {
58
- ensureModulesChunksGraphFn(compiler, this);
59
- }
60
- getRspackConfig(compiler) {
61
- time('RsdoctorRspackPlugin.getRspackConfig');
62
- try {
63
- if (compiler.isChild()) return;
64
- const configuration = processCompilerConfig(compiler.options);
65
- const rspackVersion = compiler.webpack?.rspackVersion || compiler.webpack?.version;
66
- this.sdk.reportConfiguration({
67
- name: 'rspack',
68
- version: rspackVersion || 'unknown',
69
- config: configuration,
70
- root: findRoot() || ''
71
- });
72
- } finally{
73
- timeEnd('RsdoctorRspackPlugin.getRspackConfig');
74
- }
75
- }
76
- constructor(options){
77
- this.name = pluginTapName;
78
- this.browserIsOpened = false;
79
- this.afterPlugins = (compiler)=>{
80
- time('RsdoctorRspackPlugin.afterPlugins');
81
- try {
82
- this.getRspackConfig(compiler);
83
- } finally{
84
- timeEnd('RsdoctorRspackPlugin.afterPlugins');
85
- }
86
- };
87
- this.done = async (compiler)=>{
88
- time('RsdoctorRspackPlugin.done');
89
- try {
90
- logger.debug('[RsdoctorRspackPlugin] bootstrap(start) in done()');
91
- await this.sdk.bootstrap();
92
- logger.debug('[RsdoctorRspackPlugin] bootstrap(end) in done()');
93
- this.sdk.addClientRoutes([
94
- Manifest.RsdoctorManifestClientRoutes.Overall
95
- ]);
96
- if (this.outsideInstance && 'parent' in this.sdk) this.sdk.parent.master.setOutputDir(path.resolve(this.options.output.reportDir || compiler.outputPath, this.options.output.mode === SDK.IMode[SDK.IMode.brief] ? '' : `./${Constants.RsdoctorOutputFolder}`));
97
- this.sdk.setOutputDir(path.resolve(this.options.output.reportDir || compiler.outputPath, this.options.output.mode === SDK.IMode[SDK.IMode.brief] ? '' : `./${Constants.RsdoctorOutputFolder}`));
98
- await this.sdk.writeStore();
99
- if (!this.options.disableClientServer) if (this.options.output.mode === SDK.IMode[SDK.IMode.brief]) await handleBriefModeReport(this.sdk, this.options, this.options.disableClientServer);
100
- else await this.sdk.server.openClientPage('homepage');
101
- if (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]) await this.sdk.dispose();
102
- } finally{
103
- timeEnd('RsdoctorRspackPlugin.done');
104
- }
105
- };
106
- this.options = normalizeRspackUserOptions(Object.assign(options || {}, {
107
- supports: {
108
- ...options?.supports
109
- }
110
- }));
111
- const { port, server, output, innerClientPath, printLog, sdkInstance } = this.options;
112
- this.sdk = this.options.sdkInstance ?? new RsdoctorSDK({
113
- port,
114
- name: pluginTapName,
115
- root: process.cwd(),
116
- type: output.reportCodeType,
117
- config: {
118
- innerClientPath,
119
- printLog,
120
- server,
121
- mode: output.mode ? output.mode : void 0,
122
- brief: output.mode === SDK.IMode[SDK.IMode.brief] ? output.options || void 0 : void 0,
123
- features: {
124
- treeShaking: this.options.features.treeShaking
125
- }
126
- }
127
- });
128
- this.outsideInstance = Boolean(sdkInstance);
129
- this.modulesGraph = new ModuleGraph();
130
- this.isRsdoctorPlugin = true;
131
- }
132
- }
133
- export { RsdoctorRspackPlugin };
@@ -1,46 +0,0 @@
1
- import "node:module";
2
- import { Lodash } from "../../common/index.js";
3
- import { LinesAndColumns } from "lines-and-columns";
4
- class Document {
5
- createFinder() {
6
- const find = new LinesAndColumns(this._text);
7
- this.positionAt = (offset)=>{
8
- if (offset >= this._text.length) offset = this._text.length - 1;
9
- if (offset < 0) offset = 0;
10
- const result = find.locationForIndex(offset);
11
- if (!result) return;
12
- return {
13
- line: result.line + 1,
14
- column: result.column
15
- };
16
- };
17
- this.offsetAt = (position)=>find.indexForLocation({
18
- line: position.line - 1,
19
- column: position.column
20
- }) ?? void 0;
21
- }
22
- getText(range) {
23
- if (!range) return this._text;
24
- const start = 'number' == typeof range.start ? range.start : this.offsetAt(range.start);
25
- const end = 'number' == typeof range.end ? range.end : this.offsetAt(range.end);
26
- if (Lodash.isUndefined(start)) throw new Error(`Location ${JSON.stringify(start)} is illegal`);
27
- if (Lodash.isUndefined(end)) throw new Error(`Location ${JSON.stringify(end)} is illegal`);
28
- return this._text.slice(start, end);
29
- }
30
- edit(data) {
31
- let { _text: content } = this;
32
- const startOffset = Lodash.isNumber(data.start) ? data.start : this.offsetAt(data.start);
33
- const endOffset = Lodash.isNumber(data.end) ? data.end : this.offsetAt(data.end);
34
- if (Lodash.isUndefined(startOffset) || Lodash.isUndefined(endOffset)) return;
35
- const startTxt = content.substring(0, startOffset);
36
- const endTxt = content.substring(endOffset, content.length);
37
- content = startTxt + data.newText + endTxt;
38
- return content;
39
- }
40
- constructor(content){
41
- this._text = '';
42
- this._text = content;
43
- this.createFinder();
44
- }
45
- }
46
- export { Document };
@@ -1,4 +0,0 @@
1
- import "node:module";
2
- export * from "./document.js";
3
- export * from "./types.js";
4
- export * from "./server.js";
@@ -1,13 +0,0 @@
1
- import "node:module";
2
- import { Document } from "./document.js";
3
- const store = new Map();
4
- function getDocument(content) {
5
- if (store.has(content)) return store.get(content);
6
- const doc = new Document(content);
7
- store.set(content, doc);
8
- return doc;
9
- }
10
- function clearDocument() {
11
- store.clear();
12
- }
13
- export { clearDocument, getDocument };
@@ -1 +0,0 @@
1
- import "node:module";
@@ -1,3 +0,0 @@
1
- import "node:module";
2
- export * from "./document/index.js";
3
- export * from "./parser/index.js";
@@ -1,105 +0,0 @@
1
- import "node:module";
2
- import { Lodash } from "../../common/index.js";
3
- function isSyntaxNode(node) {
4
- return Lodash.isObject(node) && 'type' in node;
5
- }
6
- function assertCreator(type) {
7
- return (node)=>isSyntaxNode(node) && node.type === type;
8
- }
9
- const asserts = {
10
- isProgram: assertCreator('Program'),
11
- isEmptyStatement: assertCreator('EmptyStatement'),
12
- isBlockStatement: assertCreator('BlockStatement'),
13
- isStaticBlock: assertCreator('StaticBlock'),
14
- isExpressionStatement: assertCreator('ExpressionStatement'),
15
- isIfStatement: assertCreator('IfStatement'),
16
- isLabeledStatement: assertCreator('LabeledStatement'),
17
- isBreakStatement: assertCreator('BreakStatement'),
18
- isContinueStatement: assertCreator('ContinueStatement'),
19
- isWithStatement: assertCreator('WithStatement'),
20
- isSwitchStatement: assertCreator('SwitchStatement'),
21
- isReturnStatement: assertCreator('ReturnStatement'),
22
- isThrowStatement: assertCreator('ThrowStatement'),
23
- isTryStatement: assertCreator('TryStatement'),
24
- isWhileStatement: assertCreator('WhileStatement'),
25
- isDoWhileStatement: assertCreator('DoWhileStatement'),
26
- isForStatement: assertCreator('ForStatement'),
27
- isForInStatement: assertCreator('ForInStatement'),
28
- isForOfStatement: assertCreator('ForOfStatement'),
29
- isDebuggerStatement: assertCreator('DebuggerStatement'),
30
- isFunctionDeclaration: assertCreator('FunctionDeclaration'),
31
- isVariableDeclaration: assertCreator('VariableDeclaration'),
32
- isVariableDeclarator: assertCreator('VariableDeclarator'),
33
- isChainExpression: assertCreator('ChainExpression'),
34
- isThisExpression: assertCreator('ThisExpression'),
35
- isArrayExpression: assertCreator('ArrayExpression'),
36
- isObjectExpression: assertCreator('ObjectExpression'),
37
- isPrivateIdentifier: assertCreator('PrivateIdentifier'),
38
- isProperty: assertCreator('Property'),
39
- isPropertyDefinition: assertCreator('PropertyDefinition'),
40
- isFunctionExpression: assertCreator('FunctionExpression'),
41
- isSequenceExpression: assertCreator('SequenceExpression'),
42
- isUnaryExpression: assertCreator('UnaryExpression'),
43
- isBinaryExpression: assertCreator('BinaryExpression'),
44
- isAssignmentExpression: assertCreator('AssignmentExpression'),
45
- isUpdateExpression: assertCreator('UpdateExpression'),
46
- isLogicalExpression: assertCreator('LogicalExpression'),
47
- isConditionalExpression: assertCreator('ConditionalExpression'),
48
- isNewExpression: assertCreator('NewExpression'),
49
- isSwitchCase: assertCreator('SwitchCase'),
50
- isCatchClause: assertCreator('CatchClause'),
51
- isIdentifier: assertCreator('Identifier'),
52
- isLiteral: assertCreator('Literal'),
53
- isSuper: assertCreator('Super'),
54
- isSpreadElement: assertCreator('SpreadElement'),
55
- isArrowFunctionExpression: assertCreator('ArrowFunctionExpression'),
56
- isYieldExpression: assertCreator('YieldExpression'),
57
- isTemplateLiteral: assertCreator('TemplateLiteral'),
58
- isTaggedTemplateExpression: assertCreator('TaggedTemplateExpression'),
59
- isTemplateElement: assertCreator('TemplateElement'),
60
- isObjectPattern: assertCreator('ObjectPattern'),
61
- isArrayPattern: assertCreator('ArrayPattern'),
62
- isRestElement: assertCreator('RestElement'),
63
- isAssignmentPattern: assertCreator('AssignmentPattern'),
64
- isClassBody: assertCreator('ClassBody'),
65
- isClassDeclaration: assertCreator('ClassDeclaration'),
66
- isClassExpression: assertCreator('ClassExpression'),
67
- isMetaProperty: assertCreator('MetaProperty'),
68
- isImportDeclaration: assertCreator('ImportDeclaration'),
69
- isImportSpecifier: assertCreator('ImportSpecifier'),
70
- isImportExpression: assertCreator('ImportExpression'),
71
- isImportDefaultSpecifier: assertCreator('ImportDefaultSpecifier'),
72
- isImportNamespaceSpecifier: assertCreator('ImportNamespaceSpecifier'),
73
- isExportNamedDeclaration: assertCreator('ExportNamedDeclaration'),
74
- isExportSpecifier: assertCreator('ExportSpecifier'),
75
- isExportDefaultDeclaration: assertCreator('ExportDefaultDeclaration'),
76
- isExportAllDeclaration: assertCreator('ExportAllDeclaration'),
77
- isAwaitExpression: assertCreator('AwaitExpression'),
78
- isMethodDefinition: assertCreator('MethodDefinition'),
79
- isMemberExpression: assertCreator('MemberExpression'),
80
- isComment (node) {
81
- return isSyntaxNode(node) && ('Line' === node.type || 'Block' === node.type);
82
- },
83
- isDirective (node) {
84
- return asserts.isExpressionStatement(node) && 'directive' in node;
85
- },
86
- isSimpleCallExpression (node) {
87
- return isSyntaxNode(node) && 'CallExpression' === node.type;
88
- },
89
- isAssignmentProperty (node) {
90
- return asserts.isProperty(node) && 'init' === node.kind;
91
- },
92
- isSimpleLiteral (node) {
93
- return asserts.isLiteral(node) && !asserts.isRegExpLiteral(node) && !asserts.isBigIntLiteral(node);
94
- },
95
- isRegExpLiteral (node) {
96
- return asserts.isLiteral(node) && 'regex' in node;
97
- },
98
- isBigIntLiteral (node) {
99
- return asserts.isLiteral(node) && 'bigint' in node;
100
- },
101
- isExportStatement (node) {
102
- return asserts.isExportAllDeclaration(node) || asserts.isExportDefaultDeclaration(node) || asserts.isExportNamedDeclaration(node);
103
- }
104
- };
105
- export { asserts };
@@ -1,5 +0,0 @@
1
- import "node:module";
2
- export * from "./asserts.js";
3
- export * from "./parser.js";
4
- export * from "./utils.js";
5
- export * from "./types.js";
@@ -1,24 +0,0 @@
1
- import "node:module";
2
- import { Parser } from "acorn";
3
- import { importAttributes } from "acorn-import-attributes";
4
- import * as __rspack_external_acorn_walk_1e4235a7 from "acorn-walk";
5
- import { asserts } from "./asserts.js";
6
- import * as __rspack_external__utils_js_a9c81ddd from "./utils.js";
7
- const acornParserInternal = Parser.extend(importAttributes);
8
- let acornParserExport = Parser.extend(importAttributes);
9
- const parser = {
10
- walk: __rspack_external_acorn_walk_1e4235a7,
11
- parse: (input, options)=>acornParserExport.parse(input, options),
12
- parseExpressionAt: (input, pos, options)=>acornParserExport.parseExpressionAt(input, pos, options),
13
- extend (...args) {
14
- acornParserExport = acornParserExport.extend(...args);
15
- return acornParserExport;
16
- },
17
- asserts: asserts,
18
- utils: __rspack_external__utils_js_a9c81ddd,
19
- internal: {
20
- parse: (input, options)=>acornParserInternal.parse(input, options),
21
- parseExpressionAt: (input, pos, options)=>acornParserInternal.parseExpressionAt(input, pos, options)
22
- }
23
- };
24
- export { parser };
@@ -1,8 +0,0 @@
1
- import "node:module";
2
- var types_ECMAVersion = /*#__PURE__*/ function(ECMAVersion) {
3
- ECMAVersion["ES5"] = "ES5";
4
- ECMAVersion["ES6"] = "ES6";
5
- ECMAVersion["ES7P"] = "ES7+";
6
- return ECMAVersion;
7
- }({});
8
- export { types_ECMAVersion as ECMAVersion };