weapp-tailwindcss 5.5.4 → 5.5.6

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 (134) hide show
  1. package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +5 -4
  2. package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -2
  3. package/dist/bundlers/shared/framework-css-composition.d.ts +1 -0
  4. package/dist/bundlers/shared/framework-postcss.d.ts +2 -1
  5. package/dist/bundlers/shared/framework-user-css.d.ts +1 -0
  6. package/dist/bundlers/shared/generated-css-marker.d.ts +1 -0
  7. package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +5 -7
  8. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +4 -1
  9. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -4
  10. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -1
  11. package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +4 -2
  12. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +1 -1
  13. package/dist/bundlers/shared/generator-css/types.d.ts +6 -3
  14. package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -0
  15. package/dist/bundlers/shared/generator-css/user-css/compile-functions.d.ts +4 -0
  16. package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +3 -1
  17. package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +1 -1
  18. package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +3 -0
  19. package/dist/bundlers/shared/style-handler-options.d.ts +7 -0
  20. package/dist/bundlers/shared/v4-generation-core.d.ts +0 -1
  21. package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +3 -0
  22. package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +3 -0
  23. package/dist/bundlers/vite/css-handler-options.d.ts +1 -1
  24. package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -1
  25. package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +1 -0
  26. package/dist/bundlers/vite/generate-bundle/finalize/sync-processed-css.d.ts +4 -0
  27. package/dist/bundlers/vite/generate-bundle/framework-style-memory.d.ts +4 -0
  28. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +7 -0
  29. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -0
  30. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +1 -1
  31. package/dist/bundlers/vite/generate-bundle/runtime.d.ts +3 -1
  32. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +1 -1
  33. package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +2 -2
  34. package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
  35. package/dist/bundlers/vite/generate-bundle/web-css-module.d.ts +1 -0
  36. package/dist/bundlers/vite/plugin-hook.d.ts +3 -0
  37. package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +3 -1
  38. package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +1 -1
  39. package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +1 -1
  40. package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +3 -1
  41. package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +2 -1
  42. package/dist/bundlers/vite/shared/framework-runtime-configuration.d.ts +3 -0
  43. package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +9 -0
  44. package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +6 -5
  45. package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +3 -3
  46. package/dist/bundlers/vite/shared/framework-strategy.d.ts +3 -1
  47. package/dist/bundlers/vite/shared/hmr-source.d.ts +2 -0
  48. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +2 -1
  49. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
  50. package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +1 -1
  51. package/dist/compiler/index.d.ts +2 -0
  52. package/dist/compiler/semantic-css.d.ts +1 -1
  53. package/dist/compiler/types.d.ts +1 -1
  54. package/dist/{compiler-DFROuh5Z.cjs → compiler-C8FqI-P3.cjs} +1060 -1163
  55. package/dist/{compiler-CJ5yX-on.js → compiler-D3GBwxoa.js} +32 -23
  56. package/dist/core/compiler/transforms.d.ts +1 -1
  57. package/dist/core.cjs +4 -4
  58. package/dist/core.js +4 -4
  59. package/dist/{css-imports-_5cwJnx-.cjs → css-imports-XvtI1zCY.cjs} +2 -3
  60. package/dist/css-macro.cjs +1 -1
  61. package/dist/css-macro.js +1 -1
  62. package/dist/{defaults-CKx-4LcW.js → defaults-AQuvJS-h.js} +4 -2
  63. package/dist/{defaults-CiGsr8Xq.cjs → defaults-CyX5iO9y.cjs} +4 -2
  64. package/dist/defaults.cjs +1 -1
  65. package/dist/defaults.js +1 -1
  66. package/dist/final-css-cleanup-CDTmVAye.cjs +1 -0
  67. package/dist/{final-css-cleanup-B0HUBtiE.js → final-css-cleanup-u_sI2p56.js} +1 -126
  68. package/dist/framework/index.d.ts +1 -1
  69. package/dist/framework/platform.d.ts +2 -2
  70. package/dist/{generator-RK2HtgOb.cjs → generator-Bvr4WmuF.cjs} +150 -150
  71. package/dist/{generator-BgbYHNgD.js → generator-C0BJjyLM.js} +131 -131
  72. package/dist/generator.cjs +1 -1
  73. package/dist/generator.js +1 -1
  74. package/dist/{gulp-BS7fTmyj.cjs → gulp-BExe5RBF.cjs} +8 -8
  75. package/dist/{gulp-nl-2p5Dw.js → gulp-BhkIIk7J.js} +5 -5
  76. package/dist/gulp.cjs +1 -1
  77. package/dist/gulp.js +1 -1
  78. package/dist/{hmr-timing-BfxWwMeT.js → hmr-timing-B9Yt86-U.js} +299 -404
  79. package/dist/{hmr-timing-D45cTIzM.cjs → hmr-timing-CoiJIqDu.cjs} +4 -4
  80. package/dist/index.cjs +4 -4
  81. package/dist/index.js +4 -4
  82. package/dist/js/NodePathWalker.d.ts +1 -1
  83. package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
  84. package/dist/js/node-path-walker/import-tokens.d.ts +1 -1
  85. package/dist/{pipeline-helpers-BEhISt4D.cjs → pipeline-helpers-BOjTEmMi.cjs} +6 -6
  86. package/dist/postcss.cjs +1 -1
  87. package/dist/postcss.js +1 -1
  88. package/dist/presets.cjs +2 -2
  89. package/dist/presets.js +2 -2
  90. package/dist/rspack.cjs +2 -2
  91. package/dist/rspack.js +2 -2
  92. package/dist/{scoped-generator-Dqq2iLky.js → scoped-generator-B6Y1bxzM.js} +46 -31
  93. package/dist/{scoped-generator-DccPwmJT.cjs → scoped-generator-BUBls_oM.cjs} +46 -31
  94. package/dist/{source-candidate-scan-signature-CnUlGWhP.cjs → source-candidate-scan-signature-BtJZp28T.cjs} +32 -3
  95. package/dist/{source-candidate-scan-signature-BJkQJtRM.js → source-candidate-scan-signature-DNuGKTqf.js} +21 -4
  96. package/dist/style-injector/internal.d.ts +118 -8
  97. package/dist/style-injector/options.d.ts +5 -1
  98. package/dist/tailwindcss/runtime-options.d.ts +5 -0
  99. package/dist/tailwindcss/v4/preflight.d.ts +0 -1
  100. package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +1 -0
  101. package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +4 -0
  102. package/dist/{tailwindcss-o3Xe-o7M.js → tailwindcss-B_4E52WF.js} +7 -13
  103. package/dist/{tailwindcss-B03BGeTO.cjs → tailwindcss-CBYjzRmV.cjs} +4 -10
  104. package/dist/{transform-BVH7iLHn.js → transform-CkEnJYIP.js} +18 -12
  105. package/dist/{transform-MIhriZRr.cjs → transform-FkqbTBJR.cjs} +17 -11
  106. package/dist/types/index.d.ts +3 -2
  107. package/dist/uni-app-x/border-preflight.d.ts +1 -2
  108. package/dist/uni-app-x/component-local-style.d.ts +2 -1
  109. package/dist/uni-app-x/transform.d.ts +4 -2
  110. package/dist/uni-app-x/vite/author-apply.d.ts +3 -1
  111. package/dist/uni-app-x/vite/native-hmr.d.ts +1 -1
  112. package/dist/uni-app-x/vite/style-result.d.ts +5 -0
  113. package/dist/{v4-generation-core-BvW2aK23.cjs → v4-generation-core-Cz1D7wm1.cjs} +313 -418
  114. package/dist/vite/web.cjs +1 -1
  115. package/dist/vite/web.js +1 -1
  116. package/dist/{vite-4RznbXVI.cjs → vite-DxuKPZlp.cjs} +565 -592
  117. package/dist/{vite-hGECCqfq.js → vite-lP35OguX.js} +558 -578
  118. package/dist/vite-web.d.ts +1 -1
  119. package/dist/vite.cjs +1 -1
  120. package/dist/vite.js +1 -1
  121. package/dist/weapp-tw-css-generation-loader.cjs +2 -2
  122. package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
  123. package/dist/{web-0FAisq6H.js → web-Dfz_jpNj.js} +144 -107
  124. package/dist/{web-DQZ27KWH.cjs → web-DhDxhlkq.cjs} +156 -107
  125. package/dist/{webpack-8cQlXIo4.js → webpack-D6jp1o3m.js} +18 -17
  126. package/dist/{webpack-DOQ_3ViW.cjs → webpack-R2Sbggiy.cjs} +20 -20
  127. package/dist/webpack.cjs +1 -1
  128. package/dist/webpack.js +1 -1
  129. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
  130. package/dist/wxml/utils/custom-template.d.ts +1 -1
  131. package/package.json +9 -11
  132. package/dist/final-css-cleanup-DSjczga3.cjs +0 -138
  133. package/dist/tailwindcss/v4-engine/css-import.d.ts +0 -14
  134. package/dist/uni-app-x/style-asset/source-parser.d.ts +0 -2
