extension-develop 4.1.39 → 4.1.40-canary.459.2c1ba7b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +13 -10
  2. package/dist/{771~0.mjs → 5h~0.mjs} +13 -3
  3. package/dist/{273~0.mjs → 6l~0.mjs} +1 -1
  4. package/dist/{524~0.mjs → 9~0.mjs} +18 -2
  5. package/dist/{640~0.mjs → bh~0.mjs} +6 -1
  6. package/dist/bridge.mjs +14 -8
  7. package/dist/b~0.mjs +8644 -0
  8. package/dist/command-dev.d.ts +2 -0
  9. package/dist/command-preview.d.ts +2 -0
  10. package/dist/contracts.mjs +2 -1
  11. package/dist/{469~0.mjs → cp~0.mjs} +66 -17
  12. package/dist/css-parse-guard-loader.mjs +2 -2
  13. package/dist/c~0.mjs +56 -0
  14. package/dist/dead-css-url-loader.mjs +20 -119
  15. package/dist/dev-server/control-bridge/actions-file.d.ts +7 -0
  16. package/dist/dev-server/control-bridge/broker.d.ts +42 -2
  17. package/dist/dev-server/control-bridge/consumer-client.d.ts +7 -0
  18. package/dist/dev-server/control-bridge/contracts.d.ts +29 -1
  19. package/dist/dev-server/control-bridge/logs-file.d.ts +6 -0
  20. package/dist/dev-server/control-bridge/loopback.d.ts +1 -0
  21. package/dist/dev-server/control-bridge/producer-runtime.d.ts +5 -2
  22. package/dist/dev-server/control-bridge/production-control.d.ts +1 -0
  23. package/dist/dev-server/control-bridge/session-token.d.ts +5 -2
  24. package/dist/dev-server/cors.d.ts +4 -2
  25. package/dist/dev-server/messages.d.ts +6 -0
  26. package/dist/dev-server/session-restart.d.ts +3 -1
  27. package/dist/dev-server~0.mjs +71 -129
  28. package/dist/df~0.mjs +197 -0
  29. package/dist/{846~0.mjs → d~0.mjs} +4 -3
  30. package/dist/ensure-hmr-for-scripts.js +3 -3
  31. package/dist/ensure-hmr-for-scripts.mjs +3 -3
  32. package/dist/extension-js-devtools/build-stamp.json +2 -2
  33. package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
  34. package/dist/extension-js-devtools/chrome/pages/welcome.js +2 -2
  35. package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
  36. package/dist/extension-js-devtools/chromium/pages/welcome.js +2 -2
  37. package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
  38. package/dist/extension-js-devtools/edge/pages/welcome.js +2 -2
  39. package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
  40. package/dist/extension-js-devtools/firefox/pages/welcome.js +2 -2
  41. package/dist/extension-js-theme/build-stamp.json +2 -2
  42. package/dist/{143~0.mjs → ey~0.mjs} +2 -2
  43. package/dist/e~0.mjs +33 -0
  44. package/dist/feature-scripts-classic-traced-globals-loader.mjs +7 -2
  45. package/dist/feature-scripts-content-script-wrapper.js +56 -18
  46. package/dist/feature-scripts-content-script-wrapper.mjs +56 -18
  47. package/dist/feature-scripts-native-geturl-import-loader.mjs +1 -1
  48. package/dist/{105~0.mjs → g0~0.mjs} +1 -1
  49. package/dist/{88~0.mjs → j6~0.mjs} +9 -1
  50. package/dist/{731~0.mjs → j~0.mjs} +2 -2
  51. package/dist/{712~0.mjs → ka~0.mjs} +18 -2
  52. package/dist/{852~0.mjs → k~0.mjs} +4 -2
  53. package/dist/late-css-import-loader.mjs +1 -1
  54. package/dist/lib/addon-lint.d.ts +6 -0
  55. package/dist/lib/build-summary.d.ts +6 -0
  56. package/dist/lib/dev-additions.d.ts +12 -0
  57. package/dist/lib/extension-base-from-stack.d.ts +16 -0
  58. package/dist/lib/localized-manifest-name.d.ts +9 -0
  59. package/dist/lib/manifest-types.d.ts +276 -0
  60. package/dist/lib/messages.d.ts +6 -2
  61. package/dist/lib/process-started-at.d.ts +1 -0
  62. package/dist/lib/real-path.d.ts +8 -0
  63. package/dist/lib/resource-path.d.ts +1 -0
  64. package/dist/lib/session-paths.d.ts +2 -0
  65. package/dist/lib/split-chunks.d.ts +2 -1
  66. package/dist/lib/stats-handler.d.ts +1 -0
  67. package/dist/lib/tsconfig-includes-file.d.ts +1 -0
  68. package/dist/l~0.mjs +2290 -0
  69. package/dist/main-world-bridge.js +92 -23
  70. package/dist/main-world-bridge.mjs +92 -23
  71. package/dist/manifest-entry.d.ts +2 -0
  72. package/dist/manifest.mjs +3 -1
  73. package/dist/module.mjs +3 -3
  74. package/dist/{832~0.mjs → m~0.mjs} +2244 -288
  75. package/dist/o~0.mjs +47 -0
  76. package/dist/plugin-browsers/index.d.ts +7 -0
  77. package/dist/plugin-browsers/safari-dev-plugin.d.ts +2 -0
  78. package/dist/plugin-compatibility/compatibility-lib/messages.d.ts +5 -1
  79. package/dist/plugin-compatibility/compatibility-lib/native-browser-namespace.d.ts +5 -0
  80. package/dist/plugin-compatibility/feature-browser-global.d.ts +11 -1
  81. package/dist/plugin-compatibility/index.d.ts +2 -0
  82. package/dist/plugin-compilation/compilation-lib/messages.d.ts +4 -1
  83. package/dist/plugin-compilation/env.d.ts +1 -0
  84. package/dist/plugin-compilation/index.d.ts +2 -0
  85. package/dist/plugin-compilation/node-builtins.d.ts +5 -0
  86. package/dist/plugin-compilation/one-diagnostic-per-location.d.ts +13 -0
  87. package/dist/plugin-compilation/resolve-file-requests.d.ts +16 -0
  88. package/dist/plugin-compilation/warm-ancestor-watchers.d.ts +19 -0
  89. package/dist/plugin-compilation/watch-real-project-path.d.ts +27 -0
  90. package/dist/plugin-compilation/zip.d.ts +2 -0
  91. package/dist/plugin-css/css-in-content-script-loader.d.ts +1 -1
  92. package/dist/plugin-css/css-lib/build-css-rules.d.ts +3 -0
  93. package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +3 -1
  94. package/dist/plugin-css/css-lib/messages.d.ts +4 -0
  95. package/dist/plugin-css/css-lib/sfc-style-block.d.ts +26 -0
  96. package/dist/plugin-css/css-lib/unplaced-style-imports.d.ts +7 -0
  97. package/dist/plugin-css/css-lib/verbatim-css.d.ts +1 -0
  98. package/dist/plugin-css/dead-css-url-loader.d.ts +9 -1
  99. package/dist/plugin-css/index.d.ts +1 -0
  100. package/dist/plugin-css/sfc-style-block-loader.d.ts +18 -0
  101. package/dist/plugin-css/unplaced-style-import-loader.d.ts +16 -0
  102. package/dist/plugin-playwright/index.d.ts +22 -0
  103. package/dist/plugin-reload/classify-reload.d.ts +20 -0
  104. package/dist/plugin-reload/index.d.ts +4 -2
  105. package/dist/plugin-reload/messages.d.ts +1 -0
  106. package/dist/plugin-reload/reload-dispatch.d.ts +21 -2
  107. package/dist/plugin-reload/reload-lib/dev-content-scripts.d.ts +6 -0
  108. package/dist/plugin-reload/reload-lib/scripts-replay-shim.d.ts +1 -1
  109. package/dist/plugin-reload/steps/inject-bridge-producer.d.ts +6 -0
  110. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/ChunkLoader.d.ts +3 -0
  111. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/AutoPublicPath.d.ts +1 -1
  112. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/BaseUri.d.ts +1 -1
  113. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/LoadScript.d.ts +1 -1
  114. package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/PublicPath.d.ts +1 -1
  115. package/dist/plugin-special-folders/get-data.d.ts +2 -0
  116. package/dist/plugin-special-folders/hint-import-only-scripts.d.ts +4 -0
  117. package/dist/plugin-special-folders/include-files.d.ts +2 -0
  118. package/dist/plugin-special-folders/messages.d.ts +1 -0
  119. package/dist/plugin-web-extension/feature-html/html-lib/inject.d.ts +1 -1
  120. package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +1 -0
  121. package/dist/plugin-web-extension/feature-html/steps/update-html-file.d.ts +1 -0
  122. package/dist/plugin-web-extension/feature-icons/extract-action-theme-icons.d.ts +1 -0
  123. package/dist/plugin-web-extension/feature-icons/extract-icon-variants.d.ts +2 -0
  124. package/dist/plugin-web-extension/feature-json/json-validation.d.ts +2 -1
  125. package/dist/plugin-web-extension/feature-json/messages.d.ts +2 -0
  126. package/dist/plugin-web-extension/feature-json/process-assets.d.ts +1 -1
  127. package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-gecko.d.ts +21 -0
  128. package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-safari.d.ts +1 -1
  129. package/dist/plugin-web-extension/feature-manifest/manifest-lib/icon-variants-fallback.d.ts +15 -0
  130. package/dist/plugin-web-extension/feature-manifest/manifest-lib/sanitize-fatal-shapes.d.ts +2 -1
  131. package/dist/plugin-web-extension/feature-manifest/manifest-lib/webkit-unsupported-keys.d.ts +15 -0
  132. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/content_scripts.d.ts +1 -1
  133. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/icons.d.ts +3 -2
  134. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/omnibox.d.ts +1 -1
  135. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/page_action.d.ts +2 -1
  136. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/permissions.d.ts +1 -1
  137. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/sandbox.d.ts +1 -1
  138. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/browser_action.d.ts +4 -3
  139. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/action.d.ts +3 -2
  140. package/dist/plugin-web-extension/feature-manifest/messages.d.ts +15 -1
  141. package/dist/plugin-web-extension/feature-manifest/normalize-manifest-path.d.ts +2 -0
  142. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/dev-additions.d.ts +8 -0
  143. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-background.d.ts +2 -2
  144. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-externally-connectable.d.ts +1 -1
  145. package/dist/plugin-web-extension/feature-manifest/steps/patch-gecko-background.d.ts +1 -0
  146. package/dist/plugin-web-extension/feature-manifest/steps/warn-content-script-host-access.d.ts +17 -0
  147. package/dist/plugin-web-extension/feature-manifest/steps/warn-description-length.d.ts +26 -0
  148. package/dist/plugin-web-extension/feature-manifest/steps/warn-gecko-unsupported-apis.d.ts +37 -2
  149. package/dist/plugin-web-extension/feature-scripts/contracts.d.ts +3 -0
  150. package/dist/plugin-web-extension/feature-scripts/index.d.ts +1 -0
  151. package/dist/plugin-web-extension/feature-scripts/messages.d.ts +10 -1
  152. package/dist/plugin-web-extension/feature-scripts/scripts-lib/completion-value.d.ts +13 -0
  153. package/dist/plugin-web-extension/feature-scripts/scripts-lib/injected-sheet-urls.d.ts +5 -0
  154. package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-bridge-pairing.d.ts +5 -0
  155. package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-copy-routing.d.ts +2 -0
  156. package/dist/plugin-web-extension/feature-scripts/scripts-lib/registration-worlds.d.ts +10 -0
  157. package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-main-world-scripts.d.ts +25 -2
  158. package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-script-sheet.d.ts +14 -0
  159. package/dist/plugin-web-extension/feature-scripts/scripts-lib/taken-extension-base.d.ts +10 -0
  160. package/dist/plugin-web-extension/feature-scripts/steps/add-base-uri-runtime-module.d.ts +7 -1
  161. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/content-script-wrapper.d.ts +2 -0
  162. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/index.d.ts +2 -0
  163. package/dist/plugin-web-extension/feature-scripts/steps/add-public-path-runtime-module.d.ts +6 -0
  164. package/dist/plugin-web-extension/feature-scripts/steps/classic-traced-globals-loader.d.ts +1 -0
  165. package/dist/plugin-web-extension/feature-scripts/steps/compile-main-world-scripts.d.ts +4 -0
  166. package/dist/plugin-web-extension/feature-scripts/steps/keep-completion-value.d.ts +6 -0
  167. package/dist/plugin-web-extension/feature-scripts/steps/pair-runtime-main-world-bridges.d.ts +12 -0
  168. package/dist/plugin-web-extension/feature-scripts/steps/place-runtime-script-sheets.d.ts +12 -0
  169. package/dist/plugin-web-extension/feature-scripts/steps/prune-main-world-bridges.d.ts +1 -0
  170. package/dist/plugin-web-extension/feature-scripts/steps/root-injected-sheet-urls.d.ts +9 -0
  171. package/dist/plugin-web-extension/feature-scripts/steps/route-main-world-copies.d.ts +10 -0
  172. package/dist/plugin-web-extension/feature-scripts/steps/source-literals.d.ts +24 -0
  173. package/dist/plugin-web-extension/feature-scripts/steps/take-extension-base.d.ts +11 -0
  174. package/dist/plugin-web-extension/feature-scripts/steps/trace-runtime-loaded-files.d.ts +18 -3
  175. package/dist/plugin-web-extension/feature-scripts/steps/warn-main-world-registration-changed.d.ts +12 -0
  176. package/dist/plugin-web-extension/feature-scripts/steps/warn-moved-page-relative-urls.d.ts +30 -0
  177. package/dist/plugin-web-extension/feature-scripts/steps/warn-page-relative-script-path.d.ts +10 -0
  178. package/dist/plugin-web-extension/feature-scripts/steps/warn-unknown-registration-world.d.ts +10 -0
  179. package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
  180. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/messages.d.ts +2 -0
  181. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/page-requests.d.ts +5 -0
  182. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/resolve-war.d.ts +1 -0
  183. package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/unreachable-resources.d.ts +1 -0
  184. package/dist/plugin-web-extension/shared/script-graph.d.ts +12 -0
  185. package/dist/preprocessor-passthrough-loader.mjs +1 -1
  186. package/dist/preview.mjs +1 -1
  187. package/dist/public-css-url-loader.mjs +1 -1
  188. package/dist/{331~0.mjs → q~0.mjs} +2 -2
  189. package/dist/rj~0.mjs +125 -0
  190. package/dist/{519~0.mjs → rl~0.mjs} +56 -5
  191. package/dist/rspack-config~0.mjs +3140 -3302
  192. package/dist/{177~0.mjs → r~0.mjs} +2 -2
  193. package/dist/sfc-style-block-loader.mjs +49 -0
  194. package/dist/stats-handler~0.mjs +15 -7
  195. package/dist/tm~0.mjs +71 -0
  196. package/dist/types.d.ts +46 -5
  197. package/dist/{285~0.mjs → t~0.mjs} +41 -26
  198. package/dist/unplaced-style-import-loader.mjs +131 -0
  199. package/dist/x~0.mjs +3 -0
  200. package/dist/y~0.mjs +234 -0
  201. package/dist/zip~0.mjs +5 -4
  202. package/dist/{363~0.mjs → z~0.mjs} +563 -281
  203. package/package.json +6 -6
  204. package/dist/527~0.mjs +0 -3
  205. package/dist/840~0.mjs +0 -5635
  206. /package/dist/{895~0.mjs → 3~0.mjs} +0 -0
  207. /package/dist/{374~0.mjs → 5~0.mjs} +0 -0
  208. /package/dist/{206~0.mjs → 6~0.mjs} +0 -0
  209. /package/dist/{471~0.mjs → g~0.mjs} +0 -0
  210. /package/dist/{117~0.mjs → w~0.mjs} +0 -0
