@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,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { Chunks } from "
|
|
2
|
+
import { Chunks } from "../../../graph/index.js";
|
|
3
3
|
import { parseBundle } from "../utils/index.js";
|
|
4
4
|
async function getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, sourceMapSets, hasParseBundle = true, assetsWithoutSourceMap) {
|
|
5
5
|
return Chunks.getAssetsModulesData(moduleGraph, chunkGraph, bundleDir, hasParseBundle ? {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { Asset, Chunk, EntryPoint } from "
|
|
2
|
+
import { Asset, Chunk, EntryPoint } from "../../../../graph/index.js";
|
|
3
3
|
function patchNativeChunkGraph(cg, rawChunkGraph) {
|
|
4
4
|
const { chunks: rawChunks, entrypoints: rawEntrypoints } = rawChunkGraph;
|
|
5
5
|
const chunks = rawChunks.map((chunk)=>new Chunk(chunk.ukey.toString(), chunk.name, 0, chunk.initial, chunk.entry));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const getCPUInfo: () => Promise<string>;
|
|
2
|
+
export declare const getOSInfo: () => Promise<string>;
|
|
3
|
+
export declare const getMemoryInfo: () => Promise<string>;
|
|
4
|
+
export declare const getNodeVersion: () => Promise<string>;
|
|
5
|
+
export declare const getYarnVersion: () => Promise<string>;
|
|
6
|
+
export declare const getNpmVersion: () => Promise<string>;
|
|
7
|
+
export declare const getPnpmVersion: () => Promise<string>;
|
|
8
|
+
export declare function getNpmPackageVersion(pkg: string): Promise<string>;
|
|
9
|
+
export declare function getNpmPackageVersion(pkgs: string[]): Promise<string[]>;
|
|
10
|
+
export declare function getGlobalNpmPackageVersion(pkg: string): Promise<string>;
|
|
11
|
+
export declare function getGlobalNpmPackageVersion(pkgs: string[]): Promise<string[]>;
|
|
12
|
+
export declare function getGitBranch(): Promise<string>;
|
|
13
|
+
export declare function getGitRepo(): Promise<string>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import envinfo from "envinfo";
|
|
3
|
+
import { exec } from "child_process";
|
|
4
|
+
const helpers = envinfo.helpers;
|
|
5
|
+
const run = envinfo.run;
|
|
6
|
+
const getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]);
|
|
7
|
+
const getOSInfo = ()=>helpers.getOSInfo().then((res)=>res[1]);
|
|
8
|
+
const getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]);
|
|
9
|
+
const getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]);
|
|
10
|
+
const getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]);
|
|
11
|
+
const getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]);
|
|
12
|
+
const getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
|
|
13
|
+
function getNpmPackageVersion(pkg) {
|
|
14
|
+
const isArray = Array.isArray(pkg);
|
|
15
|
+
return run({
|
|
16
|
+
npmPackages: isArray ? pkg : [
|
|
17
|
+
pkg
|
|
18
|
+
]
|
|
19
|
+
}, {
|
|
20
|
+
json: true,
|
|
21
|
+
showNotFound: true
|
|
22
|
+
}).then((res)=>{
|
|
23
|
+
const { npmPackages = {} } = JSON.parse(res) || {};
|
|
24
|
+
return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function getGlobalNpmPackageVersion(pkg) {
|
|
28
|
+
const isArray = Array.isArray(pkg);
|
|
29
|
+
return run({
|
|
30
|
+
npmGlobalPackages: isArray ? pkg : [
|
|
31
|
+
pkg
|
|
32
|
+
]
|
|
33
|
+
}, {
|
|
34
|
+
json: true,
|
|
35
|
+
showNotFound: true
|
|
36
|
+
}).then((res)=>{
|
|
37
|
+
const { npmGlobalPackages = {} } = JSON.parse(res) || {};
|
|
38
|
+
return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function getGitBranch() {
|
|
42
|
+
return new Promise((resolve, reject)=>{
|
|
43
|
+
exec('git branch --show-current', (err, stdout)=>{
|
|
44
|
+
if (err) exec('git branch', (err, stdout)=>{
|
|
45
|
+
if (err) reject(err);
|
|
46
|
+
else resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
|
|
47
|
+
});
|
|
48
|
+
else resolve(stdout.trim());
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function getGitRepo() {
|
|
53
|
+
return new Promise((resolve, reject)=>{
|
|
54
|
+
exec('git config --get remote.origin.url', (err, stdout)=>{
|
|
55
|
+
if (err) reject(err);
|
|
56
|
+
else resolve(stdout.trim());
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export { getCPUInfo, getGitBranch, getGitRepo, getGlobalNpmPackageVersion, getMemoryInfo, getNodeVersion, getNpmPackageVersion, getNpmVersion, getOSInfo, getPnpmVersion, getYarnVersion };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Common } from '@rsdoctor/shared/types';
|
|
2
|
+
export declare function readFile(path: string): Promise<string>;
|
|
3
|
+
export declare function readFileSync(path: string): string;
|
|
4
|
+
export declare function readJSON<T extends Common.PlainObject>(path: string): Promise<T>;
|
|
5
|
+
export declare function readJSONSync<T extends Common.PlainObject>(path: string): T;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
const cache = new Map();
|
|
4
|
+
async function readFile(path) {
|
|
5
|
+
if (cache.has(path)) return cache.get(path);
|
|
6
|
+
const res = await node_fs.promises.readFile(path, 'utf-8');
|
|
7
|
+
cache.set(path, res);
|
|
8
|
+
return res;
|
|
9
|
+
}
|
|
10
|
+
function readFileSync(path) {
|
|
11
|
+
if (cache.has(path)) return cache.get(path);
|
|
12
|
+
const res = node_fs.readFileSync(path, 'utf-8');
|
|
13
|
+
cache.set(path, res);
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
async function readJSON(path) {
|
|
17
|
+
const str = await readFile(path);
|
|
18
|
+
return JSON.parse(str);
|
|
19
|
+
}
|
|
20
|
+
function readJSONSync(path) {
|
|
21
|
+
const str = readFileSync(path);
|
|
22
|
+
return JSON.parse(str);
|
|
23
|
+
}
|
|
24
|
+
export { readFile, readFileSync, readJSON, readJSONSync };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class FileSharding {
|
|
2
|
+
protected content: string;
|
|
3
|
+
protected limitBytes: number;
|
|
4
|
+
protected encoding: BufferEncoding;
|
|
5
|
+
constructor(content: string, limitBytes?: number, encoding?: BufferEncoding);
|
|
6
|
+
/**
|
|
7
|
+
* @param ext the extension name of the output file (must starts with ".")
|
|
8
|
+
*/
|
|
9
|
+
createVirtualShardingFiles(ext?: string, index?: number): {
|
|
10
|
+
filename: string;
|
|
11
|
+
content: Buffer<ArrayBufferLike>;
|
|
12
|
+
}[];
|
|
13
|
+
/**
|
|
14
|
+
* @param folder absolute path of folder which used to save string sharding files.
|
|
15
|
+
* @param ext the extension name of the output file (must starts with ".")
|
|
16
|
+
*/
|
|
17
|
+
writeStringToFolder(folder: string, ext?: string, index?: number): Promise<{
|
|
18
|
+
filename: string;
|
|
19
|
+
content: Buffer<ArrayBufferLike>;
|
|
20
|
+
}[]>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import fs_extra from "fs-extra";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
class FileSharding {
|
|
6
|
+
createVirtualShardingFiles(ext = '', index = 0) {
|
|
7
|
+
const bf = Buffer.from(this.content, this.encoding);
|
|
8
|
+
const res = [];
|
|
9
|
+
const threshold = this.limitBytes;
|
|
10
|
+
let tmpBytes = 0;
|
|
11
|
+
while(bf.byteLength > tmpBytes){
|
|
12
|
+
res.push(bf.subarray(tmpBytes, tmpBytes + threshold));
|
|
13
|
+
tmpBytes += threshold;
|
|
14
|
+
}
|
|
15
|
+
return res.map((e, i)=>({
|
|
16
|
+
filename: `${i + index}${ext}`,
|
|
17
|
+
content: e
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
async writeStringToFolder(folder, ext = '', index) {
|
|
21
|
+
const dist = path.resolve(folder);
|
|
22
|
+
await fs_extra.ensureDir(dist);
|
|
23
|
+
const res = this.createVirtualShardingFiles(ext, index);
|
|
24
|
+
await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
|
|
25
|
+
const stream = fs.createWriteStream(path.join(dist, e.filename), this.encoding);
|
|
26
|
+
stream.end(e.content);
|
|
27
|
+
stream.once('close', ()=>resolve(void 0));
|
|
28
|
+
stream.once('error', (err)=>reject(err));
|
|
29
|
+
})));
|
|
30
|
+
return res;
|
|
31
|
+
}
|
|
32
|
+
constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
|
|
33
|
+
this.content = content;
|
|
34
|
+
this.limitBytes = limitBytes;
|
|
35
|
+
this.encoding = encoding;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export { FileSharding };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export * as File from './file/index.js';
|
|
2
|
+
export * as Json from './json.js';
|
|
3
|
+
export * as Server from './server.js';
|
|
4
|
+
export * as EnvInfo from './envinfo.js';
|
|
5
|
+
export * as Process from './process.js';
|
|
1
6
|
export * as Chunks from './chunks/index.js';
|
|
2
7
|
export * as Utils from './utils/index.js';
|
|
3
8
|
export * as Loader from './loader/index.js';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
7
|
-
|
|
2
|
+
import * as __rspack_external__file_index_js_5cbcde29 from "./file/index.js";
|
|
3
|
+
import * as __rspack_external__json_js_faef839e from "./json.js";
|
|
4
|
+
import * as __rspack_external__server_js_186b33b9 from "./server.js";
|
|
5
|
+
import * as __rspack_external__envinfo_js_2b90a03d from "./envinfo.js";
|
|
6
|
+
import * as __rspack_external__process_js_7eda60d3 from "./process.js";
|
|
7
|
+
import * as __rspack_external__chunks_index_js_c4bbc2de from "./chunks/index.js";
|
|
8
|
+
import * as __rspack_external__utils_index_js_d2e4ad7a from "./utils/index.js";
|
|
9
|
+
import * as __rspack_external__loader_index_js_ef25077c from "./loader/index.js";
|
|
10
|
+
import * as __rspack_external__types_index_js_d78e4824 from "../../types/index.js";
|
|
11
|
+
import * as __rspack_external__module_graph_index_js_f91481f4 from "./module-graph/index.js";
|
|
12
|
+
export { __rspack_external__chunks_index_js_c4bbc2de as Chunks, __rspack_external__envinfo_js_2b90a03d as EnvInfo, __rspack_external__file_index_js_5cbcde29 as File, __rspack_external__json_js_faef839e as Json, __rspack_external__loader_index_js_ef25077c as Loader, __rspack_external__module_graph_index_js_f91481f4 as ModuleGraph, __rspack_external__process_js_7eda60d3 as Process, __rspack_external__server_js_186b33b9 as Server, __rspack_external__types_index_js_d78e4824 as Types, __rspack_external__utils_index_js_d2e4ad7a as Utils };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/shared/types';
|
|
2
|
+
export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean): Promise<P>;
|
|
3
|
+
export declare const readPackageJson: (file: string, readFile?: SDK.GetPackageFile) => SDK.PackageBasicData | undefined;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { JsonStreamStringify } from "json-stream-stringify";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { Package } from "../../common/index.js";
|
|
5
|
+
import { Transform } from "stream";
|
|
6
|
+
const maxFileSize = 419430400;
|
|
7
|
+
function stringify(json, replacer, space, cycle) {
|
|
8
|
+
const jsonList = [];
|
|
9
|
+
if (json && 'object' == typeof json) return new Promise((resolve, reject)=>{
|
|
10
|
+
const stream = new JsonStreamStringify(json, replacer, space, cycle);
|
|
11
|
+
let currentLength = 0;
|
|
12
|
+
let currentContent = '';
|
|
13
|
+
const batchProcessor = new Transform({
|
|
14
|
+
readableObjectMode: true,
|
|
15
|
+
transform (chunk, _encoding, callback) {
|
|
16
|
+
const lines = chunk.toString().split('\\n');
|
|
17
|
+
lines.forEach((line)=>{
|
|
18
|
+
if (currentLength + line.length > maxFileSize) {
|
|
19
|
+
jsonList.push(currentContent);
|
|
20
|
+
currentContent = '';
|
|
21
|
+
currentLength = 0;
|
|
22
|
+
}
|
|
23
|
+
if (line.length) {
|
|
24
|
+
currentContent += line;
|
|
25
|
+
currentLength += line.length;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
callback();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
stream.pipe(batchProcessor).on('data', (line)=>{
|
|
32
|
+
if (currentLength + line.length > maxFileSize) {
|
|
33
|
+
jsonList.push(currentContent);
|
|
34
|
+
currentContent = '';
|
|
35
|
+
currentLength = 0;
|
|
36
|
+
}
|
|
37
|
+
if (line.length) {
|
|
38
|
+
currentContent += line;
|
|
39
|
+
currentLength += line.length;
|
|
40
|
+
}
|
|
41
|
+
}).on('end', ()=>{
|
|
42
|
+
if (jsonList.length < 1) jsonList.push(currentContent);
|
|
43
|
+
resolve(jsonList);
|
|
44
|
+
}).on('error', (err)=>reject(err));
|
|
45
|
+
});
|
|
46
|
+
return Promise.resolve(JSON.stringify(json, replacer, space));
|
|
47
|
+
}
|
|
48
|
+
const readPackageJson = (file, readFile)=>{
|
|
49
|
+
let result;
|
|
50
|
+
let current = file;
|
|
51
|
+
while('/' !== current && !result){
|
|
52
|
+
const parent = dirname(current);
|
|
53
|
+
if (parent === current) break;
|
|
54
|
+
current = parent;
|
|
55
|
+
if (readFile) result = readFile(join(current, 'package.json'));
|
|
56
|
+
if (readFile) {
|
|
57
|
+
if (!result?.name) result = void 0;
|
|
58
|
+
} else result = Package.getPackageMetaFromModulePath(file);
|
|
59
|
+
}
|
|
60
|
+
if (!result) return;
|
|
61
|
+
if (readFile && (!result.name || !result.version)) return readPackageJson(dirname(current), readFile);
|
|
62
|
+
return {
|
|
63
|
+
...result,
|
|
64
|
+
root: current
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export { readPackageJson, stringify };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '@rsdoctor/types';
|
|
1
|
+
import type { Plugin } from '@rsdoctor/shared/types';
|
|
2
2
|
import type { LoaderDefinitionFunction } from '@rspack/core';
|
|
3
|
-
export declare const loaderModule: Plugin.LoaderDefinition<Parameters<LoaderDefinitionFunction>,
|
|
3
|
+
export declare const loaderModule: Plugin.LoaderDefinition<Parameters<LoaderDefinitionFunction>, object>;
|
|
4
4
|
export default loaderModule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import {
|
|
3
|
-
import { getSDK } from "../../../inner-plugins/
|
|
4
|
-
import { omit } from "
|
|
2
|
+
import { parseQuery } from "../utils/index.js";
|
|
3
|
+
import { getSDK } from "../../../inner-plugins/utils/sdk.js";
|
|
4
|
+
import { omit } from "../../../collection.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
const loaderModule = function(...args) {
|
|
7
7
|
const time = Date.now();
|
|
@@ -11,7 +11,7 @@ const loaderModule = function(...args) {
|
|
|
11
11
|
const loaderData = {
|
|
12
12
|
resource: {
|
|
13
13
|
path: this._module?.layer ? `${this.resourcePath}[${this._module.layer}]` : this.resourcePath,
|
|
14
|
-
query:
|
|
14
|
+
query: parseQuery(this.resourceQuery),
|
|
15
15
|
queryRaw: this.resourceQuery,
|
|
16
16
|
ext: path.extname(this.resourcePath).slice(1),
|
|
17
17
|
...this._module?.layer ? {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Node } from '
|
|
1
|
+
import { Node } from '../../../rule-utils/index.js';
|
|
2
2
|
export declare function hasSetEsModuleStatement(program: Node.Program): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { parser } from "
|
|
2
|
+
import { parser } from "../../../rule-utils/index.js";
|
|
3
3
|
const esmLabelStatement = parser.internal.parseExpressionAt('Object.defineProperty(exports, "__esModule", { value: true })', 0, {
|
|
4
4
|
ecmaVersion: 6,
|
|
5
5
|
ranges: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { Dependency, Module,
|
|
3
|
-
import { SDK } from "@rsdoctor/types";
|
|
2
|
+
import { Dependency, Module, extractCodeFromSourceLines, parseLocation } from "../../../../graph/index.js";
|
|
3
|
+
import { SDK } from "@rsdoctor/shared/types";
|
|
4
4
|
const createDependencyKind = (type)=>{
|
|
5
5
|
if (type.includes('harmony') || 'esm import' === type) return SDK.DependencyKind.ImportStatement;
|
|
6
6
|
if (type.includes('cjs')) return SDK.DependencyKind.RequireCall;
|
|
@@ -81,7 +81,7 @@ function patchNativeModuleSources(mg, rawModuleSourcesPatch) {
|
|
|
81
81
|
}
|
|
82
82
|
const jsonModuleSizes = rawModuleSourcesPatch.jsonModuleSizes;
|
|
83
83
|
if (jsonModuleSizes && jsonModuleSizes.length > 0) for (const jsonModuleSize of jsonModuleSizes){
|
|
84
|
-
const module = mg.
|
|
84
|
+
const module = mg.getModuleByIdentifier(jsonModuleSize.identifier);
|
|
85
85
|
if (module) module.setSize({
|
|
86
86
|
parsedSize: jsonModuleSize.size
|
|
87
87
|
});
|
|
@@ -94,10 +94,12 @@ function extractSideEffectCodes(mg) {
|
|
|
94
94
|
if (!sideEffectLocations.length) continue;
|
|
95
95
|
const moduleSource = module.getSource();
|
|
96
96
|
const source = moduleSource.source || moduleSource.parsedSource;
|
|
97
|
-
if (source)
|
|
97
|
+
if (!source) continue;
|
|
98
|
+
const sourceLines = source.split('\n');
|
|
99
|
+
for (const sideEffectLocation of sideEffectLocations){
|
|
98
100
|
const parsedLocation = parseLocation(sideEffectLocation.location);
|
|
99
101
|
if (!parsedLocation) continue;
|
|
100
|
-
const code =
|
|
102
|
+
const code = extractCodeFromSourceLines(sourceLines, parsedLocation);
|
|
101
103
|
if (code) module.addSideEffectCode({
|
|
102
104
|
moduleId: module.id,
|
|
103
105
|
startLine: parsedLocation.startLine,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SDK } from '@rsdoctor/types';
|
|
1
|
+
import { SDK } from '@rsdoctor/shared/types';
|
|
2
2
|
export declare function getExportIdentifierStatement(name: string, module: SDK.ModuleInstance): SDK.StatementInstance | undefined;
|
|
3
3
|
export declare function getDeclarationIdentifier(name: string, module: SDK.ModuleInstance): SDK.StatementInstance | undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import {
|
|
3
|
-
import { parser } from "@rsdoctor/utils/ruleUtils";
|
|
2
|
+
import { parser } from "../../../rule-utils/index.js";
|
|
4
3
|
function getDefaultExportIdentifier(node, module, searchId) {
|
|
5
4
|
const { declaration } = node;
|
|
6
5
|
if (parser.asserts.isLiteral(declaration) && declaration.loc) return module.getStatement(declaration.loc);
|
|
@@ -14,9 +13,11 @@ function getDefaultExportIdentifier(node, module, searchId) {
|
|
|
14
13
|
if (declaration.id?.loc) return module.getStatement(declaration.id.loc);
|
|
15
14
|
}
|
|
16
15
|
const startLine = node.declaration.loc?.start.line;
|
|
17
|
-
if (
|
|
16
|
+
if ('number' != typeof startLine) return;
|
|
18
17
|
const { transformed } = module.getSource();
|
|
19
|
-
const
|
|
18
|
+
const line = transformed.split('\n')[startLine - 1];
|
|
19
|
+
if (void 0 === line) return;
|
|
20
|
+
const endColumn = line.length - 1;
|
|
20
21
|
return module.getStatement({
|
|
21
22
|
start: {
|
|
22
23
|
line: startLine,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { filesize } from "filesize";
|
|
3
|
+
import { memoryUsage, pid } from "process";
|
|
4
|
+
function getMemoryUsage() {
|
|
5
|
+
return memoryUsage();
|
|
6
|
+
}
|
|
7
|
+
function getMemoryUsageMessage() {
|
|
8
|
+
const usage = getMemoryUsage();
|
|
9
|
+
const msgs = [
|
|
10
|
+
`RSS: ${filesize(usage.rss)}`,
|
|
11
|
+
`Heap Total: ${filesize(usage.heapTotal)}`,
|
|
12
|
+
`Heap Used: ${filesize(usage.heapUsed)}`
|
|
13
|
+
];
|
|
14
|
+
if (usage.arrayBuffers) msgs.push(`ArrayBuffers: ${filesize(usage.arrayBuffers)}`);
|
|
15
|
+
if (usage.external) msgs.push(`External: ${filesize(usage.external)}`);
|
|
16
|
+
return `["${pid}" Memory Usage] ${msgs.join(', ')}`;
|
|
17
|
+
}
|
|
18
|
+
export { getMemoryUsage, getMemoryUsageMessage };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import connect from 'connect';
|
|
2
|
+
import http from 'http';
|
|
3
|
+
import { Thirdparty } from '@rsdoctor/shared/types';
|
|
4
|
+
export declare const defaultHost = "127.0.0.1";
|
|
5
|
+
export declare const defaultPort: number;
|
|
6
|
+
export declare function getPort(expectPort: number, host?: string): Promise<number>;
|
|
7
|
+
export declare const createGetPortSyncFunctionString: (expectPort: number, host?: string) => string;
|
|
8
|
+
export declare function getPortSync(expectPort: number, host?: string): number | never;
|
|
9
|
+
export declare function createApp(): connect.Server;
|
|
10
|
+
export declare function createServer(port: number, host?: string): Promise<{
|
|
11
|
+
app: Thirdparty.connect.Server;
|
|
12
|
+
server: http.Server;
|
|
13
|
+
port: number;
|
|
14
|
+
close(): Promise<void> | never;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import connect from "connect";
|
|
3
|
+
import http from "http";
|
|
4
|
+
import os from "os";
|
|
5
|
+
import get_port from "get-port";
|
|
6
|
+
import { execFileSync } from "child_process";
|
|
7
|
+
import { Algorithm } from "../../common/index.js";
|
|
8
|
+
const RESTRICTED_PORTS = [
|
|
9
|
+
3659,
|
|
10
|
+
4045,
|
|
11
|
+
6000,
|
|
12
|
+
6665,
|
|
13
|
+
6666,
|
|
14
|
+
6667,
|
|
15
|
+
6668,
|
|
16
|
+
6669
|
|
17
|
+
];
|
|
18
|
+
const defaultHost = '127.0.0.1';
|
|
19
|
+
function getRandomPort(min, max) {
|
|
20
|
+
let port;
|
|
21
|
+
do port = Algorithm.random(min, max);
|
|
22
|
+
while (RESTRICTED_PORTS.includes(port));
|
|
23
|
+
return port;
|
|
24
|
+
}
|
|
25
|
+
const defaultPort = getRandomPort(3000, 8999);
|
|
26
|
+
async function getPort(expectPort, host = defaultHost) {
|
|
27
|
+
return get_port({
|
|
28
|
+
port: expectPort,
|
|
29
|
+
host
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const createGetPortSyncFunctionString = (expectPort, host = defaultHost)=>`
|
|
33
|
+
(() => {
|
|
34
|
+
const net = require('net');
|
|
35
|
+
|
|
36
|
+
function getPort(expectPort, host) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const server = net.createServer();
|
|
39
|
+
server.unref();
|
|
40
|
+
server.on('error', reject);
|
|
41
|
+
server.listen(expectPort, host, () => {
|
|
42
|
+
const { port } = server.address();
|
|
43
|
+
server.close(() => {
|
|
44
|
+
resolve(port);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function getAvailablePort(expectPort) {
|
|
51
|
+
let port = expectPort;
|
|
52
|
+
while (true) {
|
|
53
|
+
try {
|
|
54
|
+
const res = await getPort(port, ${JSON.stringify(host)});
|
|
55
|
+
return res;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
port += Math.floor(Math.random() * 100 + 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getAvailablePort(${expectPort}).then(port => process.stdout.write(port.toString()));
|
|
63
|
+
})();
|
|
64
|
+
`.trim();
|
|
65
|
+
function getPortSync(expectPort, host = defaultHost) {
|
|
66
|
+
const statement = '\n' === os.EOL ? createGetPortSyncFunctionString(expectPort, host) : createGetPortSyncFunctionString(expectPort, host).replace(/\n/g, '');
|
|
67
|
+
const port = execFileSync(process.execPath, [
|
|
68
|
+
'-e',
|
|
69
|
+
statement
|
|
70
|
+
], {
|
|
71
|
+
encoding: 'utf-8'
|
|
72
|
+
});
|
|
73
|
+
return Number(port);
|
|
74
|
+
}
|
|
75
|
+
function createApp() {
|
|
76
|
+
return connect();
|
|
77
|
+
}
|
|
78
|
+
async function createServer(port, host = defaultHost) {
|
|
79
|
+
const app = createApp();
|
|
80
|
+
const server = http.createServer(app);
|
|
81
|
+
const res = {
|
|
82
|
+
app,
|
|
83
|
+
server,
|
|
84
|
+
port,
|
|
85
|
+
close () {
|
|
86
|
+
return new Promise((resolve, reject)=>{
|
|
87
|
+
if ('closeAllConnections' in server) server.closeAllConnections();
|
|
88
|
+
if ('closeIdleConnections' in server) server.closeIdleConnections();
|
|
89
|
+
server.close((err)=>{
|
|
90
|
+
if (err) reject(err);
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return new Promise((resolve, reject)=>{
|
|
97
|
+
const onError = (error)=>{
|
|
98
|
+
reject(error);
|
|
99
|
+
};
|
|
100
|
+
server.once('error', onError);
|
|
101
|
+
server.listen(port, host, ()=>{
|
|
102
|
+
server.off('error', onError);
|
|
103
|
+
resolve(res);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
export { createApp, createGetPortSyncFunctionString, createServer, defaultHost, defaultPort, getPort, getPortSync };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Common, Plugin } from '@rsdoctor/types';
|
|
1
|
+
import type { Common, Plugin } from '@rsdoctor/shared/types';
|
|
2
2
|
export declare function parsePathQueryFragment(str: string): {
|
|
3
3
|
path: string;
|
|
4
4
|
query: string;
|
|
5
5
|
fragment: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function loadLoaderModule(loaderPath: string, cwd?: string): {
|
|
8
|
-
default: Plugin.LoaderDefinition<Common.PlainObject,
|
|
8
|
+
default: Plugin.LoaderDefinition<Common.PlainObject, object>;
|
|
9
9
|
pitch: Plugin.PitchLoaderDefinitionFunction;
|
|
10
10
|
raw: boolean | void;
|
|
11
11
|
};
|