@@ -1,13 +1,13 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_framework = require("./framework.cjs");
3
- const require_generator = require("./generator-RK2HtgOb.cjs");
4
- const require_tailwindcss = require("./tailwindcss-B03BGeTO.cjs");
5
- const require_v4_generation_core = require("./v4-generation-core-BvW2aK23.cjs");
6
- const require_compiler = require("./compiler-DFROuh5Z.cjs");
3
+ const require_generator = require("./generator-Bvr4WmuF.cjs");
4
+ const require_tailwindcss = require("./tailwindcss-CBYjzRmV.cjs");
5
+ const require_v4_generation_core = require("./v4-generation-core-Cz1D7wm1.cjs");
6
+ const require_compiler = require("./compiler-C8FqI-P3.cjs");
7
7
  const require_runtime_state = require("./runtime-state-XYSycuGu.cjs");
8
- const require_hmr_timing = require("./hmr-timing-D45cTIzM.cjs");
9
- const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-CnUlGWhP.cjs");
10
- const require_css_imports = require("./css-imports-_5cwJnx-.cjs");
8
+ const require_hmr_timing = require("./hmr-timing-CoiJIqDu.cjs");
9
+ const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-BtJZp28T.cjs");
10
+ const require_css_imports = require("./css-imports-XvtI1zCY.cjs");
11
11
  let node_fs = require("node:fs");
12
12
  let node_path = require("node:path");
13
13
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
@@ -208,6 +208,19 @@ function createViteCssAssetIdentityResolver(options) {
208
208
  };
209
209
  }
210
210
  //#endregion
211
+ //#region src/bundlers/vite/processed-css-assets/style-files.ts
212
+ const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
213
+ function isCssOutputFile(file) {
214
+ return CSS_OUTPUT_FILE_RE.test(file);
215
+ }
216
+ function isRootStyleOutputFile(file) {
217
+ const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
218
+ return isCssOutputFile(normalized) && !normalized.includes("/");
219
+ }
220
+ function isMiniProgramStyleOutputFile(file) {
221
+ return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
222
+ }
223
+ //#endregion
211
224
  //#region src/bundlers/vite/css-handler-options.ts
212
225
  function resolveViteCssHandlerExtraOptions(file) {
213
226
  return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, "")).includes("/") ? { isMainChunk: false } : {};
