@rsdoctor/core 1.6.1 → 2.0.0-alpha.1
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/chunks/assetsModules.d.ts +1 -1
- package/dist/build-utils/build/chunks/assetsModules.js +1 -1
- package/dist/build-utils/build/chunks/index.d.ts +0 -1
- package/dist/build-utils/build/chunks/index.js +0 -1
- package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/chunks/rspack/transform.js +1 -1
- package/dist/build-utils/build/envinfo.d.ts +13 -0
- package/dist/build-utils/build/envinfo.js +60 -0
- package/dist/build-utils/build/file/cache.d.ts +5 -0
- package/dist/build-utils/build/file/cache.js +24 -0
- package/dist/build-utils/build/file/index.d.ts +3 -0
- package/dist/build-utils/build/file/index.js +5 -0
- package/dist/build-utils/build/file/sharding.d.ts +21 -0
- package/dist/build-utils/build/file/sharding.js +38 -0
- package/dist/build-utils/build/index.d.ts +5 -0
- package/dist/build-utils/build/index.js +11 -6
- package/dist/build-utils/build/json.d.ts +3 -0
- package/dist/build-utils/build/json.js +67 -0
- package/dist/build-utils/build/loader/probeLoader.d.ts +2 -2
- package/dist/build-utils/build/loader/probeLoader.js +4 -4
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +1 -1
- package/dist/build-utils/build/module-graph/index.d.ts +0 -3
- package/dist/build-utils/build/module-graph/index.js +0 -3
- package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
- package/dist/build-utils/build/module-graph/parser.js +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.js +7 -5
- package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
- package/dist/build-utils/build/module-graph/utils.js +5 -4
- package/dist/build-utils/build/process.d.ts +2 -0
- package/dist/build-utils/build/process.js +18 -0
- package/dist/build-utils/build/server.d.ts +15 -0
- package/dist/build-utils/build/server.js +107 -0
- package/dist/build-utils/build/utils/loader.d.ts +2 -2
- package/dist/build-utils/build/utils/loader.js +10 -19
- package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
- package/dist/build-utils/build/utils/parseBundle.js +6 -8
- package/dist/build-utils/build/utils/plugin.d.ts +1 -1
- package/dist/build-utils/build/utils/plugin.js +1 -2
- package/dist/build-utils/index.d.ts +10 -0
- package/dist/build-utils/index.js +12 -2
- package/dist/collection.d.ts +1 -0
- package/dist/collection.js +2 -0
- package/dist/common/file.d.ts +2 -0
- package/dist/common/file.js +8 -0
- package/dist/common/global-config.d.ts +21 -0
- package/dist/common/global-config.js +33 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +6 -0
- package/dist/common-browser.d.ts +1 -0
- package/dist/common-browser.js +2 -0
- package/dist/error/error.d.ts +35 -0
- package/dist/error/error.js +143 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.js +3 -0
- package/dist/error/transform.d.ts +3 -0
- package/dist/error/transform.js +138 -0
- package/dist/error/utils.d.ts +4 -0
- package/dist/error/utils.js +23 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/graph/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -2
- package/dist/inner-plugins/constants.d.ts +1 -1
- package/dist/inner-plugins/constants.js +1 -1
- package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
- package/dist/inner-plugins/plugins/base.d.ts +1 -1
- package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
- package/dist/inner-plugins/plugins/bundle.js +4 -20
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +6 -8
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +12 -77
- package/dist/inner-plugins/plugins/errors.d.ts +3 -3
- package/dist/inner-plugins/plugins/errors.js +6 -6
- package/dist/inner-plugins/plugins/index.d.ts +0 -1
- package/dist/inner-plugins/plugins/index.js +0 -1
- package/dist/inner-plugins/plugins/loader.d.ts +1 -1
- package/dist/inner-plugins/plugins/loader.js +8 -20
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/plugins.js +3 -3
- package/dist/inner-plugins/plugins/progress.d.ts +3 -3
- package/dist/inner-plugins/plugins/progress.js +16 -18
- package/dist/inner-plugins/plugins/resolver.d.ts +2 -3
- package/dist/inner-plugins/plugins/resolver.js +2 -2
- package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
- package/dist/inner-plugins/plugins/rspack.js +18 -4
- package/dist/inner-plugins/plugins/rules.d.ts +1 -1
- package/dist/inner-plugins/plugins/rules.js +6 -6
- package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
- package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
- package/dist/inner-plugins/plugins/summary.d.ts +1 -1
- package/dist/inner-plugins/plugins/summary.js +3 -3
- package/dist/inner-plugins/utils/config.d.ts +3 -4
- package/dist/inner-plugins/utils/config.js +4 -17
- package/dist/inner-plugins/utils/loader.d.ts +4 -7
- package/dist/inner-plugins/utils/loader.js +10 -36
- package/dist/inner-plugins/utils/normalize-config.d.ts +4 -7
- package/dist/inner-plugins/utils/openBrowser.d.ts +1 -0
- package/dist/inner-plugins/utils/openBrowser.js +55 -0
- package/dist/inner-plugins/utils/plugin-common.js +4 -4
- package/dist/inner-plugins/utils/plugin.d.ts +1 -1
- package/dist/inner-plugins/utils/plugin.js +1 -1
- package/dist/inner-plugins/utils/sdk.d.ts +2 -3
- package/dist/inner-plugins/utils/sdk.js +2 -2
- package/dist/logger.d.ts +9 -0
- package/dist/logger.js +51 -0
- package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +4 -1
- package/dist/rspack-plugin/constants.js +23 -0
- package/dist/rspack-plugin/index.d.ts +2 -0
- package/dist/rspack-plugin/index.js +3 -0
- package/dist/rspack-plugin/multiple.d.ts +8 -0
- package/dist/rspack-plugin/multiple.js +39 -0
- package/dist/rspack-plugin/plugin.d.ts +25 -0
- package/dist/rspack-plugin/plugin.js +133 -0
- package/dist/rule-utils/document/document.d.ts +16 -0
- package/dist/rule-utils/document/document.js +46 -0
- package/dist/rule-utils/document/index.d.ts +3 -0
- package/dist/rule-utils/document/index.js +4 -0
- package/dist/rule-utils/document/server.d.ts +4 -0
- package/dist/rule-utils/document/server.js +13 -0
- package/dist/rule-utils/document/types.d.ts +31 -0
- package/dist/rule-utils/index.d.ts +2 -0
- package/dist/rule-utils/index.js +3 -0
- package/dist/rule-utils/parser/asserts.d.ts +81 -0
- package/dist/rule-utils/parser/asserts.js +105 -0
- package/dist/rule-utils/parser/index.d.ts +4 -0
- package/dist/rule-utils/parser/index.js +5 -0
- package/dist/rule-utils/parser/parser.d.ts +118 -0
- package/dist/rule-utils/parser/parser.js +24 -0
- package/dist/rule-utils/parser/types.d.ts +30 -0
- package/dist/rule-utils/parser/types.js +8 -0
- package/dist/rule-utils/parser/utils.d.ts +30 -0
- package/dist/rule-utils/parser/utils.js +106 -0
- package/dist/rules/linter.d.ts +1 -1
- package/dist/rules/linter.js +1 -1
- package/dist/rules/rule.d.ts +2 -2
- package/dist/rules/rule.js +2 -2
- package/dist/rules/rules/cjs-require/index.d.ts +1 -1
- package/dist/rules/rules/cjs-require/index.js +3 -3
- package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
- package/dist/rules/rules/cross-chunks-package/index.js +2 -2
- package/dist/rules/rules/default-import-check/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/index.js +2 -2
- package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
- package/dist/rules/rules/default-import-check/utils.js +2 -2
- package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
- package/dist/rules/rules/duplicate-package/index.js +3 -3
- package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
- package/dist/rules/rules/ecma-version-check/index.js +1 -1
- package/dist/rules/rules/ecma-version-check/types.d.ts +1 -2
- package/dist/rules/rules/ecma-version-check/utils.d.ts +1 -1
- package/dist/rules/rules/esm-resolved-to-cjs/index.d.ts +1 -1
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +3 -18
- package/dist/rules/rules/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.js +3 -3
- package/dist/rules/rules/loader-performance-optimization/types.d.ts +1 -1
- package/dist/rules/rules/module-mixed-chunks/index.d.ts +1 -1
- package/dist/rules/rules/module-mixed-chunks/index.js +2 -2
- package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.js +2 -2
- package/dist/rules/utils.d.ts +1 -1
- package/dist/rules/utils.js +1 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +3 -0
- package/dist/sdk/multiple/controller.d.ts +12 -0
- package/dist/sdk/multiple/controller.js +42 -0
- package/dist/sdk/multiple/index.d.ts +2 -0
- package/dist/sdk/multiple/index.js +3 -0
- package/dist/sdk/multiple/primary.d.ts +32 -0
- package/dist/sdk/multiple/primary.js +64 -0
- package/dist/sdk/multiple/server.d.ts +7 -0
- package/dist/sdk/multiple/server.js +14 -0
- package/dist/sdk/sdk/core.d.ts +33 -0
- package/dist/sdk/sdk/core.js +163 -0
- package/dist/sdk/sdk/index.d.ts +52 -0
- package/dist/sdk/sdk/index.js +435 -0
- package/dist/sdk/sdk/types.d.ts +26 -0
- package/dist/sdk/sdk/types.js +1 -0
- package/dist/sdk/server/apis/alerts.d.ts +5 -0
- package/dist/sdk/server/apis/alerts.js +30 -0
- package/dist/sdk/server/apis/base.d.ts +11 -0
- package/dist/sdk/server/apis/base.js +22 -0
- package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
- package/dist/sdk/server/apis/bundle-diff.js +51 -0
- package/dist/sdk/server/apis/data.d.ts +6 -0
- package/dist/sdk/server/apis/data.js +44 -0
- package/dist/sdk/server/apis/fs.d.ts +5 -0
- package/dist/sdk/server/apis/fs.js +28 -0
- package/dist/sdk/server/apis/graph.d.ts +12 -0
- package/dist/sdk/server/apis/graph.js +116 -0
- package/dist/sdk/server/apis/index.d.ts +10 -0
- package/dist/sdk/server/apis/index.js +11 -0
- package/dist/sdk/server/apis/loader.d.ts +15 -0
- package/dist/sdk/server/apis/loader.js +120 -0
- package/dist/sdk/server/apis/plugin.d.ts +6 -0
- package/dist/sdk/server/apis/plugin.js +39 -0
- package/dist/sdk/server/apis/project.d.ts +8 -0
- package/dist/sdk/server/apis/project.js +59 -0
- package/dist/sdk/server/apis/renderer.d.ts +6 -0
- package/dist/sdk/server/apis/renderer.js +33 -0
- package/dist/sdk/server/apis/resolver.d.ts +6 -0
- package/dist/sdk/server/apis/resolver.js +38 -0
- package/dist/sdk/server/client.d.ts +3 -0
- package/dist/sdk/server/client.js +8 -0
- package/dist/sdk/server/fakeServer.d.ts +9 -0
- package/dist/sdk/server/fakeServer.js +12 -0
- package/dist/sdk/server/index.d.ts +44 -0
- package/dist/sdk/server/index.js +292 -0
- package/dist/sdk/server/json-body.d.ts +6 -0
- package/dist/sdk/server/json-body.js +150 -0
- package/dist/sdk/server/router.d.ts +24 -0
- package/dist/sdk/server/router.js +83 -0
- package/dist/sdk/server/security.d.ts +5 -0
- package/dist/sdk/server/security.js +47 -0
- package/dist/sdk/server/socket/api.d.ts +15 -0
- package/dist/sdk/server/socket/api.js +22 -0
- package/dist/sdk/server/socket/index.d.ts +48 -0
- package/dist/sdk/server/socket/index.js +166 -0
- package/dist/sdk/server/utils.d.ts +6 -0
- package/dist/sdk/server/utils.js +19 -0
- package/dist/sdk/utils/base.d.ts +1 -0
- package/dist/sdk/utils/base.js +22 -0
- package/dist/sdk/utils/constant.d.ts +1 -0
- package/dist/sdk/utils/constant.js +4 -0
- package/dist/sdk/utils/index.d.ts +3 -0
- package/dist/sdk/utils/index.js +4 -0
- package/dist/sdk/utils/openBrowser.d.ts +4 -0
- package/dist/sdk/utils/openBrowser.js +53 -0
- package/dist/sdk/utils/upload.d.ts +2 -0
- package/dist/sdk/utils/upload.js +6 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +2 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/loader.d.ts +1 -1
- package/dist/types/plugin.d.ts +7 -28
- package/dist/types/rules.d.ts +4 -4
- package/package.json +123 -55
- package/static/openChrome.applescript +95 -0
- package/dist/build-utils/build/chunks/assetsModules.cjs +0 -46
- package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
- package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -43
- package/dist/build-utils/build/chunks/chunkTransform.d.cts +0 -4
- package/dist/build-utils/build/chunks/chunkTransform.d.ts +0 -4
- package/dist/build-utils/build/chunks/chunkTransform.js +0 -6
- package/dist/build-utils/build/chunks/index.cjs +0 -76
- package/dist/build-utils/build/chunks/index.d.cts +0 -3
- package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -84
- package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
- package/dist/build-utils/build/index.cjs +0 -56
- package/dist/build-utils/build/index.d.cts +0 -5
- package/dist/build-utils/build/loader/index.cjs +0 -69
- package/dist/build-utils/build/loader/index.d.cts +0 -2
- package/dist/build-utils/build/loader/probeLoader.cjs +0 -93
- package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
- package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -69
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
- package/dist/build-utils/build/module-graph/index.cjs +0 -83
- package/dist/build-utils/build/module-graph/index.d.cts +0 -4
- package/dist/build-utils/build/module-graph/parser.cjs +0 -50
- package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
- package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -155
- package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
- package/dist/build-utils/build/module-graph/transform.cjs +0 -44
- package/dist/build-utils/build/module-graph/transform.d.cts +0 -4
- package/dist/build-utils/build/module-graph/transform.d.ts +0 -4
- package/dist/build-utils/build/module-graph/transform.js +0 -7
- package/dist/build-utils/build/module-graph/treeShaking.cjs +0 -110
- package/dist/build-utils/build/module-graph/treeShaking.d.cts +0 -2
- package/dist/build-utils/build/module-graph/treeShaking.d.ts +0 -2
- package/dist/build-utils/build/module-graph/treeShaking.js +0 -73
- package/dist/build-utils/build/module-graph/utils.cjs +0 -99
- package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
- package/dist/build-utils/build/module-graph/webpack/transform.cjs +0 -174
- package/dist/build-utils/build/module-graph/webpack/transform.d.cts +0 -16
- package/dist/build-utils/build/module-graph/webpack/transform.d.ts +0 -16
- package/dist/build-utils/build/module-graph/webpack/transform.js +0 -124
- package/dist/build-utils/build/utils/index.cjs +0 -76
- package/dist/build-utils/build/utils/index.d.cts +0 -3
- package/dist/build-utils/build/utils/loader.cjs +0 -358
- package/dist/build-utils/build/utils/loader.d.cts +0 -20
- package/dist/build-utils/build/utils/parseBundle.cjs +0 -287
- package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
- package/dist/build-utils/build/utils/plugin.cjs +0 -65
- package/dist/build-utils/build/utils/plugin.d.cts +0 -5
- package/dist/build-utils/index.cjs +0 -40
- package/dist/build-utils/index.d.cts +0 -1
- package/dist/index.cjs +0 -85
- package/dist/index.d.cts +0 -3
- package/dist/inner-plugins/constants.cjs +0 -68
- package/dist/inner-plugins/index.cjs +0 -69
- package/dist/inner-plugins/index.d.cts +0 -2
- package/dist/inner-plugins/loaders/proxy.cjs +0 -108
- package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
- package/dist/inner-plugins/plugins/base.cjs +0 -57
- package/dist/inner-plugins/plugins/base.d.cts +0 -12
- package/dist/inner-plugins/plugins/bundle.cjs +0 -116
- package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
- package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +0 -88
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.cts +0 -6
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts +0 -6
- package/dist/inner-plugins/plugins/bundleTagPlugin.js +0 -51
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -182
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -36
- package/dist/inner-plugins/plugins/errors.cjs +0 -102
- package/dist/inner-plugins/plugins/errors.d.cts +0 -11
- package/dist/inner-plugins/plugins/index.cjs +0 -132
- package/dist/inner-plugins/plugins/index.d.cts +0 -11
- package/dist/inner-plugins/plugins/loader.cjs +0 -169
- package/dist/inner-plugins/plugins/loader.d.cts +0 -10
- package/dist/inner-plugins/plugins/plugins.cjs +0 -77
- package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
- package/dist/inner-plugins/plugins/progress.cjs +0 -74
- package/dist/inner-plugins/plugins/progress.d.cts +0 -8
- package/dist/inner-plugins/plugins/resolver.cjs +0 -94
- package/dist/inner-plugins/plugins/resolver.d.cts +0 -13
- package/dist/inner-plugins/plugins/rspack.cjs +0 -122
- package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
- package/dist/inner-plugins/plugins/rules.cjs +0 -101
- package/dist/inner-plugins/plugins/rules.d.cts +0 -8
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -279
- package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
- package/dist/inner-plugins/plugins/summary.cjs +0 -129
- package/dist/inner-plugins/plugins/summary.d.cts +0 -14
- package/dist/inner-plugins/utils/circleDetect.cjs +0 -53
- package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
- package/dist/inner-plugins/utils/config.cjs +0 -207
- package/dist/inner-plugins/utils/config.d.cts +0 -5
- package/dist/inner-plugins/utils/index.cjs +0 -110
- package/dist/inner-plugins/utils/index.d.cts +0 -9
- package/dist/inner-plugins/utils/loader.cjs +0 -222
- package/dist/inner-plugins/utils/loader.d.cts +0 -13
- package/dist/inner-plugins/utils/normalize-config.cjs +0 -126
- package/dist/inner-plugins/utils/normalize-config.d.cts +0 -40
- package/dist/inner-plugins/utils/plugin-common.cjs +0 -147
- package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
- package/dist/inner-plugins/utils/plugin.cjs +0 -110
- package/dist/inner-plugins/utils/plugin.d.cts +0 -4
- package/dist/inner-plugins/utils/sdk.cjs +0 -59
- package/dist/inner-plugins/utils/sdk.d.cts +0 -8
- package/dist/rslib-runtime.js +0 -19
- package/dist/rules/index.cjs +0 -85
- package/dist/rules/index.d.cts +0 -3
- package/dist/rules/linter.cjs +0 -76
- package/dist/rules/linter.d.cts +0 -9
- package/dist/rules/rule.cjs +0 -141
- package/dist/rules/rule.d.cts +0 -27
- package/dist/rules/rules/cjs-require/index.cjs +0 -87
- package/dist/rules/rules/cjs-require/index.d.cts +0 -4
- package/dist/rules/rules/cjs-require/types.cjs +0 -18
- package/dist/rules/rules/cjs-require/types.d.cts +0 -7
- package/dist/rules/rules/cross-chunks-package/index.cjs +0 -78
- package/dist/rules/rules/cross-chunks-package/index.d.cts +0 -4
- package/dist/rules/rules/cross-chunks-package/types.cjs +0 -18
- package/dist/rules/rules/cross-chunks-package/types.d.cts +0 -3
- package/dist/rules/rules/cross-chunks-package/utils.cjs +0 -44
- package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
- package/dist/rules/rules/default-import-check/index.cjs +0 -120
- package/dist/rules/rules/default-import-check/index.d.cts +0 -4
- package/dist/rules/rules/default-import-check/types.cjs +0 -18
- package/dist/rules/rules/default-import-check/types.d.cts +0 -4
- package/dist/rules/rules/default-import-check/utils.cjs +0 -101
- package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
- package/dist/rules/rules/duplicate-package/index.cjs +0 -76
- package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
- package/dist/rules/rules/duplicate-package/types.cjs +0 -64
- package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
- package/dist/rules/rules/duplicate-package/utils.cjs +0 -88
- package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
- package/dist/rules/rules/ecma-version-check/index.cjs +0 -100
- package/dist/rules/rules/ecma-version-check/index.d.cts +0 -4
- package/dist/rules/rules/ecma-version-check/types.cjs +0 -18
- package/dist/rules/rules/ecma-version-check/types.d.cts +0 -3
- package/dist/rules/rules/ecma-version-check/utils.cjs +0 -43
- package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
- package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -256
- package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +0 -4
- package/dist/rules/rules/esm-resolved-to-cjs/types.cjs +0 -18
- package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +0 -8
- package/dist/rules/rules/index.cjs +0 -59
- package/dist/rules/rules/index.d.cts +0 -2
- package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -123
- package/dist/rules/rules/loader-performance-optimization/index.d.cts +0 -4
- package/dist/rules/rules/loader-performance-optimization/types.cjs +0 -18
- package/dist/rules/rules/loader-performance-optimization/types.d.cts +0 -22
- package/dist/rules/rules/loader-performance-optimization/utils.cjs +0 -47
- package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
- package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -89
- package/dist/rules/rules/module-mixed-chunks/index.d.cts +0 -4
- package/dist/rules/rules/module-mixed-chunks/types.cjs +0 -18
- package/dist/rules/rules/module-mixed-chunks/types.d.cts +0 -3
- package/dist/rules/rules/side-effects-only-imports/index.cjs +0 -118
- package/dist/rules/rules/side-effects-only-imports/index.d.cts +0 -4
- package/dist/rules/rules/side-effects-only-imports/types.cjs +0 -18
- package/dist/rules/rules/side-effects-only-imports/types.d.cts +0 -9
- package/dist/rules/utils.cjs +0 -50
- package/dist/rules/utils.d.cts +0 -3
- package/dist/types/chunks.cjs +0 -18
- package/dist/types/chunks.d.cts +0 -6
- package/dist/types/chunks.d.ts +0 -6
- package/dist/types/index.cjs +0 -83
- package/dist/types/index.d.cts +0 -4
- package/dist/types/loader.cjs +0 -18
- package/dist/types/loader.d.cts +0 -19
- package/dist/types/plugin.cjs +0 -18
- package/dist/types/plugin.d.cts +0 -51
- package/dist/types/rules.cjs +0 -18
- package/dist/types/rules.d.cts +0 -7
- /package/dist/{types/chunks.js → rule-utils/document/types.js} +0 -0
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
1
|
+
import "node:module";
|
|
3
2
|
import node_path from "node:path";
|
|
4
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
5
|
import fs_extra from "fs-extra";
|
|
6
|
-
import { omit } from "
|
|
7
|
-
import { Loader } from "
|
|
8
|
-
import { readPackageJson } from "
|
|
9
|
-
import { logger } from "
|
|
10
|
-
import { __webpack_require__ } from "../../../rslib-runtime.js";
|
|
11
|
-
import { createRequire as __rspack_createRequire } from "node:module";
|
|
12
|
-
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
13
|
-
__webpack_require__.add({
|
|
14
|
-
"module?2382" (module) {
|
|
15
|
-
module.exports = __rspack_createRequire_require("module");
|
|
16
|
-
}
|
|
17
|
-
});
|
|
6
|
+
import { omit } from "../../../collection.js";
|
|
7
|
+
import { Loader } from "../../../common/index.js";
|
|
8
|
+
import { readPackageJson } from "../json.js";
|
|
9
|
+
import { logger } from "../../../logger.js";
|
|
18
10
|
const loader_filename = fileURLToPath(import.meta.url);
|
|
19
11
|
const loader_dirname = node_path.dirname(loader_filename);
|
|
12
|
+
const loader_require = createRequire(import.meta.url);
|
|
20
13
|
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
|
21
14
|
function parsePathQueryFragment(str) {
|
|
22
15
|
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
@@ -28,9 +21,7 @@ function parsePathQueryFragment(str) {
|
|
|
28
21
|
}
|
|
29
22
|
function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
30
23
|
const cleanLoaderPath = parsePathQueryFragment(loaderPath).path;
|
|
31
|
-
const
|
|
32
|
-
const requireFn = createRequire(import.meta.url);
|
|
33
|
-
const mod = requireFn(process.env.DOCTOR_TEST ? node_path.resolve(cwd, cleanLoaderPath) : requireFn.resolve(cleanLoaderPath, {
|
|
24
|
+
const mod = loader_require(process.env.DOCTOR_TEST ? node_path.resolve(cwd, cleanLoaderPath) : loader_require.resolve(cleanLoaderPath, {
|
|
34
25
|
paths: [
|
|
35
26
|
cwd,
|
|
36
27
|
node_path.resolve(cwd, 'node_modules')
|
|
@@ -134,7 +125,7 @@ function appendProbeLoaders(compiler, loaderConfig) {
|
|
|
134
125
|
const _options = 'object' == typeof loaderConfig ? 'string' == typeof loaderConfig.options ? {
|
|
135
126
|
options: loaderConfig.options
|
|
136
127
|
} : loaderConfig.options : {};
|
|
137
|
-
const loaderPath = process.env.DOCTOR_TEST ? node_path.resolve(loader_dirname, '../loader/probeLoader.ts') :
|
|
128
|
+
const loaderPath = process.env.DOCTOR_TEST ? node_path.resolve(loader_dirname, '../loader/probeLoader.ts') : loader_require.resolve(node_path.join(loader_dirname, '../loader/probeLoader'));
|
|
138
129
|
const loader = 'string' == typeof loaderConfig ? loaderConfig : 'object' == typeof loaderConfig && loaderConfig.loader;
|
|
139
130
|
const createProbeLoader = (type)=>({
|
|
140
131
|
loader: loaderPath,
|
|
@@ -228,7 +219,7 @@ function createLoaderContextTrap(final) {
|
|
|
228
219
|
case 'query':
|
|
229
220
|
if (target.query) {
|
|
230
221
|
if ('string' == typeof target.query) {
|
|
231
|
-
const res = target.query.replace(new RegExp(`"${Loader.LoaderInternalPropertyName}"
|
|
222
|
+
const res = target.query.replace(new RegExp(`"${Loader.LoaderInternalPropertyName}":{[^}]*},{0,1}`), '');
|
|
232
223
|
return res;
|
|
233
224
|
}
|
|
234
225
|
if ('object' == typeof target.query) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParseBundle } from '
|
|
1
|
+
import type { ParseBundle } from '../../../graph/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* The following code is based on
|
|
4
4
|
* https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/src/parseUtils.js#L10
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import { find, mapValues } from "
|
|
3
|
+
import { find, mapValues } from "../../../collection.js";
|
|
4
4
|
import { filesize } from "filesize";
|
|
5
|
-
import { parser } from "
|
|
5
|
+
import { parser } from "../../../rule-utils/index.js";
|
|
6
6
|
import { extname } from "path";
|
|
7
|
-
import { Constants } from "@rsdoctor/types";
|
|
8
|
-
import { logger } from "
|
|
7
|
+
import { Constants } from "@rsdoctor/shared/types";
|
|
8
|
+
import { logger } from "../../../logger.js";
|
|
9
9
|
const parseBundle = (bundlePath, modulesData)=>{
|
|
10
10
|
if (bundlePath.indexOf('.worker.') > 0) return {};
|
|
11
11
|
const ext = extname(bundlePath);
|
|
@@ -20,7 +20,7 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
20
20
|
content = tagMatchResult.result?.trim() || content;
|
|
21
21
|
tagCache.set(bundlePath, tagMatchResult.loc);
|
|
22
22
|
hasBannerPlugin = true;
|
|
23
|
-
} else if (hasBannerPlugin &&
|
|
23
|
+
} else if (hasBannerPlugin && tagCache.get(bundlePath)) {
|
|
24
24
|
const loc = tagCache.get(bundlePath);
|
|
25
25
|
content = content.slice(loc.start, loc.end);
|
|
26
26
|
hasBannerPlugin = true;
|
|
@@ -108,9 +108,7 @@ const parseBundle = (bundlePath, modulesData)=>{
|
|
|
108
108
|
if (!module) return {};
|
|
109
109
|
const moduleContent = modules[module];
|
|
110
110
|
const size = moduleContent && Buffer.byteLength(moduleContent);
|
|
111
|
-
const identifier = find(modulesData,
|
|
112
|
-
renderId: module
|
|
113
|
-
})?.webpackId || '';
|
|
111
|
+
const identifier = find(modulesData, (item)=>item.renderId === module)?.identifier || '';
|
|
114
112
|
modulesObj[identifier] = {
|
|
115
113
|
size,
|
|
116
114
|
sizeConvert: filesize(size || 0),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '@rsdoctor/types';
|
|
1
|
+
import type { Plugin } from '@rsdoctor/shared/types';
|
|
2
2
|
export type IHook = Plugin.BaseCompiler['hooks'][keyof Plugin.BaseCompiler['hooks']];
|
|
3
3
|
export declare function shouldInterceptPluginHook<T extends IHook>(hook: T): boolean;
|
|
4
4
|
export declare function interceptCompilerHooks(compiler: Plugin.BaseCompiler, interceptor: (name: string, hook: IHook, scope: 'compiler') => void): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { ModuleGraphTrans } from "@rsdoctor/graph";
|
|
3
2
|
function shouldInterceptPluginHook(hook) {
|
|
4
3
|
if (hook && hook._fakeHook) return false;
|
|
5
4
|
if (hook?.isUsed && 'function' == typeof hook.isUsed) return hook.isUsed();
|
|
@@ -14,7 +13,7 @@ function interceptCompilerHooks(compiler, interceptor) {
|
|
|
14
13
|
}
|
|
15
14
|
function interceptCompilationHooks(compilation, interceptor) {
|
|
16
15
|
Object.keys(compilation.hooks).forEach((hook)=>{
|
|
17
|
-
if ('normalModuleLoader' === hook
|
|
16
|
+
if ('normalModuleLoader' === hook) return;
|
|
18
17
|
const v = compilation.hooks[hook];
|
|
19
18
|
if (shouldInterceptPluginHook(v)) interceptor(hook, v, 'compilation');
|
|
20
19
|
});
|
|
@@ -1 +1,11 @@
|
|
|
1
1
|
export * as Build from './build/index.js';
|
|
2
|
+
export * as EnvInfo from './build/envinfo.js';
|
|
3
|
+
export * as File from './build/file/index.js';
|
|
4
|
+
export * as Json from './build/json.js';
|
|
5
|
+
export * as Process from './build/process.js';
|
|
6
|
+
export * as Server from './build/server.js';
|
|
7
|
+
export * as Chunks from './build/chunks/index.js';
|
|
8
|
+
export * as Utils from './build/utils/index.js';
|
|
9
|
+
export * as Loader from './build/loader/index.js';
|
|
10
|
+
export * as Types from '../types/index.js';
|
|
11
|
+
export * as ModuleGraph from './build/module-graph/index.js';
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import * as
|
|
3
|
-
|
|
2
|
+
import * as __rspack_external__build_index_js_dd3d3112 from "./build/index.js";
|
|
3
|
+
import * as __rspack_external__build_envinfo_js_bb7cc383 from "./build/envinfo.js";
|
|
4
|
+
import * as __rspack_external__build_file_index_js_b486e89f from "./build/file/index.js";
|
|
5
|
+
import * as __rspack_external__build_json_js_4cd59ece from "./build/json.js";
|
|
6
|
+
import * as __rspack_external__build_process_js_dbdc7299 from "./build/process.js";
|
|
7
|
+
import * as __rspack_external__build_server_js_f760cf8d from "./build/server.js";
|
|
8
|
+
import * as __rspack_external__build_chunks_index_js_b63f9e6b from "./build/chunks/index.js";
|
|
9
|
+
import * as __rspack_external__build_utils_index_js_2ab2484c from "./build/utils/index.js";
|
|
10
|
+
import * as __rspack_external__build_loader_index_js_a995ea1e from "./build/loader/index.js";
|
|
11
|
+
import * as __rspack_external__types_index_js_b312a465 from "../types/index.js";
|
|
12
|
+
import * as __rspack_external__build_module_graph_index_js_808da562 from "./build/module-graph/index.js";
|
|
13
|
+
export { __rspack_external__build_chunks_index_js_b63f9e6b as Chunks, __rspack_external__build_envinfo_js_bb7cc383 as EnvInfo, __rspack_external__build_file_index_js_b486e89f as File, __rspack_external__build_index_js_dd3d3112 as Build, __rspack_external__build_json_js_4cd59ece as Json, __rspack_external__build_loader_index_js_a995ea1e as Loader, __rspack_external__build_module_graph_index_js_808da562 as ModuleGraph, __rspack_external__build_process_js_dbdc7299 as Process, __rspack_external__build_server_js_f760cf8d as Server, __rspack_external__build_utils_index_js_2ab2484c as Utils, __rspack_external__types_index_js_b312a465 as Types };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@rsdoctor/shared/collection';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Writes the builder port information to mcp.json.
|
|
3
|
+
*
|
|
4
|
+
* The mcp.json file uses the following format:
|
|
5
|
+
* {
|
|
6
|
+
* portList: {
|
|
7
|
+
* builder1: portNumber,
|
|
8
|
+
* builder2: portNumber,
|
|
9
|
+
* },
|
|
10
|
+
* port: portNumber, // The port of the last builder is used by default
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* @param {number} port - The port number to write.
|
|
14
|
+
* @param {string} [builderName] - The name of the builder.
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeMcpPort(port: number, builderName?: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* @description Gets the path to the mcp.json file.
|
|
19
|
+
* @returns {string} The path to the mcp.json file.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getMcpConfigPath(): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import os from "os";
|
|
5
|
+
import { logger } from "../logger.js";
|
|
6
|
+
function writeMcpPort(port, builderName) {
|
|
7
|
+
const homeDir = os.homedir();
|
|
8
|
+
const rsdoctorDir = path.join(homeDir, '.cache/rsdoctor');
|
|
9
|
+
const mcpPortFilePath = path.join(rsdoctorDir, 'mcp.json');
|
|
10
|
+
if (!fs.existsSync(rsdoctorDir)) fs.mkdirSync(rsdoctorDir, {
|
|
11
|
+
recursive: true
|
|
12
|
+
});
|
|
13
|
+
let mcpJson = {
|
|
14
|
+
portList: {},
|
|
15
|
+
port: 0
|
|
16
|
+
};
|
|
17
|
+
if (fs.existsSync(mcpPortFilePath)) try {
|
|
18
|
+
mcpJson = JSON.parse(fs.readFileSync(mcpPortFilePath, 'utf8'));
|
|
19
|
+
} catch (error) {
|
|
20
|
+
logger.debug('Failed to parse mcp.json', error);
|
|
21
|
+
}
|
|
22
|
+
if (!mcpJson.portList) mcpJson.portList = {};
|
|
23
|
+
mcpJson.portList[builderName || 'builder'] = port;
|
|
24
|
+
mcpJson.port = port;
|
|
25
|
+
fs.writeFileSync(mcpPortFilePath, JSON.stringify(mcpJson, null, 2), 'utf8');
|
|
26
|
+
}
|
|
27
|
+
function getMcpConfigPath() {
|
|
28
|
+
const homeDir = os.homedir();
|
|
29
|
+
const rsdoctorDir = path.join(homeDir, '.cache/rsdoctor');
|
|
30
|
+
const mcpPortFilePath = path.join(rsdoctorDir, 'mcp.json');
|
|
31
|
+
return mcpPortFilePath;
|
|
32
|
+
}
|
|
33
|
+
export { getMcpConfigPath, writeMcpPort };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Alerts, Algorithm, Bundle, Crypto, Data, Fetch, Graph, Loader, Lodash, Manifest, Package, Plugin, Resolver, Rspack, Summary, Time, Url, } from '@rsdoctor/shared/common-browser';
|
|
2
|
+
export * as GlobalConfig from './global-config.js';
|
|
3
|
+
export * as File from './file.js';
|
|
4
|
+
export * from '@rsdoctor/shared/common-browser';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import * as __rspack_external__file_js_9fa33ca6 from "./file.js";
|
|
3
|
+
import * as __rspack_external__global_config_js_a07079db from "./global-config.js";
|
|
4
|
+
export * from "@rsdoctor/shared/common-browser";
|
|
5
|
+
export { Alerts, Algorithm, Bundle, Crypto, Data, Fetch, Graph, Loader, Lodash, Manifest, Package, Plugin, Resolver, Rspack, Summary, Time, Url } from "@rsdoctor/shared/common-browser";
|
|
6
|
+
export { __rspack_external__file_js_9fa33ca6 as File, __rspack_external__global_config_js_a07079db as GlobalConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@rsdoctor/shared/common-browser';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Err, Rule } from '@rsdoctor/shared/types';
|
|
2
|
+
export declare class DevToolError extends Error implements Err.DevToolErrorInstance {
|
|
3
|
+
static from(err: unknown, opt?: Err.DevToolErrorParams): DevToolError;
|
|
4
|
+
readonly id: number;
|
|
5
|
+
readonly code?: string;
|
|
6
|
+
readonly category?: string;
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly detail?: any;
|
|
9
|
+
readonly fixData?: Err.FixData;
|
|
10
|
+
readonly hint?: string;
|
|
11
|
+
readonly referenceUrl?: string;
|
|
12
|
+
private _codeFrame?;
|
|
13
|
+
private _controller;
|
|
14
|
+
private readonly _level;
|
|
15
|
+
constructor(title: string, message: string, opts?: Err.DevToolErrorParams);
|
|
16
|
+
get level(): keyof typeof Err.ErrorLevel;
|
|
17
|
+
get path(): string | undefined;
|
|
18
|
+
set path(file: string | undefined);
|
|
19
|
+
get codeFrame(): Err.CodeFrameOption | undefined;
|
|
20
|
+
private printCodeFrame;
|
|
21
|
+
toString(): string;
|
|
22
|
+
toData(): Rule.RuleStoreDataItem;
|
|
23
|
+
toError(): Error;
|
|
24
|
+
/**
|
|
25
|
+
* for json stringify
|
|
26
|
+
*/
|
|
27
|
+
toJSON(): {
|
|
28
|
+
message: string;
|
|
29
|
+
name: string;
|
|
30
|
+
stack: string | undefined;
|
|
31
|
+
};
|
|
32
|
+
setControllerOption(opt: Err.ControllerOption): void;
|
|
33
|
+
setCodeFrame(opt: Err.CodeFrameOption): void;
|
|
34
|
+
isSame(error: Err.DevToolErrorInstance): boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { codeFrameColumns } from "@babel/code-frame";
|
|
3
|
+
import { Lodash } from "../common/index.js";
|
|
4
|
+
import { Err } from "@rsdoctor/shared/types";
|
|
5
|
+
import { createColors } from "picocolors";
|
|
6
|
+
import deep_eql from "deep-eql";
|
|
7
|
+
import strip_ansi from "strip-ansi";
|
|
8
|
+
import { transform } from "./transform.js";
|
|
9
|
+
import { insertSpace, toLevel } from "./utils.js";
|
|
10
|
+
let id = 1;
|
|
11
|
+
class DevToolError extends Error {
|
|
12
|
+
static from(err, opt) {
|
|
13
|
+
if (err instanceof DevToolError) return err;
|
|
14
|
+
return transform(err, opt);
|
|
15
|
+
}
|
|
16
|
+
get level() {
|
|
17
|
+
return Err.ErrorLevel[this._level];
|
|
18
|
+
}
|
|
19
|
+
get path() {
|
|
20
|
+
return this._codeFrame?.filePath;
|
|
21
|
+
}
|
|
22
|
+
set path(file) {
|
|
23
|
+
if (!file) return;
|
|
24
|
+
if (this._codeFrame) {
|
|
25
|
+
this._codeFrame.filePath = file;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this._codeFrame = {
|
|
29
|
+
filePath: file
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
get codeFrame() {
|
|
33
|
+
return this._codeFrame;
|
|
34
|
+
}
|
|
35
|
+
printCodeFrame(print) {
|
|
36
|
+
const msgs = [];
|
|
37
|
+
const { _codeFrame: codeFrameOpt, _controller: controller } = this;
|
|
38
|
+
if (!codeFrameOpt) return msgs;
|
|
39
|
+
if ('start' in codeFrameOpt && codeFrameOpt.start) {
|
|
40
|
+
const { filePath, start } = codeFrameOpt;
|
|
41
|
+
msgs.push(`\n ${print.red(print.bold('File: '))}${print.bold(filePath)}:${start.line}${start.column ? `:${start.column}` : ''}`);
|
|
42
|
+
if ('fileContent' in codeFrameOpt) {
|
|
43
|
+
const { end, fileContent } = codeFrameOpt;
|
|
44
|
+
msgs.push(codeFrameColumns(fileContent, {
|
|
45
|
+
start,
|
|
46
|
+
end
|
|
47
|
+
}, {
|
|
48
|
+
highlightCode: !controller.noColor
|
|
49
|
+
}));
|
|
50
|
+
} else if ('lineText' in codeFrameOpt) {
|
|
51
|
+
const { length, lineText } = codeFrameOpt;
|
|
52
|
+
let lineCodeFrame = codeFrameColumns(lineText, {
|
|
53
|
+
start: {
|
|
54
|
+
line: 1,
|
|
55
|
+
column: start.column
|
|
56
|
+
},
|
|
57
|
+
end: {
|
|
58
|
+
line: 1,
|
|
59
|
+
column: Lodash.isNil(start.column) || Lodash.isNil(length) ? void 0 : start.column + length
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
highlightCode: !controller.noColor
|
|
63
|
+
});
|
|
64
|
+
if (start.line > 1) {
|
|
65
|
+
lineCodeFrame = lineCodeFrame.replace(' 1 |', ` ${start.line} |`);
|
|
66
|
+
if (start.line >= 10) lineCodeFrame = insertSpace(lineCodeFrame, 2, String(start.line).length - 1);
|
|
67
|
+
}
|
|
68
|
+
msgs.push(lineCodeFrame);
|
|
69
|
+
}
|
|
70
|
+
} else msgs.push(`\n ${print.red(print.bold('File: '))}${print.bold(codeFrameOpt.filePath)}\n`);
|
|
71
|
+
return msgs;
|
|
72
|
+
}
|
|
73
|
+
toString() {
|
|
74
|
+
const msgs = [];
|
|
75
|
+
const { code, title, message, hint, referenceUrl, _controller: controller } = this;
|
|
76
|
+
const print = createColors(!controller.noColor);
|
|
77
|
+
const mainColorPrint = this._level === Err.ErrorLevel.Error ? print.red : print.yellow;
|
|
78
|
+
const codeText = code ? `${mainColorPrint(print.blue(code))}:` : '';
|
|
79
|
+
msgs.push(mainColorPrint(print.bold(`[${codeText}${this.level}:${title.toUpperCase()}] `) + message));
|
|
80
|
+
msgs.push(...this.printCodeFrame(print));
|
|
81
|
+
if (hint || referenceUrl) msgs.push('');
|
|
82
|
+
if (hint) msgs.push(` ${print.blue(`HINT: ${hint}`)}`);
|
|
83
|
+
if (referenceUrl) msgs.push(print.magenta(print.bold(` See: ${referenceUrl}`)));
|
|
84
|
+
if (!controller.noStack && this.stack) msgs.push(print.red(print.bold(` Error Stack:\n${this.stack}\n`)));
|
|
85
|
+
return msgs.join('\n');
|
|
86
|
+
}
|
|
87
|
+
toData() {
|
|
88
|
+
return {
|
|
89
|
+
...this.detail,
|
|
90
|
+
id: this.id,
|
|
91
|
+
category: this.category,
|
|
92
|
+
description: strip_ansi(this.detail?.description ?? this.message),
|
|
93
|
+
title: this.title.toUpperCase(),
|
|
94
|
+
code: this.code,
|
|
95
|
+
level: this.level.toLowerCase()
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
toError() {
|
|
99
|
+
const error = new Error();
|
|
100
|
+
error.message = this.toString();
|
|
101
|
+
error.name = this.name;
|
|
102
|
+
error.stack = this.stack;
|
|
103
|
+
return error;
|
|
104
|
+
}
|
|
105
|
+
toJSON() {
|
|
106
|
+
return {
|
|
107
|
+
message: this.toString(),
|
|
108
|
+
name: this.name,
|
|
109
|
+
stack: this.stack
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
setControllerOption(opt) {
|
|
113
|
+
this._controller = {
|
|
114
|
+
noStack: opt.noStack ?? this._controller.noStack ?? true,
|
|
115
|
+
noColor: opt.noColor ?? this._controller.noColor ?? false
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
setCodeFrame(opt) {
|
|
119
|
+
this._codeFrame = opt;
|
|
120
|
+
}
|
|
121
|
+
isSame(error) {
|
|
122
|
+
return this.code === error.code && this.message === error.message && this.hint === error.hint && this.level === error.level && this.title === error.title && this.referenceUrl === error.referenceUrl && this.code === error.code && deep_eql(this.codeFrame, error.codeFrame);
|
|
123
|
+
}
|
|
124
|
+
constructor(title, message, opts){
|
|
125
|
+
super(message), this._controller = {
|
|
126
|
+
noStack: true,
|
|
127
|
+
noColor: false
|
|
128
|
+
};
|
|
129
|
+
this.id = id++;
|
|
130
|
+
this.title = title;
|
|
131
|
+
this.code = opts?.code;
|
|
132
|
+
this.hint = opts?.hint;
|
|
133
|
+
this.stack = opts?.stack;
|
|
134
|
+
this.detail = opts?.detail;
|
|
135
|
+
this.fixData = opts?.fixData;
|
|
136
|
+
this.category = opts?.category;
|
|
137
|
+
this.referenceUrl = opts?.referenceUrl;
|
|
138
|
+
this._level = opts?.level ? toLevel(opts.level) : Err.ErrorLevel.Error;
|
|
139
|
+
this._codeFrame = opts?.codeFrame;
|
|
140
|
+
this.setControllerOption(opts?.controller ?? {});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export { DevToolError };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import strip_ansi from "strip-ansi";
|
|
3
|
+
import { Linter } from "@rsdoctor/shared/types";
|
|
4
|
+
import { DevToolError } from "./error.js";
|
|
5
|
+
const MAX_ERROR_MESSAGE_LENGTH = 1000;
|
|
6
|
+
function truncateMessage(input, maxLen = MAX_ERROR_MESSAGE_LENGTH) {
|
|
7
|
+
const str = 'string' == typeof input ? input : String(input ?? '');
|
|
8
|
+
return str.length > maxLen ? str.slice(0, maxLen) : str;
|
|
9
|
+
}
|
|
10
|
+
function isEsbuildError(err) {
|
|
11
|
+
return 'pluginName' in err && 'text' in err && 'location' in err;
|
|
12
|
+
}
|
|
13
|
+
function isBabelError(err) {
|
|
14
|
+
return 'code' in err && 'reasonCode' in err;
|
|
15
|
+
}
|
|
16
|
+
function isDiagnosticError(err) {
|
|
17
|
+
return 'severity' in err && 'title' in err;
|
|
18
|
+
}
|
|
19
|
+
function parseBabelErrorMessage(input) {
|
|
20
|
+
const lines = strip_ansi(truncateMessage(input)).split('\n');
|
|
21
|
+
const filePath = lines[0].replace(/^([^:]+):.*/, '$1');
|
|
22
|
+
const message = lines[0].replace(/.*: (.*) \(\d+:\d+\)*/, '$1');
|
|
23
|
+
const lineText = lines.find((line)=>line.startsWith('> '))?.replace(/> \d+ \| /, '') ?? '';
|
|
24
|
+
return {
|
|
25
|
+
message,
|
|
26
|
+
filePath,
|
|
27
|
+
lineText
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function clearMessage(str) {
|
|
31
|
+
return strip_ansi(truncateMessage(str)).replace(/.*: (.*)\n\n[\s\S]*/g, '$1');
|
|
32
|
+
}
|
|
33
|
+
function clearStack(str) {
|
|
34
|
+
return str.slice(str.indexOf(' at')).replace(/\s*at(.*) \((.*)\)/g, '$1\n$2\n');
|
|
35
|
+
}
|
|
36
|
+
function transformEsbuildError(err, opt) {
|
|
37
|
+
if (isEsbuildError(err)) {
|
|
38
|
+
const errorCode = opt?.code ?? 'ESBUILD_ERROR';
|
|
39
|
+
const speedyError = 'object' == typeof err.detail ? DevToolError.from(err.detail) : new DevToolError(errorCode, clearMessage(err.text), {
|
|
40
|
+
...opt,
|
|
41
|
+
hint: err.location?.suggestion,
|
|
42
|
+
codeFrame: {
|
|
43
|
+
filePath: err.text.split(':')[0]
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
if (err.location) speedyError.setCodeFrame({
|
|
47
|
+
filePath: err.location.file,
|
|
48
|
+
lineText: err.location.lineText,
|
|
49
|
+
length: err.location.length,
|
|
50
|
+
start: {
|
|
51
|
+
line: err.location.line,
|
|
52
|
+
column: err.location.column + 1
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return speedyError;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function transformBabelError(err, opt) {
|
|
59
|
+
if (isBabelError(err)) {
|
|
60
|
+
const errorCode = opt?.code ?? err.code ?? 'BABEL';
|
|
61
|
+
const title = err.reasonCode;
|
|
62
|
+
const errorParsed = parseBabelErrorMessage(err.message);
|
|
63
|
+
const speedyError = new DevToolError(title, truncateMessage(errorParsed.message), {
|
|
64
|
+
...opt,
|
|
65
|
+
code: errorCode,
|
|
66
|
+
stack: err.stack && clearStack(err.stack)
|
|
67
|
+
});
|
|
68
|
+
if (err.loc) speedyError.setCodeFrame({
|
|
69
|
+
...errorParsed,
|
|
70
|
+
start: {
|
|
71
|
+
line: err.loc.line,
|
|
72
|
+
column: err.loc.column + 1
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return speedyError;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function transformNormalError(err, opt) {
|
|
79
|
+
if (err instanceof Error) {
|
|
80
|
+
const stacks = [];
|
|
81
|
+
const filePath = stacks?.[0]?.getFileName?.();
|
|
82
|
+
return new DevToolError(err.name, clearMessage(err.message), {
|
|
83
|
+
...opt,
|
|
84
|
+
codeFrame: filePath ? {
|
|
85
|
+
filePath
|
|
86
|
+
} : void 0,
|
|
87
|
+
stack: err.stack && clearStack(err.stack)
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function transformErrorLike(err, opt) {
|
|
92
|
+
const isErrorLike = err && 'object' == typeof err && err.message;
|
|
93
|
+
if (isErrorLike) {
|
|
94
|
+
const stacks = [];
|
|
95
|
+
const filePath = stacks?.[0]?.getFileName?.();
|
|
96
|
+
const message = truncateMessage(err.message);
|
|
97
|
+
return new DevToolError(err.name || 'UNKNOWN_ERROR', clearMessage(message), {
|
|
98
|
+
...opt,
|
|
99
|
+
codeFrame: filePath ? {
|
|
100
|
+
filePath
|
|
101
|
+
} : void 0,
|
|
102
|
+
stack: err.stack && clearStack(err.stack)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function transformDiagnostic(err, opt) {
|
|
107
|
+
if (isDiagnosticError(err)) return new DevToolError(err.title, truncateMessage(err.message), {
|
|
108
|
+
...err,
|
|
109
|
+
...opt,
|
|
110
|
+
hint: err.suggestions?.description,
|
|
111
|
+
fixData: err.suggestions?.fixData,
|
|
112
|
+
codeFrame: err.document ? {
|
|
113
|
+
filePath: err.document.path,
|
|
114
|
+
fileContent: err.document.content,
|
|
115
|
+
start: err.document.range.start,
|
|
116
|
+
end: err.document.range.end
|
|
117
|
+
} : void 0,
|
|
118
|
+
level: Linter.Severity[err.severity]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function defaultError(err, opt) {
|
|
122
|
+
return new DevToolError('UNKNOWN_ERROR', JSON.stringify(err), opt);
|
|
123
|
+
}
|
|
124
|
+
function transform(err, opt) {
|
|
125
|
+
const transformers = [
|
|
126
|
+
transformEsbuildError,
|
|
127
|
+
transformBabelError,
|
|
128
|
+
transformDiagnostic,
|
|
129
|
+
transformNormalError,
|
|
130
|
+
transformErrorLike
|
|
131
|
+
];
|
|
132
|
+
for (const fn of transformers){
|
|
133
|
+
const result = fn(err, opt);
|
|
134
|
+
if (result) return result;
|
|
135
|
+
}
|
|
136
|
+
return defaultError(err, opt);
|
|
137
|
+
}
|
|
138
|
+
export { transform };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Err, Logger } from '@rsdoctor/shared/types';
|
|
2
|
+
export declare function toLevel(level: keyof typeof Err.ErrorLevel): Err.ErrorLevel;
|
|
3
|
+
export declare function insertSpace(rawLines: string, line: number, width: number): string;
|
|
4
|
+
export declare function printErrors({ errors, warnings }: Err.DevToolErrorsData, logLevel?: Logger.LogLevelName): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { Err } from "@rsdoctor/shared/types";
|
|
3
|
+
function toLevel(level) {
|
|
4
|
+
return Err.ErrorLevel[level];
|
|
5
|
+
}
|
|
6
|
+
function insertSpace(rawLines, line, width) {
|
|
7
|
+
const lines = rawLines.split('\n');
|
|
8
|
+
lines[line - 1] = Array(width).fill(' ').join('') + lines[line - 1];
|
|
9
|
+
return lines.join('\n');
|
|
10
|
+
}
|
|
11
|
+
function printErrors({ errors, warnings }, logLevel = 'Error') {
|
|
12
|
+
const onlyError = 'Error' === logLevel;
|
|
13
|
+
if ('Silent' === logLevel) return '';
|
|
14
|
+
if (onlyError && 0 === errors.length || !onlyError && 0 === errors.length && 0 === warnings.length) return '';
|
|
15
|
+
const msgs = [];
|
|
16
|
+
if (onlyError) msgs.push(`Build failed with ${errors.length} error:`, ...errors.map((item)=>item.toString()), '');
|
|
17
|
+
else {
|
|
18
|
+
const title = 0 === errors.length ? `Build succuss with ${warnings.length} warning:` : `Build failed with ${errors.length} error, ${warnings.length} warning:`;
|
|
19
|
+
msgs.push(title, ...errors.map((item)=>item.toString()), ...warnings.map((item)=>item.toString()), '');
|
|
20
|
+
}
|
|
21
|
+
return msgs.join('\n\n');
|
|
22
|
+
}
|
|
23
|
+
export { insertSpace, printErrors, toLevel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@rsdoctor/shared/graph';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * from './build-utils/index.js';
|
|
2
2
|
export * as InnerPlugins from './inner-plugins/index.js';
|
|
3
|
+
export { RsdoctorRspackPlugin } from './rspack-plugin/plugin.js';
|
|
4
|
+
export { RsdoctorRspackMultiplePlugin } from './rspack-plugin/multiple.js';
|
|
3
5
|
export * from './types/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import * as
|
|
2
|
+
import * as __rspack_external__inner_plugins_index_js_64c09f4a from "./inner-plugins/index.js";
|
|
3
3
|
export * from "./build-utils/index.js";
|
|
4
4
|
export * from "./types/index.js";
|
|
5
|
-
export {
|
|
5
|
+
export { RsdoctorRspackPlugin } from "./rspack-plugin/plugin.js";
|
|
6
|
+
export { RsdoctorRspackMultiplePlugin } from "./rspack-plugin/multiple.js";
|
|
7
|
+
export { __rspack_external__inner_plugins_index_js_64c09f4a as InnerPlugins };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Tap } from 'tapable';
|
|
2
|
-
export declare const pluginTapName = "
|
|
2
|
+
export declare const pluginTapName = "RsdoctorRspackPlugin";
|
|
3
3
|
export declare const pluginTapPostOptions: Tap;
|
|
4
4
|
export declare const pluginTapPreOptions: Tap;
|
|
5
5
|
export declare const internalPluginTapPreOptions: (namespace: string) => Tap;
|