package/dist/l~0.mjs ADDED
@@ -0,0 +1,2290 @@
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import { createRequire } from "node:module";
3
+ import { execFileSync } from "node:child_process";
4
+ import { spawn, sync } from "cross-spawn";
5
+ import { buildExecEnv, detectPackageManagerFromLockfile } from "prefers-yarn";
6
+ import pintor from "pintor";
7
+ import { DefinePlugin, WebpackError, rspack } from "@rspack/core";
8
+ import { pathToFileURL } from "node:url";
9
+ import { package_namespaceObject } from "./x~0.mjs";
10
+ import { parseJsonSafe } from "./5~0.mjs";
11
+ import { debugLine, isDebug, CODES, humanLine, prefix as messaging_prefix } from "./k~0.mjs";
12
+ import { codedError, real_path_isInsidePath } from "./tm~0.mjs";
13
+ import { hasProjectDependency, findNearestProjectManifestDirSync } from "./j~0.mjs";
14
+ import { isResourceUnderDirs as resource_path_isResourceUnderDirs, canonicalizeDir as resource_path_canonicalizeDir } from "./ka~0.mjs";
15
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
16
+ import { dirname as __rspack_dirname } from "node:path";
17
+ var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
18
+ import * as __rspack_external_node_fs_1b05aee1 from "node:fs";
19
+ import * as __rspack_external_node_path_806ed179 from "node:path";
20
+ const cjsRequire = createRequire(import.meta.url);
21
+ if (!process.env.EXTENSION_JS_OPTIONAL_DEPS_VERSION) process.env.EXTENSION_JS_OPTIONAL_DEPS_VERSION = package_namespaceObject.rE;
22
+ function resolveDevelopRootFromDir(dir) {
23
+ try {
24
+ const packageJsonPath = __rspack_external_node_path_806ed179.join(dir, 'package.json');
25
+ if (!__rspack_external_node_fs_1b05aee1.existsSync(packageJsonPath)) return;
26
+ const pkg = parseJsonSafe(__rspack_external_node_fs_1b05aee1.readFileSync(packageJsonPath, 'utf8'));
27
+ if (pkg?.name === 'extension-develop') return dir;
28
+ } catch {}
29
+ }
30
+ function findDevelopRootFrom(startDir) {
31
+ let currentDir = startDir;
32
+ const maxDepth = 6;
33
+ for(let i = 0; i < maxDepth; i++){
34
+ const root = resolveDevelopRootFromDir(currentDir);
35
+ if (root) return root;
36
+ const parent = __rspack_external_node_path_806ed179.dirname(currentDir);
37
+ if (parent === currentDir) break;
38
+ currentDir = parent;
39
+ }
40
+ }
41
+ function findExtensionDevelopRoot(startDir = __rspack_import_meta_dirname__) {
42
+ const envRoot = process.env.EXTENSION_DEVELOP_ROOT;
43
+ if (envRoot) {
44
+ const resolvedEnvRoot = resolveDevelopRootFromDir(__rspack_external_node_path_806ed179.resolve(envRoot));
45
+ if (resolvedEnvRoot) return resolvedEnvRoot;
46
+ }
47
+ return findDevelopRootFrom(startDir) || null;
48
+ }
49
+ function resolveDevelopInstallRoot() {
50
+ const directRoot = findExtensionDevelopRoot();
51
+ if (directRoot) return directRoot;
52
+ try {
53
+ const pkgPath = cjsRequire.resolve('extension-develop/package.json', {
54
+ paths: [
55
+ __rspack_import_meta_dirname__
56
+ ]
57
+ });
58
+ return resolveDevelopRootFromDir(__rspack_external_node_path_806ed179.dirname(pkgPath));
59
+ } catch {
60
+ return;
61
+ }
62
+ }
63
+ function resolveDevelopDistFile(stem) {
64
+ const installRoot = resolveDevelopInstallRoot();
65
+ const distRoot = installRoot ? __rspack_external_node_path_806ed179.join(installRoot, 'dist') : __rspack_external_node_path_806ed179.resolve(__rspack_import_meta_dirname__, '..');
66
+ const base = __rspack_external_node_path_806ed179.join(distRoot, stem);
67
+ const candidates = [
68
+ `${base}.js`,
69
+ `${base}.cjs`,
70
+ `${base}.mjs`,
71
+ base
72
+ ];
73
+ for (const candidate of candidates)if (__rspack_external_node_fs_1b05aee1.existsSync(candidate)) {
74
+ if ('1' === process.env.EXTENSION_DEBUG_DEVELOP_ROOT) debugLine(`[extjs:develop-root] ${stem} -> ${candidate} (installRoot=${installRoot || '<none>'})`);
75
+ return candidate;
76
+ }
77
+ if ('1' === process.env.EXTENSION_DEBUG_DEVELOP_ROOT) debugLine(`[extjs:develop-root] ${stem} -> ${base} (fallback, installRoot=${installRoot || '<none>'})`);
78
+ return base;
79
+ }
80
+ const BUNDLED_DEPENDENCY_VERSIONS = {
81
+ ...package_namespaceObject.El || {}
82
+ };
83
+ function optional_deps_contracts_spec(packageId) {
84
+ const version = BUNDLED_DEPENDENCY_VERSIONS[packageId];
85
+ return version ? `${packageId}@${version}` : packageId;
86
+ }
87
+ function specs(packageIds) {
88
+ return packageIds.map(optional_deps_contracts_spec);
89
+ }
90
+ function installRootRules(packageIds) {
91
+ return packageIds.map((packageId)=>({
92
+ type: 'install-root',
93
+ packageId
94
+ }));
95
+ }
96
+ function defineContract(contract) {
97
+ return contract;
98
+ }
99
+ const OPTIONAL_DEPENDENCY_CONTRACTS = {
100
+ 'react-refresh': defineContract({
101
+ id: 'react-refresh',
102
+ integration: 'React',
103
+ installPackages: specs([
104
+ 'react-refresh',
105
+ '@rspack/plugin-react-refresh'
106
+ ]),
107
+ verificationRules: [
108
+ ...installRootRules([
109
+ 'react-refresh',
110
+ '@rspack/plugin-react-refresh'
111
+ ]),
112
+ {
113
+ type: 'module-context-resolve',
114
+ fromPackage: '@rspack/plugin-react-refresh',
115
+ packageId: 'react-refresh'
116
+ }
117
+ ]
118
+ }),
119
+ 'preact-refresh': defineContract({
120
+ id: 'preact-refresh',
121
+ integration: 'Preact',
122
+ installPackages: specs([
123
+ '@prefresh/core',
124
+ '@prefresh/utils',
125
+ '@rspack/plugin-preact-refresh',
126
+ 'preact'
127
+ ]),
128
+ verificationRules: [
129
+ ...installRootRules([
130
+ '@prefresh/core',
131
+ '@prefresh/utils',
132
+ '@rspack/plugin-preact-refresh',
133
+ 'preact'
134
+ ]),
135
+ {
136
+ type: 'module-context-resolve',
137
+ fromPackage: '@rspack/plugin-preact-refresh',
138
+ packageId: '@prefresh/core'
139
+ },
140
+ {
141
+ type: 'module-context-resolve',
142
+ fromPackage: '@rspack/plugin-preact-refresh',
143
+ packageId: '@prefresh/utils'
144
+ },
145
+ {
146
+ type: 'module-context-resolve',
147
+ fromPackage: '@rspack/plugin-preact-refresh',
148
+ packageId: 'preact'
149
+ }
150
+ ]
151
+ }),
152
+ vue: defineContract({
153
+ id: 'vue',
154
+ integration: 'Vue',
155
+ installPackages: specs([
156
+ 'vue-loader',
157
+ '@vue/compiler-sfc',
158
+ 'vue'
159
+ ]),
160
+ verificationRules: [
161
+ ...installRootRules([
162
+ 'vue-loader',
163
+ '@vue/compiler-sfc',
164
+ 'vue'
165
+ ]),
166
+ {
167
+ type: 'module-context-load',
168
+ fromPackage: 'vue-loader',
169
+ packageId: '@vue/compiler-sfc'
170
+ }
171
+ ]
172
+ }),
173
+ solid: defineContract({
174
+ id: 'solid',
175
+ integration: 'Solid',
176
+ installPackages: specs([
177
+ 'babel-loader',
178
+ '@babel/core',
179
+ 'babel-preset-solid',
180
+ "@babel/preset-typescript"
181
+ ]),
182
+ verificationRules: installRootRules([
183
+ 'babel-loader',
184
+ '@babel/core',
185
+ 'babel-preset-solid',
186
+ "@babel/preset-typescript"
187
+ ])
188
+ }),
189
+ svelte: defineContract({
190
+ id: 'svelte',
191
+ integration: 'Svelte',
192
+ installPackages: specs([
193
+ 'svelte-loader'
194
+ ]),
195
+ verificationRules: installRootRules([
196
+ 'svelte-loader'
197
+ ])
198
+ }),
199
+ less: defineContract({
200
+ id: 'less',
201
+ integration: 'LESS',
202
+ installPackages: specs([
203
+ 'less',
204
+ 'less-loader'
205
+ ]),
206
+ verificationRules: installRootRules([
207
+ 'less',
208
+ 'less-loader'
209
+ ])
210
+ }),
211
+ postcss: defineContract({
212
+ id: 'postcss',
213
+ integration: 'PostCSS',
214
+ installPackages: specs([
215
+ 'postcss',
216
+ 'postcss-loader'
217
+ ]),
218
+ verificationRules: installRootRules([
219
+ 'postcss',
220
+ 'postcss-loader'
221
+ ])
222
+ }),
223
+ sass: defineContract({
224
+ id: 'sass',
225
+ integration: 'SASS',
226
+ installPackages: specs([
227
+ 'postcss-loader',
228
+ 'postcss-scss',
229
+ 'postcss-preset-env',
230
+ 'sass-loader'
231
+ ]),
232
+ verificationRules: installRootRules([
233
+ 'postcss-loader',
234
+ 'postcss-scss',
235
+ 'postcss-preset-env',
236
+ 'sass-loader'
237
+ ])
238
+ })
239
+ };
240
+ function getOptionalDependencyContract(contractId) {
241
+ const contract = OPTIONAL_DEPENDENCY_CONTRACTS[contractId];
242
+ if (!contract) throw codedError(CODES.E_OPTIONAL_DEP_UNKNOWN, `Unknown optional dependency contract: ${contractId}`);
243
+ return contract;
244
+ }
245
+ const NPMRC_REGISTRY = /^\s*registry\s*=\s*(.*?)\s*$/;
246
+ const PUBLIC_REGISTRY_HOSTS = [
247
+ 'registry.npmjs.org',
248
+ 'registry.yarnpkg.com'
249
+ ];
250
+ function readEnv(source, name) {
251
+ const key = Object.keys(source).find((candidate)=>candidate.toLowerCase() === name.toLowerCase() && source[candidate]);
252
+ return void 0 === key ? void 0 : source[key];
253
+ }
254
+ function readNpmrcRegistry(projectDir) {
255
+ let registry;
256
+ try {
257
+ for (const line of __rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(projectDir, '.npmrc'), 'utf8').split(/\r?\n/)){
258
+ const match = NPMRC_REGISTRY.exec(line);
259
+ if (match) registry = match[1].replace(/^(['"])(.*)\1$/, '$2');
260
+ }
261
+ } catch {}
262
+ return registry;
263
+ }
264
+ function privateRegistry(value) {
265
+ const raw = String(value || '').trim();
266
+ if (!raw || raw.includes('${')) return;
267
+ try {
268
+ const url = new URL(raw);
269
+ if ('http:' !== url.protocol && 'https:' !== url.protocol) return;
270
+ if (PUBLIC_REGISTRY_HOSTS.includes(url.hostname)) return;
271
+ return url.href.replace(/\/+$/, '');
272
+ } catch {
273
+ return;
274
+ }
275
+ }
276
+ function corepackRegistryEnv(source, projectDir) {
277
+ if (readEnv(source, 'COREPACK_NPM_REGISTRY')) return {};
278
+ const registry = privateRegistry(readEnv(source, 'npm_config_registry') || readNpmrcRegistry(projectDir));
279
+ return registry ? {
280
+ COREPACK_NPM_REGISTRY: registry
281
+ } : {};
282
+ }
283
+ const package_manager_require = createRequire(import.meta.url);
284
+ function normalizePackageManager(value) {
285
+ if (!value) return;
286
+ const lower = value.toLowerCase().trim();
287
+ if ('pnpm' === lower) return 'pnpm';
288
+ if ('yarn' === lower) return 'yarn';
289
+ if ('bun' === lower) return 'bun';
290
+ if ('npm' === lower) return 'npm';
291
+ if ('deno' === lower) return 'deno';
292
+ }
293
+ function inferPackageManagerFromPath(value) {
294
+ if (!value) return;
295
+ const lower = value.toLowerCase();
296
+ if (lower.includes('pnpm')) return 'pnpm';
297
+ if (lower.includes('yarn')) return 'yarn';
298
+ if (lower.includes('bun')) return 'bun';
299
+ if (lower.includes('npm')) return 'npm';
300
+ }
301
+ function getPackageManagerOverride() {
302
+ const name = normalizePackageManager(process.env.EXTENSION_JS_PACKAGE_MANAGER);
303
+ const execPath = process.env.EXTENSION_JS_PM_EXEC_PATH || process.env.npm_execpath || process.env.NPM_EXEC_PATH;
304
+ if (!name && !execPath) return;
305
+ const inferredName = name || inferPackageManagerFromPath(execPath) || 'npm';
306
+ return {
307
+ name: inferredName,
308
+ execPath
309
+ };
310
+ }
311
+ function detectPackageManagerFromEnv() {
312
+ const userAgent = process.env.npm_config_user_agent || '';
313
+ const execPath = process.env.npm_execpath || process.env.NPM_EXEC_PATH || '';
314
+ if (userAgent.includes('pnpm')) return {
315
+ name: 'pnpm',
316
+ execPath: execPath || void 0
317
+ };
318
+ if (userAgent.includes('yarn')) return {
319
+ name: 'yarn',
320
+ execPath: execPath || void 0
321
+ };
322
+ if (userAgent.includes('bun')) return {
323
+ name: 'bun',
324
+ execPath: execPath || void 0
325
+ };
326
+ if (userAgent.includes('npm')) return {
327
+ name: 'npm',
328
+ execPath: execPath || void 0
329
+ };
330
+ if (execPath) {
331
+ const inferred = inferPackageManagerFromPath(execPath) || 'npm';
332
+ return {
333
+ name: inferred,
334
+ execPath
335
+ };
336
+ }
337
+ }
338
+ function resolveNpmCliFromNode(execPath) {
339
+ const execDir = __rspack_external_node_path_806ed179.dirname(execPath);
340
+ const candidates = [
341
+ __rspack_external_node_path_806ed179.join(execDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
342
+ __rspack_external_node_path_806ed179.join(execDir, '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
343
+ __rspack_external_node_path_806ed179.join(execDir, '..', 'node_modules', 'npm', 'bin', 'npm-cli.js')
344
+ ];
345
+ for (const candidate of candidates)if (__rspack_external_node_fs_1b05aee1.existsSync(candidate)) return candidate;
346
+ }
347
+ function resolveBundledNpmCliPath() {
348
+ if (process.env.EXTENSION_JS_PM_EXEC_PATH) {
349
+ const overridePath = process.env.EXTENSION_JS_PM_EXEC_PATH;
350
+ if (overridePath && __rspack_external_node_fs_1b05aee1.existsSync(overridePath)) return overridePath;
351
+ }
352
+ try {
353
+ const resolved = package_manager_require.resolve('npm/bin/npm-cli.js', {
354
+ paths: [
355
+ process.cwd(),
356
+ __rspack_import_meta_dirname__
357
+ ]
358
+ });
359
+ if (resolved && __rspack_external_node_fs_1b05aee1.existsSync(resolved)) return resolved;
360
+ } catch {}
361
+ return resolveNpmCliFromNode(process.execPath);
362
+ }
363
+ function isWindowsExecutablePath(value) {
364
+ if (!value || 'win32' !== process.platform) return false;
365
+ return /\.(cmd|bat|exe)$/i.test(value);
366
+ }
367
+ function isNodeScriptPath(value) {
368
+ if (!value) return false;
369
+ return /\.(mjs|cjs|js)$/i.test(value);
370
+ }
371
+ function resolveWindowsCommandPath(command) {
372
+ if ('win32' !== process.platform) return;
373
+ try {
374
+ const systemRoot = process.env.SystemRoot || 'C:\\Windows';
375
+ const whereExe = __rspack_external_node_path_806ed179.join(systemRoot, 'System32', 'where.exe');
376
+ const whereCommand = __rspack_external_node_fs_1b05aee1.existsSync(whereExe) ? whereExe : 'where';
377
+ const output = execFileSync(whereCommand, [
378
+ command
379
+ ], {
380
+ encoding: 'utf8',
381
+ stdio: [
382
+ 'ignore',
383
+ 'pipe',
384
+ 'ignore'
385
+ ],
386
+ windowsHide: true
387
+ });
388
+ const candidates = String(output).split(/\r?\n/).map((line)=>line.trim()).filter(Boolean);
389
+ const cmdMatch = candidates.find((line)=>/\.cmd$/i.test(line));
390
+ return cmdMatch || candidates[0];
391
+ } catch {
392
+ return;
393
+ }
394
+ }
395
+ function resolveUnixCommandPath(command) {
396
+ if ('win32' === process.platform) return;
397
+ try {
398
+ const output = execFileSync('which', [
399
+ command
400
+ ], {
401
+ encoding: 'utf8',
402
+ stdio: [
403
+ 'ignore',
404
+ 'pipe',
405
+ 'ignore'
406
+ ]
407
+ });
408
+ const candidate = String(output).trim();
409
+ return candidate || void 0;
410
+ } catch {
411
+ return;
412
+ }
413
+ }
414
+ function resolveCommandOnPath(command) {
415
+ return resolveWindowsCommandPath(command) || resolveUnixCommandPath(command) || void 0;
416
+ }
417
+ function canRunCorepack() {
418
+ try {
419
+ const result = sync('corepack', [
420
+ '--version'
421
+ ], {
422
+ stdio: 'ignore',
423
+ windowsHide: true
424
+ });
425
+ return result?.status === 0;
426
+ } catch {
427
+ return false;
428
+ }
429
+ }
430
+ function hydrateResolvedPackageManager(name) {
431
+ const resolvedCommand = resolveCommandOnPath(name);
432
+ if (resolvedCommand) return {
433
+ name,
434
+ execPath: resolvedCommand
435
+ };
436
+ if ('npm' === name) {
437
+ const bundledNpmCli = resolveBundledNpmCliPath();
438
+ if (bundledNpmCli) return {
439
+ name: 'npm',
440
+ execPath: bundledNpmCli,
441
+ runnerCommand: process.execPath,
442
+ runnerArgs: [
443
+ bundledNpmCli
444
+ ]
445
+ };
446
+ }
447
+ }
448
+ function detectDenoProject(cwd) {
449
+ if (!cwd) return;
450
+ try {
451
+ const hasDenoLock = __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(cwd, 'deno.lock'));
452
+ const hasDenoConfig = __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(cwd, 'deno.jsonc')) || __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(cwd, 'deno.json'));
453
+ const hasPackageJson = __rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(cwd, 'package.json'));
454
+ if (!hasDenoLock && !(hasDenoConfig && !hasPackageJson)) return;
455
+ } catch {
456
+ return;
457
+ }
458
+ const execPath = resolveCommandOnPath('deno');
459
+ if (execPath) return {
460
+ name: 'deno',
461
+ execPath
462
+ };
463
+ }
464
+ function resolvePackageManager(opts) {
465
+ const lockPm = detectPackageManagerFromLockfile(opts?.cwd);
466
+ if (lockPm) {
467
+ const hydrated = hydrateResolvedPackageManager(lockPm);
468
+ if (hydrated) return hydrated;
469
+ return {
470
+ name: lockPm
471
+ };
472
+ }
473
+ const override = getPackageManagerOverride();
474
+ if (override) return override;
475
+ const denoPm = detectDenoProject(opts?.cwd);
476
+ if (denoPm) return denoPm;
477
+ const envPm = detectPackageManagerFromEnv();
478
+ if (envPm) return envPm;
479
+ const candidates = [
480
+ 'pnpm',
481
+ 'yarn',
482
+ 'bun'
483
+ ];
484
+ for (const candidate of candidates){
485
+ const resolved = resolveCommandOnPath(candidate);
486
+ if (resolved) return {
487
+ name: candidate,
488
+ execPath: resolved
489
+ };
490
+ }
491
+ const corepackPath = resolveCommandOnPath('corepack');
492
+ if (corepackPath || canRunCorepack()) return {
493
+ name: 'pnpm',
494
+ runnerCommand: corepackPath || 'corepack',
495
+ runnerArgs: [
496
+ 'pnpm'
497
+ ]
498
+ };
499
+ const bundledNpmCli = resolveBundledNpmCliPath();
500
+ if (bundledNpmCli) return {
501
+ name: 'npm',
502
+ execPath: bundledNpmCli,
503
+ runnerCommand: process.execPath,
504
+ runnerArgs: [
505
+ bundledNpmCli
506
+ ]
507
+ };
508
+ return {
509
+ name: 'npm'
510
+ };
511
+ }
512
+ function projectInstallArgs(pm, projectDir) {
513
+ if ('pnpm' !== pm.name) return [];
514
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(projectDir, 'pnpm-workspace.yaml'))) return [];
515
+ try {
516
+ const raw = __rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(projectDir, 'package.json'), 'utf8');
517
+ const pkg = JSON.parse(raw);
518
+ const depFields = [
519
+ pkg.dependencies,
520
+ pkg.devDependencies,
521
+ pkg.optionalDependencies,
522
+ pkg.peerDependencies
523
+ ];
524
+ for (const deps of depFields)if (deps) {
525
+ for (const spec of Object.values(deps))if ('string' == typeof spec && spec.startsWith('workspace:')) return [];
526
+ }
527
+ } catch {}
528
+ return [
529
+ '--ignore-workspace'
530
+ ];
531
+ }
532
+ function findPnpmWorkspaceRoot(startDir) {
533
+ let current = __rspack_external_node_path_806ed179.resolve(startDir);
534
+ while(true){
535
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(current, 'pnpm-workspace.yaml'))) return current;
536
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(current, '.git'))) return;
537
+ const parent = __rspack_external_node_path_806ed179.dirname(current);
538
+ if (parent === current) return;
539
+ current = parent;
540
+ }
541
+ }
542
+ function cleanYamlListItem(value) {
543
+ const trimmed = value.trim();
544
+ const quoted = /^(['"])(.*?)\1/.exec(trimmed);
545
+ if (quoted) return quoted[2].trim();
546
+ return trimmed.replace(/\s+#.*$/, '').trim();
547
+ }
548
+ function readPnpmWorkspacePackages(workspaceRoot) {
549
+ let raw;
550
+ try {
551
+ raw = __rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(workspaceRoot, 'pnpm-workspace.yaml'), 'utf8');
552
+ } catch {
553
+ return [];
554
+ }
555
+ const lines = raw.split(/\r?\n/);
556
+ const patterns = [];
557
+ for(let i = 0; i < lines.length; i++){
558
+ const key = /^packages\s*:(.*)$/.exec(lines[i]);
559
+ if (!key) continue;
560
+ const inline = key[1].trim();
561
+ if (inline.startsWith('[')) {
562
+ let flow = inline;
563
+ let j = i;
564
+ while(!flow.includes(']') && j + 1 < lines.length){
565
+ j++;
566
+ flow += lines[j];
567
+ }
568
+ const body = flow.slice(1, flow.indexOf(']'));
569
+ for (const item of body.split(',')){
570
+ const value = cleanYamlListItem(item);
571
+ if (value) patterns.push(value);
572
+ }
573
+ break;
574
+ }
575
+ for(let j = i + 1; j < lines.length; j++){
576
+ const line = lines[j];
577
+ if (!line.trim() || line.trim().startsWith('#')) continue;
578
+ const item = /^\s*-\s*(.+)$/.exec(line);
579
+ if (!item) break;
580
+ const value = cleanYamlListItem(item[1]);
581
+ if (value) patterns.push(value);
582
+ }
583
+ break;
584
+ }
585
+ return patterns;
586
+ }
587
+ function workspaceGlobToRegExp(pattern) {
588
+ let source = '^';
589
+ for(let i = 0; i < pattern.length; i++){
590
+ const char = pattern[i];
591
+ if ('*' === char && '*' === pattern[i + 1]) {
592
+ const spansSegments = '/' === pattern[i + 2];
593
+ source += spansSegments ? '(?:.*/)?' : '.*';
594
+ i += spansSegments ? 2 : 1;
595
+ } else if ('*' === char) source += '[^/]*';
596
+ else if ('?' === char) source += '[^/]';
597
+ else source += char.replace(/[.+^${}()|[\]\\]/g, '\\$&');
598
+ }
599
+ return new RegExp(`${source}$`);
600
+ }
601
+ function isPnpmWorkspaceMemberDir(patterns, relativeDir) {
602
+ const target = relativeDir.split(__rspack_external_node_path_806ed179.sep).join('/');
603
+ let included = false;
604
+ for (const raw of patterns){
605
+ const negated = raw.startsWith('!');
606
+ const glob = (negated ? raw.slice(1) : raw).replace(/^\.\//, '').replace(/\/+$/, '');
607
+ if (workspaceGlobToRegExp(glob).test(target)) {
608
+ if (negated) return false;
609
+ included = true;
610
+ }
611
+ }
612
+ return included;
613
+ }
614
+ function findPnpmWorkspaceMember(projectDir) {
615
+ const root = findPnpmWorkspaceRoot(projectDir);
616
+ if (!root) return;
617
+ const resolvedProject = __rspack_external_node_path_806ed179.resolve(projectDir);
618
+ if (root === resolvedProject) return;
619
+ const relativeDir = __rspack_external_node_path_806ed179.relative(root, resolvedProject).split(__rspack_external_node_path_806ed179.sep).join('/');
620
+ if (!isPnpmWorkspaceMemberDir(readPnpmWorkspacePackages(root), relativeDir)) return;
621
+ return {
622
+ root,
623
+ relativeDir
624
+ };
625
+ }
626
+ function readPackageJsonWorkspaces(dir) {
627
+ try {
628
+ const pkg = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(dir, 'package.json'), 'utf8'));
629
+ const field = pkg?.workspaces;
630
+ const list = Array.isArray(field) ? field : field?.packages;
631
+ if (!Array.isArray(list)) return;
632
+ return list.filter((item)=>'string' == typeof item);
633
+ } catch {
634
+ return;
635
+ }
636
+ }
637
+ function findPackageJsonWorkspaceRoot(startDir) {
638
+ let current = __rspack_external_node_path_806ed179.resolve(startDir);
639
+ while(true){
640
+ if (readPackageJsonWorkspaces(current)) return current;
641
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(current, '.git'))) return;
642
+ const parent = __rspack_external_node_path_806ed179.dirname(current);
643
+ if (parent === current) return;
644
+ current = parent;
645
+ }
646
+ }
647
+ function packageJsonWorkspaceManager(root) {
648
+ const lockPm = detectPackageManagerFromLockfile(root);
649
+ if ('pnpm' === lockPm) return;
650
+ if (lockPm) return lockPm;
651
+ try {
652
+ const pkg = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(root, 'package.json'), 'utf8'));
653
+ const pinned = /^(npm|yarn|bun)@/.exec(String(pkg?.packageManager || ''));
654
+ if (pinned) return pinned[1];
655
+ } catch {}
656
+ return 'npm';
657
+ }
658
+ function findWorkspaceMember(projectDir) {
659
+ const pnpmMember = findPnpmWorkspaceMember(projectDir);
660
+ if (pnpmMember) return {
661
+ ...pnpmMember,
662
+ manager: 'pnpm'
663
+ };
664
+ const root = findPackageJsonWorkspaceRoot(projectDir);
665
+ if (!root) return;
666
+ const resolvedProject = __rspack_external_node_path_806ed179.resolve(projectDir);
667
+ if (root === resolvedProject) return;
668
+ const relativeDir = __rspack_external_node_path_806ed179.relative(root, resolvedProject).split(__rspack_external_node_path_806ed179.sep).join('/');
669
+ const patterns = readPackageJsonWorkspaces(root) || [];
670
+ if (!isPnpmWorkspaceMemberDir(patterns, relativeDir)) return;
671
+ const manager = packageJsonWorkspaceManager(root);
672
+ if (!manager) return;
673
+ return {
674
+ root,
675
+ relativeDir,
676
+ manager
677
+ };
678
+ }
679
+ function workspaceManagerOverride(member) {
680
+ if ('pnpm' === member.manager) return;
681
+ if (detectPackageManagerFromLockfile(member.root)) return;
682
+ return hydrateResolvedPackageManager(member.manager) || {
683
+ name: member.manager
684
+ };
685
+ }
686
+ function projectInstallTarget(pm, projectDir, member) {
687
+ const memberManager = member ? 'manager' in member ? member.manager : 'pnpm' : void 0;
688
+ if (member && 'pnpm' === pm.name && 'pnpm' === memberManager) return {
689
+ cwd: member.root,
690
+ args: [
691
+ '--filter',
692
+ `{${member.relativeDir}}...`
693
+ ]
694
+ };
695
+ if (member && memberManager && 'pnpm' !== memberManager) return {
696
+ cwd: member.root,
697
+ args: []
698
+ };
699
+ return {
700
+ cwd: projectDir,
701
+ args: projectInstallArgs(pm, projectDir)
702
+ };
703
+ }
704
+ function installScriptSuppression(pm) {
705
+ if ('true' === process.env.EXTENSION_ALLOW_INSTALL_SCRIPTS) return {
706
+ args: [],
707
+ env: {}
708
+ };
709
+ if ('deno' === pm.name) return {
710
+ args: [],
711
+ env: {}
712
+ };
713
+ if ('yarn' === pm.name) return {
714
+ args: [],
715
+ env: {
716
+ YARN_ENABLE_SCRIPTS: 'false',
717
+ npm_config_ignore_scripts: 'true'
718
+ }
719
+ };
720
+ return {
721
+ args: [
722
+ "--ignore-scripts"
723
+ ],
724
+ env: {}
725
+ };
726
+ }
727
+ function resolveNpmPackageManager() {
728
+ return hydrateResolvedPackageManager('npm') || {
729
+ name: 'npm'
730
+ };
731
+ }
732
+ function buildInstallCommand(pm, args) {
733
+ if (pm.runnerCommand) return {
734
+ command: pm.runnerCommand,
735
+ args: [
736
+ ...pm.runnerArgs || [],
737
+ ...args
738
+ ]
739
+ };
740
+ if (pm.execPath) {
741
+ if (isWindowsExecutablePath(pm.execPath)) return {
742
+ command: pm.execPath,
743
+ args
744
+ };
745
+ if (isNodeScriptPath(pm.execPath)) return {
746
+ command: process.execPath,
747
+ args: [
748
+ pm.execPath,
749
+ ...args
750
+ ]
751
+ };
752
+ return {
753
+ command: pm.execPath,
754
+ args
755
+ };
756
+ }
757
+ return {
758
+ command: pm.name,
759
+ args
760
+ };
761
+ }
762
+ function buildSpawnInvocation(command, args) {
763
+ return {
764
+ command,
765
+ args
766
+ };
767
+ }
768
+ function spawnInstallCommand(command, args, options) {
769
+ const invocation = buildSpawnInvocation(command, args);
770
+ const env = buildExecEnv() || process.env;
771
+ return spawn(invocation.command, invocation.args, {
772
+ cwd: options?.cwd,
773
+ stdio: options?.stdio ?? 'ignore',
774
+ env: {
775
+ ...env,
776
+ ...corepackRegistryEnv(env, options?.cwd ?? process.cwd()),
777
+ ...options?.env
778
+ }
779
+ });
780
+ }
781
+ function execInstallCommand(command, args, options) {
782
+ return new Promise((resolve, reject)=>{
783
+ const child = spawnInstallCommand(command, args, options);
784
+ child.on('close', (code)=>{
785
+ if (0 !== code) reject(new Error(`Install failed with exit code ${code}`));
786
+ else resolve();
787
+ });
788
+ child.on('error', (error)=>reject(error));
789
+ });
790
+ }
791
+ function debugSwallowed(step, error) {
792
+ if (!isVerboseMode()) return;
793
+ debugLine(`${messaging_prefix('debug')} optional-deps ${step}: ${String(error?.message || error)}`);
794
+ }
795
+ function isVerboseMode() {
796
+ return '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
797
+ }
798
+ function installVerbForPackageManager(name) {
799
+ if ('npm' === name) return 'install -D';
800
+ if ('deno' === name) return 'add --dev';
801
+ return 'add -D';
802
+ }
803
+ function formatInstallHint(projectPath, packageSpecs) {
804
+ const { name } = resolvePackageManager({
805
+ cwd: projectPath
806
+ });
807
+ const verb = installVerbForPackageManager(name);
808
+ return `${name} ${verb} ${packageSpecs.join(' ')}`;
809
+ }
810
+ function formatResolverError(args) {
811
+ const hint = formatInstallHint(args.projectPath, args.installSpecs);
812
+ const readableLine = `[${args.integration}] ${args.headline} Install it with: ${hint}`;
813
+ if (!isVerboseMode()) return readableLine;
814
+ return `${readableLine}\n${JSON.stringify(args.diagnostics, null, 2)}`;
815
+ }
816
+ function toInstallRootContract(integration, contractId, installDependencies, verifyPackageIds) {
817
+ return {
818
+ id: contractId,
819
+ integration,
820
+ installPackages: installDependencies,
821
+ verificationRules: verifyPackageIds.map((packageId)=>({
822
+ type: 'install-root',
823
+ packageId
824
+ }))
825
+ };
826
+ }
827
+ function getVerificationContract(input) {
828
+ if (input.contract) return input.contract;
829
+ const installDependencies = input.installDependencies || [
830
+ input.dependencyId
831
+ ];
832
+ const verifyPackageIds = input.verifyPackageIds || installDependencies;
833
+ return toInstallRootContract(input.integration, input.integration, installDependencies, verifyPackageIds);
834
+ }
835
+ function getResolutionBases(projectPath) {
836
+ const extensionRoot = resolveDevelopInstallRoot();
837
+ const bases = [
838
+ projectPath,
839
+ extensionRoot || void 0,
840
+ process.cwd()
841
+ ].filter(Boolean);
842
+ if (extensionRoot?.includes('.pnpm')) bases.push(__rspack_external_node_path_806ed179.join(extensionRoot, '..', '..'));
843
+ return Array.from(new Set(bases));
844
+ }
845
+ function optional_deps_resolver_packageJsonPath(basePath) {
846
+ return __rspack_external_node_path_806ed179.join(basePath, 'package.json');
847
+ }
848
+ function tryResolveWithBase(dependencyId, basePath) {
849
+ try {
850
+ const req = createRequire(optional_deps_resolver_packageJsonPath(basePath));
851
+ return req.resolve(dependencyId);
852
+ } catch (error) {
853
+ debugSwallowed(`resolve ${dependencyId} from ${basePath}`, error);
854
+ return;
855
+ }
856
+ }
857
+ function resolveDependency(dependencyId, projectPath) {
858
+ const bases = getResolutionBases(projectPath);
859
+ for (const basePath of bases){
860
+ const resolvedPath = tryResolveWithBase(dependencyId, basePath);
861
+ if (resolvedPath) return {
862
+ resolvedPath,
863
+ basePath
864
+ };
865
+ }
866
+ try {
867
+ const resolvedPath = require.resolve(dependencyId, {
868
+ paths: bases
869
+ });
870
+ return {
871
+ resolvedPath,
872
+ basePath: projectPath
873
+ };
874
+ } catch (error) {
875
+ debugSwallowed(`resolve ${dependencyId} from the project bases`, error);
876
+ return;
877
+ }
878
+ }
879
+ function resolveFromKnownLocations(dependencyId, projectPath) {
880
+ const direct = resolveDependency(dependencyId, projectPath)?.resolvedPath;
881
+ if (direct) return direct;
882
+ if (declaresDependency(projectPath, dependencyId)) return projectPath;
883
+ }
884
+ function declaresDependency(projectPath, dependencyId) {
885
+ try {
886
+ return hasProjectDependency(projectPath, dependencyId);
887
+ } catch (error) {
888
+ debugSwallowed(`read the project manifest for ${dependencyId}`, error);
889
+ return false;
890
+ }
891
+ }
892
+ function dedupeFailures(packageIds) {
893
+ return Array.from(new Set(packageIds));
894
+ }
895
+ function resolveRealPathSafe(targetPath) {
896
+ try {
897
+ return __rspack_external_node_fs_1b05aee1.realpathSync(targetPath);
898
+ } catch (error) {
899
+ debugSwallowed(`realpath ${targetPath}`, error);
900
+ return __rspack_external_node_path_806ed179.resolve(targetPath);
901
+ }
902
+ }
903
+ function findOwningPackageDir(resolvedPath) {
904
+ let currentPath = __rspack_external_node_path_806ed179.dirname(resolvedPath);
905
+ for(let depth = 0; depth < 8; depth++){
906
+ const packageJson = __rspack_external_node_path_806ed179.join(currentPath, 'package.json');
907
+ if (__rspack_external_node_fs_1b05aee1.existsSync(packageJson)) return currentPath;
908
+ const parent = __rspack_external_node_path_806ed179.dirname(currentPath);
909
+ if (parent === currentPath) break;
910
+ currentPath = parent;
911
+ }
912
+ }
913
+ function isSameInstalledPackage(resolvedPath, expectedInstalledPath) {
914
+ const resolvedPackageDir = findOwningPackageDir(resolvedPath);
915
+ const expectedPackageDir = findOwningPackageDir(expectedInstalledPath);
916
+ if (resolvedPackageDir && expectedPackageDir) return resolveRealPathSafe(resolvedPackageDir) === resolveRealPathSafe(expectedPackageDir);
917
+ return resolveRealPathSafe(resolvedPath) === resolveRealPathSafe(expectedInstalledPath);
918
+ }
919
+ function evaluateModuleContextRule(rule, fromPackagePath, options) {
920
+ try {
921
+ const req = createRequire(fromPackagePath);
922
+ const resolvedPeer = req.resolve(rule.packageId);
923
+ if (options?.expectedInstalledPath && !isSameInstalledPackage(resolvedPeer, options.expectedInstalledPath)) return rule.packageId;
924
+ if ('module-context-load' === rule.type) req(rule.packageId);
925
+ return;
926
+ } catch (error) {
927
+ debugSwallowed(`verify ${rule.packageId}`, error);
928
+ return rule.packageId;
929
+ }
930
+ }
931
+ function getContractVerificationFailuresFromKnownLocations(contract, projectPath) {
932
+ const resolvedByPackage = new Map();
933
+ const resolvePackage = (packageId)=>{
934
+ if (!resolvedByPackage.has(packageId)) resolvedByPackage.set(packageId, resolveFromKnownLocations(packageId, projectPath));
935
+ return resolvedByPackage.get(packageId);
936
+ };
937
+ const failures = [];
938
+ for (const rule of contract.verificationRules){
939
+ if ('install-root' === rule.type) {
940
+ if (!resolvePackage(rule.packageId)) failures.push(rule.packageId);
941
+ continue;
942
+ }
943
+ const fromPackagePath = resolvePackage(rule.fromPackage);
944
+ if (!fromPackagePath) {
945
+ failures.push(rule.fromPackage);
946
+ continue;
947
+ }
948
+ const failure = evaluateModuleContextRule(rule, fromPackagePath);
949
+ if (!(failure && declaresDependency(projectPath, failure))) {
950
+ if (failure) failures.push(failure);
951
+ }
952
+ }
953
+ return dedupeFailures(failures);
954
+ }
955
+ function buildDiagnostics(input) {
956
+ const bases = getResolutionBases(input.projectPath);
957
+ return {
958
+ contractId: input.contract?.id || null,
959
+ integration: input.integration,
960
+ dependencyId: input.dependencyId,
961
+ projectPath: input.projectPath,
962
+ installDependencies: input.installDependencies,
963
+ verifyPackageIds: input.verifyPackageIds,
964
+ resolutionBases: bases
965
+ };
966
+ }
967
+ async function ensureOptionalPackageResolved(input) {
968
+ const contract = getVerificationContract(input);
969
+ const missing = getContractVerificationFailuresFromKnownLocations(contract, input.projectPath);
970
+ const resolved = resolveFromKnownLocations(input.dependencyId, input.projectPath);
971
+ if (resolved && 0 === missing.length) return resolved;
972
+ const diagnostics = buildDiagnostics({
973
+ integration: input.integration,
974
+ dependencyId: input.dependencyId,
975
+ projectPath: input.projectPath,
976
+ contract,
977
+ installDependencies: contract.installPackages,
978
+ verifyPackageIds: contract.installPackages
979
+ });
980
+ const headline = `${input.dependencyId} could not be resolved.` + (missing.length > 0 ? ` Missing or invalid packages: ${missing.join(', ')}.` : '');
981
+ throw codedError(CODES.E_OPTIONAL_DEP_UNRESOLVED, formatResolverError({
982
+ integration: input.integration,
983
+ dependencyId: input.dependencyId,
984
+ headline,
985
+ installSpecs: missing.length > 0 ? missing : contract.installPackages,
986
+ projectPath: input.projectPath,
987
+ diagnostics: {
988
+ ...diagnostics,
989
+ missing
990
+ }
991
+ }));
992
+ }
993
+ function resolveOptionalPackageWithoutInstall(input) {
994
+ const contract = getVerificationContract(input);
995
+ const resolved = resolveFromKnownLocations(input.dependencyId, input.projectPath);
996
+ const missingPeerDeps = getContractVerificationFailuresFromKnownLocations(contract, input.projectPath);
997
+ if (resolved && 0 === missingPeerDeps.length) return resolved;
998
+ const diagnostics = buildDiagnostics({
999
+ integration: input.integration,
1000
+ dependencyId: input.dependencyId,
1001
+ projectPath: input.projectPath,
1002
+ contract,
1003
+ installDependencies: contract.installPackages,
1004
+ verifyPackageIds: contract.installPackages
1005
+ });
1006
+ throw codedError(CODES.E_OPTIONAL_DEP_UNRESOLVED, formatResolverError({
1007
+ integration: input.integration,
1008
+ dependencyId: input.dependencyId,
1009
+ headline: `${input.dependencyId} could not be resolved from the project or extension-develop.`,
1010
+ installSpecs: missingPeerDeps.length > 0 ? missingPeerDeps : contract.installPackages,
1011
+ projectPath: input.projectPath,
1012
+ diagnostics: {
1013
+ ...diagnostics,
1014
+ missingPeerDeps,
1015
+ expectation: 'Run optional dependency preflight or reinstall extension-develop.'
1016
+ }
1017
+ }));
1018
+ }
1019
+ async function ensureOptionalModuleLoaded(input) {
1020
+ const resolvedPath = await ensureOptionalPackageResolved(input);
1021
+ const candidateBases = getResolutionBases(input.projectPath);
1022
+ let loaded;
1023
+ let didLoad = false;
1024
+ let lastLoadError;
1025
+ for (const basePath of candidateBases){
1026
+ const req = createRequire(optional_deps_resolver_packageJsonPath(basePath));
1027
+ const candidateModuleIds = [
1028
+ input.dependencyId,
1029
+ resolvedPath
1030
+ ];
1031
+ for (const candidateModuleId of candidateModuleIds)try {
1032
+ loaded = req(candidateModuleId);
1033
+ didLoad = true;
1034
+ break;
1035
+ } catch (error) {
1036
+ lastLoadError = error;
1037
+ }
1038
+ if (didLoad) break;
1039
+ }
1040
+ if (!didLoad) try {
1041
+ loaded = require(resolvedPath);
1042
+ didLoad = true;
1043
+ } catch (directRequireError) {
1044
+ lastLoadError = directRequireError;
1045
+ }
1046
+ if (!didLoad) {
1047
+ const diagnostics = {
1048
+ ...buildDiagnostics({
1049
+ integration: input.integration,
1050
+ dependencyId: input.dependencyId,
1051
+ projectPath: input.projectPath,
1052
+ installDependencies: input.installDependencies || [
1053
+ input.dependencyId
1054
+ ],
1055
+ verifyPackageIds: input.verifyPackageIds || input.installDependencies || [
1056
+ input.dependencyId
1057
+ ]
1058
+ }),
1059
+ resolvedPath,
1060
+ loadError: lastLoadError instanceof Error ? lastLoadError.message : String(lastLoadError)
1061
+ };
1062
+ throw codedError(CODES.E_OPTIONAL_DEP_LOAD, formatResolverError({
1063
+ integration: input.integration,
1064
+ dependencyId: input.dependencyId,
1065
+ headline: `${input.dependencyId} could not be loaded after it resolved.`,
1066
+ installSpecs: input.installDependencies || [
1067
+ input.dependencyId
1068
+ ],
1069
+ projectPath: input.projectPath,
1070
+ diagnostics
1071
+ }));
1072
+ }
1073
+ return input.moduleAdapter ? input.moduleAdapter(loaded) : loaded;
1074
+ }
1075
+ function loadOptionalModuleWithoutInstall(input) {
1076
+ const resolvedPath = resolveOptionalPackageWithoutInstall(input);
1077
+ const candidateBases = getResolutionBases(input.projectPath);
1078
+ let loaded;
1079
+ let didLoad = false;
1080
+ let lastLoadError;
1081
+ for (const basePath of candidateBases){
1082
+ const req = createRequire(optional_deps_resolver_packageJsonPath(basePath));
1083
+ const candidateModuleIds = [
1084
+ input.dependencyId,
1085
+ resolvedPath
1086
+ ];
1087
+ for (const candidateModuleId of candidateModuleIds)try {
1088
+ loaded = req(candidateModuleId);
1089
+ didLoad = true;
1090
+ break;
1091
+ } catch (error) {
1092
+ lastLoadError = error;
1093
+ }
1094
+ if (didLoad) break;
1095
+ }
1096
+ if (!didLoad) try {
1097
+ loaded = require(resolvedPath);
1098
+ didLoad = true;
1099
+ } catch (directRequireError) {
1100
+ lastLoadError = directRequireError;
1101
+ }
1102
+ if (!didLoad) throw codedError(CODES.E_OPTIONAL_DEP_LOAD, formatResolverError({
1103
+ integration: input.integration,
1104
+ dependencyId: input.dependencyId,
1105
+ headline: `${input.dependencyId} could not be loaded after resolving.`,
1106
+ installSpecs: input.installDependencies || [
1107
+ input.dependencyId
1108
+ ],
1109
+ projectPath: input.projectPath,
1110
+ diagnostics: {
1111
+ resolvedPath,
1112
+ loadError: lastLoadError instanceof Error ? lastLoadError.message : String(lastLoadError)
1113
+ }
1114
+ }));
1115
+ return input.moduleAdapter ? input.moduleAdapter(loaded) : loaded;
1116
+ }
1117
+ async function ensureOptionalContractPackageResolved(input) {
1118
+ const contract = getOptionalDependencyContract(input.contractId);
1119
+ return ensureOptionalPackageResolved({
1120
+ integration: contract.integration,
1121
+ projectPath: input.projectPath,
1122
+ dependencyId: input.dependencyId,
1123
+ contract
1124
+ });
1125
+ }
1126
+ async function ensureOptionalContractModuleLoaded(input) {
1127
+ const contract = getOptionalDependencyContract(input.contractId);
1128
+ return ensureOptionalModuleLoaded({
1129
+ integration: contract.integration,
1130
+ projectPath: input.projectPath,
1131
+ dependencyId: input.dependencyId,
1132
+ contract,
1133
+ moduleAdapter: input.moduleAdapter
1134
+ });
1135
+ }
1136
+ function resolveOptionalContractPackageWithoutInstall(input) {
1137
+ const contract = getOptionalDependencyContract(input.contractId);
1138
+ return resolveOptionalPackageWithoutInstall({
1139
+ integration: contract.integration,
1140
+ projectPath: input.projectPath,
1141
+ dependencyId: input.dependencyId,
1142
+ contract
1143
+ });
1144
+ }
1145
+ function loadOptionalContractModuleWithoutInstall(input) {
1146
+ const contract = getOptionalDependencyContract(input.contractId);
1147
+ return loadOptionalModuleWithoutInstall({
1148
+ integration: contract.integration,
1149
+ projectPath: input.projectPath,
1150
+ dependencyId: input.dependencyId,
1151
+ contract,
1152
+ moduleAdapter: input.moduleAdapter
1153
+ });
1154
+ }
1155
+ function hasDependency(projectPath, packageName) {
1156
+ return hasProjectDependency(projectPath, packageName);
1157
+ }
1158
+ function isUsingJSFramework(projectPath) {
1159
+ const frameworks = [
1160
+ 'react',
1161
+ 'vue',
1162
+ '@angular/core',
1163
+ 'svelte',
1164
+ 'solid-js',
1165
+ 'preact'
1166
+ ];
1167
+ return frameworks.some((fw)=>hasDependency(projectPath, fw));
1168
+ }
1169
+ function isUsingIntegration(name) {
1170
+ return `integration use=${name}`;
1171
+ }
1172
+ function vueTwoSingleFileComponent(version, files) {
1173
+ const list = files.map((file)=>`- ${pintor.underline(file)}`).join('\n');
1174
+ return `Vue ${version} is installed, and Extension.js compiles .vue files for Vue 3 only.\n${list}\nVue 2 reached end of life in December 2023 and vue-loader 15 cannot read the loader rules this build uses.\nUpgrade to ${pintor.yellow('vue@3')} with ${pintor.yellow('vue-loader@17')}, or write these components as render functions.`;
1175
+ }
1176
+ function creatingTSConfig() {
1177
+ return `${messaging_prefix('info')} Creating a default tsconfig.json…`;
1178
+ }
1179
+ function svelteCompilerRuntimeMismatch(compilerVersion, projectVersion) {
1180
+ return `${messaging_prefix('warn')} Svelte ${pintor.blue(compilerVersion)} compiles this project, which pins svelte ${pintor.blue(projectVersion)}.\nThe build uses ${pintor.blue(compilerVersion)} for both, so the output links. Add ${pintor.blue('svelte-loader')} to the project to compile with ${pintor.blue(projectVersion)} instead.`;
1181
+ }
1182
+ function isUsingCustomLoader(loaderPath) {
1183
+ return `${messaging_prefix('debug')} loader custom=${loaderPath}`;
1184
+ }
1185
+ function jsFrameworksIntegrationsEnabled(integrations) {
1186
+ const names = integrations.length > 0 ? integrations.join(',') : 'none';
1187
+ return `${messaging_prefix('debug')} js integrations=${integrations.length} names=${names}`;
1188
+ }
1189
+ function jsFrameworksConfigsDetected(tsConfigPath, tsRoot, targets) {
1190
+ const val = (v)=>v || 'none';
1191
+ const tgt = targets?.length ? targets.join(',') : 'default';
1192
+ return `${messaging_prefix('debug')} js config tsconfig=${val(tsConfigPath)} tsRoot=${val(tsRoot)} swcTargets="${tgt}"`;
1193
+ }
1194
+ function jsFrameworksHmrSummary(enabled, frameworks) {
1195
+ const names = frameworks.length > 0 ? frameworks.join(',') : 'none';
1196
+ return `${messaging_prefix('debug')} js hmr=${enabled ? 'enabled' : 'disabled'} frameworks=${names}`;
1197
+ }
1198
+ let userMessageDelivered = false;
1199
+ function isUsingReact(projectPath) {
1200
+ if (hasDependency(projectPath, 'react')) {
1201
+ if (!userMessageDelivered) {
1202
+ if (isDebug()) debugLine(`${messaging_prefix('debug')} ${isUsingIntegration('React')}`);
1203
+ userMessageDelivered = true;
1204
+ }
1205
+ return true;
1206
+ }
1207
+ return false;
1208
+ }
1209
+ async function maybeUseReact(projectPath, options = {}) {
1210
+ if (!isUsingReact(projectPath)) return;
1211
+ const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
1212
+ let reactPath;
1213
+ let reactDomPath;
1214
+ let reactDomClientPath;
1215
+ let jsxRuntimePath;
1216
+ let jsxDevRuntimePath;
1217
+ try {
1218
+ reactPath = requireFromProject.resolve('react');
1219
+ } catch {}
1220
+ try {
1221
+ reactDomPath = requireFromProject.resolve('react-dom');
1222
+ } catch {}
1223
+ try {
1224
+ reactDomClientPath = requireFromProject.resolve('react-dom/client');
1225
+ } catch {}
1226
+ try {
1227
+ jsxRuntimePath = requireFromProject.resolve('react/jsx-runtime');
1228
+ } catch {}
1229
+ try {
1230
+ jsxDevRuntimePath = requireFromProject.resolve('react/jsx-dev-runtime');
1231
+ } catch {}
1232
+ const alias = {};
1233
+ if (reactPath) alias.react$ = reactPath;
1234
+ if (reactDomPath) alias['react-dom$'] = reactDomPath;
1235
+ if (reactDomClientPath) alias['react-dom/client'] = reactDomClientPath;
1236
+ if (jsxRuntimePath) alias['react/jsx-runtime'] = jsxRuntimePath;
1237
+ if (jsxDevRuntimePath) alias['react/jsx-dev-runtime'] = jsxDevRuntimePath;
1238
+ if (true === options.disableRefresh) return {
1239
+ plugins: [],
1240
+ loaders: void 0,
1241
+ alias
1242
+ };
1243
+ resolveOptionalContractPackageWithoutInstall({
1244
+ contractId: 'react-refresh',
1245
+ projectPath,
1246
+ dependencyId: 'react-refresh'
1247
+ });
1248
+ const ReactRefreshPlugin = loadOptionalContractModuleWithoutInstall({
1249
+ contractId: 'react-refresh',
1250
+ projectPath,
1251
+ dependencyId: '@rspack/plugin-react-refresh',
1252
+ moduleAdapter: (mod)=>mod && (mod.default || mod.ReactRefreshRspackPlugin) || mod
1253
+ });
1254
+ const refreshEntry = resolveReactRefreshEntry(projectPath);
1255
+ const reactPlugins = [
1256
+ new ReactRefreshPlugin({
1257
+ overlay: false,
1258
+ injectEntry: !refreshEntry,
1259
+ ...void 0 === options.refreshExclude ? {} : {
1260
+ exclude: options.refreshExclude
1261
+ }
1262
+ })
1263
+ ];
1264
+ return {
1265
+ plugins: reactPlugins,
1266
+ loaders: void 0,
1267
+ alias
1268
+ };
1269
+ }
1270
+ function resolveReactRefreshEntry(projectPath) {
1271
+ try {
1272
+ const pluginMain = resolveOptionalContractPackageWithoutInstall({
1273
+ contractId: 'react-refresh',
1274
+ projectPath,
1275
+ dependencyId: '@rspack/plugin-react-refresh'
1276
+ });
1277
+ const marker = `${__rspack_external_node_path_806ed179.sep}@rspack${__rspack_external_node_path_806ed179.sep}plugin-react-refresh${__rspack_external_node_path_806ed179.sep}`;
1278
+ const at = String(pluginMain || '').lastIndexOf(marker);
1279
+ if (-1 === at) return;
1280
+ const root = String(pluginMain).slice(0, at + marker.length);
1281
+ const entry = __rspack_external_node_path_806ed179.join(root, 'client', 'reactRefreshEntry.js');
1282
+ return __rspack_external_node_fs_1b05aee1.existsSync(entry) ? entry : void 0;
1283
+ } catch {
1284
+ return;
1285
+ }
1286
+ }
1287
+ let preact_userMessageDelivered = false;
1288
+ function isUsingPreact(projectPath) {
1289
+ if (hasDependency(projectPath, 'preact')) {
1290
+ if (!preact_userMessageDelivered) {
1291
+ if (isDebug()) debugLine(`${messaging_prefix('debug')} ${isUsingIntegration('Preact')}`);
1292
+ preact_userMessageDelivered = true;
1293
+ }
1294
+ return true;
1295
+ }
1296
+ return false;
1297
+ }
1298
+ async function maybeUsePreact(projectPath) {
1299
+ if (!isUsingPreact(projectPath)) return;
1300
+ const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
1301
+ const resolveFromProject = (id)=>{
1302
+ try {
1303
+ return requireFromProject.resolve(id);
1304
+ } catch {
1305
+ return;
1306
+ }
1307
+ };
1308
+ const preactPkgJson = resolveFromProject('preact/package.json');
1309
+ const preactDir = preactPkgJson ? __rspack_external_node_path_806ed179.dirname(preactPkgJson) : void 0;
1310
+ const preactCompat = resolveFromProject('preact/compat');
1311
+ const preactTestUtils = resolveFromProject('preact/test-utils');
1312
+ const preactJsxRuntime = resolveFromProject('preact/jsx-runtime');
1313
+ const preactJsxDevRuntime = resolveFromProject('preact/jsx-dev-runtime');
1314
+ const alias = {};
1315
+ if (preactJsxRuntime) alias['preact/jsx-runtime'] = preactJsxRuntime;
1316
+ if (preactJsxDevRuntime) alias['preact/jsx-dev-runtime'] = preactJsxDevRuntime;
1317
+ if (preactDir) alias.preact = preactDir;
1318
+ if (!isUsingReact(projectPath)) {
1319
+ if (preactCompat) {
1320
+ alias.react = preactCompat;
1321
+ alias['react-dom'] = preactCompat;
1322
+ }
1323
+ if (preactTestUtils) alias['react-dom/test-utils'] = preactTestUtils;
1324
+ if (preactJsxRuntime) alias['react/jsx-runtime'] = preactJsxRuntime;
1325
+ if (preactJsxDevRuntime) alias['react/jsx-dev-runtime'] = preactJsxDevRuntime;
1326
+ }
1327
+ return {
1328
+ plugins: [],
1329
+ loaders: void 0,
1330
+ alias
1331
+ };
1332
+ }
1333
+ const RAW_RESOURCE_QUERY = /(?:^\?|&)raw(?:&|=|$)/;
1334
+ const NOT_RAW_RESOURCE_QUERY = {
1335
+ not: [
1336
+ RAW_RESOURCE_QUERY
1337
+ ]
1338
+ };
1339
+ function normalizePath(filePath) {
1340
+ return filePath.replace(/\\/g, '/');
1341
+ }
1342
+ function tryReadJson(filePath) {
1343
+ try {
1344
+ return JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(filePath, 'utf-8'));
1345
+ } catch {
1346
+ return;
1347
+ }
1348
+ }
1349
+ function findPackageRootFromEntry(entryPath, packageName) {
1350
+ let currentDir = __rspack_external_node_path_806ed179.dirname(entryPath);
1351
+ while(true){
1352
+ const packageJsonPath = __rspack_external_node_path_806ed179.join(currentDir, 'package.json');
1353
+ const packageJson = tryReadJson(packageJsonPath);
1354
+ if (packageJson?.name === packageName) return currentDir;
1355
+ const parentDir = __rspack_external_node_path_806ed179.dirname(currentDir);
1356
+ if (parentDir === currentDir) return;
1357
+ currentDir = parentDir;
1358
+ }
1359
+ }
1360
+ function resolvePackageRoot(requireFromProject, projectRoot, packageName) {
1361
+ try {
1362
+ return __rspack_external_node_path_806ed179.dirname(requireFromProject.resolve(`${packageName}/package.json`));
1363
+ } catch {}
1364
+ try {
1365
+ const entryPath = requireFromProject.resolve(packageName);
1366
+ const discovered = findPackageRootFromEntry(entryPath, packageName);
1367
+ if (discovered) return discovered;
1368
+ } catch {}
1369
+ const guessedPackageDir = __rspack_external_node_path_806ed179.join(projectRoot, 'node_modules', ...packageName.split('/'));
1370
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(guessedPackageDir, 'package.json'))) return guessedPackageDir;
1371
+ }
1372
+ function getWorkspaceDependencyNames(projectRoot) {
1373
+ const packageJsonPath = __rspack_external_node_path_806ed179.join(projectRoot, 'package.json');
1374
+ try {
1375
+ const packageJson = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(packageJsonPath, 'utf-8'));
1376
+ const dependencySections = [
1377
+ packageJson.dependencies,
1378
+ packageJson.devDependencies,
1379
+ packageJson.peerDependencies,
1380
+ packageJson.optionalDependencies
1381
+ ];
1382
+ const names = new Set();
1383
+ for (const section of dependencySections)if (section && 'object' == typeof section) {
1384
+ for (const [name, version] of Object.entries(section))if ('string' == typeof version) {
1385
+ if (version.startsWith('workspace:') || version.startsWith('link:') || version.startsWith('file:')) names.add(name);
1386
+ }
1387
+ }
1388
+ return Array.from(names);
1389
+ } catch {
1390
+ return [];
1391
+ }
1392
+ }
1393
+ function resolveTranspilePackageDirs(projectRoot, transpilePackages) {
1394
+ const autoWorkspacePackages = getWorkspaceDependencyNames(projectRoot);
1395
+ const packageNames = Array.from(new Set([
1396
+ ...autoWorkspacePackages,
1397
+ ...transpilePackages || []
1398
+ ].map((entry)=>String(entry || '').trim()).filter(Boolean)));
1399
+ if (0 === packageNames.length) return [];
1400
+ const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectRoot, 'package.json'));
1401
+ const resolvedDirs = new Set();
1402
+ for (const packageName of packageNames){
1403
+ const packageDir = resolvePackageRoot(requireFromProject, projectRoot, packageName);
1404
+ if (packageDir) {
1405
+ resolvedDirs.add(normalizePath(packageDir));
1406
+ try {
1407
+ resolvedDirs.add(normalizePath(__rspack_external_node_fs_1b05aee1.realpathSync(packageDir)));
1408
+ } catch {}
1409
+ }
1410
+ }
1411
+ return Array.from(resolvedDirs);
1412
+ }
1413
+ function createNodeModulesExclude(transpilePackageDirs) {
1414
+ const isInNodeModules = (resourcePath)=>/[\\/]node_modules[\\/]/.test(resourcePath);
1415
+ if (0 === transpilePackageDirs.length) return isInNodeModules;
1416
+ const packageDirs = Array.from(new Set(transpilePackageDirs.map(resource_path_canonicalizeDir)));
1417
+ const transpiledByFolder = new Map();
1418
+ return (resourcePath)=>{
1419
+ if (!isInNodeModules(resourcePath)) return false;
1420
+ const folder = __rspack_external_node_path_806ed179.dirname(resourcePath);
1421
+ let transpiled = transpiledByFolder.get(folder);
1422
+ if (void 0 === transpiled) {
1423
+ transpiled = resource_path_isResourceUnderDirs(resourcePath, packageDirs);
1424
+ transpiledByFolder.set(folder, transpiled);
1425
+ }
1426
+ return !transpiled;
1427
+ };
1428
+ }
1429
+ let solid_userMessageDelivered = false;
1430
+ function isUsingSolid(projectPath) {
1431
+ const using = hasDependency(projectPath, 'solid-js');
1432
+ if (using && !solid_userMessageDelivered) {
1433
+ if (isDebug()) debugLine(`${messaging_prefix('debug')} ${isUsingIntegration('Solid')}`);
1434
+ solid_userMessageDelivered = true;
1435
+ }
1436
+ return using;
1437
+ }
1438
+ function pickEsmCondition(entry) {
1439
+ if ('string' == typeof entry) return entry;
1440
+ if (!entry || 'object' != typeof entry) return;
1441
+ const conditions = entry;
1442
+ for (const name of [
1443
+ 'browser',
1444
+ 'import',
1445
+ 'module',
1446
+ 'default'
1447
+ ]){
1448
+ const picked = pickEsmCondition(conditions[name]);
1449
+ if (picked) return picked;
1450
+ }
1451
+ }
1452
+ function resolveSolidHyperscript(resolveFromProject) {
1453
+ const packageJsonPath = resolveFromProject('solid-js/package.json');
1454
+ if (packageJsonPath) try {
1455
+ const packageJson = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(packageJsonPath, 'utf-8'));
1456
+ const subpath = pickEsmCondition(packageJson?.exports?.['./h']);
1457
+ if (subpath) {
1458
+ const esmPath = __rspack_external_node_path_806ed179.resolve(__rspack_external_node_path_806ed179.dirname(packageJsonPath), subpath);
1459
+ if (__rspack_external_node_fs_1b05aee1.existsSync(esmPath)) return esmPath;
1460
+ }
1461
+ } catch {}
1462
+ return resolveFromProject('solid-js/h/dist/h.js') || resolveFromProject('solid-js/h');
1463
+ }
1464
+ function solidBabelOptions(input) {
1465
+ return {
1466
+ babelrc: false,
1467
+ configFile: false,
1468
+ sourceMaps: true,
1469
+ compact: false,
1470
+ sourceType: 'module',
1471
+ parserOpts: {
1472
+ strictMode: false
1473
+ },
1474
+ presets: [
1475
+ [
1476
+ input.solidPreset,
1477
+ {
1478
+ development: input.development
1479
+ }
1480
+ ],
1481
+ ...input.typescript ? [
1482
+ [
1483
+ input.typescriptPreset,
1484
+ {
1485
+ isTSX: true,
1486
+ allExtensions: true,
1487
+ onlyRemoveTypeImports: true
1488
+ }
1489
+ ]
1490
+ ] : []
1491
+ ]
1492
+ };
1493
+ }
1494
+ async function maybeUseSolid(projectPath, mode = 'development', transpilePackageDirs = []) {
1495
+ if (!isUsingSolid(projectPath)) return;
1496
+ const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
1497
+ const resolveFromProject = (id)=>{
1498
+ try {
1499
+ return requireFromProject.resolve(id);
1500
+ } catch {
1501
+ return;
1502
+ }
1503
+ };
1504
+ const resolveContractPackage = (dependencyId)=>ensureOptionalContractPackageResolved({
1505
+ contractId: 'solid',
1506
+ projectPath,
1507
+ dependencyId
1508
+ });
1509
+ const babelLoader = await resolveContractPackage('babel-loader');
1510
+ const solidPreset = await resolveContractPackage('babel-preset-solid');
1511
+ const typescriptPreset = await resolveContractPackage("@babel/preset-typescript");
1512
+ const adapter = resolveDevelopDistFile('solid-jsx-runtime');
1513
+ const hyperscript = resolveSolidHyperscript(resolveFromProject);
1514
+ const alias = {
1515
+ 'solid-js/jsx-runtime$': adapter,
1516
+ 'solid-js/jsx-dev-runtime$': adapter
1517
+ };
1518
+ if (hyperscript) alias['solid-js/h$'] = hyperscript;
1519
+ const development = 'development' === mode;
1520
+ const excludeNodeModules = createNodeModulesExclude(transpilePackageDirs);
1521
+ const javascriptOptions = solidBabelOptions({
1522
+ solidPreset,
1523
+ typescriptPreset,
1524
+ typescript: false,
1525
+ development
1526
+ });
1527
+ const loaders = [
1528
+ {
1529
+ test: /\.(jsx|mjsx)$/,
1530
+ exclude: excludeNodeModules,
1531
+ resourceQuery: NOT_RAW_RESOURCE_QUERY,
1532
+ loader: babelLoader,
1533
+ options: javascriptOptions
1534
+ },
1535
+ {
1536
+ test: /\.(tsx|mtsx)$/,
1537
+ exclude: excludeNodeModules,
1538
+ resourceQuery: NOT_RAW_RESOURCE_QUERY,
1539
+ loader: babelLoader,
1540
+ options: solidBabelOptions({
1541
+ solidPreset,
1542
+ typescriptPreset,
1543
+ typescript: true,
1544
+ development
1545
+ })
1546
+ },
1547
+ {
1548
+ test: /\.(js|mjs|cjs)$/,
1549
+ exclude: excludeNodeModules,
1550
+ resourceQuery: NOT_RAW_RESOURCE_QUERY,
1551
+ loader: resolveDevelopDistFile('solid-jsx-gate-loader'),
1552
+ options: {
1553
+ ...javascriptOptions,
1554
+ babelLoader
1555
+ }
1556
+ }
1557
+ ];
1558
+ return {
1559
+ plugins: [],
1560
+ loaders,
1561
+ alias
1562
+ };
1563
+ }
1564
+ let load_loader_options_userMessageDelivered = false;
1565
+ function resolveLoaderConfigPath(projectPath, framework) {
1566
+ const candidates = [
1567
+ __rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.ts`),
1568
+ __rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.mts`),
1569
+ __rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.js`),
1570
+ __rspack_external_node_path_806ed179.join(projectPath, `${framework}.loader.mjs`)
1571
+ ];
1572
+ return candidates.find((p)=>__rspack_external_node_fs_1b05aee1.existsSync(p)) || null;
1573
+ }
1574
+ function isPlainObject(value) {
1575
+ return 'object' == typeof value && null !== value && !Array.isArray(value);
1576
+ }
1577
+ function mergeLoaderOptions(defaults, custom) {
1578
+ if (!isPlainObject(custom)) return {
1579
+ ...defaults
1580
+ };
1581
+ const merged = {
1582
+ ...defaults,
1583
+ ...custom
1584
+ };
1585
+ for (const [key, value] of Object.entries(custom))if (isPlainObject(defaults[key]) && isPlainObject(value)) merged[key] = {
1586
+ ...defaults[key],
1587
+ ...value
1588
+ };
1589
+ return merged;
1590
+ }
1591
+ async function loadLoaderOptions(projectPath, framework) {
1592
+ const configPath = resolveLoaderConfigPath(projectPath, framework);
1593
+ if (configPath) {
1594
+ if (!load_loader_options_userMessageDelivered && isDebug()) {
1595
+ const display = __rspack_external_node_path_806ed179.basename(configPath);
1596
+ debugLine(isUsingCustomLoader(display));
1597
+ load_loader_options_userMessageDelivered = true;
1598
+ }
1599
+ try {
1600
+ const module = await import(pathToFileURL(configPath).href);
1601
+ return module.default || module;
1602
+ } catch (err) {
1603
+ const error = err;
1604
+ console.error(`Error loading ${framework} loader options: ${error.message}`);
1605
+ throw err;
1606
+ }
1607
+ }
1608
+ return null;
1609
+ }
1610
+ let vue_userMessageDelivered = false;
1611
+ function isUsingVue(projectPath) {
1612
+ const using = hasDependency(projectPath, 'vue');
1613
+ if (using && !vue_userMessageDelivered) {
1614
+ if (isDebug()) debugLine(`${messaging_prefix('debug')} ${isUsingIntegration('Vue')}`);
1615
+ vue_userMessageDelivered = true;
1616
+ }
1617
+ return using;
1618
+ }
1619
+ function resolveVueBundlerEntry(requireFromProject, id) {
1620
+ try {
1621
+ const manifestPath = requireFromProject.resolve(`${id}/package.json`);
1622
+ const manifest = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(manifestPath, 'utf8'));
1623
+ if ('string' == typeof manifest.module && manifest.module) {
1624
+ const entry = __rspack_external_node_path_806ed179.join(__rspack_external_node_path_806ed179.dirname(manifestPath), manifest.module);
1625
+ if (__rspack_external_node_fs_1b05aee1.existsSync(entry)) return entry;
1626
+ }
1627
+ } catch {}
1628
+ try {
1629
+ return requireFromProject.resolve(id);
1630
+ } catch {
1631
+ return;
1632
+ }
1633
+ }
1634
+ function readInstalledVueVersion(requireFromProject) {
1635
+ try {
1636
+ const manifestPath = requireFromProject.resolve('vue/package.json');
1637
+ const version = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(manifestPath, 'utf8')).version;
1638
+ return 'string' == typeof version ? version : void 0;
1639
+ } catch {
1640
+ return;
1641
+ }
1642
+ }
1643
+ class RefuseVueTwoSingleFileComponents {
1644
+ version;
1645
+ constructor(version){
1646
+ this.version = version;
1647
+ }
1648
+ apply(compiler) {
1649
+ const name = RefuseVueTwoSingleFileComponents.name;
1650
+ compiler.hooks.thisCompilation.tap(name, (compilation)=>{
1651
+ compilation.hooks.finishModules.tap(name, (modules)=>{
1652
+ const files = new Set();
1653
+ for (const module of modules){
1654
+ const { resource = '', type } = module;
1655
+ const file = resource.split('?')[0];
1656
+ if ('asset/source' === type && file.endsWith('.vue')) files.add(file);
1657
+ }
1658
+ if (0 === files.size) return;
1659
+ const sorted = [
1660
+ ...files
1661
+ ].sort();
1662
+ const error = new WebpackError(vueTwoSingleFileComponent(this.version, sorted));
1663
+ error.file = __rspack_external_node_path_806ed179.relative(compiler.context, sorted[0]);
1664
+ error.stack = '';
1665
+ compilation.errors.push(error);
1666
+ });
1667
+ });
1668
+ }
1669
+ }
1670
+ function vueTwoWithoutLoader(requireFromProject, version) {
1671
+ const alias = {};
1672
+ const vuePath = resolveVueBundlerEntry(requireFromProject, 'vue');
1673
+ if (vuePath) alias.vue$ = vuePath;
1674
+ return {
1675
+ plugins: [
1676
+ new RefuseVueTwoSingleFileComponents(version)
1677
+ ],
1678
+ loaders: [
1679
+ {
1680
+ test: /\.vue$/,
1681
+ type: 'asset/source'
1682
+ }
1683
+ ],
1684
+ alias
1685
+ };
1686
+ }
1687
+ async function maybeUseVue(projectPath, mode = 'development', transpilePackageDirs = []) {
1688
+ if (!isUsingVue(projectPath)) return;
1689
+ const requireFromProject = createRequire(__rspack_external_node_path_806ed179.join(projectPath, 'package.json'));
1690
+ const installedVersion = readInstalledVueVersion(requireFromProject);
1691
+ if (installedVersion && /^2\./.test(installedVersion)) return vueTwoWithoutLoader(requireFromProject, installedVersion);
1692
+ const vueLoaderPath = await ensureOptionalContractPackageResolved({
1693
+ contractId: 'vue',
1694
+ projectPath,
1695
+ dependencyId: 'vue-loader'
1696
+ });
1697
+ const VueLoaderPlugin = await ensureOptionalContractModuleLoaded({
1698
+ contractId: 'vue',
1699
+ projectPath,
1700
+ dependencyId: 'vue-loader',
1701
+ moduleAdapter: (mod)=>mod?.VueLoaderPlugin || mod?.default?.VueLoaderPlugin
1702
+ });
1703
+ const customOptions = await loadLoaderOptions(projectPath, 'vue');
1704
+ const defaultLoaders = [
1705
+ {
1706
+ test: /\.vue$/,
1707
+ loader: vueLoaderPath,
1708
+ options: mergeLoaderOptions({
1709
+ experimentalInlineMatchResource: true
1710
+ }, customOptions),
1711
+ exclude: createNodeModulesExclude(transpilePackageDirs)
1712
+ }
1713
+ ];
1714
+ const isProd = 'production' === mode;
1715
+ const defaultPlugins = [
1716
+ new VueLoaderPlugin(),
1717
+ new DefinePlugin({
1718
+ __VUE_OPTIONS_API__: JSON.stringify(true),
1719
+ __VUE_PROD_DEVTOOLS__: JSON.stringify(!isProd),
1720
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(!isProd)
1721
+ })
1722
+ ];
1723
+ const resolveFromProject = (id)=>resolveVueBundlerEntry(requireFromProject, id);
1724
+ const alias = {};
1725
+ const vuePath = resolveFromProject('vue');
1726
+ const vueRuntimeDom = resolveFromProject('@vue/runtime-dom');
1727
+ const vueRuntimeCore = resolveFromProject('@vue/runtime-core');
1728
+ const vueShared = resolveFromProject('@vue/shared');
1729
+ if (vuePath) alias.vue$ = vuePath;
1730
+ if (vueRuntimeDom) alias['@vue/runtime-dom'] = vueRuntimeDom;
1731
+ if (vueRuntimeCore) alias['@vue/runtime-core'] = vueRuntimeCore;
1732
+ if (vueShared) alias['@vue/shared'] = vueShared;
1733
+ return {
1734
+ plugins: defaultPlugins,
1735
+ loaders: defaultLoaders,
1736
+ alias
1737
+ };
1738
+ }
1739
+ function isUsingJsxFramework(projectPath) {
1740
+ return isUsingReact(projectPath) || isUsingPreact(projectPath) || isUsingSolid(projectPath) || isUsingVue(projectPath);
1741
+ }
1742
+ function getJsxImportSource(projectPath) {
1743
+ if (isUsingSolid(projectPath)) return 'solid-js';
1744
+ if (isUsingPreact(projectPath) && !isUsingReact(projectPath)) return 'preact';
1745
+ if (isUsingVue(projectPath) && !isUsingReact(projectPath) && !isUsingPreact(projectPath)) return 'vue';
1746
+ return 'react';
1747
+ }
1748
+ function swcParserForFile(resourcePath, jsxInPlainJs) {
1749
+ const clean = String(resourcePath || '').split('?')[0];
1750
+ const ext = __rspack_external_node_path_806ed179.extname(clean).toLowerCase();
1751
+ if ('.tsx' === ext || '.mtsx' === ext) return {
1752
+ syntax: "typescript",
1753
+ tsx: true,
1754
+ dynamicImport: true
1755
+ };
1756
+ if ('.ts' === ext || '.mts' === ext || '.cts' === ext) return {
1757
+ syntax: "typescript",
1758
+ tsx: false,
1759
+ dynamicImport: true
1760
+ };
1761
+ if ('.jsx' === ext || '.mjsx' === ext) return {
1762
+ syntax: "ecmascript",
1763
+ jsx: true,
1764
+ dynamicImport: true
1765
+ };
1766
+ return {
1767
+ syntax: "ecmascript",
1768
+ jsx: jsxInPlainJs,
1769
+ dynamicImport: true
1770
+ };
1771
+ }
1772
+ let hasShownUserMessage = false;
1773
+ function findNearestPackageJsonDirectory(startPath) {
1774
+ return findNearestProjectManifestDirSync(startPath, 6);
1775
+ }
1776
+ const NON_SOURCE_DIRS = new Set([
1777
+ 'node_modules',
1778
+ 'dist',
1779
+ 'public'
1780
+ ]);
1781
+ const MAX_SOURCE_SCAN_DEPTH = 4;
1782
+ function hasTypeScriptSourceFiles(projectPath, depth = 0) {
1783
+ if (depth > MAX_SOURCE_SCAN_DEPTH) return false;
1784
+ try {
1785
+ const entries = __rspack_external_node_fs_1b05aee1.readdirSync(projectPath, {
1786
+ withFileTypes: true
1787
+ });
1788
+ return entries.some((entry)=>{
1789
+ if (entry.isFile()) {
1790
+ const name = entry.name;
1791
+ if (!/\.(ts|tsx|mts|cts|mtsx)$/i.test(name)) return false;
1792
+ if (/\.(d\.ts|d\.mts|d\.cts|d\.mtsx)$/i.test(name)) return false;
1793
+ if (/\.(spec|test)\.(ts|tsx|mts|cts|mtsx)$/i.test(name)) return false;
1794
+ return true;
1795
+ }
1796
+ if (entry.isDirectory()) {
1797
+ if (entry.name.startsWith('.') || NON_SOURCE_DIRS.has(entry.name)) return false;
1798
+ const sub = __rspack_external_node_path_806ed179.join(projectPath, entry.name);
1799
+ if (__rspack_external_node_fs_1b05aee1.existsSync(__rspack_external_node_path_806ed179.join(sub, 'package.json'))) return false;
1800
+ return hasTypeScriptSourceFiles(sub, depth + 1);
1801
+ }
1802
+ return false;
1803
+ });
1804
+ } catch {
1805
+ return false;
1806
+ }
1807
+ }
1808
+ function hasTypeScriptDependency(projectPath) {
1809
+ const manifestDirectory = findNearestPackageJsonDirectory(projectPath);
1810
+ if (!manifestDirectory) return false;
1811
+ return hasProjectDependency(manifestDirectory, "typescript");
1812
+ }
1813
+ function isUsingTypeScript(projectPath) {
1814
+ const tsConfigFilePath = getUserTypeScriptConfigFile(projectPath);
1815
+ if (!tsConfigFilePath) return false;
1816
+ return hasTypeScriptDependency(projectPath) || hasTypeScriptSourceFiles(projectPath);
1817
+ }
1818
+ function ensureTypeScriptConfig(projectPath) {
1819
+ const tsConfigFilePath = getUserTypeScriptConfigFile(projectPath);
1820
+ const hasDep = hasTypeScriptDependency(projectPath);
1821
+ const hasTsFiles = hasTypeScriptSourceFiles(projectPath);
1822
+ if (hasTsFiles || hasDep && tsConfigFilePath) {
1823
+ if (tsConfigFilePath) {
1824
+ if (!hasShownUserMessage && isDebug()) debugLine(`${messaging_prefix('debug')} ${isUsingIntegration('TypeScript')}`);
1825
+ } else {
1826
+ if (!hasShownUserMessage) humanLine(creatingTSConfig());
1827
+ writeTsConfig(projectPath);
1828
+ }
1829
+ hasShownUserMessage = true;
1830
+ }
1831
+ }
1832
+ function defaultTypeScriptConfig(projectPath, _opts) {
1833
+ const usesJsFramework = isUsingJSFramework(projectPath);
1834
+ const jsxImportSource = usesJsFramework ? {
1835
+ jsxImportSource: getJsxImportSource(projectPath)
1836
+ } : {};
1837
+ return {
1838
+ compilerOptions: {
1839
+ allowJs: true,
1840
+ allowSyntheticDefaultImports: true,
1841
+ esModuleInterop: true,
1842
+ forceConsistentCasingInFileNames: true,
1843
+ jsx: usesJsFramework ? 'react-jsx' : 'preserve',
1844
+ ...jsxImportSource,
1845
+ lib: [
1846
+ 'dom',
1847
+ 'dom.iterable',
1848
+ 'esnext'
1849
+ ],
1850
+ moduleResolution: 'bundler',
1851
+ module: 'esnext',
1852
+ resolveJsonModule: true,
1853
+ strict: true,
1854
+ target: 'esnext',
1855
+ isolatedModules: false,
1856
+ skipLibCheck: true
1857
+ },
1858
+ exclude: [
1859
+ 'node_modules',
1860
+ 'dist'
1861
+ ]
1862
+ };
1863
+ }
1864
+ function getUserTypeScriptConfigFile(projectPath) {
1865
+ const searchDirs = [
1866
+ findNearestPackageJsonDirectory(projectPath),
1867
+ projectPath
1868
+ ];
1869
+ for (const dir of searchDirs){
1870
+ if (!dir) continue;
1871
+ const tsconfigPath = __rspack_external_node_path_806ed179.join(dir, 'tsconfig.json');
1872
+ if (__rspack_external_node_fs_1b05aee1.existsSync(tsconfigPath)) return tsconfigPath;
1873
+ }
1874
+ }
1875
+ function getUserJsConfigFile(projectPath) {
1876
+ const searchDirs = [
1877
+ findNearestPackageJsonDirectory(projectPath),
1878
+ projectPath
1879
+ ];
1880
+ for (const dir of searchDirs){
1881
+ if (!dir) continue;
1882
+ const jsconfigPath = __rspack_external_node_path_806ed179.join(dir, 'jsconfig.json');
1883
+ if (__rspack_external_node_fs_1b05aee1.existsSync(jsconfigPath)) return jsconfigPath;
1884
+ }
1885
+ }
1886
+ function writeTsConfig(projectPath) {
1887
+ const targetDir = findNearestPackageJsonDirectory(projectPath) || projectPath;
1888
+ __rspack_external_node_fs_1b05aee1.writeFileSync(__rspack_external_node_path_806ed179.join(targetDir, 'tsconfig.json'), JSON.stringify(defaultTypeScriptConfig(projectPath, {
1889
+ mode: 'development'
1890
+ }), null, 2));
1891
+ }
1892
+ const SCRIPT_SRC_PATTERN = /<script[^>]*\ssrc\s*=\s*["']([^"']+)["']/gi;
1893
+ const RELATIVE_IMPORT_PATTERN = /(?:import\s[^'"]*|import\s*\(\s*|require\s*\(\s*|from\s*)['"](\.{1,2}\/[^'"]+)['"]/g;
1894
+ const MODULE_SPECIFIER_PATTERN = /(?:\bimport\s*\(\s*|\brequire\s*\(\s*|\bfrom\s*|\bimport\s*)(['"`])([^'"`\n$]+)\1/g;
1895
+ const SOURCE_SIBLING_EXTENSIONS = [
1896
+ '.ts',
1897
+ '.mts',
1898
+ '.tsx',
1899
+ '.jsx',
1900
+ '.mjs'
1901
+ ];
1902
+ const MAX_IMPORT_DEPTH = 3;
1903
+ const RESOLVE_EXTENSIONS = [
1904
+ '.js',
1905
+ '.cjs',
1906
+ '.mjs',
1907
+ '.jsx',
1908
+ '.ts',
1909
+ '.mts',
1910
+ '.cts',
1911
+ '.tsx',
1912
+ '.json',
1913
+ '.svelte',
1914
+ '.vue'
1915
+ ];
1916
+ const RESOLVE_EXTENSION_ALIAS = {
1917
+ '.js': [
1918
+ '.ts',
1919
+ '.tsx',
1920
+ '.js',
1921
+ '.jsx'
1922
+ ],
1923
+ '.mjs': [
1924
+ '.mts',
1925
+ '.mjs'
1926
+ ],
1927
+ '.cjs': [
1928
+ '.cts',
1929
+ '.cjs'
1930
+ ]
1931
+ };
1932
+ const SCRIPT_SOURCE = /\.(?:[cm]?[jt]s|[jt]sx|vue|svelte)$/i;
1933
+ const SINGLE_FILE_COMPONENT = /\.(?:vue|svelte)$/i;
1934
+ const COMPONENT_SCRIPT_BLOCK = /<script\b[^>]*>([\s\S]*?)<\/script\b[^>]*>/gi;
1935
+ const NODE_MODULES_SEGMENT = /[\\/]node_modules[\\/]/;
1936
+ const DEPENDENCY_KINDS = [
1937
+ 'esm',
1938
+ 'commonjs'
1939
+ ];
1940
+ const LINKED_DEPENDENCY = /^(?:file|link|portal):/;
1941
+ const DEPENDENCY_FIELDS = [
1942
+ 'dependencies',
1943
+ 'devDependencies',
1944
+ 'optionalDependencies'
1945
+ ];
1946
+ const MAX_LOCAL_IMPORT_DEPTH = 8;
1947
+ const MAX_LOCAL_IMPORT_FILES = 2000;
1948
+ function readIfFile(absPath) {
1949
+ try {
1950
+ if (__rspack_external_node_fs_1b05aee1.statSync(absPath).isFile()) return __rspack_external_node_fs_1b05aee1.readFileSync(absPath, 'utf-8');
1951
+ } catch {}
1952
+ }
1953
+ function readScriptSource(absPath) {
1954
+ const direct = readIfFile(absPath);
1955
+ if (void 0 !== direct) return direct;
1956
+ const parsed = __rspack_external_node_path_806ed179.parse(absPath);
1957
+ for (const ext of SOURCE_SIBLING_EXTENSIONS){
1958
+ const sibling = readIfFile(__rspack_external_node_path_806ed179.join(parsed.dir, parsed.name + ext));
1959
+ if (void 0 !== sibling) return sibling;
1960
+ }
1961
+ }
1962
+ function collectRelativeImports(source) {
1963
+ const specifiers = [];
1964
+ for (const match of source.matchAll(RELATIVE_IMPORT_PATTERN))specifiers.push(match[1]);
1965
+ return specifiers;
1966
+ }
1967
+ function scanScriptGraph(entryAbsPath, collect) {
1968
+ const found = [];
1969
+ const queue = [
1970
+ {
1971
+ file: entryAbsPath,
1972
+ depth: 0
1973
+ }
1974
+ ];
1975
+ const seen = new Set();
1976
+ while(queue.length){
1977
+ const { file, depth } = queue.shift();
1978
+ if (seen.has(file)) continue;
1979
+ seen.add(file);
1980
+ const source = readScriptSource(file);
1981
+ if (void 0 === source) continue;
1982
+ found.push(...collect(source));
1983
+ if (depth >= MAX_IMPORT_DEPTH) continue;
1984
+ for (const specifier of collectRelativeImports(source)){
1985
+ const resolved = __rspack_external_node_path_806ed179.resolve(__rspack_external_node_path_806ed179.dirname(file), specifier);
1986
+ const withExt = __rspack_external_node_path_806ed179.extname(resolved) ? resolved : `${resolved}.js`;
1987
+ queue.push({
1988
+ file: withExt,
1989
+ depth: depth + 1
1990
+ });
1991
+ }
1992
+ }
1993
+ return found;
1994
+ }
1995
+ function collectModuleSpecifiers(source) {
1996
+ const specifiers = [];
1997
+ for (const match of source.matchAll(MODULE_SPECIFIER_PATTERN))specifiers.push(match[2]);
1998
+ return specifiers;
1999
+ }
2000
+ function isLocalScriptSource(file) {
2001
+ return SCRIPT_SOURCE.test(file) && !NODE_MODULES_SEGMENT.test(file);
2002
+ }
2003
+ function readScriptText(file) {
2004
+ const source = readIfFile(file);
2005
+ if (void 0 === source || !SINGLE_FILE_COMPONENT.test(file)) return source;
2006
+ return [
2007
+ ...source.matchAll(COMPONENT_SCRIPT_BLOCK)
2008
+ ].map((block)=>block[1]).join('\n');
2009
+ }
2010
+ const buildResolveByProject = new Map();
2011
+ let buildResolveCount = 0;
2012
+ function rememberBuildResolve(projectPath, resolve) {
2013
+ if (!resolve || 'object' != typeof resolve) return void buildResolveByProject.delete(projectPath);
2014
+ if (buildResolveByProject.get(projectPath)?.resolve === resolve) return;
2015
+ buildResolveByProject.set(projectPath, {
2016
+ resolve: resolve,
2017
+ scope: `${projectPath}#${++buildResolveCount}`
2018
+ });
2019
+ }
2020
+ const isString = (value)=>'string' == typeof value;
2021
+ function stringList(value) {
2022
+ const list = (Array.isArray(value) ? value : [
2023
+ value
2024
+ ]).filter((item)=>isString(item) && '...' !== item);
2025
+ return list.length > 0 ? list : void 0;
2026
+ }
2027
+ function aliasTargets(value) {
2028
+ if (false === value || isString(value)) return value;
2029
+ if (Array.isArray(value)) return value.filter(isString);
2030
+ }
2031
+ function aliasMap(value) {
2032
+ if (!value || 'object' != typeof value) return;
2033
+ const pairs = Array.isArray(value) ? value.filter((item)=>item && 'object' == typeof item).map((item)=>[
2034
+ `${item.name}${item.onlyModule ? '$' : ''}`,
2035
+ item.alias
2036
+ ]) : Object.entries(value);
2037
+ const map = {};
2038
+ for (const [name, raw] of pairs){
2039
+ const targets = aliasTargets(raw);
2040
+ if (void 0 !== targets) map[name] = targets;
2041
+ }
2042
+ return Object.keys(map).length > 0 ? map : void 0;
2043
+ }
2044
+ function fieldList(value) {
2045
+ if (!Array.isArray(value)) return;
2046
+ const list = value.map((item)=>Array.isArray(item) ? item.filter(isString) : item).filter((item)=>Array.isArray(item) || isString(item) && '...' !== item);
2047
+ return list.length > 0 ? list : void 0;
2048
+ }
2049
+ function tsconfigFile(value) {
2050
+ if (isString(value)) return value;
2051
+ const configFile = value?.configFile;
2052
+ return isString(configFile) ? configFile : void 0;
2053
+ }
2054
+ function buildResolverOptions(projectPath, resolve) {
2055
+ const configFile = tsconfigFile(resolve?.tsConfig) ?? getUserTypeScriptConfigFile(projectPath) ?? getUserJsConfigFile(projectPath);
2056
+ const options = {
2057
+ extensions: stringList(resolve?.extensions) ?? RESOLVE_EXTENSIONS,
2058
+ extensionAlias: RESOLVE_EXTENSION_ALIAS,
2059
+ symlinks: false,
2060
+ ...configFile ? {
2061
+ tsconfig: {
2062
+ configFile,
2063
+ references: 'auto'
2064
+ }
2065
+ } : {}
2066
+ };
2067
+ if (!resolve) return options;
2068
+ const alias = aliasMap(resolve.alias);
2069
+ if (alias) options.alias = alias;
2070
+ const fallback = aliasMap(resolve.fallback);
2071
+ if (fallback) options.fallback = Object.fromEntries(Object.entries(fallback).filter(([, targets])=>false !== targets).map(([name, targets])=>[
2072
+ name,
2073
+ [
2074
+ targets
2075
+ ].flat()
2076
+ ]));
2077
+ const extensionAlias = resolve.extensionAlias;
2078
+ if (extensionAlias && 'object' == typeof extensionAlias) options.extensionAlias = Object.fromEntries(Object.entries(extensionAlias).map(([extension, targets])=>[
2079
+ extension,
2080
+ stringList(targets) ?? []
2081
+ ]));
2082
+ for (const key of [
2083
+ 'modules',
2084
+ 'mainFields',
2085
+ 'mainFiles',
2086
+ 'roots'
2087
+ ]){
2088
+ const list = stringList(resolve[key]);
2089
+ if (list) options[key] = list;
2090
+ }
2091
+ const conditionNames = stringList(resolve.conditionNames);
2092
+ if (conditionNames) options.conditionNames = conditionNames;
2093
+ for (const key of [
2094
+ 'aliasFields',
2095
+ 'exportsFields',
2096
+ 'importsFields'
2097
+ ]){
2098
+ const list = fieldList(resolve[key]);
2099
+ if (list) options[key] = list;
2100
+ }
2101
+ for (const key of [
2102
+ 'preferRelative',
2103
+ 'preferAbsolute'
2104
+ ])if ('boolean' == typeof resolve[key]) options[key] = resolve[key];
2105
+ return options;
2106
+ }
2107
+ const script_graph_isPlainObject = (value)=>!!value && 'object' == typeof value && !Array.isArray(value);
2108
+ function resolveForDependency(resolve, kind) {
2109
+ const byDependency = resolve?.byDependency;
2110
+ const override = script_graph_isPlainObject(byDependency) ? byDependency[kind] : void 0;
2111
+ if (!resolve || !script_graph_isPlainObject(override)) return;
2112
+ const merged = {
2113
+ ...resolve
2114
+ };
2115
+ delete merged.byDependency;
2116
+ for (const [key, value] of Object.entries(override)){
2117
+ const base = resolve[key];
2118
+ if (Array.isArray(value)) merged[key] = value.flatMap((item)=>'...' === item ? Array.isArray(base) ? base : [] : [
2119
+ item
2120
+ ]);
2121
+ else if (script_graph_isPlainObject(value) && script_graph_isPlainObject(base)) merged[key] = {
2122
+ ...base,
2123
+ ...value
2124
+ };
2125
+ else merged[key] = value;
2126
+ }
2127
+ return merged;
2128
+ }
2129
+ function linkedDependencies(packageDir) {
2130
+ const linked = [];
2131
+ try {
2132
+ const manifest = JSON.parse(__rspack_external_node_fs_1b05aee1.readFileSync(__rspack_external_node_path_806ed179.join(packageDir, 'package.json'), 'utf-8'));
2133
+ if (!script_graph_isPlainObject(manifest)) return linked;
2134
+ for (const field of DEPENDENCY_FIELDS){
2135
+ const dependencies = manifest[field];
2136
+ if (script_graph_isPlainObject(dependencies)) for (const [name, spec] of Object.entries(dependencies)){
2137
+ if (!isString(spec) || !LINKED_DEPENDENCY.test(spec)) continue;
2138
+ const target = __rspack_external_node_path_806ed179.resolve(packageDir, spec.replace(LINKED_DEPENDENCY, ''));
2139
+ linked.push({
2140
+ name,
2141
+ dir: resource_path_canonicalizeDir(target),
2142
+ mayBeCopied: spec.startsWith('file:')
2143
+ });
2144
+ }
2145
+ }
2146
+ } catch {}
2147
+ return linked;
2148
+ }
2149
+ function installedPackageFile(file) {
2150
+ const parts = file.split(/[\\/]/);
2151
+ const at = parts.lastIndexOf('node_modules');
2152
+ if (-1 === at) return;
2153
+ const scoped = parts[at + 1]?.startsWith('@');
2154
+ const name = parts.slice(at + 1, at + (scoped ? 3 : 2)).join('/');
2155
+ const inner = parts.slice(at + (scoped ? 3 : 2));
2156
+ return name && inner.length > 0 ? {
2157
+ name,
2158
+ inner: inner.join('/')
2159
+ } : void 0;
2160
+ }
2161
+ function isInsideDir(file, dir) {
2162
+ return real_path_isInsidePath(dir, file);
2163
+ }
2164
+ function createLocalImportResolver(projectPath) {
2165
+ const build = buildResolveByProject.get(projectPath);
2166
+ let factory;
2167
+ let dependencyFactories;
2168
+ let sourceRoots;
2169
+ let linked;
2170
+ const createFactory = (resolve)=>new rspack.experiments.resolver.ResolverFactory(buildResolverOptions(projectPath, resolve));
2171
+ const getFactory = ()=>{
2172
+ if (void 0 !== factory) return factory;
2173
+ try {
2174
+ factory = createFactory(build?.resolve);
2175
+ } catch {
2176
+ try {
2177
+ factory = createFactory(void 0);
2178
+ } catch {
2179
+ factory = null;
2180
+ }
2181
+ }
2182
+ return factory;
2183
+ };
2184
+ const getDependencyFactories = ()=>{
2185
+ if (dependencyFactories) return dependencyFactories;
2186
+ dependencyFactories = [];
2187
+ for (const kind of DEPENDENCY_KINDS){
2188
+ const resolve = resolveForDependency(build?.resolve, kind);
2189
+ if (resolve) try {
2190
+ dependencyFactories.push(createFactory(resolve));
2191
+ } catch {}
2192
+ }
2193
+ return dependencyFactories;
2194
+ };
2195
+ const resolveWith = (resolver, fromFile, specifier)=>{
2196
+ try {
2197
+ return resolver?.sync(__rspack_external_node_path_806ed179.dirname(fromFile), specifier)?.path;
2198
+ } catch {
2199
+ return;
2200
+ }
2201
+ };
2202
+ const getSourceRoots = ()=>{
2203
+ if (sourceRoots) return sourceRoots;
2204
+ const workspaceRoot = findPnpmWorkspaceRoot(projectPath) ?? findPackageJsonWorkspaceRoot(projectPath);
2205
+ sourceRoots = [
2206
+ projectPath,
2207
+ ...workspaceRoot ? [
2208
+ workspaceRoot
2209
+ ] : []
2210
+ ].map(resource_path_canonicalizeDir);
2211
+ return sourceRoots;
2212
+ };
2213
+ const getLinked = ()=>{
2214
+ linked ??= [
2215
+ ...new Set([
2216
+ projectPath,
2217
+ ...getSourceRoots()
2218
+ ])
2219
+ ].flatMap(linkedDependencies);
2220
+ return linked;
2221
+ };
2222
+ const copiedSource = (real)=>{
2223
+ const installed = installedPackageFile(real);
2224
+ if (!installed) return;
2225
+ return getLinked().some((dependency)=>dependency.mayBeCopied && dependency.name === installed.name && void 0 !== readIfFile(__rspack_external_node_path_806ed179.join(dependency.dir, installed.inner))) ? real : void 0;
2226
+ };
2227
+ const linkedSource = (file)=>{
2228
+ const real = __rspack_external_node_fs_1b05aee1.realpathSync.native(file);
2229
+ if (NODE_MODULES_SEGMENT.test(real)) return copiedSource(real);
2230
+ if (real === file) return;
2231
+ if (getSourceRoots().some((root)=>isInsideDir(real, root))) return real;
2232
+ return getLinked().some((dependency)=>isInsideDir(real, dependency.dir)) ? real : void 0;
2233
+ };
2234
+ const resolveImport = (fromFile, specifier)=>{
2235
+ try {
2236
+ const file = resolveWith(getFactory(), fromFile, specifier) ?? getDependencyFactories().map((resolver)=>resolveWith(resolver, fromFile, specifier)).find(Boolean);
2237
+ if (!file || !SCRIPT_SOURCE.test(file)) return;
2238
+ return NODE_MODULES_SEGMENT.test(file) ? linkedSource(file) : file;
2239
+ } catch {
2240
+ return;
2241
+ }
2242
+ };
2243
+ return Object.assign(resolveImport, {
2244
+ scope: build?.scope ?? projectPath
2245
+ });
2246
+ }
2247
+ function walkLocalImportGraph(entries, importsOf) {
2248
+ const seen = new Set();
2249
+ let level = entries;
2250
+ for(let depth = 0; depth <= MAX_LOCAL_IMPORT_DEPTH && level.length > 0; depth++){
2251
+ const next = [];
2252
+ for (const file of level){
2253
+ if (seen.has(file) || seen.size >= MAX_LOCAL_IMPORT_FILES) continue;
2254
+ seen.add(file);
2255
+ const imports = importsOf(file);
2256
+ if (depth < MAX_LOCAL_IMPORT_DEPTH) next.push(...imports);
2257
+ }
2258
+ level = next;
2259
+ }
2260
+ return [
2261
+ ...seen
2262
+ ];
2263
+ }
2264
+ function scanPageScripts(htmlAbsPath, projectDir, collect) {
2265
+ const html = readIfFile(htmlAbsPath);
2266
+ if (void 0 === html) return [];
2267
+ const found = collect(html);
2268
+ for (const match of html.matchAll(SCRIPT_SRC_PATTERN)){
2269
+ const src = String(match[1] || '');
2270
+ if (/^(https?:)?\/\//i.test(src)) continue;
2271
+ const scriptAbs = src.startsWith('/') ? __rspack_external_node_path_806ed179.join(projectDir, src.slice(1)) : __rspack_external_node_path_806ed179.resolve(__rspack_external_node_path_806ed179.dirname(htmlAbsPath), src);
2272
+ found.push(...scanScriptGraph(scriptAbs, collect));
2273
+ }
2274
+ return found;
2275
+ }
2276
+ function rootRelativePages(literals, projectDir) {
2277
+ const pages = {};
2278
+ for (const literal of literals){
2279
+ const rootRel = literal.replace(/^\.?\/+/, '').split(/[?#]/)[0];
2280
+ if (!rootRel || !/\.html?$/i.test(rootRel)) continue;
2281
+ const absPage = __rspack_external_node_path_806ed179.join(projectDir, rootRel);
2282
+ const relToProject = __rspack_external_node_path_806ed179.relative(projectDir, absPage);
2283
+ if (!relToProject || relToProject.startsWith('..')) continue;
2284
+ if (!__rspack_external_node_fs_1b05aee1.existsSync(absPage)) continue;
2285
+ const key = rootRel.replace(/\.html?$/i, '').replace(/\\/g, '/');
2286
+ pages[key] = absPage;
2287
+ }
2288
+ return pages;
2289
+ }
2290
+ export { NOT_RAW_RESOURCE_QUERY, RAW_RESOURCE_QUERY, buildInstallCommand, collectModuleSpecifiers, createLocalImportResolver, createNodeModulesExclude, ensureOptionalContractPackageResolved, ensureOptionalModuleLoaded, ensureTypeScriptConfig, execInstallCommand, findExtensionDevelopRoot, findWorkspaceMember, formatInstallHint, getJsxImportSource, getUserJsConfigFile, getUserTypeScriptConfigFile, hasDependency, installScriptSuppression, isLocalScriptSource, isUsingIntegration, isUsingJsxFramework, isUsingReact, isUsingTypeScript, isUsingVue, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, loadLoaderOptions, maybeUsePreact, maybeUseReact, maybeUseSolid, maybeUseVue, mergeLoaderOptions, projectInstallTarget, readScriptText, rememberBuildResolve, resolveDevelopDistFile, resolveDevelopInstallRoot, resolveNpmPackageManager, resolvePackageManager, resolveReactRefreshEntry, resolveTranspilePackageDirs, rootRelativePages, scanPageScripts, scanScriptGraph, svelteCompilerRuntimeMismatch, swcParserForFile, walkLocalImportGraph, workspaceManagerOverride };