@@ -920,19 +933,6 @@ const mix = (del = delimiter) => {
920
933
  const posix = /* @__PURE__ */ mix(":");
921
934
  const win32 = /* @__PURE__ */ mix(";");
922
935
  //#endregion
923
- //#region src/bundlers/vite/processed-css-assets/style-files.ts
924
- const CSS_OUTPUT_FILE_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i;
925
- function isCssOutputFile(file) {
926
- return CSS_OUTPUT_FILE_RE.test(file);
927
- }
928
- function isRootStyleOutputFile(file) {
929
- const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
930
- return isCssOutputFile(normalized) && !normalized.includes("/");
931
- }
932
- function isMiniProgramStyleOutputFile(file) {
933
- return /\.(?:wxss|acss|ttss|qss|jxss|tyss)(?:$|[?#])/i.test(file);
934
- }
935
- //#endregion
936
936
  //#region src/bundlers/vite/processed-css-assets/markers-imports.ts
937
937
  function createCssAssetPipelineContext(options, file, bundle) {
938
938
  const context = options.createCssPipelineContext?.(file);
@@ -986,15 +986,16 @@ function removeTailwindSourceMediaWrappersRoot(root) {
986
986
  function removeTailwindSourceMediaWrappersFallback(css) {
987
987
  return css.replace(/@media\s+source\([^)]*\)\s*\{\s*\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/?\s*\}/gi, "").replace(/@media\s+source\([^)]*\)\s*\{\s*\}/gi, "");
988
988
  }
989
- function removeTailwindEntryDirectivesFromCss(css) {
989
+ function removeTailwindEntryDirectivesFromCss(css, preserveCssLayers = false) {
990
990
  try {
991
991
  const source = require_generator.stripGeneratorPlaceholderMarkers(css);
992
992
  const root = _weapp_tailwindcss_postcss.postcss.parse(source);
993
993
  const removedMediaWrappers = removeTailwindSourceMediaWrappersRoot(root);
994
- const removedTailwindDirectives = (0, _weapp_tailwindcss_postcss.removeTailwindSourceDirectivesRoot)(root);
994
+ const removedTailwindDirectives = (0, _weapp_tailwindcss_postcss.removeTailwindSourceDirectivesRoot)(root, { preserveCssLayers });
995
995
  return removedMediaWrappers || removedTailwindDirectives ? root.toString() : source;
996
996
  } catch {
997
- return require_generator.removeTailwindSourceDirectives(removeTailwindSourceMediaWrappersFallback(css));
997
+ const source = removeTailwindSourceMediaWrappersFallback(css);
998
+ return preserveCssLayers ? source : require_generator.removeTailwindSourceDirectives(source);
998
999
  }
999
1000
  }
1000
1001
  function removeUnsupportedMiniProgramCssImportsFallback(css, file) {
@@ -1625,7 +1626,7 @@ async function resolveHotTailwindCssModules(ctx, tailwindRootCssModuleIds, selec
1625
1626
  const root = ctx.server.config?.root ?? node_process.default.cwd();
1626
1627
  const outDir = ctx.server.config?.build?.outDir ? resolveViteModuleIdentity(ctx.server.config.build.outDir, root) : void 0;
1627
1628
  const isHotSourceStyleModule = (id) => {
1628
- if (!require_v4_generation_core.isSourceStyleRequest(id)) return false;
1629
+ if (typeof id !== "string" || !require_v4_generation_core.isSourceStyleRequest(id)) return false;
1629
1630
  const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
1630
1631
  if (isRootMiniProgramStyleUrl(file) || !isAbsoluteFilePath(file) && !file.startsWith("/")) return false;
1631
1632
  if (outDir) {
@@ -1806,59 +1807,6 @@ function sendFullReloadForUnresolvedHotUpdate(ctx) {
1806
1807
  });
1807
1808
  }
1808
1809
  //#endregion
1809
- //#region src/bundlers/vite/shared/generic-web-production-fast-path.ts
1810
- /**
1811
- * Generic Web 非 watch 生产构建由 Tailwind Scanner 直接提供候选,不需要重复维护小程序候选状态。
1812
- */
1813
- function shouldSkipGenericWebProductionSourceCandidates(options) {
1814
- return options.frameworkName === "generic" && options.command === "build" && options.watch == null && options.isWebGeneratorTarget && options.requiresSourceCandidateState !== true;
1815
- }
1816
- /**
1817
- * 在 Vite 解析插件列表时排除无需维护的候选层,避免其 hooks 进入模块图。
1818
- */
1819
- function createGenericWebProductionSourceCandidatesApply(options) {
1820
- return (config, env) => !shouldSkipGenericWebProductionSourceCandidates({
1821
- command: env.command,
1822
- frameworkName: options.frameworkName,
1823
- isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
1824
- requiresSourceCandidateState: options.requiresSourceCandidateState,
1825
- watch: config.build?.watch
1826
- });
1827
- }
1828
- /**
1829
- * Generic Web 生产构建的 CSS 已在 Vite transform 阶段生成时,不需要再建立面向小程序的完整产物快照。
1830
- */
1831
- function shouldUseGenericWebProductionFastPath(options) {
1832
- return shouldSkipGenericWebProductionSourceCandidates(options) && options.hasProcessedCss;
1833
- }
1834
- /**
1835
- * Finalizer fast path 只处理无小程序结构语义的 Generic Web 生产产物。
1836
- */
1837
- function shouldUseGenericWebFinalizerFastPath(options) {
1838
- return shouldUseGenericWebProductionFastPath(options) && !options.hasFrameworkRootImportShells && !options.isHarmonyAppStyleTarget && !options.isNativeAppStyleTarget;
1839
- }
1840
- /**
1841
- * 将 Generic Web fast path 的判定和跳过生命周期集中起来,供 generateBundle hook 直接消费。
1842
- */
1843
- function createGenericWebProductionBundleHooks(options) {
1844
- return {
1845
- onSkipProcessBundle: () => {
1846
- options.onStart();
1847
- options.onEnd();
1848
- },
1849
- shouldProcessBundle: () => {
1850
- const config = options.getResolvedConfig();
1851
- return !shouldUseGenericWebProductionFastPath({
1852
- command: config?.command,
1853
- frameworkName: options.frameworkName,
1854
- hasProcessedCss: options.getHasProcessedCss(),
1855
- isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
1856
- watch: config?.build?.watch
1857
- });
1858
- }
1859
- };
1860
- }
1861
- //#endregion
1862
1810
  //#region src/bundlers/vite/css-finalizer/options.ts
1863
1811
  function inferPlatformFromViteOutDir(outDir) {
1864
1812
  const segment = outDir ? node_path.default.basename(node_path.default.normalize(outDir)) : void 0;
@@ -1922,6 +1870,84 @@ function finalizeWebCss(css, context, cssPipelineStrategy) {
1922
1870
  }) ?? (shouldApplyWebCssCompat ? defaultWebCssCompat(css) : css);
1923
1871
  }
1924
1872
  //#endregion
1873
+ //#region src/bundlers/vite/css-finalizer/css-calc.ts
1874
+ /** 在所有 CSS 资产完成组装后,为普通 Web 样式补齐显式启用的 calc 计算。 */
1875
+ async function finalizeWebCssCalc(bundle, context) {
1876
+ const cssCalc = context.opts.cssOptions?.cssCalc ?? context.opts.cssCalc;
1877
+ if (!cssCalc) return;
1878
+ const pending = Object.values(bundle).filter((output) => output.type === "asset" && context.opts.cssMatcher(output.fileName) && !context.opts.htmlMatcher(output.fileName)).map((asset) => ({
1879
+ asset,
1880
+ original: typeof asset.source === "string" ? asset.source : new TextDecoder().decode(asset.source)
1881
+ })).filter(({ original }) => original.includes("calc("));
1882
+ if (pending.length === 0) return;
1883
+ const sources = new Set(collectViteProcessedCssSources(context.getViteProcessedCssAssetResults));
1884
+ const contextCss = sources.size === 1 ? sources.values().next().value : void 0;
1885
+ for (const { asset, original } of pending) {
1886
+ const css = await (0, _weapp_tailwindcss_postcss.applyConfiguredCssCalc)(original, {
1887
+ cssCalc,
1888
+ contextCss
1889
+ });
1890
+ if (css !== original) {
1891
+ asset.source = css;
1892
+ context.recordCssAssetResult?.(asset.fileName, css);
1893
+ context.opts.onUpdate(asset.fileName, original, css);
1894
+ }
1895
+ }
1896
+ }
1897
+ //#endregion
1898
+ //#region src/bundlers/vite/shared/generic-web-production-fast-path.ts
1899
+ /**
1900
+ * Generic Web 非 watch 生产构建由 Tailwind Scanner 直接提供候选,不需要重复维护小程序候选状态。
1901
+ */
1902
+ function shouldSkipGenericWebProductionSourceCandidates(options) {
1903
+ return options.frameworkName === "generic" && options.command === "build" && options.watch == null && options.isWebGeneratorTarget && options.requiresSourceCandidateState !== true;
1904
+ }
1905
+ /**
1906
+ * 在 Vite 解析插件列表时排除无需维护的候选层,避免其 hooks 进入模块图。
1907
+ */
1908
+ function createGenericWebProductionSourceCandidatesApply(options) {
1909
+ return (config, env) => !shouldSkipGenericWebProductionSourceCandidates({
1910
+ command: env.command,
1911
+ frameworkName: options.frameworkName,
1912
+ isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
1913
+ requiresSourceCandidateState: options.requiresSourceCandidateState,
1914
+ watch: config.build?.watch
1915
+ });
1916
+ }
1917
+ /**
1918
+ * Generic Web 生产构建的 CSS 已在 Vite transform 阶段生成时,不需要再建立面向小程序的完整产物快照。
1919
+ */
1920
+ function shouldUseGenericWebProductionFastPath(options) {
1921
+ return shouldSkipGenericWebProductionSourceCandidates(options) && options.hasProcessedCss;
1922
+ }
1923
+ /**
1924
+ * Finalizer fast path 只处理无小程序结构语义的 Generic Web 生产产物。
1925
+ */
1926
+ function shouldUseGenericWebFinalizerFastPath(options) {
1927
+ return shouldUseGenericWebProductionFastPath(options) && !options.hasFrameworkRootImportShells && !options.isHarmonyAppStyleTarget && !options.isNativeAppStyleTarget;
1928
+ }
1929
+ /**
1930
+ * 将 Generic Web fast path 的判定和跳过生命周期集中起来,供 generateBundle hook 直接消费。
1931
+ */
1932
+ function createGenericWebProductionBundleHooks(options) {
1933
+ return {
1934
+ onSkipProcessBundle: () => {
1935
+ options.onStart();
1936
+ options.onEnd();
1937
+ },
1938
+ shouldProcessBundle: () => {
1939
+ const config = options.getResolvedConfig();
1940
+ return !shouldUseGenericWebProductionFastPath({
1941
+ command: config?.command,
1942
+ frameworkName: options.frameworkName,
1943
+ hasProcessedCss: options.getHasProcessedCss(),
1944
+ isWebGeneratorTarget: options.getIsWebGeneratorTarget(),
1945
+ watch: config?.build?.watch
1946
+ });
1947
+ }
1948
+ };
1949
+ }
1950
+ //#endregion
1925
1951
  //#region src/bundlers/vite/css-finalizer/generic-web-fast-path.ts
1926
1952
  function readAssetSource(asset) {
1927
1953
  return typeof asset.source === "string" ? asset.source : asset.source.toString();
@@ -1964,7 +1990,7 @@ function resolveProcessedCssAssets(cssAssets, records, options, bundleFiles) {
1964
1990
  useAssetSource = true;
1965
1991
  }
1966
1992
  }
1967
- if (!output && records.length === 1 && htmlOwnedAssets.length === 1) {
1993
+ if (!output && records.length === 1 && htmlOwnedAssets.length === 1 && htmlOwnedAssets[0]) {
1968
1994
  output = htmlOwnedAssets[0];
1969
1995
  useAssetSource = require_generator.hasTailwindGeneratedCss(output.original) || require_generator.hasTailwindGeneratedCssMarkers(output.original);
1970
1996
  }
@@ -2026,8 +2052,8 @@ function tryFinalizeGenericWebCss(options) {
2026
2052
  /**
2027
2053
  * Generic Web 专用 CSS finalizer。
2028
2054
  *
2029
- * 该插件只处理已经在 CSS transform 阶段记录的 CSS asset,不扫描或改写
2030
- * HTML、JavaScript、模板和小程序分包产物。
2055
+ * 该插件复用 CSS transform 阶段记录的 CSS asset,显式开启 cssCalc 时也处理
2056
+ * 最终资产中的普通 CSS;不扫描或改写 HTML、JavaScript、模板和小程序分包产物。
2031
2057
  */
2032
2058
  function createViteWebCssFinalizerOutputPlugin(context) {
2033
2059
  return {
@@ -2076,6 +2102,7 @@ function createViteWebCssFinalizerOutputPlugin(context) {
2076
2102
  rootDir,
2077
2103
  sourceRoot: void 0
2078
2104
  })) context.debug("Generic Web CSS finalizer skipped: no unique processed CSS asset");
2105
+ await finalizeWebCssCalc(bundle, context);
2079
2106
  require_hmr_timing.finalizeCompilerShadowRun(context.runtimeState);
2080
2107
  context.hmrTimingRecorder?.record("webCssFinalizer.total", performance.now() - startedAt);
2081
2108
  }
@@ -3123,6 +3150,16 @@ function createFrameworkProcessedCssRegistry() {
3123
3150
  };
3124
3151
  }
3125
3152
  //#endregion
3153
+ //#region src/bundlers/vite/shared/hmr-source.ts
3154
+ /** 兼容 Vite 同步或异步的 HMR 源码读取,并沿用读取失败后的候选扫描。 */
3155
+ async function readViteHmrSource(context) {
3156
+ try {
3157
+ return await context.read?.();
3158
+ } catch {
3159
+ return;
3160
+ }
3161
+ }
3162
+ //#endregion
3126
3163
  //#region src/bundlers/vite/shared/framework-hmr-runtime-signature.ts
3127
3164
  const WEB_HMR_RUNTIME_AFFECTING_DIRECTIVE_RE = /@(?:theme|source|config|plugin|apply)\b/;
3128
3165
  function createFrameworkHmrRuntimeSignature(file, source) {
@@ -3137,7 +3174,7 @@ function hasFrameworkHmrRuntimeSourceChange(file, previousSource, nextSource) {
3137
3174
  const SOURCE_CANDIDATE_SCAN_CACHE_MAX = 8;
3138
3175
  const sourceCandidateScanSnapshotCache = new lru_cache.LRUCache({ max: SOURCE_CANDIDATE_SCAN_CACHE_MAX });
3139
3176
  async function syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx) {
3140
- const source = typeof ctx.read === "function" ? await ctx.read().catch(() => void 0) : void 0;
3177
+ const source = typeof ctx.read === "function" ? await readViteHmrSource(ctx) : void 0;
3141
3178
  await sourceScanSession.syncChangedFile(ctx.file, source);
3142
3179
  await sourceScanSession.waitForPendingSyncs();
3143
3180
  }
@@ -3466,26 +3503,22 @@ function createFrameworkTailwindRootCss(options) {
3466
3503
  }
3467
3504
  //#endregion
3468
3505
  //#region src/style-injector/vite-web.ts
3469
- function getHandler(hook) {
3470
- if (typeof hook === "function") return hook;
3471
- if (hook && typeof hook === "object" && typeof hook.handler === "function") return hook.handler;
3472
- }
3473
3506
  /** Generic Web 专用 style injector,避免引入其他构建器和框架适配。 */
3474
3507
  function createBuiltinViteWebStyleInjectorPlugins(options) {
3475
3508
  const normalized = require_source_candidate_scan_signature.normalizeStyleInjectorOptions(options);
3476
3509
  if (!normalized) return [];
3477
3510
  const injector = (0, weapp_style_injector_vite.weappStyleInjector)(normalized);
3478
- const transform = getHandler(injector.transform);
3479
- const generateBundle = getHandler(injector.generateBundle);
3511
+ const transform = require_source_candidate_scan_signature.getViteHookHandler(injector.transform);
3512
+ const generateBundle = require_source_candidate_scan_signature.getViteHookHandler(injector.generateBundle);
3480
3513
  return [{
3481
3514
  name: "weapp-tailwindcss:web-style-injector-pre",
3482
3515
  apply: "build",
3483
3516
  enforce: "pre",
3484
3517
  configResolved(config) {
3485
- injector.configResolved?.(config);
3518
+ return require_source_candidate_scan_signature.getViteHookHandler(injector.configResolved)?.call(this, config);
3486
3519
  },
3487
- async buildStart() {
3488
- await injector.buildStart?.call(this, {});
3520
+ async buildStart(buildOptions) {
3521
+ await require_source_candidate_scan_signature.getViteHookHandler(injector.buildStart)?.call(this, buildOptions);
3489
3522
  },
3490
3523
  async transform(code, id, options2) {
3491
3524
  return transform?.call(this, code, id, options2);
@@ -3495,7 +3528,7 @@ function createBuiltinViteWebStyleInjectorPlugins(options) {
3495
3528
  apply: "build",
3496
3529
  enforce: "post",
3497
3530
  configResolved(config) {
3498
- injector.configResolved?.(config);
3531
+ return require_source_candidate_scan_signature.getViteHookHandler(injector.configResolved)?.call(this, config);
3499
3532
  },
3500
3533
  async generateBundle(outputOptions, bundle, isWrite) {
3501
3534
  await generateBundle?.call(this, outputOptions, bundle, isWrite);
@@ -3540,7 +3573,7 @@ function createCssOnlyVitePlugins(options = {}) {
3540
3573
  });
3541
3574
  const hmrCssModuleVersions = createViteHmrCssModuleVersionTracker();
3542
3575
  const hmrTimingRecorder = require_hmr_timing.createHmrTimingRecorder("vite");
3543
- const { runtimeState, ensureRuntimeClassSet, refreshRuntimeState } = createViteRuntimeClassSet({
3576
+ const { runtimeState, refreshRuntimeState } = createViteRuntimeClassSet({
3544
3577
  opts,
3545
3578
  initialTailwindRuntime: opts.tailwindRuntime,
3546
3579
  refreshTailwindcssRuntime: opts.refreshTailwindcssRuntime,
@@ -3560,7 +3593,6 @@ function createCssOnlyVitePlugins(options = {}) {
3560
3593
  let recordedCandidates;
3561
3594
  const processedCssRegistry = createFrameworkProcessedCssRegistry();
3562
3595
  const processedCssAssets = /* @__PURE__ */ new WeakSet();
3563
- const tailwindRootCssModuleIds = /* @__PURE__ */ new Set();
3564
3596
  const sourceScanSession = createFrameworkSourceScanSession({
3565
3597
  cssMemory,
3566
3598
  debug,
@@ -3573,7 +3605,12 @@ function createCssOnlyVitePlugins(options = {}) {
3573
3605
  shouldOwnTailwindGeneration: shouldGenerate,
3574
3606
  sourceCandidateCollector
3575
3607
  });
3576
- const { refreshSource: refreshTailwindRootCssSource, register: registerTailwindRootCss, rememberModule: rememberTailwindRootCssModule } = createFrameworkTailwindRootCss({
3608
+ async function collectCssSourceCandidates() {
3609
+ await runtimeState.readyPromise;
3610
+ await sourceScanSession.waitForPendingSyncs();
3611
+ return sourceCandidateCollector.values();
3612
+ }
3613
+ const { moduleIds: tailwindRootCssModuleIds, refreshSource: refreshTailwindRootCssSource, register: registerTailwindRootCss, rememberModule: rememberTailwindRootCssModule } = createFrameworkTailwindRootCss({
3577
3614
  getImportFallback: () => resolveWebGeneratorOptions(opts).importFallback,
3578
3615
  refreshRuntimeState: async () => {
3579
3616
  await refreshRuntimeState(true);
@@ -3597,7 +3634,7 @@ function createCssOnlyVitePlugins(options = {}) {
3597
3634
  await sourceScanSession.waitForPendingSyncs();
3598
3635
  const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
3599
3636
  const outputFile = resolveViteCssPipelineOutputFile(file, opts, resolvedConfig?.root ?? node_process.default.cwd(), true, false, void 0);
3600
- const runtime = hookContext?.sourceCandidates ? new Set(hookContext.sourceCandidates) : await ensureRuntimeClassSet();
3637
+ const runtime = hookContext?.sourceCandidates ? new Set(hookContext.sourceCandidates) : await collectCssSourceCandidates();
3601
3638
  const generated = await require_v4_generation_core.generateTailwindV4Css({
3602
3639
  opts,
3603
3640
  runtimeState,
@@ -3692,7 +3729,7 @@ function createCssOnlyVitePlugins(options = {}) {
3692
3729
  const finalizer = createViteWebCssFinalizerOutputPlugin({
3693
3730
  opts,
3694
3731
  runtimeState,
3695
- ensureRuntimeClassSet,
3732
+ ensureRuntimeClassSet: collectCssSourceCandidates,
3696
3733
  debug,
3697
3734
  frameworkName: "generic",
3698
3735
  getResolvedConfig: () => resolvedConfig,
@@ -3767,11 +3804,12 @@ function createFrameworkSourceCandidatesPluginForCssOnly(options) {
3767
3804
  function createGenericWebVitePlugins(options = {}) {
3768
3805
  const capability = createGenericWebViteCapabilityProfile(options);
3769
3806
  const owner = createViteSourceOutputRelationOwner();
3770
- const plugins = withViteSourceOutputRelationOwner(owner, () => createCssOnlyVitePlugins({
3807
+ const runtimeOptions = {
3771
3808
  ...options,
3772
3809
  __internalViteCapabilityProfile: capability,
3773
3810
  __internalViteWebStyleInjectorFactory: createBuiltinViteWebStyleInjectorPlugins
3774
- }));
3811
+ };
3812
+ const plugins = withViteSourceOutputRelationOwner(owner, () => createCssOnlyVitePlugins(runtimeOptions));
3775
3813
  if (!plugins) {
3776
3814
  owner.dispose();
3777
3815
  return;
@@ -3780,26 +3818,25 @@ function createGenericWebVitePlugins(options = {}) {
3780
3818
  const wrapped = { ...plugin };
3781
3819
  if (plugin.watchChange) {
3782
3820
  const hook = plugin.watchChange;
3783
- wrapped.watchChange = async function(...args) {
3784
- const id = args[0];
3785
- if (args[1]?.event === "delete") owner.removeSource(id);
3821
+ wrapped.watchChange = async function(id, change) {
3822
+ if (change?.event === "delete") owner.removeSource(id);
3786
3823
  else if (typeof id === "string") owner.observeSource(id);
3787
- return typeof hook === "function" ? hook.apply(this, args) : hook.handler?.apply(this, args);
3824
+ return typeof hook === "function" ? hook.call(this, id, change) : hook.handler.call(this, id, change);
3788
3825
  };
3789
3826
  }
3790
3827
  if (plugin.handleHotUpdate) {
3791
3828
  const hook = plugin.handleHotUpdate;
3792
- wrapped.handleHotUpdate = async function(...args) {
3793
- const file = args[0]?.file;
3829
+ wrapped.handleHotUpdate = async function(context) {
3830
+ const file = context.file;
3794
3831
  if (typeof file === "string") owner.observeSource(file);
3795
- return typeof hook === "function" ? hook.apply(this, args) : hook.handler?.apply(this, args);
3832
+ return typeof hook === "function" ? hook.call(this, context) : hook.handler.call(this, context);
3796
3833
  };
3797
3834
  }
3798
3835
  if (plugin.closeBundle) {
3799
3836
  const hook = plugin.closeBundle;
3800
- wrapped.closeBundle = async function(...args) {
3837
+ wrapped.closeBundle = async function() {
3801
3838
  try {
3802
- return typeof hook === "function" ? await hook.apply(this, args) : await hook.handler?.apply(this, args);
3839
+ return typeof hook === "function" ? await hook.call(this) : await hook.handler.call(this);
3803
3840
  } finally {
3804
3841
  owner.dispose();
3805
3842
  }
@@ -4019,6 +4056,12 @@ Object.defineProperty(exports, "finalizeWebCss", {
4019
4056
  return finalizeWebCss;
4020
4057
  }
4021
4058
  });
4059
+ Object.defineProperty(exports, "finalizeWebCssCalc", {
4060
+ enumerable: true,
4061
+ get: function() {
4062
+ return finalizeWebCssCalc;
4063
+ }
4064
+ });
4022
4065
  Object.defineProperty(exports, "formatPostcssSourceMap", {
4023
4066
  enumerable: true,
4024
4067
  get: function() {
@@ -4211,6 +4254,12 @@ Object.defineProperty(exports, "readAssetSource", {
4211
4254
  return readAssetSource$1;
4212
4255
  }
4213
4256
  });
4257
+ Object.defineProperty(exports, "readViteHmrSource", {
4258
+ enumerable: true,
4259
+ get: function() {
4260
+ return readViteHmrSource;
4261
+ }
4262
+ });
4214
4263
  Object.defineProperty(exports, "registerGeneratorDependencies", {
4215
4264
  enumerable: true,
4216
4265
  get: function() {
@@ -1,12 +1,12 @@
1
- import { $ as hasTailwindRootDirectives, F as stripTailwindSourceMediaFragments, H as removeTailwindV4GeneratedUserCssArtifacts, I as stripUnmatchedTailwindSourceMediaCloseFragments, L as finalizeMiniProgramCss$1, M as isCommentOnlyCss, Mt as _defineProperty, N as removeMiniProgramInteractiveSelectors, O as resolveTailwindcssOptions, P as removeTailwindV4GeneratorAtRules, Rt as getTailwindV4IncrementalGenerateCacheStats, V as stripMiniProgramCssSpecificityPlaceholders, Z as hasTailwindApplyDirective, _ as upsertTailwindV4CssSource, at as removeTailwindSourceDirectives, dt as hasTailwindGeneratedCssMarkers, et as hasTailwindSourceDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as parseImportRequest, kt as resolveSourceScanPath, o as resolveRuntimeBranch, tt as normalizeTailwindConfigDirectives, ut as hasTailwindGeneratedCss, z as pruneMiniProgramGeneratedCss } from "./generator-BgbYHNgD.js";
2
- import { f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature } from "./tailwindcss-o3Xe-o7M.js";
1
+ import { $ as hasTailwindApplyDirective, B as pruneMiniProgramGeneratedCss, F as removeTailwindV4GeneratorAtRules, H as stripMiniProgramCssSpecificityPlaceholders, I as stripTailwindSourceMediaFragments, L as stripUnmatchedTailwindSourceMediaCloseFragments, N as isCommentOnlyCss, P as removeMiniProgramInteractiveSelectors, Pt as _defineProperty, R as finalizeMiniProgramCss$1, Rt as getTailwindV4IncrementalGenerateCacheStats, W as removeTailwindV4GeneratedUserCssArtifacts, _ as upsertTailwindV4CssSource, ft as hasTailwindGeneratedCss, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, jt as resolveSourceScanPath, k as resolveTailwindcssOptions, nt as hasTailwindSourceDirectives, o as resolveRuntimeBranch, ot as parseImportRequest, pt as hasTailwindGeneratedCssMarkers, rt as normalizeTailwindConfigDirectives, st as removeTailwindSourceDirectives, tt as hasTailwindRootDirectives } from "./generator-C0BJjyLM.js";
2
+ import { f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature } from "./tailwindcss-B_4E52WF.js";
3
3
  import { r as getGroupedEntries } from "./utils-MVwpU07P.js";
4
- import { A as createCssSourceTraceCacheSignature, C as isSourceStyleRequest, E as hasBundlerGeneratedCssMarker, F as createEscapeFragments, G as resolveSourceCandidateScanFiles, H as isSourceCandidateRequest, I as isPureLocalCssImportWrapper, M as isCssSourceTraceEnabled, N as createRuntimeClassSetManager, O as stripBundlerGeneratedCssMarkers, P as collectStrictEscapedRuntimeCandidates, V as createSourceCandidateStore, _ as captureResolvedFrameworkPostcssOptions, c as resolveTaskConcurrency, f as scoreTailwindV4CssSourceFileMatch, j as createCssTokenSourceMap, k as annotateCssSourceTrace, n as emitHmrTiming, o as collectRawSourceClassSelectors, p as removeGeneratedSelectorCompatCss, r as generateTailwindV4Css, s as pushConcurrentTaskFactories, v as collectFrameworkPostcssOptionsFromLoaderEntries, w as stripRequestQuery, x as hasMiniProgramTailwindV4PreflightReset, y as createCssSourceOrderAppend, z as finalizeCompilerShadowRun } from "./hmr-timing-BfxWwMeT.js";
5
- import { C as createTailwindRuntimeReadyPromise, K as createDebug, L as createCompilationDependencyChanges, N as recordCompilationDependencyChanges, O as AssetEmissionPlan, T as refreshTailwindRuntimeState, Y as md5Hash, a as beginCompilerShadowRun, f as getCompilerContext, h as pluginName, i as disposeCompilerOwner, j as getCompilationScopeDependencyRevision, m as resolveStyleOptionsFromContext, n as createRuntimeAffectingSourceSignature, p as normalizeStyleHandlerMajorVersion, t as createCompilerRuntimeState, v as shouldSkipJsTransform, w as ensureRuntimeClassSet } from "./compiler-CJ5yX-on.js";
6
- import { n as getDefaultCssPreflight } from "./defaults-CKx-4LcW.js";
7
- import { a as createRuntimeCompilationAffectingSignature, c as resetRuntimeCompilationBuildState, i as buildRuntimeCompilationSnapshot, l as updateRuntimeCompilationBuildState, o as createRuntimeCompilationBuildState, r as processCachedTask, t as finalizeMiniProgramCssStructure } from "./final-css-cleanup-B0HUBtiE.js";
8
- import { _ as resolveWebpackFrameworkProfile, d as resolvePluginDisabledState, h as webpackStyleInjectorDelegates, i as createCandidateSignature, n as createScopedGeneratorRuntime, p as createBuiltinWebpackStyleInjectorPlugin, u as classifyRuntimeEntry } from "./scoped-generator-Dqq2iLky.js";
9
- import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, t as createSourceCandidateScanSignature } from "./source-candidate-scan-signature-BJkQJtRM.js";
4
+ import { A as annotateCssSourceTrace, B as finalizeCompilerShadowRun, C as isSourceStyleRequest, D as hasBundlerGeneratedCssMarker, F as collectStrictEscapedRuntimeCandidates, H as createSourceCandidateStore, I as createEscapeFragments, K as resolveSourceCandidateScanFiles, L as isPureLocalCssImportWrapper, M as createCssTokenSourceMap, N as isCssSourceTraceEnabled, P as createRuntimeClassSetManager, U as isSourceCandidateRequest, _ as captureResolvedFrameworkPostcssOptions, c as resolveTaskConcurrency, f as scoreTailwindV4CssSourceFileMatch, j as createCssSourceTraceCacheSignature, k as stripBundlerGeneratedCssMarkers, n as emitHmrTiming, o as collectRawSourceClassSelectors, p as removeGeneratedSelectorCompatCss, r as generateTailwindV4Css, s as pushConcurrentTaskFactories, v as collectFrameworkPostcssOptionsFromLoaderEntries, w as stripRequestQuery, x as hasMiniProgramTailwindV4PreflightReset, y as createCssSourceOrderAppend } from "./hmr-timing-B9Yt86-U.js";
5
+ import { C as createTailwindRuntimeReadyPromise, K as createDebug, L as createCompilationDependencyChanges, N as recordCompilationDependencyChanges, O as AssetEmissionPlan, T as refreshTailwindRuntimeState, Y as md5Hash, a as beginCompilerShadowRun, f as getCompilerContext, h as pluginName, i as disposeCompilerOwner, j as getCompilationScopeDependencyRevision, m as resolveStyleOptionsFromContext, n as createRuntimeAffectingSourceSignature, p as normalizeStyleHandlerMajorVersion, t as createCompilerRuntimeState, v as shouldSkipJsTransform, w as ensureRuntimeClassSet } from "./compiler-D3GBwxoa.js";
6
+ import { n as getDefaultCssPreflight } from "./defaults-AQuvJS-h.js";
7
+ import { a as createRuntimeCompilationAffectingSignature, c as resetRuntimeCompilationBuildState, i as buildRuntimeCompilationSnapshot, l as updateRuntimeCompilationBuildState, o as createRuntimeCompilationBuildState, r as processCachedTask, t as finalizeMiniProgramCssStructure } from "./final-css-cleanup-u_sI2p56.js";
8
+ import { _ as resolveWebpackFrameworkProfile, d as resolvePluginDisabledState, h as webpackStyleInjectorDelegates, i as createCandidateSignature, n as createScopedGeneratorRuntime, p as createBuiltinWebpackStyleInjectorPlugin, u as classifyRuntimeEntry } from "./scoped-generator-B6Y1bxzM.js";
9
+ import { a as toAbsoluteOutputPath, i as resolveOutputSpecifier, n as resolvePackageDir, t as createSourceCandidateScanSignature } from "./source-candidate-scan-signature-DNuGKTqf.js";
10
10
  import Module, { createRequire } from "node:module";
11
11
  import fs from "node:fs";
12
12
  import path from "node:path";
@@ -739,7 +739,7 @@ function dirnameWebpackResourcePath(file) {
739
739
  return path.dirname(file);
740
740
  }
741
741
  function resolveWebpackCssAssetModuleResource(resource, issuer, options) {
742
- if (!isCssLikeModuleResource(resource, options.cssMatcher, options.appType)) return;
742
+ if (!isCssLikeModuleResource(resource, options.cssMatcher)) return;
743
743
  const normalized = stripResourceQuery(resource);
744
744
  if (!normalized) return;
745
745
  const absoluteResource = resolveWebpackResourcePath(normalized);
@@ -2493,7 +2493,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
2493
2493
  onUpdate: compilerOptions.onUpdate,
2494
2494
  debug
2495
2495
  });
2496
- for (const [file, asset] of groupedEntries.css) updateAssetIfChanged(file, finalizeWebpackCssAssetOutputSource(stringifyWebpackSourceLike(compilation.getAsset(file)?.source.source() ?? asset.source()), compilerOptions, isWebGeneratorTarget));
2496
+ for (const [file, asset] of groupedEntries.css) updateAssetIfChanged(file, finalizeWebpackCssAssetOutputSource((compilation.getAsset(file)?.source.source() ?? asset.source()).toString(), compilerOptions, isWebGeneratorTarget));
2497
2497
  });
2498
2498
  });
2499
2499
  }
@@ -2712,7 +2712,7 @@ function addMpxWebpackPluginAlias(alias, pkgDir) {
2712
2712
  }
2713
2713
  ];
2714
2714
  const managedNames = new Set(entries.filter((entry) => typeof entry.name === "string").map((entry) => entry.name));
2715
- const managedPatterns = new Set(entries.filter((entry) => entry.name instanceof RegExp).map((entry) => `${entry.name.source}/${entry.name.flags}`));
2715
+ const managedPatterns = new Set(entries.flatMap((entry) => entry.name instanceof RegExp ? [`${entry.name.source}/${entry.name.flags}`] : []));
2716
2716
  for (let index = alias.length - 1; index >= 0; index--) {
2717
2717
  const name = alias[index]?.name;
2718
2718
  if (managedNames.has(name) || name instanceof RegExp && managedPatterns.has(`${name.source}/${name.flags}`)) alias.splice(index, 1);
@@ -2993,7 +2993,7 @@ function setupWebpackV5Loaders(options) {
2993
2993
  const isLynxMainThreadCss = compilerOptions.platform === "lynx" && (module.layer === "react:main-thread" || loaderEntries.some((entry) => entry.loader?.includes?.("ignore-css-loader")));
2994
2994
  let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
2995
2995
  const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
2996
- const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
2996
+ const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher);
2997
2997
  if (isCssModule) {
2998
2998
  const frameworkPostcssOptions = collectFrameworkPostcssOptionsFromLoaderEntries(loaderEntries, _loaderContext);
2999
2999
  if (frameworkPostcssOptions) captureResolvedFrameworkPostcssOptions(compilerOptions, frameworkPostcssOptions);
@@ -3024,7 +3024,7 @@ function setupWebpackV5Loaders(options) {
3024
3024
  if (cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoaderExists && runtimeCssImportRewriteLoader && isCssModule && !isLynxMainThreadCss) {
3025
3025
  const existingIndex = loaderEntries.findIndex((entry) => entry.loader?.includes?.(runtimeCssImportRewriteLoader));
3026
3026
  const existingOptions = existingIndex === -1 ? void 0 : loaderEntries[existingIndex]?.options;
3027
- const generateInRegisteredLoader = typeof existingOptions === "object" && existingOptions !== null && "generateCss" in existingOptions && existingOptions.generateCss === true;
3027
+ const generateInRegisteredLoader = typeof existingOptions === "object" && existingOptions !== null && "generateCss" in existingOptions && existingOptions["generateCss"] === true;
3028
3028
  const rewriteLoaderEntry = existingIndex !== -1 ? {
3029
3029
  ...loaderEntries.splice(existingIndex, 1)[0],
3030
3030
  loader: runtimeCssImportRewriteLoader,
@@ -3091,6 +3091,7 @@ function appendIgnoredPath(ignored, ignoredPath) {
3091
3091
  return createOutputIgnoredPredicate(normalizeIgnoredList(ignored), ignoredPath);
3092
3092
  }
3093
3093
  function setupWebpackWatchOutputIgnore(compiler) {
3094
+ const compilerOptions = compiler.options;
3094
3095
  const appendOutputIgnoredPath = (watchOptions, outputPath) => {
3095
3096
  const resolvedOutputPath = outputPath || compiler.outputPath || compiler.options?.output?.path;
3096
3097
  const paths = resolvedOutputPath && path.win32.isAbsolute(resolvedOutputPath) && !path.posix.isAbsolute(resolvedOutputPath) ? path.win32 : path;
@@ -3104,8 +3105,8 @@ function setupWebpackWatchOutputIgnore(compiler) {
3104
3105
  }
3105
3106
  return { ignored: appendIgnoredPath(void 0, outputDir) };
3106
3107
  };
3107
- const compilerWatchOptions = appendOutputIgnoredPath(compiler.options.watchOptions);
3108
- if (compilerWatchOptions) compiler.options.watchOptions = compilerWatchOptions;
3108
+ const compilerWatchOptions = appendOutputIgnoredPath(compilerOptions.watchOptions);
3109
+ if (compilerWatchOptions) compilerOptions.watchOptions = compilerWatchOptions;
3109
3110
  const syncOutputIgnoredPath = () => {
3110
3111
  const outputPath = compiler.outputPath || compiler.options?.output?.path;
3111
3112
  const watchOptions = compiler.watching?.watchOptions;
@@ -3117,8 +3118,8 @@ function setupWebpackWatchOutputIgnore(compiler) {
3117
3118
  const watchOptions = compiler.watching?.watchOptions;
3118
3119
  if (watchOptions) appendOutputIgnoredPath(watchOptions, outputPath);
3119
3120
  else {
3120
- const compilerWatchOptions = appendOutputIgnoredPath(compiler.options.watchOptions, outputPath);
3121
- if (compilerWatchOptions) compiler.options.watchOptions = compilerWatchOptions;
3121
+ const compilerWatchOptions = appendOutputIgnoredPath(compilerOptions.watchOptions, outputPath);
3122
+ if (compilerWatchOptions) compilerOptions.watchOptions = compilerWatchOptions;
3122
3123
  }
3123
3124
  });
3124
3125
  }