weapp-tailwindcss 5.0.0-next.1 → 5.0.0-next.10

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 (189) hide show
  1. package/README.md +4 -5
  2. package/bin/weapp-tailwindcss.js +1 -21
  3. package/dist/bundle-state-BWqi5ZyX.mjs +343 -0
  4. package/dist/bundle-state-EUbcdKqo.js +410 -0
  5. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
  6. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
  7. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
  8. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
  9. package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
  10. package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
  11. package/dist/bundlers/shared/generator-css/directives.d.ts +13 -0
  12. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
  13. package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
  14. package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
  15. package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
  16. package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
  17. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
  18. package/dist/bundlers/shared/generator-css.d.ts +12 -20
  19. package/dist/bundlers/vite/css-finalizer.d.ts +4 -1
  20. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
  21. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
  22. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
  23. package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
  24. package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
  25. package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
  26. package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
  27. package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
  28. package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
  29. package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
  30. package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
  31. package/dist/bundlers/vite/generate-bundle.d.ts +16 -2
  32. package/dist/bundlers/vite/index.d.ts +1 -1
  33. package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
  34. package/dist/bundlers/vite/postcss-config.d.ts +6 -0
  35. package/dist/bundlers/vite/rewrite-css-imports.d.ts +2 -0
  36. package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
  37. package/dist/bundlers/vite/source-candidates.d.ts +18 -0
  38. package/dist/bundlers/vite/source-scan.d.ts +8 -0
  39. package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
  40. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
  41. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +4 -1
  42. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -1
  43. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
  44. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -1
  45. package/dist/cache-BVAiJV3J.js +502 -0
  46. package/dist/cache-CHs4DXui.mjs +434 -0
  47. package/dist/cli/context.d.ts +0 -3
  48. package/dist/cli/helpers.d.ts +1 -2
  49. package/dist/cli/mount-options.d.ts +2 -0
  50. package/dist/cli/types.d.ts +0 -2
  51. package/dist/cli.js +108 -598
  52. package/dist/cli.mjs +119 -608
  53. package/dist/constants.d.ts +1 -2
  54. package/dist/context/tailwindcss.d.ts +1 -1
  55. package/dist/core.js +13 -20
  56. package/dist/core.mjs +8 -14
  57. package/dist/css-macro/postcss.js +1 -1
  58. package/dist/css-macro/postcss.mjs +1 -1
  59. package/dist/css-macro.d.ts +1 -0
  60. package/dist/css-macro.js +2 -2
  61. package/dist/css-macro.mjs +2 -2
  62. package/dist/defaults.d.ts +15 -1
  63. package/dist/defaults.js +33 -14
  64. package/dist/defaults.mjs +30 -15
  65. package/dist/generator/index.d.ts +1 -1
  66. package/dist/generator/options.d.ts +5 -4
  67. package/dist/generator/types.d.ts +1 -0
  68. package/dist/generator-DKkhJbOg.js +1531 -0
  69. package/dist/generator-UBmfduYg.mjs +1432 -0
  70. package/dist/generator.js +1 -1
  71. package/dist/generator.mjs +1 -1
  72. package/dist/gulp.js +142 -43
  73. package/dist/gulp.mjs +137 -38
  74. package/dist/{generator-css-CnYjiMrD.js → incremental-runtime-class-set-BYmzQ-_f.js} +1057 -586
  75. package/dist/{generator-css-DhPFjSzK.mjs → incremental-runtime-class-set-BgMW6wf2.mjs} +1046 -593
  76. package/dist/index.d.ts +1 -1
  77. package/dist/index.js +6 -6
  78. package/dist/index.mjs +5 -5
  79. package/dist/js/index.d.ts +1 -0
  80. package/dist/js/literal-transform.d.ts +2 -0
  81. package/dist/logger-CZUxvJJD.mjs +2 -0
  82. package/dist/logger-EVNB9z7i.js +1 -0
  83. package/dist/postcss/config-directive.d.ts +1 -0
  84. package/dist/postcss/context.d.ts +9 -0
  85. package/dist/postcss/source-files.d.ts +8 -0
  86. package/dist/postcss/tailwind-version.d.ts +3 -0
  87. package/dist/postcss-C7efq3hr.mjs +231 -0
  88. package/dist/postcss-Dg-_lyHS.js +240 -0
  89. package/dist/postcss.d.ts +2 -2
  90. package/dist/postcss.js +3 -274
  91. package/dist/postcss.mjs +1 -267
  92. package/dist/{recorder-rn_2v_nd.js → precheck-B32p-gLI.js} +141 -283
  93. package/dist/{recorder-B_XyZ576.mjs → precheck-B4RH6ZNN.mjs} +107 -248
  94. package/dist/presets.js +6 -4
  95. package/dist/presets.mjs +4 -2
  96. package/dist/reset.d.ts +1 -0
  97. package/dist/runtime-patch-CwN5ya72.mjs +71 -0
  98. package/dist/runtime-patch-D6mBo_KB.js +85 -0
  99. package/dist/source-scan-BaYvNx-k.js +293 -0
  100. package/dist/source-scan-cGZxoJqP.mjs +254 -0
  101. package/dist/tailwindcss/miniprogram.d.ts +5 -1
  102. package/dist/tailwindcss/patcher-options.d.ts +3 -51
  103. package/dist/tailwindcss/patcher.d.ts +1 -2
  104. package/dist/tailwindcss/runtime-patch.d.ts +5 -0
  105. package/dist/tailwindcss/runtime.d.ts +2 -3
  106. package/dist/tailwindcss/source-scan.d.ts +25 -0
  107. package/dist/tailwindcss/targets.d.ts +1 -5
  108. package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
  109. package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
  110. package/dist/tailwindcss/v4/patcher.d.ts +2 -1
  111. package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
  112. package/dist/tailwindcss/v4-engine/miniprogram.d.ts +1 -0
  113. package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
  114. package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
  115. package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
  116. package/dist/tailwindcss/v4-engine/types.d.ts +2 -0
  117. package/dist/tailwindcss/version.d.ts +4 -0
  118. package/dist/{logger-BZ45DZJT.js → tailwindcss-Bu-RWIHx.js} +84 -457
  119. package/dist/{logger-BoVx1Dbt.mjs → tailwindcss-C5IgPlQ0.mjs} +71 -427
  120. package/dist/typedoc.export.d.ts +0 -2
  121. package/dist/types/index.d.ts +2 -9
  122. package/dist/types/shared.d.ts +3 -0
  123. package/dist/types/user-defined-options/general.d.ts +0 -2
  124. package/dist/types/user-defined-options/important.d.ts +3 -3
  125. package/dist/uni-app-x/vite.d.ts +1 -1
  126. package/dist/utils/disabled.d.ts +2 -3
  127. package/dist/{vite-C8JlHiyR.mjs → vite-BU74SkOi.mjs} +1132 -826
  128. package/dist/{vite-BHpAqldo.js → vite-CKjx_5c3.js} +1170 -861
  129. package/dist/vite.d.ts +1 -2
  130. package/dist/vite.js +3 -4
  131. package/dist/vite.mjs +2 -2
  132. package/dist/weapp-tw-css-import-rewrite-loader.js +11 -2
  133. package/dist/{webpack-CABjKGGQ.mjs → webpack-CAk_ITq7.mjs} +323 -51
  134. package/dist/webpack-damWiYqY.js +723 -0
  135. package/dist/webpack.js +1 -1
  136. package/dist/webpack.mjs +1 -1
  137. package/package.json +27 -40
  138. package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
  139. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
  140. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
  141. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
  142. package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
  143. package/dist/cli/config.d.ts +0 -5
  144. package/dist/cli/helpers/patch-cwd.d.ts +0 -1
  145. package/dist/cli/mount-options/patch-status.d.ts +0 -2
  146. package/dist/cli/patch-options.d.ts +0 -6
  147. package/dist/cli/tokens.d.ts +0 -4
  148. package/dist/cli/workspace/package-dirs.d.ts +0 -3
  149. package/dist/cli/workspace/patch-package.d.ts +0 -3
  150. package/dist/cli/workspace/patch-utils.d.ts +0 -3
  151. package/dist/cli/workspace/types.d.ts +0 -11
  152. package/dist/cli/workspace/workspace-globs.d.ts +0 -2
  153. package/dist/cli/workspace/workspace-io.d.ts +0 -1
  154. package/dist/cli/workspace/workspace-lock.d.ts +0 -1
  155. package/dist/cli/workspace.d.ts +0 -2
  156. package/dist/css-imports-BbrbluP9.js +0 -177
  157. package/dist/css-imports-CSdPq_Sc.mjs +0 -128
  158. package/dist/experimental/index.d.ts +0 -2
  159. package/dist/experimental/oxc/ast-utils.d.ts +0 -30
  160. package/dist/experimental/oxc/index.d.ts +0 -2
  161. package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
  162. package/dist/experimental/shared/cache.d.ts +0 -3
  163. package/dist/experimental/shared/transform.d.ts +0 -3
  164. package/dist/experimental/shared.d.ts +0 -8
  165. package/dist/experimental/swc/ast-utils.d.ts +0 -30
  166. package/dist/experimental/swc/index.d.ts +0 -2
  167. package/dist/experimental/swc/module-specifiers.d.ts +0 -2
  168. package/dist/generator-CZ-JXw6T.js +0 -492
  169. package/dist/generator-Dwxgra97.mjs +0 -399
  170. package/dist/js/syntax.d.ts +0 -10
  171. package/dist/loader-anchors-DvwgIYdA.mjs +0 -205
  172. package/dist/loader-anchors-cprm4Klq.js +0 -273
  173. package/dist/patcher-options-6gJN2EXy.js +0 -115
  174. package/dist/patcher-options-DQfR5xxT.mjs +0 -92
  175. package/dist/tailwindcss/recorder.d.ts +0 -13
  176. package/dist/tailwindcss/targets/paths.d.ts +0 -13
  177. package/dist/tailwindcss/targets/record-io.d.ts +0 -5
  178. package/dist/tailwindcss/targets/recorder.d.ts +0 -3
  179. package/dist/tailwindcss/targets/types.d.ts +0 -35
  180. package/dist/types/disabled-options.d.ts +0 -4
  181. package/dist/webpack-DNIJ0ysE.js +0 -456
  182. package/dist/webpack4.d.ts +0 -4
  183. package/dist/webpack4.js +0 -387
  184. package/dist/webpack4.mjs +0 -379
  185. package/scripts/postinstall.mjs +0 -59
  186. /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
  187. /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
  188. /package/dist/{utils-DmC9_In3.js → utils-BiShvil9.js} +0 -0
  189. /package/dist/{utils-7DUGTFED.mjs → utils-Btw1iOVV.mjs} +0 -0
