weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -7
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/auto-TH1jG2UW.js +115 -0
- package/dist/auto-XyKTOP7B.mjs +78 -0
- package/dist/bundle-state-Bi-cQua6.mjs +413 -0
- package/dist/bundle-state-Ct_8GcSR.js +529 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -4
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +21 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
- package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +16 -22
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/index.d.ts +5 -2
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
- package/dist/bundlers/vite/source-candidates.d.ts +19 -1
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +2 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -6
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cache/index.d.ts +6 -6
- package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +758 -604
- package/dist/cli.mjs +766 -612
- package/dist/constants.d.ts +1 -2
- package/dist/context/runtime-package-replacements.d.ts +2 -0
- package/dist/context/style-options.d.ts +3 -0
- package/dist/core.js +12 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/auto.d.ts +10 -0
- package/dist/css-macro/constants.d.ts +5 -2
- package/dist/css-macro/postcss.d.ts +1 -0
- package/dist/css-macro/postcss.js +7 -46
- package/dist/css-macro/postcss.mjs +2 -46
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +16 -7
- package/dist/css-macro.mjs +15 -6
- package/dist/defaults-8xrgzxFY.mjs +151 -0
- package/dist/defaults-zKUH2mDe.js +193 -0
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +6 -131
- package/dist/defaults.mjs +2 -129
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +9 -8
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-CrU-Ghc1.js +90 -0
- package/dist/generator-Qw-tZ0Z2.mjs +65 -0
- package/dist/generator.js +12 -12
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +187 -48
- package/dist/gulp.mjs +180 -41
- package/dist/incremental-runtime-class-set-Boqi1QlB.mjs +2224 -0
- package/dist/incremental-runtime-class-set-FAOHZmzh.js +2293 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +19 -7
- package/dist/index.mjs +6 -5
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/precheck.d.ts +2 -2
- package/dist/logger-BNzxZbZj.mjs +2 -0
- package/dist/logger-TlKT3xmR.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-C6zOQqlL.mjs +228 -0
- package/dist/postcss-C7BMYpEF.mjs +169 -0
- package/dist/postcss-CiYLsqZn.js +192 -0
- package/dist/postcss-DAWf9D3C.js +237 -0
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/precheck-D7K12zeX.mjs +4716 -0
- package/dist/precheck-D7gJSmJz.js +4842 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/uni-app-x.d.ts +1 -0
- package/dist/presets.js +29 -13
- package/dist/presets.mjs +25 -11
- package/dist/reset.d.ts +1 -0
- package/dist/reset.js +1 -1
- package/dist/runtime-registry-DpcR3IHI.js +5496 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-CX2ozpKM.mjs +322 -0
- package/dist/source-candidates-DNM8iwXW.js +335 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-B-e2RiXr.js +642 -0
- package/dist/tailwindcss-C7dJHZ0G.mjs +591 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +52 -49
- package/dist/types/shared.d.ts +6 -0
- package/dist/types/user-defined-options/general.d.ts +25 -24
- package/dist/types/user-defined-options/important.d.ts +33 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/unocss/index.d.ts +2 -0
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/utils/options.d.ts +2 -0
- package/dist/utils/regex.d.ts +1 -0
- package/dist/{utils-DmC9_In3.js → utils-D7Ygohep.js} +2 -2
- package/dist/{utils-7DUGTFED.mjs → utils-DsaS975I.mjs} +1 -1
- package/dist/v3-engine-CHItlVq5.js +3616 -0
- package/dist/v3-engine-DcvCCHfs.mjs +3321 -0
- package/dist/vite-BgTPSkQS.js +24446 -0
- package/dist/vite-fFRpSvyz.mjs +24432 -0
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +5227 -18
- package/dist/weapp-tw-runtime-classset-loader.js +32 -9
- package/dist/webpack-BXSWVdXh.js +851 -0
- package/dist/webpack-Dx2AZpGU.mjs +841 -0
- package/dist/webpack.d.ts +1 -3
- package/dist/webpack.js +3 -4
- package/dist/webpack.mjs +2 -2
- package/package.json +38 -48
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/constants-B-_T5UnW.mjs +0 -44
- package/dist/constants-p1dyh1x1.js +0 -73
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
- package/dist/generator-css-Bwy_Uz89.mjs +0 -1097
- package/dist/generator-css-CRLrHW4F.js +0 -1124
- package/dist/generator-mmhXzZnv.js +0 -1276
- package/dist/js/syntax.d.ts +0 -10
- package/dist/lightningcss/index.d.ts +0 -8
- package/dist/lightningcss/style-handler/options.d.ts +0 -3
- package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
- package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
- package/dist/lightningcss/style-handler.d.ts +0 -17
- package/dist/loader-anchors-1MumTAtA.mjs +0 -205
- package/dist/loader-anchors-TrFvT6g1.js +0 -273
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/recorder-GdTJ3QqX.js +0 -2878
- package/dist/recorder-XdFvVASS.mjs +0 -2763
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/vite-BDywuCjn.mjs +0 -2186
- package/dist/vite-DgRh_GXn.js +0 -2199
- package/dist/webpack-CAJR4hhP.js +0 -456
- package/dist/webpack-CiHqVZTg.mjs +0 -441
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
package/dist/gulp.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { b as ensureRuntimeClassSet, n as getCompilerContext, t as shouldSkipJsTransform, y as createTailwindRuntimeReadyPromise } from "./precheck-D7K12zeX.mjs";
|
|
2
|
+
import { B as createDebug, _ as resolveViteSourceScanEntries, l as getRuntimeClassSetSignature } from "./v3-engine-DcvCCHfs.mjs";
|
|
3
|
+
import { c as hasTailwindRootDirectives, i as generateCssByGenerator, r as emitHmrTiming, s as processCachedTask, t as createBundleRuntimeClassSetManager, u as normalizeTailwindSourceForGenerator } from "./incremental-runtime-class-set-Boqi1QlB.mjs";
|
|
4
|
+
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-C7dJHZ0G.mjs";
|
|
5
|
+
import { t as createSourceCandidateCollector } from "./source-candidates-CX2ozpKM.mjs";
|
|
6
|
+
import fs from "node:fs";
|
|
3
7
|
import path from "node:path";
|
|
4
8
|
import process from "node:process";
|
|
5
9
|
import { Buffer } from "node:buffer";
|
|
6
|
-
import fs from "node:fs";
|
|
7
10
|
import stream from "node:stream";
|
|
8
11
|
//#region src/bundlers/gulp/index.ts
|
|
9
12
|
const debug = createDebug();
|
|
@@ -14,18 +17,18 @@ const Transform = stream.Transform;
|
|
|
14
17
|
* @link https://tw.icebreaker.top/docs/quick-start/frameworks/native
|
|
15
18
|
*/
|
|
16
19
|
function createPlugins(options = {}) {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
cwd: opts.tailwindcssBasedir ?? process.cwd()
|
|
20
|
+
const hasInitialTailwindCssRoots = hasConfiguredTailwindV4CssRoots(options);
|
|
21
|
+
const opts = getCompilerContext({
|
|
22
|
+
...options,
|
|
23
|
+
__internalDeferMissingCssEntriesWarning: true
|
|
22
24
|
});
|
|
25
|
+
const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
26
|
+
const readyPromise = createTailwindRuntimeReadyPromise(initialTwPatcher);
|
|
23
27
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
24
28
|
const runtimeState = {
|
|
25
29
|
twPatcher: initialTwPatcher,
|
|
26
|
-
|
|
27
|
-
refreshTailwindcssPatcher
|
|
28
|
-
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
30
|
+
readyPromise,
|
|
31
|
+
refreshTailwindcssPatcher
|
|
29
32
|
};
|
|
30
33
|
const defaultStyleHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
31
34
|
let cachedDefaultTemplateHandlerOptions;
|
|
@@ -40,20 +43,138 @@ function createPlugins(options = {}) {
|
|
|
40
43
|
".jsx"
|
|
41
44
|
];
|
|
42
45
|
let runtimeSetInitialized = false;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
let runtimeSetDirty = false;
|
|
47
|
+
const runtimeSourceHashByFile = /* @__PURE__ */ new Map();
|
|
48
|
+
const runtimeSourcesByFile = /* @__PURE__ */ new Map();
|
|
49
|
+
let cachedGulpSourceCandidates;
|
|
50
|
+
let cachedGulpSourceCandidateSignature;
|
|
51
|
+
const bundleRuntimeClassSetManager = options.__internalGulpRuntimeClassSetManager ?? createBundleRuntimeClassSetManager();
|
|
52
|
+
async function refreshRuntimeSet(options = false) {
|
|
53
|
+
const normalizedOptions = typeof options === "boolean" ? {
|
|
54
|
+
forceRefresh: options,
|
|
55
|
+
forceCollect: options,
|
|
56
|
+
clearCache: options
|
|
57
|
+
} : options;
|
|
58
|
+
const forceRefresh = normalizedOptions.forceRefresh === true;
|
|
59
|
+
const shouldForceCollect = normalizedOptions.forceCollect === true || runtimeSetDirty;
|
|
60
|
+
const clearCache = normalizedOptions.clearCache === true || runtimeSetDirty;
|
|
61
|
+
if (!forceRefresh && !shouldForceCollect && runtimeSetInitialized) return runtimeSet;
|
|
48
62
|
runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
49
|
-
forceRefresh
|
|
50
|
-
forceCollect:
|
|
51
|
-
clearCache
|
|
63
|
+
forceRefresh,
|
|
64
|
+
forceCollect: shouldForceCollect,
|
|
65
|
+
clearCache,
|
|
52
66
|
allowEmpty: false
|
|
53
67
|
});
|
|
54
68
|
runtimeSetInitialized = true;
|
|
69
|
+
runtimeSetDirty = false;
|
|
55
70
|
return runtimeSet;
|
|
56
71
|
}
|
|
72
|
+
function createRuntimeSnapshot(changedFiles) {
|
|
73
|
+
const runtimeAffectingChangedByType = {
|
|
74
|
+
html: /* @__PURE__ */ new Set(),
|
|
75
|
+
js: /* @__PURE__ */ new Set(),
|
|
76
|
+
css: /* @__PURE__ */ new Set(),
|
|
77
|
+
other: /* @__PURE__ */ new Set()
|
|
78
|
+
};
|
|
79
|
+
for (const file of changedFiles) {
|
|
80
|
+
const entry = runtimeSourcesByFile.get(file);
|
|
81
|
+
if (entry) runtimeAffectingChangedByType[entry.type].add(file);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
entries: [...runtimeSourcesByFile.entries()].map(([file, entry]) => ({
|
|
85
|
+
file,
|
|
86
|
+
output: {
|
|
87
|
+
fileName: file,
|
|
88
|
+
source: entry.source,
|
|
89
|
+
type: "asset"
|
|
90
|
+
},
|
|
91
|
+
source: entry.source,
|
|
92
|
+
type: entry.type
|
|
93
|
+
})),
|
|
94
|
+
jsEntries: /* @__PURE__ */ new Map(),
|
|
95
|
+
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
96
|
+
runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
|
|
97
|
+
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
98
|
+
changedByType: {
|
|
99
|
+
html: /* @__PURE__ */ new Set(),
|
|
100
|
+
js: /* @__PURE__ */ new Set(),
|
|
101
|
+
css: /* @__PURE__ */ new Set(),
|
|
102
|
+
other: /* @__PURE__ */ new Set()
|
|
103
|
+
},
|
|
104
|
+
runtimeAffectingChangedByType,
|
|
105
|
+
processFiles: {
|
|
106
|
+
html: /* @__PURE__ */ new Set(),
|
|
107
|
+
js: /* @__PURE__ */ new Set(),
|
|
108
|
+
css: /* @__PURE__ */ new Set()
|
|
109
|
+
},
|
|
110
|
+
linkedImpactsByEntry: /* @__PURE__ */ new Map()
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async function refreshRuntimeSetForSource(file, rawSource, type) {
|
|
114
|
+
const filename = path.resolve(file.path);
|
|
115
|
+
const hash = cache.computeHash(rawSource);
|
|
116
|
+
const changed = runtimeSourceHashByFile.get(filename) !== hash;
|
|
117
|
+
runtimeSourceHashByFile.set(filename, hash);
|
|
118
|
+
runtimeSourcesByFile.set(filename, {
|
|
119
|
+
source: rawSource,
|
|
120
|
+
type
|
|
121
|
+
});
|
|
122
|
+
if (!changed && runtimeSetInitialized) return runtimeSet;
|
|
123
|
+
if (runtimeState.twPatcher.majorVersion === 4 && !runtimeSetDirty) try {
|
|
124
|
+
runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, createRuntimeSnapshot([filename]));
|
|
125
|
+
runtimeSetInitialized = true;
|
|
126
|
+
return runtimeSet;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
debug("gulp incremental runtime set sync failed, fallback to collect: %O", error);
|
|
129
|
+
await bundleRuntimeClassSetManager.reset();
|
|
130
|
+
}
|
|
131
|
+
return refreshRuntimeSet({ forceCollect: true });
|
|
132
|
+
}
|
|
133
|
+
async function refreshGulpSourceCandidates(forceRefresh = false) {
|
|
134
|
+
if (runtimeState.twPatcher.majorVersion !== 3) return /* @__PURE__ */ new Set();
|
|
135
|
+
const root = opts.tailwindcssBasedir ?? process.cwd();
|
|
136
|
+
const sourceScan = await resolveViteSourceScanEntries(opts, runtimeState.twPatcher, { root });
|
|
137
|
+
const nextSignature = cache.computeHash(JSON.stringify({
|
|
138
|
+
root,
|
|
139
|
+
entries: sourceScan?.entries,
|
|
140
|
+
inlineCandidates: sourceScan?.inlineCandidates ? {
|
|
141
|
+
included: [...sourceScan.inlineCandidates.included].sort(),
|
|
142
|
+
excluded: [...sourceScan.inlineCandidates.excluded].sort()
|
|
143
|
+
} : void 0,
|
|
144
|
+
explicit: sourceScan?.explicit ?? false,
|
|
145
|
+
dependencies: [...sourceScan?.dependencies ?? []].sort()
|
|
146
|
+
}));
|
|
147
|
+
if (!forceRefresh && cachedGulpSourceCandidateSignature === nextSignature && cachedGulpSourceCandidates) return cachedGulpSourceCandidates;
|
|
148
|
+
const collector = createSourceCandidateCollector();
|
|
149
|
+
await collector.scanRoot({
|
|
150
|
+
entries: sourceScan?.entries,
|
|
151
|
+
root
|
|
152
|
+
});
|
|
153
|
+
collector.syncInline(sourceScan?.inlineCandidates);
|
|
154
|
+
cachedGulpSourceCandidateSignature = nextSignature;
|
|
155
|
+
cachedGulpSourceCandidates = sourceScan?.entries ? collector.valuesForEntries(sourceScan.entries) : collector.values();
|
|
156
|
+
return cachedGulpSourceCandidates;
|
|
157
|
+
}
|
|
158
|
+
function createRuntimeSetHash(rawSource, nextRuntimeSet) {
|
|
159
|
+
return cache.computeHash([
|
|
160
|
+
rawSource,
|
|
161
|
+
getRuntimeClassSetSignature(runtimeState.twPatcher),
|
|
162
|
+
[...nextRuntimeSet].sort().join("\n")
|
|
163
|
+
].join("\n\n"));
|
|
164
|
+
}
|
|
165
|
+
async function registerAutoCssSource(file, rawSource) {
|
|
166
|
+
if (hasInitialTailwindCssRoots || (runtimeState.twPatcher.majorVersion ?? 0) < 4 || !file.path || !hasTailwindRootDirectives(rawSource)) return false;
|
|
167
|
+
const sourceCss = normalizeTailwindSourceForGenerator(rawSource, { importFallback: true });
|
|
168
|
+
if (!upsertTailwindV4CssSource(opts, {
|
|
169
|
+
file: path.resolve(file.path),
|
|
170
|
+
css: sourceCss
|
|
171
|
+
})) return false;
|
|
172
|
+
runtimeSetInitialized = false;
|
|
173
|
+
runtimeSetDirty = true;
|
|
174
|
+
await bundleRuntimeClassSetManager.reset();
|
|
175
|
+
debug("detected tailwindcss v4 css source from gulp css file: %s", file.path);
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
57
178
|
function resolveWithExtensions(base) {
|
|
58
179
|
for (const ext of MODULE_EXTENSIONS) {
|
|
59
180
|
const candidate = `${base}${ext}`;
|
|
@@ -100,12 +221,14 @@ function createPlugins(options = {}) {
|
|
|
100
221
|
if (!cachedDefaultModuleGraphOptions) cachedDefaultModuleGraphOptions = createModuleGraphOptionsFor();
|
|
101
222
|
return cachedDefaultModuleGraphOptions;
|
|
102
223
|
}
|
|
103
|
-
function createVinylTransform(handler) {
|
|
224
|
+
function createVinylTransform(phase, handler) {
|
|
104
225
|
return new Transform({
|
|
105
226
|
objectMode: true,
|
|
106
227
|
async transform(file, _encoding, callback) {
|
|
228
|
+
const hmrTimingStartedAt = performance.now();
|
|
107
229
|
try {
|
|
108
230
|
await handler(file);
|
|
231
|
+
emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, { file: file.relative || path.basename(file.path) });
|
|
109
232
|
callback(null, file);
|
|
110
233
|
} catch (error) {
|
|
111
234
|
callback(error, file);
|
|
@@ -118,12 +241,12 @@ function createPlugins(options = {}) {
|
|
|
118
241
|
if (!options || Object.keys(options).length === 0) {
|
|
119
242
|
let cached = defaultStyleHandlerOptionsCache.get(majorVersion);
|
|
120
243
|
if (!cached) {
|
|
121
|
-
cached = { majorVersion: runtimeState.twPatcher.majorVersion };
|
|
244
|
+
cached = runtimeState.twPatcher.majorVersion === void 0 ? {} : { majorVersion: runtimeState.twPatcher.majorVersion };
|
|
122
245
|
defaultStyleHandlerOptionsCache.set(majorVersion, cached);
|
|
123
246
|
}
|
|
124
247
|
return cached;
|
|
125
248
|
}
|
|
126
|
-
return {
|
|
249
|
+
return runtimeState.twPatcher.majorVersion === void 0 ? { ...options } : {
|
|
127
250
|
majorVersion: runtimeState.twPatcher.majorVersion,
|
|
128
251
|
...options
|
|
129
252
|
};
|
|
@@ -158,15 +281,28 @@ function createPlugins(options = {}) {
|
|
|
158
281
|
...options
|
|
159
282
|
};
|
|
160
283
|
}
|
|
161
|
-
const transformWxss = (options = {}) => createVinylTransform(async (file) => {
|
|
284
|
+
const transformWxss = (options = {}) => createVinylTransform("css", async (file) => {
|
|
162
285
|
if (!file.contents) return;
|
|
163
|
-
await refreshRuntimeState(true);
|
|
164
|
-
await runtimeState.patchPromise;
|
|
165
286
|
const rawSource = file.contents.toString();
|
|
287
|
+
const cssSourceChanged = await registerAutoCssSource(file, rawSource);
|
|
288
|
+
const isMainChunk = opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType);
|
|
289
|
+
const shouldUseGenerator = runtimeState.twPatcher.majorVersion !== 3 || hasTailwindRootDirectives(rawSource);
|
|
290
|
+
let nextRuntimeSet = await refreshRuntimeSet({
|
|
291
|
+
forceRefresh: cssSourceChanged,
|
|
292
|
+
forceCollect: cssSourceChanged || runtimeState.twPatcher.majorVersion !== 4 && isMainChunk,
|
|
293
|
+
clearCache: cssSourceChanged
|
|
294
|
+
});
|
|
295
|
+
if (runtimeState.twPatcher.majorVersion === 3 && isMainChunk && shouldUseGenerator) {
|
|
296
|
+
const sourceCandidates = await refreshGulpSourceCandidates(cssSourceChanged);
|
|
297
|
+
if (sourceCandidates.size > 0) {
|
|
298
|
+
nextRuntimeSet = new Set([...nextRuntimeSet, ...sourceCandidates]);
|
|
299
|
+
runtimeSet = nextRuntimeSet;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
166
302
|
await processCachedTask({
|
|
167
303
|
cache,
|
|
168
304
|
cacheKey: file.path,
|
|
169
|
-
rawSource,
|
|
305
|
+
hash: createRuntimeSetHash(rawSource, nextRuntimeSet),
|
|
170
306
|
applyResult(source) {
|
|
171
307
|
file.contents = Buffer.from(source);
|
|
172
308
|
},
|
|
@@ -174,41 +310,41 @@ function createPlugins(options = {}) {
|
|
|
174
310
|
debug("css cache hit: %s", file.path);
|
|
175
311
|
},
|
|
176
312
|
async transform() {
|
|
177
|
-
await runtimeState.
|
|
313
|
+
await runtimeState.readyPromise;
|
|
178
314
|
const cssHandlerOptions = resolveWxssFileHandlerOptions(file, options);
|
|
179
|
-
const css = (await generateCssByGenerator({
|
|
315
|
+
const css = (shouldUseGenerator ? await generateCssByGenerator({
|
|
180
316
|
opts,
|
|
181
317
|
runtimeState,
|
|
182
|
-
runtime:
|
|
318
|
+
runtime: nextRuntimeSet,
|
|
183
319
|
rawSource,
|
|
184
320
|
file: file.path,
|
|
185
321
|
cssHandlerOptions,
|
|
186
322
|
cssUserHandlerOptions: resolveWxssUserHandlerOptions(options),
|
|
187
323
|
styleHandler,
|
|
188
324
|
debug
|
|
189
|
-
}))?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css;
|
|
325
|
+
}) : void 0)?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css;
|
|
190
326
|
debug("css handle: %s", file.path);
|
|
191
327
|
return { result: css };
|
|
192
328
|
}
|
|
193
329
|
});
|
|
194
330
|
});
|
|
195
|
-
const transformJs = (options = {}) => createVinylTransform(async (file) => {
|
|
331
|
+
const transformJs = (options = {}) => createVinylTransform("js", async (file) => {
|
|
196
332
|
if (!file.contents) return;
|
|
197
|
-
await refreshRuntimeSet(false);
|
|
198
|
-
await runtimeState.patchPromise;
|
|
199
333
|
const filename = path.resolve(file.path);
|
|
334
|
+
const rawSource = file.contents.toString();
|
|
335
|
+
await refreshRuntimeSetForSource(file, rawSource, "js");
|
|
336
|
+
await runtimeState.readyPromise;
|
|
200
337
|
const moduleGraph = resolveModuleGraphOptions(options.moduleGraph);
|
|
201
338
|
const handlerOptions = {
|
|
202
339
|
...options,
|
|
203
340
|
filename,
|
|
204
341
|
moduleGraph,
|
|
205
|
-
tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
|
|
206
342
|
babelParserOptions: {
|
|
207
343
|
...options?.babelParserOptions ?? {},
|
|
208
344
|
sourceFilename: filename
|
|
209
345
|
}
|
|
210
346
|
};
|
|
211
|
-
|
|
347
|
+
if (runtimeState.twPatcher.majorVersion !== void 0) handlerOptions.tailwindcssMajorVersion = runtimeState.twPatcher.majorVersion;
|
|
212
348
|
await processCachedTask({
|
|
213
349
|
cache,
|
|
214
350
|
cacheKey: file.path,
|
|
@@ -220,20 +356,23 @@ function createPlugins(options = {}) {
|
|
|
220
356
|
debug("js cache hit: %s", file.path);
|
|
221
357
|
},
|
|
222
358
|
async transform() {
|
|
223
|
-
await runtimeState.
|
|
359
|
+
await runtimeState.readyPromise;
|
|
224
360
|
const currentSource = file.contents?.toString() ?? rawSource;
|
|
225
|
-
if (shouldSkipJsTransform(currentSource,
|
|
361
|
+
if (shouldSkipJsTransform(currentSource, {
|
|
362
|
+
...handlerOptions,
|
|
363
|
+
classNameSet: runtimeSet
|
|
364
|
+
})) return { result: currentSource };
|
|
226
365
|
const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
227
366
|
debug("js handle: %s", file.path);
|
|
228
367
|
return { result: code };
|
|
229
368
|
}
|
|
230
369
|
});
|
|
231
370
|
});
|
|
232
|
-
const transformWxml = (options = {}) => createVinylTransform(async (file) => {
|
|
371
|
+
const transformWxml = (options = {}) => createVinylTransform("html", async (file) => {
|
|
233
372
|
if (!file.contents) return;
|
|
234
|
-
await refreshRuntimeSet(false);
|
|
235
|
-
await runtimeState.patchPromise;
|
|
236
373
|
const rawSource = file.contents.toString();
|
|
374
|
+
await refreshRuntimeSetForSource(file, rawSource, "html");
|
|
375
|
+
await runtimeState.readyPromise;
|
|
237
376
|
await processCachedTask({
|
|
238
377
|
cache,
|
|
239
378
|
cacheKey: file.path,
|
|
@@ -245,7 +384,7 @@ function createPlugins(options = {}) {
|
|
|
245
384
|
debug("html cache hit: %s", file.path);
|
|
246
385
|
},
|
|
247
386
|
async transform() {
|
|
248
|
-
await runtimeState.
|
|
387
|
+
await runtimeState.readyPromise;
|
|
249
388
|
const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options));
|
|
250
389
|
debug("html handle: %s", file.path);
|
|
251
390
|
return { result: code };
|