@rsdoctor/core 2.0.0-alpha.0 → 2.0.0-alpha.2
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/26.js +26163 -0
- package/dist/630.js +1269 -0
- package/dist/630.js.LICENSE.txt +7 -0
- package/dist/build-utils/build/chunks/assetsModules.d.ts +8 -2
- package/dist/build-utils/build/chunks/index.d.ts +0 -1
- package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/envinfo.d.ts +13 -0
- package/dist/build-utils/build/file/cache.d.ts +5 -0
- package/dist/build-utils/build/file/index.d.ts +3 -0
- package/dist/build-utils/build/file/sharding.d.ts +21 -0
- package/dist/build-utils/build/index.d.ts +5 -0
- package/dist/build-utils/build/json.d.ts +3 -0
- package/dist/build-utils/build/loader/probeLoader.d.ts +8 -3
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
- package/dist/build-utils/build/module-graph/index.d.ts +0 -1
- package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
- package/dist/build-utils/build/process.d.ts +2 -0
- package/dist/build-utils/build/server.d.ts +15 -0
- package/dist/build-utils/build/utils/loader.d.ts +2 -2
- package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
- package/dist/build-utils/build/utils/plugin.d.ts +1 -1
- package/dist/build-utils/index.d.ts +10 -0
- package/dist/common/file.d.ts +2 -0
- package/dist/common/global-config.d.ts +21 -0
- package/dist/error/error.d.ts +35 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/transform.d.ts +3 -0
- package/dist/error/utils.d.ts +4 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1725 -5
- package/dist/inner-plugins/constants.d.ts +1 -1
- package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
- package/dist/inner-plugins/plugins/base.d.ts +3 -3
- package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +3 -3
- package/dist/inner-plugins/plugins/errors.d.ts +2 -2
- package/dist/inner-plugins/plugins/loader.d.ts +1 -1
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/progress.d.ts +2 -2
- package/dist/inner-plugins/plugins/resolver.d.ts +1 -1
- package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
- package/dist/inner-plugins/plugins/rules.d.ts +1 -1
- package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
- package/dist/inner-plugins/plugins/summary.d.ts +1 -1
- package/dist/inner-plugins/utils/config.d.ts +2 -3
- package/dist/inner-plugins/utils/loader.d.ts +4 -7
- package/dist/inner-plugins/utils/normalize-config.d.ts +1 -1
- package/dist/inner-plugins/utils/openBrowser.d.ts +1 -0
- package/dist/inner-plugins/utils/plugin.d.ts +1 -1
- package/dist/inner-plugins/utils/sdk.d.ts +2 -3
- package/dist/logger.d.ts +9 -0
- package/dist/probe-loader.js +2 -0
- package/dist/proxy-loader.d.ts +1 -0
- package/dist/proxy-loader.js +48 -0
- package/dist/rslib-runtime.js +18 -9
- package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +4 -1
- package/dist/rspack-plugin/index.d.ts +2 -0
- package/dist/rspack-plugin/multiple.d.ts +8 -0
- package/dist/rspack-plugin/plugin.d.ts +25 -0
- package/dist/rule-utils/document/document.d.ts +16 -0
- package/dist/rule-utils/document/index.d.ts +3 -0
- package/dist/rule-utils/document/server.d.ts +4 -0
- package/dist/rule-utils/document/types.d.ts +31 -0
- package/dist/rule-utils/index.d.ts +2 -0
- package/dist/rule-utils/parser/asserts.d.ts +81 -0
- package/dist/rule-utils/parser/index.d.ts +4 -0
- package/dist/rule-utils/parser/parser.d.ts +118 -0
- package/dist/rule-utils/parser/types.d.ts +30 -0
- package/dist/rule-utils/parser/utils.d.ts +30 -0
- package/dist/rules/linter.d.ts +1 -1
- package/dist/rules/rule.d.ts +2 -2
- package/dist/rules/rules/cjs-require/index.d.ts +1 -1
- package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
- package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
- package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/htmlParserStub.d.ts +3 -0
- package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
- package/dist/rules/rules/ecma-version-check/types.d.ts +13 -3
- 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/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
- 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/side-effects-only-imports/index.d.ts +1 -1
- package/dist/rules/utils.d.ts +1 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/multiple/controller.d.ts +12 -0
- package/dist/sdk/multiple/index.d.ts +2 -0
- package/dist/sdk/multiple/primary.d.ts +32 -0
- package/dist/sdk/multiple/server.d.ts +7 -0
- package/dist/sdk/sdk/core.d.ts +33 -0
- package/dist/sdk/sdk/index.d.ts +52 -0
- package/dist/sdk/sdk/types.d.ts +26 -0
- package/dist/sdk/server/apis/alerts.d.ts +5 -0
- package/dist/sdk/server/apis/base.d.ts +11 -0
- package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
- package/dist/sdk/server/apis/data.d.ts +6 -0
- package/dist/sdk/server/apis/fs.d.ts +5 -0
- package/dist/sdk/server/apis/graph.d.ts +12 -0
- package/dist/sdk/server/apis/index.d.ts +10 -0
- package/dist/sdk/server/apis/loader.d.ts +15 -0
- package/dist/sdk/server/apis/plugin.d.ts +6 -0
- package/dist/sdk/server/apis/project.d.ts +8 -0
- package/dist/sdk/server/apis/renderer.d.ts +6 -0
- package/dist/sdk/server/apis/resolver.d.ts +6 -0
- package/dist/sdk/server/client.d.ts +3 -0
- package/dist/sdk/server/fakeServer.d.ts +9 -0
- package/dist/sdk/server/index.d.ts +44 -0
- package/dist/sdk/server/json-body.d.ts +6 -0
- package/dist/sdk/server/router.d.ts +24 -0
- package/dist/sdk/server/security.d.ts +5 -0
- package/dist/sdk/server/socket/api.d.ts +15 -0
- package/dist/sdk/server/socket/index.d.ts +48 -0
- package/dist/sdk/server/utils.d.ts +6 -0
- package/dist/sdk/utils/base.d.ts +1 -0
- package/dist/sdk/utils/constant.d.ts +1 -0
- package/dist/sdk/utils/date.d.ts +1 -0
- package/dist/sdk/utils/index.d.ts +3 -0
- package/dist/sdk/utils/openBrowser.d.ts +4 -0
- package/dist/sdk/utils/upload.d.ts +2 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/loader.d.ts +1 -1
- package/dist/types/plugin.d.ts +7 -28
- package/package.json +56 -80
- package/static/openChrome.applescript +95 -0
- package/dist/build-utils/build/chunks/assetsModules.cjs +0 -42
- package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
- package/dist/build-utils/build/chunks/assetsModules.js +0 -9
- package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -39
- 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 -72
- package/dist/build-utils/build/chunks/index.d.cts +0 -3
- package/dist/build-utils/build/chunks/index.js +0 -4
- package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -80
- package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
- package/dist/build-utils/build/chunks/rspack/transform.js +0 -44
- package/dist/build-utils/build/index.cjs +0 -52
- package/dist/build-utils/build/index.d.cts +0 -5
- package/dist/build-utils/build/index.js +0 -7
- package/dist/build-utils/build/loader/index.cjs +0 -65
- package/dist/build-utils/build/loader/index.d.cts +0 -2
- package/dist/build-utils/build/loader/index.js +0 -3
- package/dist/build-utils/build/loader/probeLoader.cjs +0 -89
- package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
- package/dist/build-utils/build/loader/probeLoader.js +0 -44
- package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -65
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +0 -32
- package/dist/build-utils/build/module-graph/index.cjs +0 -65
- package/dist/build-utils/build/module-graph/index.d.cts +0 -2
- package/dist/build-utils/build/module-graph/index.js +0 -3
- package/dist/build-utils/build/module-graph/parser.cjs +0 -46
- package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
- package/dist/build-utils/build/module-graph/parser.js +0 -13
- package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -151
- package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
- package/dist/build-utils/build/module-graph/rspack/transform.js +0 -109
- package/dist/build-utils/build/module-graph/transform.cjs +0 -39
- package/dist/build-utils/build/module-graph/transform.d.cts +0 -3
- package/dist/build-utils/build/module-graph/transform.d.ts +0 -3
- package/dist/build-utils/build/module-graph/transform.js +0 -6
- package/dist/build-utils/build/module-graph/utils.cjs +0 -95
- package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
- package/dist/build-utils/build/module-graph/utils.js +0 -59
- package/dist/build-utils/build/utils/index.cjs +0 -72
- package/dist/build-utils/build/utils/index.d.cts +0 -3
- package/dist/build-utils/build/utils/index.js +0 -4
- package/dist/build-utils/build/utils/loader.cjs +0 -354
- package/dist/build-utils/build/utils/loader.d.cts +0 -20
- package/dist/build-utils/build/utils/loader.js +0 -276
- package/dist/build-utils/build/utils/parseBundle.cjs +0 -283
- package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
- package/dist/build-utils/build/utils/parseBundle.js +0 -240
- package/dist/build-utils/build/utils/plugin.cjs +0 -60
- package/dist/build-utils/build/utils/plugin.d.cts +0 -5
- package/dist/build-utils/build/utils/plugin.js +0 -21
- package/dist/build-utils/index.cjs +0 -36
- package/dist/build-utils/index.d.cts +0 -1
- package/dist/build-utils/index.js +0 -3
- package/dist/index.cjs +0 -81
- package/dist/index.d.cts +0 -3
- package/dist/inner-plugins/constants.cjs +0 -64
- package/dist/inner-plugins/constants.js +0 -19
- package/dist/inner-plugins/index.cjs +0 -65
- package/dist/inner-plugins/index.d.cts +0 -2
- package/dist/inner-plugins/index.js +0 -3
- package/dist/inner-plugins/loaders/proxy.cjs +0 -104
- package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
- package/dist/inner-plugins/loaders/proxy.js +0 -65
- package/dist/inner-plugins/plugins/base.cjs +0 -53
- package/dist/inner-plugins/plugins/base.d.cts +0 -12
- package/dist/inner-plugins/plugins/base.js +0 -20
- package/dist/inner-plugins/plugins/bundle.cjs +0 -96
- package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
- package/dist/inner-plugins/plugins/bundle.js +0 -63
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -141
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -34
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +0 -102
- package/dist/inner-plugins/plugins/errors.cjs +0 -98
- package/dist/inner-plugins/plugins/errors.d.cts +0 -11
- package/dist/inner-plugins/plugins/errors.js +0 -65
- package/dist/inner-plugins/plugins/index.cjs +0 -121
- package/dist/inner-plugins/plugins/index.d.cts +0 -10
- package/dist/inner-plugins/plugins/index.js +0 -11
- package/dist/inner-plugins/plugins/loader.cjs +0 -165
- package/dist/inner-plugins/plugins/loader.d.cts +0 -10
- package/dist/inner-plugins/plugins/loader.js +0 -120
- package/dist/inner-plugins/plugins/plugins.cjs +0 -73
- package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
- package/dist/inner-plugins/plugins/plugins.js +0 -40
- package/dist/inner-plugins/plugins/progress.cjs +0 -68
- package/dist/inner-plugins/plugins/progress.d.cts +0 -8
- package/dist/inner-plugins/plugins/progress.js +0 -35
- package/dist/inner-plugins/plugins/resolver.cjs +0 -90
- package/dist/inner-plugins/plugins/resolver.d.cts +0 -12
- package/dist/inner-plugins/plugins/resolver.js +0 -57
- package/dist/inner-plugins/plugins/rspack.cjs +0 -118
- package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
- package/dist/inner-plugins/plugins/rspack.js +0 -85
- package/dist/inner-plugins/plugins/rules.cjs +0 -97
- package/dist/inner-plugins/plugins/rules.d.cts +0 -8
- package/dist/inner-plugins/plugins/rules.js +0 -64
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -275
- package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
- package/dist/inner-plugins/plugins/sourcemapTool.js +0 -230
- package/dist/inner-plugins/plugins/summary.cjs +0 -125
- package/dist/inner-plugins/plugins/summary.d.cts +0 -14
- package/dist/inner-plugins/plugins/summary.js +0 -92
- package/dist/inner-plugins/utils/circleDetect.cjs +0 -49
- package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
- package/dist/inner-plugins/utils/circleDetect.js +0 -16
- package/dist/inner-plugins/utils/config.cjs +0 -191
- package/dist/inner-plugins/utils/config.d.cts +0 -5
- package/dist/inner-plugins/utils/config.js +0 -142
- package/dist/inner-plugins/utils/index.cjs +0 -106
- package/dist/inner-plugins/utils/index.d.cts +0 -9
- package/dist/inner-plugins/utils/index.js +0 -8
- package/dist/inner-plugins/utils/loader.cjs +0 -218
- package/dist/inner-plugins/utils/loader.d.cts +0 -13
- package/dist/inner-plugins/utils/loader.js +0 -160
- package/dist/inner-plugins/utils/normalize-config.cjs +0 -122
- package/dist/inner-plugins/utils/normalize-config.d.cts +0 -37
- package/dist/inner-plugins/utils/normalize-config.js +0 -77
- package/dist/inner-plugins/utils/plugin-common.cjs +0 -143
- package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
- package/dist/inner-plugins/utils/plugin-common.js +0 -94
- package/dist/inner-plugins/utils/plugin.cjs +0 -106
- package/dist/inner-plugins/utils/plugin.d.cts +0 -4
- package/dist/inner-plugins/utils/plugin.js +0 -70
- package/dist/inner-plugins/utils/sdk.cjs +0 -55
- package/dist/inner-plugins/utils/sdk.d.cts +0 -8
- package/dist/inner-plugins/utils/sdk.js +0 -19
- package/dist/rules/index.cjs +0 -81
- package/dist/rules/index.d.cts +0 -3
- package/dist/rules/index.js +0 -4
- package/dist/rules/linter.cjs +0 -72
- package/dist/rules/linter.d.cts +0 -9
- package/dist/rules/linter.js +0 -36
- package/dist/rules/rule.cjs +0 -137
- package/dist/rules/rule.d.cts +0 -27
- package/dist/rules/rule.js +0 -101
- package/dist/rules/rules/cjs-require/index.cjs +0 -83
- package/dist/rules/rules/cjs-require/index.d.cts +0 -4
- package/dist/rules/rules/cjs-require/index.js +0 -50
- 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/cjs-require/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/index.cjs +0 -74
- package/dist/rules/rules/cross-chunks-package/index.d.cts +0 -4
- package/dist/rules/rules/cross-chunks-package/index.js +0 -41
- 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/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/utils.cjs +0 -40
- package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
- package/dist/rules/rules/cross-chunks-package/utils.js +0 -7
- package/dist/rules/rules/default-import-check/index.cjs +0 -116
- package/dist/rules/rules/default-import-check/index.d.cts +0 -4
- package/dist/rules/rules/default-import-check/index.js +0 -83
- 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/types.js +0 -1
- package/dist/rules/rules/default-import-check/utils.cjs +0 -97
- package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
- package/dist/rules/rules/default-import-check/utils.js +0 -52
- package/dist/rules/rules/duplicate-package/index.cjs +0 -72
- package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
- package/dist/rules/rules/duplicate-package/index.js +0 -39
- package/dist/rules/rules/duplicate-package/types.cjs +0 -60
- package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
- package/dist/rules/rules/duplicate-package/types.js +0 -24
- package/dist/rules/rules/duplicate-package/utils.cjs +0 -84
- package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
- package/dist/rules/rules/duplicate-package/utils.js +0 -38
- package/dist/rules/rules/ecma-version-check/index.cjs +0 -96
- package/dist/rules/rules/ecma-version-check/index.d.cts +0 -4
- package/dist/rules/rules/ecma-version-check/index.js +0 -53
- 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/types.js +0 -1
- package/dist/rules/rules/ecma-version-check/utils.cjs +0 -39
- package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
- package/dist/rules/rules/ecma-version-check/utils.js +0 -6
- package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -237
- package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +0 -4
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +0 -193
- 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/esm-resolved-to-cjs/types.js +0 -1
- package/dist/rules/rules/index.cjs +0 -55
- package/dist/rules/rules/index.d.cts +0 -2
- package/dist/rules/rules/index.js +0 -22
- package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -119
- package/dist/rules/rules/loader-performance-optimization/index.d.cts +0 -4
- package/dist/rules/rules/loader-performance-optimization/index.js +0 -86
- 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/types.js +0 -1
- package/dist/rules/rules/loader-performance-optimization/utils.cjs +0 -43
- package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
- package/dist/rules/rules/loader-performance-optimization/utils.js +0 -10
- package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -85
- package/dist/rules/rules/module-mixed-chunks/index.d.cts +0 -4
- package/dist/rules/rules/module-mixed-chunks/index.js +0 -52
- 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/module-mixed-chunks/types.js +0 -1
- package/dist/rules/rules/side-effects-only-imports/index.cjs +0 -114
- package/dist/rules/rules/side-effects-only-imports/index.d.cts +0 -4
- package/dist/rules/rules/side-effects-only-imports/index.js +0 -81
- 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/rules/side-effects-only-imports/types.js +0 -1
- package/dist/rules/utils.cjs +0 -46
- package/dist/rules/utils.d.cts +0 -3
- package/dist/rules/utils.js +0 -10
- 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/chunks.js +0 -1
- package/dist/types/index.cjs +0 -79
- package/dist/types/index.d.cts +0 -4
- package/dist/types/index.js +0 -5
- package/dist/types/loader.cjs +0 -18
- package/dist/types/loader.d.cts +0 -19
- package/dist/types/loader.js +0 -1
- package/dist/types/plugin.cjs +0 -18
- package/dist/types/plugin.d.cts +0 -51
- package/dist/types/plugin.js +0 -1
- package/dist/types/rules.cjs +0 -18
- package/dist/types/rules.d.cts +0 -7
- package/dist/types/rules.js +0 -1
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import __rslib_shim_module__ from "node:module";
|
|
2
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
-
import node_path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import fs_extra from "fs-extra";
|
|
6
|
-
import { omit } from "es-toolkit/compat";
|
|
7
|
-
import { Loader } from "@rsdoctor/utils/common";
|
|
8
|
-
import { readPackageJson } from "@rsdoctor/graph";
|
|
9
|
-
import { logger } from "@rsdoctor/utils/logger";
|
|
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
|
-
});
|
|
18
|
-
const loader_filename = fileURLToPath(import.meta.url);
|
|
19
|
-
const loader_dirname = node_path.dirname(loader_filename);
|
|
20
|
-
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
|
21
|
-
function parsePathQueryFragment(str) {
|
|
22
|
-
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
23
|
-
return {
|
|
24
|
-
path: match?.[1].replace(/\0(.)/g, '$1') || '',
|
|
25
|
-
query: match?.[2] ? match[2].replace(/\0(.)/g, '$1') : '',
|
|
26
|
-
fragment: match?.[3] || ''
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
30
|
-
const cleanLoaderPath = parsePathQueryFragment(loaderPath).path;
|
|
31
|
-
const { createRequire } = __webpack_require__("module?2382");
|
|
32
|
-
const requireFn = createRequire(import.meta.url);
|
|
33
|
-
const mod = requireFn(process.env.DOCTOR_TEST ? node_path.resolve(cwd, cleanLoaderPath) : requireFn.resolve(cleanLoaderPath, {
|
|
34
|
-
paths: [
|
|
35
|
-
cwd,
|
|
36
|
-
node_path.resolve(cwd, 'node_modules')
|
|
37
|
-
]
|
|
38
|
-
}));
|
|
39
|
-
const isESM = mod.__esModule && 'function' == typeof mod.default;
|
|
40
|
-
return {
|
|
41
|
-
default: isESM ? mod.default : 'function' == typeof mod ? mod : null,
|
|
42
|
-
pitch: mod.default?.pitch || mod.pitch,
|
|
43
|
-
raw: mod.default?.raw || mod.raw || false
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function extractLoaderName(loaderPath, cwd = '') {
|
|
47
|
-
let res = loaderPath.replace(cwd, '');
|
|
48
|
-
if (!node_path.isAbsolute(res)) return res;
|
|
49
|
-
const nms = '/node_modules/';
|
|
50
|
-
const idx = res.lastIndexOf(nms);
|
|
51
|
-
if (-1 !== idx) {
|
|
52
|
-
res = res.slice(idx + nms.length);
|
|
53
|
-
const ln = 'loader';
|
|
54
|
-
const lnIdx = res.lastIndexOf(ln);
|
|
55
|
-
if (lnIdx > -1) res = res.slice(0, lnIdx + ln.length);
|
|
56
|
-
}
|
|
57
|
-
return res;
|
|
58
|
-
}
|
|
59
|
-
function mapEachRules(rules, callback) {
|
|
60
|
-
return rules.filter(Boolean).map((rule)=>{
|
|
61
|
-
if ('string' == typeof rule) return callback({
|
|
62
|
-
loader: rule
|
|
63
|
-
});
|
|
64
|
-
if (rule.loader && 'string' == typeof rule.loader) return callback(rule);
|
|
65
|
-
if (Array.isArray(rule.loaders)) {
|
|
66
|
-
const { loaders, ...rest } = rule;
|
|
67
|
-
return {
|
|
68
|
-
...rest,
|
|
69
|
-
use: mapEachRules(loaders, callback)
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (rule.use && (!Array.isArray(rule.use) || 0 !== rule.use.length)) {
|
|
73
|
-
if ('string' == typeof rule.use) return {
|
|
74
|
-
...rule,
|
|
75
|
-
use: mapEachRules([
|
|
76
|
-
{
|
|
77
|
-
loader: rule.use,
|
|
78
|
-
options: rule.options
|
|
79
|
-
}
|
|
80
|
-
], callback)
|
|
81
|
-
};
|
|
82
|
-
if ('function' == typeof rule.use) {
|
|
83
|
-
const funcUse = rule.use;
|
|
84
|
-
const newRule = {
|
|
85
|
-
...rule,
|
|
86
|
-
use: (...args)=>{
|
|
87
|
-
const rules = funcUse(...args);
|
|
88
|
-
return mapEachRules(rules, callback);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
return newRule;
|
|
92
|
-
}
|
|
93
|
-
if (Array.isArray(rule.use)) return {
|
|
94
|
-
...rule,
|
|
95
|
-
use: mapEachRules(rule.use, callback)
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
...rule,
|
|
99
|
-
use: mapEachRules([
|
|
100
|
-
rule.use
|
|
101
|
-
], callback)
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if ('rules' in rule && Array.isArray(rule.rules)) return {
|
|
105
|
-
...rule,
|
|
106
|
-
rules: mapEachRules(rule.rules, callback)
|
|
107
|
-
};
|
|
108
|
-
if (Array.isArray(rule.oneOf)) return {
|
|
109
|
-
...rule,
|
|
110
|
-
oneOf: mapEachRules(rule.oneOf, callback)
|
|
111
|
-
};
|
|
112
|
-
return rule;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function isESMLoader(r) {
|
|
116
|
-
const _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
|
|
117
|
-
if (!_loaderName) return false;
|
|
118
|
-
const isPath = node_path.isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../');
|
|
119
|
-
if (isPath) {
|
|
120
|
-
const packageJsonData = readPackageJson(_loaderName, (file)=>{
|
|
121
|
-
try {
|
|
122
|
-
return fs_extra.readJsonSync(file, {
|
|
123
|
-
encoding: 'utf8'
|
|
124
|
-
});
|
|
125
|
-
} catch (e) {
|
|
126
|
-
logger.debug(`isESMLoader function error:${e}`);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
if (packageJsonData?.type === 'module' && !packageJsonData?.name.includes('@rsdoctor/')) return true;
|
|
130
|
-
}
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
function appendProbeLoaders(compiler, loaderConfig) {
|
|
134
|
-
const _options = 'object' == typeof loaderConfig ? 'string' == typeof loaderConfig.options ? {
|
|
135
|
-
options: loaderConfig.options
|
|
136
|
-
} : loaderConfig.options : {};
|
|
137
|
-
const loaderPath = process.env.DOCTOR_TEST ? node_path.resolve(loader_dirname, '../loader/probeLoader.ts') : require.resolve(node_path.join(loader_dirname, '../loader/probeLoader'));
|
|
138
|
-
const loader = 'string' == typeof loaderConfig ? loaderConfig : 'object' == typeof loaderConfig && loaderConfig.loader;
|
|
139
|
-
const createProbeLoader = (type)=>({
|
|
140
|
-
loader: loaderPath,
|
|
141
|
-
options: {
|
|
142
|
-
..._options,
|
|
143
|
-
loader,
|
|
144
|
-
ident: void 0,
|
|
145
|
-
type,
|
|
146
|
-
builderName: compiler.options.name
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
return [
|
|
150
|
-
createProbeLoader('end'),
|
|
151
|
-
loaderConfig,
|
|
152
|
-
createProbeLoader('start')
|
|
153
|
-
];
|
|
154
|
-
}
|
|
155
|
-
function getLoaderNameMatch(r, loaderName, strict = true) {
|
|
156
|
-
if (!strict) return 'object' == typeof r && 'string' == typeof r?.loader && r.loader.includes(loaderName) || 'string' == typeof r && r.includes(loaderName);
|
|
157
|
-
return 'object' == typeof r && 'string' == typeof r?.loader && r.loader === loaderName || 'string' == typeof r && r === loaderName;
|
|
158
|
-
}
|
|
159
|
-
function addProbeLoader2Rules(rules, compiler, fn) {
|
|
160
|
-
return rules.map((rule)=>{
|
|
161
|
-
if (!rule || 'string' == typeof rule) return rule;
|
|
162
|
-
if (fn(rule) && !rule.use) {
|
|
163
|
-
const loaderConfig = {
|
|
164
|
-
loader: rule.loader ?? '',
|
|
165
|
-
options: rule.options,
|
|
166
|
-
ident: 'ident' in rule && 'string' == typeof rule.ident ? rule.ident : void 0
|
|
167
|
-
};
|
|
168
|
-
return {
|
|
169
|
-
...rule,
|
|
170
|
-
use: appendProbeLoaders(compiler, loaderConfig),
|
|
171
|
-
loader: void 0,
|
|
172
|
-
options: void 0
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
if (rule.use) {
|
|
176
|
-
if (Array.isArray(rule.use)) rule.use = rule.use.flatMap((loaderConfig)=>{
|
|
177
|
-
if ('string' == typeof loaderConfig || 'object' == typeof loaderConfig && loaderConfig && 'loader' in loaderConfig) return fn(loaderConfig) ? appendProbeLoaders(compiler, loaderConfig) : [
|
|
178
|
-
loaderConfig
|
|
179
|
-
];
|
|
180
|
-
return [
|
|
181
|
-
loaderConfig
|
|
182
|
-
];
|
|
183
|
-
});
|
|
184
|
-
else if ('object' != typeof rule.use || Array.isArray(rule.use) || 'function' == typeof rule.use) {
|
|
185
|
-
if ('string' == typeof rule.use) rule.use = fn(rule.use) ? appendProbeLoaders(compiler, {
|
|
186
|
-
loader: rule.use
|
|
187
|
-
}) : [
|
|
188
|
-
{
|
|
189
|
-
loader: rule.use
|
|
190
|
-
}
|
|
191
|
-
];
|
|
192
|
-
} else if ('loader' in rule.use) rule.use = fn(rule.use) ? appendProbeLoaders(compiler, rule.use) : [
|
|
193
|
-
rule.use
|
|
194
|
-
];
|
|
195
|
-
}
|
|
196
|
-
if ('oneOf' in rule && rule.oneOf) return {
|
|
197
|
-
...rule,
|
|
198
|
-
oneOf: addProbeLoader2Rules(rule.oneOf, compiler, fn)
|
|
199
|
-
};
|
|
200
|
-
if ('rules' in rule && rule.rules) return {
|
|
201
|
-
...rule,
|
|
202
|
-
rules: addProbeLoader2Rules(rule.rules, compiler, fn)
|
|
203
|
-
};
|
|
204
|
-
return rule;
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
function createLoaderContextTrap(final) {
|
|
208
|
-
const cb = this.callback;
|
|
209
|
-
let callback = (...args)=>{
|
|
210
|
-
final(args[0], args[1] ?? null, args[2]);
|
|
211
|
-
return cb.call(this, ...args);
|
|
212
|
-
};
|
|
213
|
-
const ac = this.async;
|
|
214
|
-
let async = (...args)=>{
|
|
215
|
-
const cb = ac(...args);
|
|
216
|
-
return (...args)=>{
|
|
217
|
-
final(args[0], args[1] ?? null, args[2]);
|
|
218
|
-
return cb(...args);
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
const trap = new Proxy(this, {
|
|
222
|
-
get (target, key, receiver) {
|
|
223
|
-
switch(key){
|
|
224
|
-
case 'async':
|
|
225
|
-
return async;
|
|
226
|
-
case 'callback':
|
|
227
|
-
return callback;
|
|
228
|
-
case 'query':
|
|
229
|
-
if (target.query) {
|
|
230
|
-
if ('string' == typeof target.query) {
|
|
231
|
-
const res = target.query.replace(new RegExp(`"${Loader.LoaderInternalPropertyName}":\{[^\}]*\},{0,1}`), '');
|
|
232
|
-
return res;
|
|
233
|
-
}
|
|
234
|
-
if ('object' == typeof target.query) {
|
|
235
|
-
const options = target.query[Loader.LoaderInternalPropertyName];
|
|
236
|
-
if (options.hasOptions) return omit(target.query, [
|
|
237
|
-
Loader.LoaderInternalPropertyName
|
|
238
|
-
]);
|
|
239
|
-
const innerLoaderPath = options?.loader;
|
|
240
|
-
const loaderQuery = parsePathQueryFragment(innerLoaderPath).query;
|
|
241
|
-
return loaderQuery;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return Reflect.get(target, key, receiver);
|
|
245
|
-
case 'getOptions':
|
|
246
|
-
return 'function' == typeof target.getOptions ? ()=>omit(target.getOptions(), [
|
|
247
|
-
Loader.LoaderInternalPropertyName
|
|
248
|
-
]) : Reflect.get(target, key, receiver);
|
|
249
|
-
default:
|
|
250
|
-
return target[key];
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
set (target, key, value, receiver) {
|
|
254
|
-
switch(key){
|
|
255
|
-
case 'async':
|
|
256
|
-
async = value;
|
|
257
|
-
return true;
|
|
258
|
-
case 'callback':
|
|
259
|
-
callback = value;
|
|
260
|
-
return true;
|
|
261
|
-
default:
|
|
262
|
-
return Reflect.set(target, key, value, receiver);
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
defineProperty (target, p, attrs) {
|
|
266
|
-
return Reflect.defineProperty(target, p, attrs);
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
return trap;
|
|
270
|
-
}
|
|
271
|
-
function parseQuery(query) {
|
|
272
|
-
if (query.startsWith('?')) query = query.slice(1);
|
|
273
|
-
const searchParams = new URLSearchParams(query);
|
|
274
|
-
return Object.fromEntries(searchParams.entries());
|
|
275
|
-
}
|
|
276
|
-
export { addProbeLoader2Rules, createLoaderContextTrap, extractLoaderName, getLoaderNameMatch, isESMLoader, loadLoaderModule, mapEachRules, parsePathQueryFragment, parseQuery };
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
parseBundle: ()=>parseBundle
|
|
37
|
-
});
|
|
38
|
-
const external_fs_namespaceObject = require("fs");
|
|
39
|
-
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
40
|
-
const compat_namespaceObject = require("es-toolkit/compat");
|
|
41
|
-
const external_filesize_namespaceObject = require("filesize");
|
|
42
|
-
const ruleUtils_namespaceObject = require("@rsdoctor/utils/ruleUtils");
|
|
43
|
-
const external_path_namespaceObject = require("path");
|
|
44
|
-
const types_namespaceObject = require("@rsdoctor/types");
|
|
45
|
-
const logger_namespaceObject = require("@rsdoctor/utils/logger");
|
|
46
|
-
const parseBundle = (bundlePath, modulesData)=>{
|
|
47
|
-
if (bundlePath.indexOf('.worker.') > 0) return {};
|
|
48
|
-
const ext = (0, external_path_namespaceObject.extname)(bundlePath);
|
|
49
|
-
if (!types_namespaceObject.Constants.JSExtensions.includes(ext)) return {};
|
|
50
|
-
let content = external_fs_default().readFileSync(bundlePath, 'utf8');
|
|
51
|
-
const tagCache = new Map();
|
|
52
|
-
const sourceMapRegex = /\/\/# sourceMappingURL=[^\n]*$/m;
|
|
53
|
-
content = content.replace(sourceMapRegex, '');
|
|
54
|
-
let hasBannerPlugin = content.indexOf('RSDOCTOR_START::') > 0;
|
|
55
|
-
if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
56
|
-
const tagMatchResult = getStringBetween(content, 0, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_START::(.*?)[;,]/, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_END::(.*?)\)/);
|
|
57
|
-
content = tagMatchResult.result?.trim() || content;
|
|
58
|
-
tagCache.set(bundlePath, tagMatchResult.loc);
|
|
59
|
-
hasBannerPlugin = true;
|
|
60
|
-
} else if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
61
|
-
const loc = tagCache.get(bundlePath);
|
|
62
|
-
content = content.slice(loc.start, loc.end);
|
|
63
|
-
hasBannerPlugin = true;
|
|
64
|
-
}
|
|
65
|
-
const ast = ruleUtils_namespaceObject.parser.internal.parse(content, {
|
|
66
|
-
sourceType: "script",
|
|
67
|
-
ecmaVersion: 'latest'
|
|
68
|
-
});
|
|
69
|
-
const walkState = {
|
|
70
|
-
locations: null,
|
|
71
|
-
expressionStatementDepth: 0
|
|
72
|
-
};
|
|
73
|
-
ruleUtils_namespaceObject.parser.walk.recursive(ast, walkState, {
|
|
74
|
-
ExpressionStatement (node, state, c) {
|
|
75
|
-
if (state.locations) return;
|
|
76
|
-
state.expressionStatementDepth++;
|
|
77
|
-
try {
|
|
78
|
-
if (1 === state.expressionStatementDepth && isIIFE(node)) {
|
|
79
|
-
const fn = getIIFECallExpression(node);
|
|
80
|
-
if (0 === fn.arguments.length && 0 === fn.callee.params.length) {
|
|
81
|
-
const firstVariableDeclaration = fn.callee.body.body.find((node)=>'VariableDeclaration' === node.type);
|
|
82
|
-
if (firstVariableDeclaration) {
|
|
83
|
-
for (const declaration of firstVariableDeclaration.declarations)if (declaration.init) {
|
|
84
|
-
state.locations = getModulesLocations(declaration.init);
|
|
85
|
-
if (state.locations) break;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (!state.locations) c(node.expression, state);
|
|
91
|
-
} catch (e) {
|
|
92
|
-
logger_namespaceObject.logger.debug(e);
|
|
93
|
-
}
|
|
94
|
-
state.expressionStatementDepth--;
|
|
95
|
-
},
|
|
96
|
-
Program (node, state, _c) {
|
|
97
|
-
if (state.locations) return;
|
|
98
|
-
try {
|
|
99
|
-
if (hasBannerPlugin) {
|
|
100
|
-
const firstVariableDeclaration = node.body.find((node)=>'VariableDeclaration' === node.type && node.declarations?.[0]?.init?.type === 'ObjectExpression' && node.declarations?.[0]?.init?.properties?.length);
|
|
101
|
-
if (firstVariableDeclaration) {
|
|
102
|
-
for (const declaration of firstVariableDeclaration.declarations)if (declaration.init) {
|
|
103
|
-
state.locations = getModulesLocations(declaration.init);
|
|
104
|
-
if (state.locations) break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (!state.locations) node.body.forEach((n)=>_c(n, state));
|
|
109
|
-
} catch (e) {
|
|
110
|
-
logger_namespaceObject.logger.debug(e);
|
|
111
|
-
}
|
|
112
|
-
state.expressionStatementDepth--;
|
|
113
|
-
},
|
|
114
|
-
AssignmentExpression (node, state) {
|
|
115
|
-
if (state.locations) return;
|
|
116
|
-
const { left, right } = node;
|
|
117
|
-
if (left?.object && 'exports' === left.object.name && left.property && 'modules' === left.property.name && isModulesHash(right)) state.locations = getModulesLocations(right);
|
|
118
|
-
},
|
|
119
|
-
CallExpression (node, state, c) {
|
|
120
|
-
if (state.locations) return;
|
|
121
|
-
const args = node.arguments;
|
|
122
|
-
if ('FunctionExpression' === node.callee.type && !node.callee.id && 1 === args.length && isSimpleModulesList(args[0])) {
|
|
123
|
-
state.locations = getModulesLocations(args[0]);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if ('Identifier' === node.callee.type && mayBeAsyncChunkArguments(args) && isModulesList(args[1])) {
|
|
127
|
-
state.locations = getModulesLocations(args[1]);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (isAsyncChunkPushExpression(node)) {
|
|
131
|
-
state.locations = getModulesLocations(args[0].elements[1]);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (isAsyncWebWorkerChunkExpression(node)) {
|
|
135
|
-
state.locations = getModulesLocations(args[1]);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
args.forEach((arg)=>c(arg, state));
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
let modules;
|
|
142
|
-
modules = walkState.locations ? (0, compat_namespaceObject.mapValues)(walkState.locations, (loc)=>content.slice(loc.start, loc.end)) : {};
|
|
143
|
-
const modulesObj = {};
|
|
144
|
-
for(const module in modules){
|
|
145
|
-
if (!module) return {};
|
|
146
|
-
const moduleContent = modules[module];
|
|
147
|
-
const size = moduleContent && Buffer.byteLength(moduleContent);
|
|
148
|
-
const identifier = (0, compat_namespaceObject.find)(modulesData, {
|
|
149
|
-
renderId: module
|
|
150
|
-
})?.identifier || '';
|
|
151
|
-
modulesObj[identifier] = {
|
|
152
|
-
size,
|
|
153
|
-
sizeConvert: (0, external_filesize_namespaceObject.filesize)(size || 0),
|
|
154
|
-
content: moduleContent
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
modules: modulesObj,
|
|
159
|
-
src: content,
|
|
160
|
-
runtimeSrc: getBundleRuntime(content, walkState.locations)
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
function getBundleRuntime(content, modulesLocations) {
|
|
164
|
-
const sortedLocations = Object.values(modulesLocations || {}).sort((a, b)=>a.start - b.start);
|
|
165
|
-
let result = '';
|
|
166
|
-
let lastIndex = 0;
|
|
167
|
-
for (const { start, end } of sortedLocations){
|
|
168
|
-
result += content.slice(lastIndex, start);
|
|
169
|
-
lastIndex = end;
|
|
170
|
-
}
|
|
171
|
-
return result + content.slice(lastIndex, content.length);
|
|
172
|
-
}
|
|
173
|
-
function isIIFE(node) {
|
|
174
|
-
return 'ExpressionStatement' === node.type && ('CallExpression' === node.expression.type || 'UnaryExpression' === node.expression.type && 'CallExpression' === node.expression.argument.type);
|
|
175
|
-
}
|
|
176
|
-
function getIIFECallExpression(node) {
|
|
177
|
-
if ('UnaryExpression' === node.expression.type) return node.expression.argument;
|
|
178
|
-
return node.expression;
|
|
179
|
-
}
|
|
180
|
-
function isModulesList(node) {
|
|
181
|
-
return isSimpleModulesList(node) || isOptimizedModulesArray(node);
|
|
182
|
-
}
|
|
183
|
-
function isSimpleModulesList(node) {
|
|
184
|
-
return isModulesHash(node) || isModulesArray(node);
|
|
185
|
-
}
|
|
186
|
-
function isModulesHash(node) {
|
|
187
|
-
return 'ObjectExpression' === node.type && node.properties.map((node)=>node.value).every(isModuleWrapper);
|
|
188
|
-
}
|
|
189
|
-
function isModulesArray(node) {
|
|
190
|
-
return 'ArrayExpression' === node.type && node.elements.every((elem)=>!elem || isModuleWrapper(elem));
|
|
191
|
-
}
|
|
192
|
-
function isOptimizedModulesArray(node) {
|
|
193
|
-
return 'CallExpression' === node.type && 'MemberExpression' === node.callee.type && 'CallExpression' === node.callee.object.type && 'Identifier' === node.callee.object.callee.type && 'Array' === node.callee.object.callee.name && 1 === node.callee.object.arguments.length && isNumericId(node.callee.object.arguments[0]) && 'Identifier' === node.callee.property.type && 'concat' === node.callee.property.name && 1 === node.arguments.length && isModulesArray(node.arguments[0]);
|
|
194
|
-
}
|
|
195
|
-
function isModuleWrapper(node) {
|
|
196
|
-
return ('FunctionExpression' === node.type || 'ArrowFunctionExpression' === node.type) && !node.id || isModuleId(node) || 'ArrayExpression' === node.type && node.elements.length > 1 && isModuleId(node.elements[0]);
|
|
197
|
-
}
|
|
198
|
-
function isModuleId(node) {
|
|
199
|
-
return 'Literal' === node.type && (isNumericId(node) || 'string' == typeof node.value);
|
|
200
|
-
}
|
|
201
|
-
function isNumericId(node) {
|
|
202
|
-
return 'Literal' === node.type && Number.isInteger(node.value) && node.value >= 0;
|
|
203
|
-
}
|
|
204
|
-
function isChunkIds(node) {
|
|
205
|
-
return 'ArrayExpression' === node.type && node.elements.every(isModuleId);
|
|
206
|
-
}
|
|
207
|
-
function isAsyncChunkPushExpression(node) {
|
|
208
|
-
const { callee, arguments: args } = node;
|
|
209
|
-
return 'MemberExpression' === callee.type && 'push' === callee.property.name && 'AssignmentExpression' === callee.object.type && 1 === args.length && 'ArrayExpression' === args[0].type && mayBeAsyncChunkArguments(args[0].elements) && isModulesList(args[0].elements[1]);
|
|
210
|
-
}
|
|
211
|
-
function mayBeAsyncChunkArguments(args) {
|
|
212
|
-
return args.length >= 2 && isChunkIds(args[0]);
|
|
213
|
-
}
|
|
214
|
-
function isAsyncWebWorkerChunkExpression(node) {
|
|
215
|
-
const { callee, type, arguments: args } = node;
|
|
216
|
-
return 'CallExpression' === type && 'MemberExpression' === callee.type && 2 === args.length && isChunkIds(args[0]) && isModulesList(args[1]);
|
|
217
|
-
}
|
|
218
|
-
function getModulesLocations(node) {
|
|
219
|
-
if ('ObjectExpression' === node.type) {
|
|
220
|
-
const modulesNodes = node.properties;
|
|
221
|
-
return modulesNodes.reduce((result, moduleNode)=>{
|
|
222
|
-
const moduleId = moduleNode.key.name || moduleNode.key.value;
|
|
223
|
-
result[moduleId] = getModuleLocation(moduleNode.value);
|
|
224
|
-
return result;
|
|
225
|
-
}, {});
|
|
226
|
-
}
|
|
227
|
-
const isOptimizedArray = 'CallExpression' === node.type;
|
|
228
|
-
if ('ArrayExpression' === node.type || isOptimizedArray) {
|
|
229
|
-
const minId = isOptimizedArray ? node.callee.object.arguments[0].value : 0;
|
|
230
|
-
const modulesNodes = isOptimizedArray ? node.arguments[0].elements : node.elements;
|
|
231
|
-
return modulesNodes.reduce((result, moduleNode, i)=>{
|
|
232
|
-
if (moduleNode) result[i + minId] = getModuleLocation(moduleNode);
|
|
233
|
-
return result;
|
|
234
|
-
}, {});
|
|
235
|
-
}
|
|
236
|
-
return {};
|
|
237
|
-
}
|
|
238
|
-
function getModuleLocation(node) {
|
|
239
|
-
return {
|
|
240
|
-
start: node.start,
|
|
241
|
-
end: node.end
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function getStringBetween(raw, position, start, end) {
|
|
245
|
-
try {
|
|
246
|
-
const matchStart = raw.match(start);
|
|
247
|
-
const startFlagIndex = matchStart?.length ? raw.indexOf(matchStart[0], position) : -1;
|
|
248
|
-
if (-1 === startFlagIndex || !matchStart?.length) return {
|
|
249
|
-
result: null,
|
|
250
|
-
remain: position
|
|
251
|
-
};
|
|
252
|
-
const startTagLength = matchStart[0].length;
|
|
253
|
-
const matchEnd = raw.match(end);
|
|
254
|
-
const endFlagIndex = matchEnd?.length ? raw.indexOf(matchEnd[0], startFlagIndex + startTagLength) : -1;
|
|
255
|
-
if (-1 === endFlagIndex || !matchEnd?.length) return {
|
|
256
|
-
result: null,
|
|
257
|
-
remain: position
|
|
258
|
-
};
|
|
259
|
-
let innerContent = raw.slice(startFlagIndex + startTagLength, endFlagIndex).trim();
|
|
260
|
-
if (innerContent.endsWith(',')) innerContent = innerContent.slice(0, -1);
|
|
261
|
-
return {
|
|
262
|
-
result: innerContent,
|
|
263
|
-
remain: matchEnd?.length ? endFlagIndex + matchEnd[0].length : endFlagIndex,
|
|
264
|
-
loc: {
|
|
265
|
-
start: startFlagIndex + startTagLength,
|
|
266
|
-
end: endFlagIndex
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
} catch (e) {
|
|
270
|
-
logger_namespaceObject.logger.debug(()=>e);
|
|
271
|
-
return {
|
|
272
|
-
result: null,
|
|
273
|
-
remain: position
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
exports.parseBundle = __webpack_exports__.parseBundle;
|
|
278
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
279
|
-
"parseBundle"
|
|
280
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
281
|
-
Object.defineProperty(exports, '__esModule', {
|
|
282
|
-
value: true
|
|
283
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ParseBundle } from '@rsdoctor/graph';
|
|
2
|
-
/**
|
|
3
|
-
* The following code is based on
|
|
4
|
-
* https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/src/parseUtils.js#L10
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* MIT Licensed
|
|
8
|
-
* Author th0r
|
|
9
|
-
* Copyright JS Foundation and other contributors.
|
|
10
|
-
* https://github.com/webpack-contrib/webpack-bundle-analyzer/blob/44bd8d0f9aa3b098e271af220096ea70cc44bc9e/LICENSE
|
|
11
|
-
*/
|
|
12
|
-
export declare const parseBundle: ParseBundle;
|