package/README.md CHANGED
@@ -15,7 +15,6 @@
15
15
 
16
16
  ![star](https://badgen.net/github/stars/sonofmagic/weapp-tailwindcss)
17
17
  ![dm0](https://badgen.net/npm/dm/weapp-tailwindcss)
18
- ![dm1](https://badgen.net/npm/dm/weapp-tailwindcss-webpack-plugin)
19
18
  ![license](https://badgen.net/npm/license/weapp-tailwindcss)
20
19
  [![test](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml)
21
20
  [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
@@ -55,12 +54,12 @@
55
54
 
56
55
  ## 版本对应
57
56
 
58
- 目前,`weapp-tailwindcss` 的 `4.x` 版本
57
+ 目前,`weapp-tailwindcss` 的 `5.x` 版本
59
58
 
60
- - 支持最新版本的 `tailwindcss v4` 和 `v3` 还有 `v2 jit` 版本。
61
- - 支持 `webpack5`,`webpack4`, `vite` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
59
+ - 支持最新版本的 `tailwindcss v4` 和 `v3`。
60
+ - 支持 `webpack5`、`vite`、`rspack`、`rollup`、`rolldown` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
62
61
 
63
- > 如果你还在使用 `tailwindcss@2` 版本,那你应该使用从 `weapp-tailwindcss/webpack4` 导出的本插件的 `postcss7` `webpack4` 版本。另外请确保你的 `nodejs` 版本 `>=16.6.0`。目前低于 `16` 的长期维护版本(`偶数版本`) 都已经结束了生命周期,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
62
+ > `weapp-tailwindcss@5` 面向 Tailwind CSS v3/v4 和现代构建链路,不再内置 Webpack4、PostCSS7、Tailwind CSS v2 兼容入口。`weapp-tailwindcss@5` 需要 `nodejs` 版本 `^20.19.0 || >=22.12.0`,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
64
63
 
65
64
  ## [安装与使用方式](https://tw.icebreaker.top/docs/quick-start/install)
66
65
 
@@ -1,28 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('node:fs')
3
3
  const path = require('node:path')
4
- const process = require('node:process')
5
-
6
- function isInstallLifecycle() {
7
- return process.env.npm_lifecycle_event === 'postinstall' || process.env.npm_lifecycle_event === 'prepare'
8
- }
9
-
10
- function isMissingRuntimeModuleError(error) {
11
- return error && error.code === 'MODULE_NOT_FOUND'
12
- }
13
4
 
14
5
  const cliPath = path.resolve(__dirname, '../dist/cli.js')
15
6
  if (fs.existsSync(cliPath)) {
16
- try {
17
- require(cliPath)
18
- }
19
- catch (error) {
20
- if (isInstallLifecycle() && isMissingRuntimeModuleError(error)) {
21
- console.error('[weapp-tailwindcss] install lifecycle patch skipped because a runtime module is missing.')
22
- console.error('Run `pnpm --filter weapp-tailwindcss build` before strict CLI validation.')
23
- }
24
- else {
25
- throw error
26
- }
27
- }
7
+ require(cliPath)
28
8
  }
@@ -0,0 +1,343 @@
1
+ import { d as traverse, u as babelParse } from "./precheck-B4RH6ZNN.mjs";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { Buffer } from "node:buffer";
5
+ import { Parser } from "htmlparser2";
6
+ //#region src/bundlers/shared/module-graph.ts
7
+ const QUERY_HASH_RE = /[?#].*$/u;
8
+ const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
9
+ const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
10
+ const VIRTUAL_PREFIX = "\0";
11
+ const JS_EXTENSIONS = [
12
+ ".js",
13
+ ".mjs",
14
+ ".cjs"
15
+ ];
16
+ function normalizeOutputPathKey(value) {
17
+ return path.normalize(value).replace(/\\/g, "/");
18
+ }
19
+ function stripQueryAndHash(specifier) {
20
+ return specifier.replace(QUERY_HASH_RE, "");
21
+ }
22
+ function isResolvableSpecifier(specifier) {
23
+ if (!specifier) return false;
24
+ const normalized = stripQueryAndHash(specifier);
25
+ if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
26
+ if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
27
+ return !PROTOCOL_RE.test(normalized);
28
+ }
29
+ function toAbsoluteOutputPath(fileName, outDir) {
30
+ if (path.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return path.normalize(fileName);
31
+ return path.resolve(outDir, fileName);
32
+ }
33
+ function matchWithExtensions(candidate, hasOutput) {
34
+ if (hasOutput(candidate)) return candidate;
35
+ if (!path.extname(candidate)) for (const ext of JS_EXTENSIONS) {
36
+ const extended = `${candidate}${ext}`;
37
+ if (hasOutput(extended)) return extended;
38
+ }
39
+ }
40
+ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
41
+ if (!isResolvableSpecifier(specifier)) return;
42
+ const normalized = stripQueryAndHash(specifier);
43
+ let candidate;
44
+ if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = path.normalize(normalized);
45
+ else if (normalized.startsWith("/")) candidate = path.resolve(outDir, normalized.slice(1));
46
+ else candidate = path.resolve(path.dirname(importer), normalized);
47
+ return matchWithExtensions(candidate, hasOutput);
48
+ }
49
+ //#endregion
50
+ //#region src/utils/disabled.ts
51
+ function resolvePluginDisabledState(disabled) {
52
+ if (disabled === true) return { plugin: true };
53
+ if (disabled === false || disabled == null) return { plugin: false };
54
+ return { plugin: disabled.plugin ?? false };
55
+ }
56
+ //#endregion
57
+ //#region src/utils/resolve-package.ts
58
+ const require = createRequire(import.meta.url);
59
+ function resolvePackageDir(name) {
60
+ const pkgPath = require.resolve(`${name}/package.json`);
61
+ return path.dirname(pkgPath);
62
+ }
63
+ //#endregion
64
+ //#region src/bundlers/shared/run-tasks.ts
65
+ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
66
+ if (factories.length === 0) return [];
67
+ const results = Array.from({ length: factories.length });
68
+ const executing = /* @__PURE__ */ new Set();
69
+ let cursor = 0;
70
+ const effectiveLimit = Math.max(1, limit);
71
+ const scheduleNext = () => {
72
+ if (cursor >= factories.length) return;
73
+ const currentIndex = cursor++;
74
+ const wrapped = Promise.resolve(factories[currentIndex]()).then((value) => {
75
+ results[currentIndex] = value;
76
+ }).finally(() => {
77
+ executing.delete(wrapped);
78
+ });
79
+ executing.add(wrapped);
80
+ };
81
+ while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
82
+ while (cursor < factories.length) {
83
+ await Promise.race(executing);
84
+ scheduleNext();
85
+ }
86
+ await Promise.all(executing);
87
+ return results;
88
+ }
89
+ function pushConcurrentTaskFactories(queue, factories, limit) {
90
+ if (factories.length === 0) return;
91
+ queue.push(runWithConcurrency(factories, limit).then(() => void 0));
92
+ }
93
+ //#endregion
94
+ //#region src/bundlers/vite/bundle-entries.ts
95
+ function readOutputEntry(entry) {
96
+ if (entry.output.type === "chunk") return entry.output.code;
97
+ const source = entry.output.source;
98
+ if (typeof source === "string") return source;
99
+ if (source instanceof Uint8Array) return Buffer.from(source).toString();
100
+ const fallbackSource = source;
101
+ if (fallbackSource == null) return;
102
+ if (typeof fallbackSource.toString === "function") return fallbackSource.toString();
103
+ }
104
+ function isJavaScriptEntry(entry) {
105
+ if (entry.output.type === "chunk") return true;
106
+ return entry.fileName.endsWith(".js");
107
+ }
108
+ function createBundleModuleGraphOptions(outputDir, entries) {
109
+ const normalizedEntries = /* @__PURE__ */ new Map();
110
+ for (const [id, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(id), entry);
111
+ const getEntry = (id) => entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
112
+ return {
113
+ resolve(specifier, importer) {
114
+ return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
115
+ },
116
+ load(id) {
117
+ const entry = getEntry(id);
118
+ if (!entry) return;
119
+ return readOutputEntry(entry);
120
+ },
121
+ filter(id) {
122
+ return Boolean(getEntry(id));
123
+ }
124
+ };
125
+ }
126
+ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
127
+ if (!linked) return;
128
+ const normalizedEntries = /* @__PURE__ */ new Map();
129
+ for (const [entryId, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(entryId), entry);
130
+ for (const [id, { code }] of Object.entries(linked)) {
131
+ const entry = entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
132
+ if (!entry) continue;
133
+ const previous = readOutputEntry(entry);
134
+ if (previous == null || previous === code) continue;
135
+ if (entry.output.type === "chunk") entry.output.code = code;
136
+ else entry.output.source = code;
137
+ onApplied?.(entry, code);
138
+ onLinkedUpdate(entry.fileName, previous, code);
139
+ }
140
+ }
141
+ //#endregion
142
+ //#region src/bundlers/vite/runtime-affecting-signature.ts
143
+ const CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
144
+ const CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
145
+ const CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
146
+ const CSS_WHITESPACE_RE = /\s+/g;
147
+ function createHtmlRuntimeAffectingSignature(source) {
148
+ try {
149
+ const parts = [];
150
+ const parser = new Parser({
151
+ onattribute(name, value) {
152
+ parts.push(`a:${name}=${value}`);
153
+ },
154
+ oncomment(data) {
155
+ parts.push(`c:${data}`);
156
+ },
157
+ ontext(data) {
158
+ const value = data.trim();
159
+ if (value.length > 0) parts.push(`t:${value}`);
160
+ }
161
+ }, { xmlMode: true });
162
+ parser.write(source);
163
+ parser.end();
164
+ return parts.join("\n");
165
+ } catch {
166
+ return source;
167
+ }
168
+ }
169
+ function createJsRuntimeAffectingSignature(source) {
170
+ try {
171
+ const ast = babelParse(source, {
172
+ cache: true,
173
+ cacheKey: "vite-runtime-affecting:unambiguous",
174
+ plugins: ["jsx", "typescript"],
175
+ sourceType: "unambiguous"
176
+ });
177
+ const parts = [];
178
+ traverse(ast, {
179
+ noScope: true,
180
+ StringLiteral(path) {
181
+ parts.push(`s:${path.node.value}`);
182
+ },
183
+ TemplateElement(path) {
184
+ parts.push(`t:${path.node.value.raw}`);
185
+ },
186
+ JSXText(path) {
187
+ const value = path.node.value.trim();
188
+ if (value.length > 0) parts.push(`x:${value}`);
189
+ }
190
+ });
191
+ const comments = ast.comments;
192
+ if (Array.isArray(comments)) {
193
+ for (const comment of comments) if (typeof comment?.value === "string" && comment.value.length > 0) parts.push(`c:${comment.value}`);
194
+ }
195
+ return parts.join("\n");
196
+ } catch {
197
+ return source;
198
+ }
199
+ }
200
+ function createCssRuntimeAffectingSignature(source) {
201
+ return source.replace(CSS_BLOCK_COMMENT_RE, "").replace(CSS_AROUND_PUNCTUATION_RE, "$1").replace(CSS_TRAILING_DECLARATION_SEMICOLON_RE, "}").replace(CSS_WHITESPACE_RE, " ").trim();
202
+ }
203
+ function createRuntimeAffectingSourceSignature(source, type) {
204
+ if (type === "html") return createHtmlRuntimeAffectingSignature(source);
205
+ if (type === "js") return createJsRuntimeAffectingSignature(source);
206
+ if (type === "css") return createCssRuntimeAffectingSignature(source);
207
+ return source;
208
+ }
209
+ //#endregion
210
+ //#region src/bundlers/vite/bundle-state.ts
211
+ function createBundleBuildState() {
212
+ return {
213
+ iteration: 0,
214
+ sourceHashByFile: /* @__PURE__ */ new Map(),
215
+ runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
216
+ runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
217
+ linkedByEntry: /* @__PURE__ */ new Map(),
218
+ dependentsByLinkedFile: /* @__PURE__ */ new Map()
219
+ };
220
+ }
221
+ function createChangedByType() {
222
+ return {
223
+ html: /* @__PURE__ */ new Set(),
224
+ js: /* @__PURE__ */ new Set(),
225
+ css: /* @__PURE__ */ new Set(),
226
+ other: /* @__PURE__ */ new Set()
227
+ };
228
+ }
229
+ function createProcessFiles() {
230
+ return {
231
+ html: /* @__PURE__ */ new Set(),
232
+ js: /* @__PURE__ */ new Set(),
233
+ css: /* @__PURE__ */ new Set()
234
+ };
235
+ }
236
+ function readEntrySource(output) {
237
+ if (output.type === "chunk") return output.code;
238
+ return output.source.toString();
239
+ }
240
+ function classifyBundleEntry(file, opts) {
241
+ if (opts.cssMatcher(file)) return "css";
242
+ if (opts.htmlMatcher(file)) return "html";
243
+ if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
244
+ return "other";
245
+ }
246
+ function collectJsEntries(fileName, output, outDir, store) {
247
+ const entry = {
248
+ fileName,
249
+ output
250
+ };
251
+ if (!isJavaScriptEntry(entry)) return;
252
+ const absolute = toAbsoluteOutputPath(fileName, outDir);
253
+ store.set(absolute, entry);
254
+ }
255
+ function markProcessFile(type, file, processFiles) {
256
+ if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
257
+ }
258
+ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
259
+ const sourceHashByFile = /* @__PURE__ */ new Map();
260
+ const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
261
+ const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
262
+ const changedByType = createChangedByType();
263
+ const runtimeAffectingChangedByType = createChangedByType();
264
+ const processFiles = createProcessFiles();
265
+ const linkedImpactsByEntry = /* @__PURE__ */ new Map();
266
+ const jsEntries = /* @__PURE__ */ new Map();
267
+ const entries = [];
268
+ const firstRun = state.linkedByEntry.size === 0;
269
+ for (const [file, output] of Object.entries(bundle)) {
270
+ const type = classifyBundleEntry(file, opts);
271
+ const source = readEntrySource(output);
272
+ const hash = opts.cache.computeHash(source);
273
+ sourceHashByFile.set(file, hash);
274
+ const previousHash = state.sourceHashByFile.get(file);
275
+ const changed = previousHash == null || previousHash !== hash;
276
+ const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
277
+ const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
278
+ const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
279
+ const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
280
+ const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
281
+ runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
282
+ runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
283
+ if (changed) changedByType[type].add(file);
284
+ if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
285
+ if (forceAll || firstRun) markProcessFile(type, file, processFiles);
286
+ else if (type === "html") processFiles.html.add(file);
287
+ else if (changed && (type === "js" || type === "css")) processFiles[type].add(file);
288
+ collectJsEntries(file, output, outDir, jsEntries);
289
+ entries.push({
290
+ file,
291
+ output,
292
+ source,
293
+ type
294
+ });
295
+ }
296
+ if (!forceAll && !firstRun) for (const changedFile of changedByType.js) {
297
+ const dependents = state.dependentsByLinkedFile.get(changedFile);
298
+ if (!dependents) continue;
299
+ for (const entryFile of dependents) {
300
+ processFiles.js.add(entryFile);
301
+ let impacts = linkedImpactsByEntry.get(entryFile);
302
+ if (!impacts) {
303
+ impacts = /* @__PURE__ */ new Set();
304
+ linkedImpactsByEntry.set(entryFile, impacts);
305
+ }
306
+ impacts.add(changedFile);
307
+ }
308
+ }
309
+ return {
310
+ entries,
311
+ jsEntries,
312
+ sourceHashByFile,
313
+ runtimeAffectingSignatureByFile,
314
+ runtimeAffectingHashByFile,
315
+ changedByType,
316
+ runtimeAffectingChangedByType,
317
+ processFiles,
318
+ linkedImpactsByEntry
319
+ };
320
+ }
321
+ function invertLinkedByEntry(linkedByEntry) {
322
+ const dependentsByLinkedFile = /* @__PURE__ */ new Map();
323
+ for (const [entryFile, linkedFiles] of linkedByEntry.entries()) for (const linkedFile of linkedFiles) {
324
+ let dependents = dependentsByLinkedFile.get(linkedFile);
325
+ if (!dependents) {
326
+ dependents = /* @__PURE__ */ new Set();
327
+ dependentsByLinkedFile.set(linkedFile, dependents);
328
+ }
329
+ dependents.add(entryFile);
330
+ }
331
+ return dependentsByLinkedFile;
332
+ }
333
+ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
334
+ const incremental = options.incremental === true;
335
+ state.iteration += 1;
336
+ state.sourceHashByFile = incremental ? new Map([...state.sourceHashByFile, ...snapshot.sourceHashByFile]) : snapshot.sourceHashByFile;
337
+ state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
338
+ state.runtimeAffectingHashByFile = incremental ? new Map([...state.runtimeAffectingHashByFile, ...snapshot.runtimeAffectingHashByFile]) : snapshot.runtimeAffectingHashByFile;
339
+ state.linkedByEntry = incremental ? new Map([...state.linkedByEntry, ...linkedByEntry]) : linkedByEntry;
340
+ state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
341
+ }
342
+ //#endregion
343
+ export { createBundleModuleGraphOptions as a, resolvePluginDisabledState as c, toAbsoluteOutputPath as d, applyLinkedResults as i, normalizeOutputPathKey as l, createBundleBuildState as n, pushConcurrentTaskFactories as o, updateBundleBuildState as r, resolvePackageDir as s, buildBundleSnapshot as t, resolveOutputSpecifier as u };