weapp-tailwindcss 4.7.4 → 4.7.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-T5BSWDY2.js → chunk-24ADBRZN.js} +25 -15
- package/dist/{chunk-FPX2BD2A.mjs → chunk-42FXROX4.mjs} +23 -13
- package/dist/{chunk-QA6SPWSQ.js → chunk-E5LRICST.js} +253 -25
- package/dist/{chunk-SIZNRUIV.js → chunk-GGD75A34.js} +8 -0
- package/dist/{chunk-6IYMPBCH.mjs → chunk-PUFKPENL.mjs} +56 -14
- package/dist/{chunk-I6FBWASF.js → chunk-RLWIDWTA.js} +59 -17
- package/dist/{chunk-3ARXMTWC.mjs → chunk-SHMBWMDV.mjs} +8 -0
- package/dist/{chunk-HMTZ4JJN.js → chunk-SJV6DCNZ.js} +22 -15
- package/dist/{chunk-JII7EQ6K.mjs → chunk-TK5LOBHZ.mjs} +23 -16
- package/dist/{chunk-V35QS2PT.mjs → chunk-XEQBYGBX.mjs} +229 -1
- package/dist/cli.js +5 -5
- package/dist/cli.mjs +2 -2
- package/dist/core.js +29 -13
- package/dist/core.mjs +30 -14
- package/dist/gulp.js +4 -5
- package/dist/gulp.mjs +3 -4
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -7
- package/dist/index.mjs +5 -6
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +1 -1
- package/dist/types.d.mts +11 -1
- package/dist/types.d.ts +11 -1
- package/dist/vite.js +4 -5
- package/dist/vite.mjs +3 -4
- package/dist/webpack.js +4 -5
- package/dist/webpack.mjs +3 -4
- package/dist/webpack4.js +26 -16
- package/dist/webpack4.mjs +24 -14
- package/package.json +1 -1
- package/dist/chunk-667CYXAH.mjs +0 -133
- package/dist/chunk-BUMQQPAO.js +0 -133
|
@@ -13,11 +13,10 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var _chunkBUMQQPAOjs = require('./chunk-BUMQQPAO.js');
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
var
|
|
19
|
+
var _chunkE5LRICSTjs = require('./chunk-E5LRICST.js');
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -26,10 +25,10 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
|
26
25
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
27
26
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
28
27
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
29
|
-
var debug =
|
|
28
|
+
var debug = _chunkE5LRICSTjs.createDebug.call(void 0, );
|
|
30
29
|
var UnifiedWebpackPluginV5 = class {
|
|
31
30
|
constructor(options = {}) {
|
|
32
|
-
this.options =
|
|
31
|
+
this.options = _chunkE5LRICSTjs.getCompilerContext.call(void 0, options);
|
|
33
32
|
this.appType = this.options.appType;
|
|
34
33
|
}
|
|
35
34
|
apply(compiler) {
|
|
@@ -45,17 +44,26 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
45
44
|
jsHandler,
|
|
46
45
|
runtimeLoaderPath,
|
|
47
46
|
cache,
|
|
48
|
-
twPatcher
|
|
47
|
+
twPatcher: initialTwPatcher,
|
|
48
|
+
refreshTailwindcssPatcher
|
|
49
49
|
} = this.options;
|
|
50
50
|
if (disabled) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
const
|
|
53
|
+
const runtimeState = {
|
|
54
|
+
twPatcher: initialTwPatcher,
|
|
55
|
+
patchPromise: _chunkE5LRICSTjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
|
|
56
|
+
refreshTailwindcssPatcher
|
|
57
|
+
};
|
|
58
|
+
const refreshRuntimeState = async (force) => {
|
|
59
|
+
await _chunkE5LRICSTjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
60
|
+
};
|
|
54
61
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
55
62
|
const { ConcatSource } = sources;
|
|
56
63
|
async function getClassSetInLoader() {
|
|
57
|
-
await
|
|
58
|
-
await
|
|
64
|
+
await refreshRuntimeState(true);
|
|
65
|
+
await runtimeState.patchPromise;
|
|
66
|
+
await _chunkE5LRICSTjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
59
67
|
}
|
|
60
68
|
onLoad();
|
|
61
69
|
const loader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js")));
|
|
@@ -68,8 +76,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
68
76
|
ident: null,
|
|
69
77
|
type: null
|
|
70
78
|
};
|
|
71
|
-
compiler.hooks.compilation.tap(
|
|
72
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
79
|
+
compiler.hooks.compilation.tap(_chunkE5LRICSTjs.pluginName, (compilation) => {
|
|
80
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunkE5LRICSTjs.pluginName, (_loaderContext, module) => {
|
|
73
81
|
if (isExisted) {
|
|
74
82
|
const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
|
|
75
83
|
if (idx > -1) {
|
|
@@ -79,13 +87,13 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
79
87
|
});
|
|
80
88
|
compilation.hooks.processAssets.tapPromise(
|
|
81
89
|
{
|
|
82
|
-
name:
|
|
90
|
+
name: _chunkE5LRICSTjs.pluginName,
|
|
83
91
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
84
92
|
},
|
|
85
93
|
async (assets) => {
|
|
86
94
|
onStart();
|
|
87
95
|
debug("start");
|
|
88
|
-
await patchPromise;
|
|
96
|
+
await runtimeState.patchPromise;
|
|
89
97
|
for (const chunk of compilation.chunks) {
|
|
90
98
|
if (chunk.id && chunk.hash) {
|
|
91
99
|
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
@@ -146,7 +154,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
146
154
|
}
|
|
147
155
|
};
|
|
148
156
|
const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
|
|
149
|
-
|
|
157
|
+
await refreshRuntimeState(true);
|
|
158
|
+
await runtimeState.patchPromise;
|
|
159
|
+
const runtimeSet = await _chunkE5LRICSTjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
150
160
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
151
161
|
const tasks = [];
|
|
152
162
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -242,7 +252,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
242
252
|
debug("css cache hit: %s", file);
|
|
243
253
|
},
|
|
244
254
|
transform: async () => {
|
|
245
|
-
await patchPromise;
|
|
255
|
+
await runtimeState.patchPromise;
|
|
246
256
|
const { css } = await styleHandler(rawSource, {
|
|
247
257
|
isMainChunk: mainCssChunkMatcher(file, this.appType),
|
|
248
258
|
postcssOptions: {
|
|
@@ -250,7 +260,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
250
260
|
from: file
|
|
251
261
|
}
|
|
252
262
|
},
|
|
253
|
-
majorVersion: twPatcher.majorVersion
|
|
263
|
+
majorVersion: runtimeState.twPatcher.majorVersion
|
|
254
264
|
});
|
|
255
265
|
const source = new ConcatSource(css);
|
|
256
266
|
onUpdate(file, rawSource, css);
|
|
@@ -12,12 +12,11 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
collectRuntimeClassSet,
|
|
14
14
|
createDebug,
|
|
15
|
-
createTailwindPatchPromise
|
|
16
|
-
} from "./chunk-667CYXAH.mjs";
|
|
17
|
-
import {
|
|
15
|
+
createTailwindPatchPromise,
|
|
18
16
|
getCompilerContext,
|
|
19
|
-
pluginName
|
|
20
|
-
|
|
17
|
+
pluginName,
|
|
18
|
+
refreshTailwindRuntimeState
|
|
19
|
+
} from "./chunk-XEQBYGBX.mjs";
|
|
21
20
|
import {
|
|
22
21
|
getGroupedEntries
|
|
23
22
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
@@ -48,17 +47,26 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
48
47
|
jsHandler,
|
|
49
48
|
runtimeLoaderPath,
|
|
50
49
|
cache,
|
|
51
|
-
twPatcher
|
|
50
|
+
twPatcher: initialTwPatcher,
|
|
51
|
+
refreshTailwindcssPatcher
|
|
52
52
|
} = this.options;
|
|
53
53
|
if (disabled) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const runtimeState = {
|
|
57
|
+
twPatcher: initialTwPatcher,
|
|
58
|
+
patchPromise: createTailwindPatchPromise(initialTwPatcher),
|
|
59
|
+
refreshTailwindcssPatcher
|
|
60
|
+
};
|
|
61
|
+
const refreshRuntimeState = async (force) => {
|
|
62
|
+
await refreshTailwindRuntimeState(runtimeState, force);
|
|
63
|
+
};
|
|
57
64
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
58
65
|
const { ConcatSource } = sources;
|
|
59
66
|
async function getClassSetInLoader() {
|
|
60
|
-
await
|
|
61
|
-
await
|
|
67
|
+
await refreshRuntimeState(true);
|
|
68
|
+
await runtimeState.patchPromise;
|
|
69
|
+
await collectRuntimeClassSet(runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
62
70
|
}
|
|
63
71
|
onLoad();
|
|
64
72
|
const loader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-loader.js");
|
|
@@ -88,7 +96,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
88
96
|
async (assets) => {
|
|
89
97
|
onStart();
|
|
90
98
|
debug("start");
|
|
91
|
-
await patchPromise;
|
|
99
|
+
await runtimeState.patchPromise;
|
|
92
100
|
for (const chunk of compilation.chunks) {
|
|
93
101
|
if (chunk.id && chunk.hash) {
|
|
94
102
|
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
@@ -149,7 +157,9 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
149
157
|
}
|
|
150
158
|
};
|
|
151
159
|
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
152
|
-
|
|
160
|
+
await refreshRuntimeState(true);
|
|
161
|
+
await runtimeState.patchPromise;
|
|
162
|
+
const runtimeSet = await collectRuntimeClassSet(runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
153
163
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
154
164
|
const tasks = [];
|
|
155
165
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -245,7 +255,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
245
255
|
debug("css cache hit: %s", file);
|
|
246
256
|
},
|
|
247
257
|
transform: async () => {
|
|
248
|
-
await patchPromise;
|
|
258
|
+
await runtimeState.patchPromise;
|
|
249
259
|
const { css } = await styleHandler(rawSource, {
|
|
250
260
|
isMainChunk: mainCssChunkMatcher(file, this.appType),
|
|
251
261
|
postcssOptions: {
|
|
@@ -253,7 +263,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
253
263
|
from: file
|
|
254
264
|
}
|
|
255
265
|
},
|
|
256
|
-
majorVersion: twPatcher.majorVersion
|
|
266
|
+
majorVersion: runtimeState.twPatcher.majorVersion
|
|
257
267
|
});
|
|
258
268
|
const source = new ConcatSource(css);
|
|
259
269
|
onUpdate(file, rawSource, css);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkDWAEHRHNjs = require('./chunk-DWAEHRHN.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkGGD75A34js = require('./chunk-GGD75A34.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkWXBFAARRjs = require('./chunk-WXBFAARR.js');
|
|
@@ -12,6 +12,191 @@ var _chunkWXBFAARRjs = require('./chunk-WXBFAARR.js');
|
|
|
12
12
|
|
|
13
13
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
14
14
|
|
|
15
|
+
// src/tailwindcss/runtime.ts
|
|
16
|
+
var _fs = require('fs');
|
|
17
|
+
|
|
18
|
+
// src/debug/index.ts
|
|
19
|
+
var _debug2 = require('debug'); var _debug3 = _interopRequireDefault(_debug2);
|
|
20
|
+
var _debug = _debug3.default.call(void 0, "weapp-tw");
|
|
21
|
+
function createDebug(prefix) {
|
|
22
|
+
function debug2(formatter, ...args) {
|
|
23
|
+
return _debug((_nullishCoalesce(prefix, () => ( ""))) + formatter, ...args);
|
|
24
|
+
}
|
|
25
|
+
return debug2;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/tailwindcss/runtime.ts
|
|
29
|
+
var debug = createDebug("[tailwindcss:runtime] ");
|
|
30
|
+
var refreshTailwindcssPatcherSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
|
|
31
|
+
var runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
function getCacheEntry(twPatcher) {
|
|
33
|
+
let entry = runtimeClassSetCache.get(twPatcher);
|
|
34
|
+
if (!entry) {
|
|
35
|
+
entry = {};
|
|
36
|
+
runtimeClassSetCache.set(twPatcher, entry);
|
|
37
|
+
}
|
|
38
|
+
return entry;
|
|
39
|
+
}
|
|
40
|
+
function getTailwindConfigSignature(twPatcher) {
|
|
41
|
+
const configPath = _optionalChain([twPatcher, 'access', _2 => _2.options, 'optionalAccess', _3 => _3.tailwind, 'optionalAccess', _4 => _4.config]);
|
|
42
|
+
if (typeof configPath !== "string" || configPath.length === 0) {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const stats = _fs.statSync.call(void 0, configPath);
|
|
47
|
+
return `${configPath}:${stats.size}:${stats.mtimeMs}`;
|
|
48
|
+
} catch (e2) {
|
|
49
|
+
return `${configPath}:missing`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function invalidateRuntimeClassSet(twPatcher) {
|
|
53
|
+
if (!twPatcher) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
runtimeClassSetCache.delete(twPatcher);
|
|
57
|
+
}
|
|
58
|
+
function createTailwindPatchPromise(twPatcher) {
|
|
59
|
+
return Promise.resolve(twPatcher.patch()).then((result) => {
|
|
60
|
+
invalidateRuntimeClassSet(twPatcher);
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async function refreshTailwindRuntimeState(state, force) {
|
|
65
|
+
if (!force) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
await state.patchPromise;
|
|
69
|
+
let refreshed = false;
|
|
70
|
+
if (typeof state.refreshTailwindcssPatcher === "function") {
|
|
71
|
+
const next = await state.refreshTailwindcssPatcher({ clearCache: true });
|
|
72
|
+
if (next !== state.twPatcher) {
|
|
73
|
+
state.twPatcher = next;
|
|
74
|
+
}
|
|
75
|
+
refreshed = true;
|
|
76
|
+
}
|
|
77
|
+
if (refreshed) {
|
|
78
|
+
state.patchPromise = createTailwindPatchPromise(state.twPatcher);
|
|
79
|
+
}
|
|
80
|
+
return refreshed;
|
|
81
|
+
}
|
|
82
|
+
function shouldPreferSync(majorVersion) {
|
|
83
|
+
if (majorVersion == null) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (majorVersion === 3) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
if (majorVersion === 4) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
function tryGetRuntimeClassSetSync(twPatcher) {
|
|
95
|
+
if (typeof twPatcher.getClassSetSync !== "function") {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
if (!shouldPreferSync(twPatcher.majorVersion)) {
|
|
99
|
+
return void 0;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
return twPatcher.getClassSetSync();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (twPatcher.majorVersion === 4) {
|
|
105
|
+
debug("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
|
|
106
|
+
} else {
|
|
107
|
+
debug("getClassSetSync() failed, fallback to async getClassSet(): %O", error);
|
|
108
|
+
}
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function mergeContentTokensIntoSet(twPatcher, target) {
|
|
113
|
+
if (typeof twPatcher.collectContentTokens !== "function") {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const report = await twPatcher.collectContentTokens();
|
|
118
|
+
const entries = _optionalChain([report, 'optionalAccess', _5 => _5.entries]);
|
|
119
|
+
if (!Array.isArray(entries)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
for (const entry of entries) {
|
|
123
|
+
const candidate = _optionalChain([entry, 'optionalAccess', _6 => _6.rawCandidate]);
|
|
124
|
+
if (typeof candidate === "string" && candidate.length > 0) {
|
|
125
|
+
target.add(candidate);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
debug("collectContentTokens() failed, continuing without merged tokens: %O", error);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
133
|
+
let activePatcher = twPatcher;
|
|
134
|
+
if (options.force && !options.skipRefresh) {
|
|
135
|
+
const refresh = activePatcher[refreshTailwindcssPatcherSymbol];
|
|
136
|
+
if (typeof refresh === "function") {
|
|
137
|
+
try {
|
|
138
|
+
const refreshed = await refresh({ clearCache: true });
|
|
139
|
+
if (refreshed) {
|
|
140
|
+
activePatcher = refreshed;
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
debug("refreshTailwindcssPatcher failed, continuing with existing patcher: %O", error);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const entry = getCacheEntry(activePatcher);
|
|
148
|
+
const signature = getTailwindConfigSignature(activePatcher);
|
|
149
|
+
const shouldAugmentWithTokens = options.force || !entry.value;
|
|
150
|
+
if (!options.force) {
|
|
151
|
+
if (entry.value && entry.signature === signature) {
|
|
152
|
+
return entry.value;
|
|
153
|
+
}
|
|
154
|
+
if (entry.promise) {
|
|
155
|
+
return entry.promise;
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
entry.value = void 0;
|
|
159
|
+
}
|
|
160
|
+
const task = (async () => {
|
|
161
|
+
const syncSet = tryGetRuntimeClassSetSync(activePatcher);
|
|
162
|
+
if (syncSet) {
|
|
163
|
+
return syncSet;
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const result = await activePatcher.extract({ write: false });
|
|
167
|
+
if (_optionalChain([result, 'optionalAccess', _7 => _7.classSet])) {
|
|
168
|
+
return result.classSet;
|
|
169
|
+
}
|
|
170
|
+
} catch (error) {
|
|
171
|
+
debug("extract() failed, fallback to getClassSet(): %O", error);
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const fallbackSet = await Promise.resolve(activePatcher.getClassSet());
|
|
175
|
+
if (fallbackSet) {
|
|
176
|
+
return fallbackSet;
|
|
177
|
+
}
|
|
178
|
+
} catch (error) {
|
|
179
|
+
debug("getClassSet() failed, returning empty set: %O", error);
|
|
180
|
+
}
|
|
181
|
+
return /* @__PURE__ */ new Set();
|
|
182
|
+
})();
|
|
183
|
+
entry.promise = task;
|
|
184
|
+
entry.signature = signature;
|
|
185
|
+
try {
|
|
186
|
+
const resolved = await task;
|
|
187
|
+
if (shouldAugmentWithTokens) {
|
|
188
|
+
await mergeContentTokensIntoSet(activePatcher, resolved);
|
|
189
|
+
}
|
|
190
|
+
entry.value = resolved;
|
|
191
|
+
entry.promise = void 0;
|
|
192
|
+
entry.signature = signature;
|
|
193
|
+
return resolved;
|
|
194
|
+
} catch (error) {
|
|
195
|
+
entry.promise = void 0;
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
15
200
|
// src/constants.ts
|
|
16
201
|
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
17
202
|
var vitePluginName = "weapp-tailwindcss:adaptor";
|
|
@@ -23,6 +208,7 @@ var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
|
23
208
|
};
|
|
24
209
|
|
|
25
210
|
// src/context/index.ts
|
|
211
|
+
var _promises = require('fs/promises');
|
|
26
212
|
var _logger = require('@weapp-tailwindcss/logger');
|
|
27
213
|
|
|
28
214
|
// src/cache/index.ts
|
|
@@ -102,13 +288,13 @@ function createCache(options) {
|
|
|
102
288
|
const nextHash = _nullishCoalesce(hash, () => ( cache.computeHash(rawSource)));
|
|
103
289
|
cache.calcHashValueChanged(cacheHashKey, nextHash);
|
|
104
290
|
const entry = cache.getHashValue(cacheHashKey);
|
|
105
|
-
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
291
|
+
hasChanged = _nullishCoalesce(_optionalChain([entry, 'optionalAccess', _8 => _8.changed]), () => ( true));
|
|
106
292
|
}
|
|
107
293
|
const readCache = _nullishCoalesce(resolveCache, () => ( (() => cache.get(key))));
|
|
108
294
|
if (!hasChanged) {
|
|
109
295
|
const cached = readCache();
|
|
110
296
|
if (cached !== void 0) {
|
|
111
|
-
await _optionalChain([onCacheHit, 'optionalCall',
|
|
297
|
+
await _optionalChain([onCacheHit, 'optionalCall', _9 => _9(cached)]);
|
|
112
298
|
return cached;
|
|
113
299
|
}
|
|
114
300
|
}
|
|
@@ -198,10 +384,10 @@ function createNameMatcher(list, { exact = false } = {}) {
|
|
|
198
384
|
const fuzzyMatcher = exact ? void 0 : buildFuzzyMatcher(fuzzyStrings);
|
|
199
385
|
const hasRegex = regexList.length > 0;
|
|
200
386
|
return (value) => {
|
|
201
|
-
if (exact && _optionalChain([exactStrings, 'optionalAccess',
|
|
387
|
+
if (exact && _optionalChain([exactStrings, 'optionalAccess', _10 => _10.has, 'call', _11 => _11(value)])) {
|
|
202
388
|
return true;
|
|
203
389
|
}
|
|
204
|
-
if (_optionalChain([fuzzyMatcher, 'optionalCall',
|
|
390
|
+
if (_optionalChain([fuzzyMatcher, 'optionalCall', _12 => _12(value)])) {
|
|
205
391
|
return true;
|
|
206
392
|
}
|
|
207
393
|
if (!hasRegex) {
|
|
@@ -367,10 +553,10 @@ function shouldTransformClassName(candidate, {
|
|
|
367
553
|
if (!classNameSet.has(candidate)) {
|
|
368
554
|
return false;
|
|
369
555
|
}
|
|
370
|
-
return !_optionalChain([jsPreserveClass, 'optionalCall',
|
|
556
|
+
return !_optionalChain([jsPreserveClass, 'optionalCall', _13 => _13(candidate)]);
|
|
371
557
|
}
|
|
372
558
|
function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
373
|
-
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess',
|
|
559
|
+
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _14 => _14.allowDoubleQuotes]);
|
|
374
560
|
let offset = 0;
|
|
375
561
|
let original;
|
|
376
562
|
if (path.isStringLiteral()) {
|
|
@@ -564,7 +750,7 @@ var JsModuleGraph = class {
|
|
|
564
750
|
continue;
|
|
565
751
|
}
|
|
566
752
|
if (exportPath.isExportNamedDeclaration()) {
|
|
567
|
-
const source = _optionalChain([exportPath, 'access',
|
|
753
|
+
const source = _optionalChain([exportPath, 'access', _15 => _15.node, 'access', _16 => _16.source, 'optionalAccess', _17 => _17.value]);
|
|
568
754
|
if (typeof source === "string") {
|
|
569
755
|
for (const spec of exportPath.get("specifiers")) {
|
|
570
756
|
if (!spec.isExportSpecifier()) {
|
|
@@ -631,7 +817,7 @@ var JsModuleGraph = class {
|
|
|
631
817
|
continue;
|
|
632
818
|
}
|
|
633
819
|
if (exportPath.isExportAllDeclaration()) {
|
|
634
|
-
const source = _optionalChain([exportPath, 'access',
|
|
820
|
+
const source = _optionalChain([exportPath, 'access', _18 => _18.node, 'access', _19 => _19.source, 'optionalAccess', _20 => _20.value]);
|
|
635
821
|
if (typeof source === "string") {
|
|
636
822
|
for (const exportName of names) {
|
|
637
823
|
propagate.push({
|
|
@@ -647,7 +833,7 @@ var JsModuleGraph = class {
|
|
|
647
833
|
let resolved;
|
|
648
834
|
try {
|
|
649
835
|
resolved = this.resolve(specifier, filename);
|
|
650
|
-
} catch (
|
|
836
|
+
} catch (e3) {
|
|
651
837
|
resolved = void 0;
|
|
652
838
|
}
|
|
653
839
|
if (!resolved) {
|
|
@@ -683,7 +869,7 @@ var JsModuleGraph = class {
|
|
|
683
869
|
}
|
|
684
870
|
for (const exportPath of state.analysis.exportDeclarations) {
|
|
685
871
|
if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
|
|
686
|
-
const source = _optionalChain([exportPath, 'access',
|
|
872
|
+
const source = _optionalChain([exportPath, 'access', _21 => _21.node, 'access', _22 => _22.source, 'optionalAccess', _23 => _23.value]);
|
|
687
873
|
if (typeof source === "string" && !dependencySpecifiers.has(source)) {
|
|
688
874
|
dependencySpecifiers.set(source, []);
|
|
689
875
|
}
|
|
@@ -693,7 +879,7 @@ var JsModuleGraph = class {
|
|
|
693
879
|
let resolved;
|
|
694
880
|
try {
|
|
695
881
|
resolved = this.resolve(specifier, filename);
|
|
696
|
-
} catch (
|
|
882
|
+
} catch (e4) {
|
|
697
883
|
continue;
|
|
698
884
|
}
|
|
699
885
|
if (!resolved) {
|
|
@@ -711,7 +897,7 @@ var JsModuleGraph = class {
|
|
|
711
897
|
let source;
|
|
712
898
|
try {
|
|
713
899
|
source = this.load(resolved);
|
|
714
|
-
} catch (
|
|
900
|
+
} catch (e5) {
|
|
715
901
|
continue;
|
|
716
902
|
}
|
|
717
903
|
if (typeof source !== "string") {
|
|
@@ -728,7 +914,7 @@ var JsModuleGraph = class {
|
|
|
728
914
|
filename: resolved
|
|
729
915
|
});
|
|
730
916
|
this.applyIgnoredExportsToAnalysis(resolved, analysis);
|
|
731
|
-
} catch (
|
|
917
|
+
} catch (e6) {
|
|
732
918
|
continue;
|
|
733
919
|
}
|
|
734
920
|
this.modules.set(resolved, {
|
|
@@ -1054,7 +1240,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1054
1240
|
const getEffectiveTagPath = (tagPath) => {
|
|
1055
1241
|
let current = tagPath;
|
|
1056
1242
|
while (true) {
|
|
1057
|
-
if (_optionalChain([current, 'access',
|
|
1243
|
+
if (_optionalChain([current, 'access', _24 => _24.isParenthesizedExpression, 'optionalCall', _25 => _25()]) || current.node.type === "ParenthesizedExpression") {
|
|
1058
1244
|
current = current.get("expression");
|
|
1059
1245
|
continue;
|
|
1060
1246
|
}
|
|
@@ -1066,7 +1252,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1066
1252
|
current = current.get("expression");
|
|
1067
1253
|
continue;
|
|
1068
1254
|
}
|
|
1069
|
-
if (_optionalChain([current, 'access',
|
|
1255
|
+
if (_optionalChain([current, 'access', _26 => _26.isTypeCastExpression, 'optionalCall', _27 => _27()])) {
|
|
1070
1256
|
current = current.get("expression");
|
|
1071
1257
|
continue;
|
|
1072
1258
|
}
|
|
@@ -1078,7 +1264,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1078
1264
|
continue;
|
|
1079
1265
|
}
|
|
1080
1266
|
}
|
|
1081
|
-
if (_optionalChain([current, 'access',
|
|
1267
|
+
if (_optionalChain([current, 'access', _28 => _28.isCallExpression, 'optionalCall', _29 => _29()]) || current.node.type === "CallExpression") {
|
|
1082
1268
|
const callee = current.get("callee");
|
|
1083
1269
|
current = callee;
|
|
1084
1270
|
continue;
|
|
@@ -1088,7 +1274,7 @@ function createTaggedTemplateIgnore({ matcher, names }) {
|
|
|
1088
1274
|
return current;
|
|
1089
1275
|
};
|
|
1090
1276
|
const evaluateTagPath = (tagPath) => {
|
|
1091
|
-
if (_optionalChain([tagPath, 'access',
|
|
1277
|
+
if (_optionalChain([tagPath, 'access', _30 => _30.isCallExpression, 'optionalCall', _31 => _31()]) || tagPath.node.type === "CallExpression") {
|
|
1092
1278
|
const calleePath = tagPath.get("callee");
|
|
1093
1279
|
return evaluateTagPath(calleePath);
|
|
1094
1280
|
}
|
|
@@ -1217,7 +1403,7 @@ function analyzeSource(ast, options, handler) {
|
|
|
1217
1403
|
const args = p.get("arguments");
|
|
1218
1404
|
if (Array.isArray(args) && args.length > 0) {
|
|
1219
1405
|
const first = args[0];
|
|
1220
|
-
if (_optionalChain([first, 'optionalAccess',
|
|
1406
|
+
if (_optionalChain([first, 'optionalAccess', _32 => _32.isStringLiteral, 'call', _33 => _33()])) {
|
|
1221
1407
|
requireCallPaths.push(first);
|
|
1222
1408
|
}
|
|
1223
1409
|
}
|
|
@@ -1611,7 +1797,7 @@ function generateCode(match, options = {}) {
|
|
|
1611
1797
|
if (t.isMemberExpression(path.parent)) {
|
|
1612
1798
|
return;
|
|
1613
1799
|
}
|
|
1614
|
-
if (t.isBinaryExpression(path.parent) && (t.isConditionalExpression(_optionalChain([path, 'access',
|
|
1800
|
+
if (t.isBinaryExpression(path.parent) && (t.isConditionalExpression(_optionalChain([path, 'access', _34 => _34.parentPath, 'optionalAccess', _35 => _35.parent])) || t.isLogicalExpression(_optionalChain([path, 'access', _36 => _36.parentPath, 'optionalAccess', _37 => _37.parent])))) {
|
|
1615
1801
|
return;
|
|
1616
1802
|
}
|
|
1617
1803
|
jsTokenUpdater.addToken(
|
|
@@ -1631,7 +1817,7 @@ function generateCode(match, options = {}) {
|
|
|
1631
1817
|
jsTokenUpdater.updateMagicString(ms);
|
|
1632
1818
|
return ms.toString();
|
|
1633
1819
|
}
|
|
1634
|
-
} catch (
|
|
1820
|
+
} catch (e7) {
|
|
1635
1821
|
return match;
|
|
1636
1822
|
}
|
|
1637
1823
|
}
|
|
@@ -1724,7 +1910,7 @@ async function customTemplateHandler(rawSource, options) {
|
|
|
1724
1910
|
}
|
|
1725
1911
|
const lowerName = name.toLowerCase();
|
|
1726
1912
|
const shouldHandleDefault = !disabledDefaultTemplateHandler && (lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass");
|
|
1727
|
-
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall',
|
|
1913
|
+
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _38 => _38(tag, name)]), () => ( false));
|
|
1728
1914
|
if (!shouldHandleDefault && !shouldHandleCustom) {
|
|
1729
1915
|
return;
|
|
1730
1916
|
}
|
|
@@ -1915,6 +2101,28 @@ function ensureDefaultsIncluded(value) {
|
|
|
1915
2101
|
}
|
|
1916
2102
|
return value;
|
|
1917
2103
|
}
|
|
2104
|
+
async function clearTailwindcssPatcherCache(patcher) {
|
|
2105
|
+
if (!patcher) {
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
const cacheOptions = _optionalChain([patcher, 'access', _39 => _39.options, 'optionalAccess', _40 => _40.cache]);
|
|
2109
|
+
if (!cacheOptions || cacheOptions.enabled === false) {
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
const cachePath = _nullishCoalesce(cacheOptions.path, () => ( _optionalChain([patcher, 'access', _41 => _41.cacheStore, 'optionalAccess', _42 => _42.options, 'optionalAccess', _43 => _43.path])));
|
|
2113
|
+
if (!cachePath) {
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
try {
|
|
2117
|
+
await _promises.rm.call(void 0, cachePath, { force: true });
|
|
2118
|
+
} catch (error) {
|
|
2119
|
+
const err = error;
|
|
2120
|
+
if (_optionalChain([err, 'optionalAccess', _44 => _44.code]) === "ENOENT") {
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2123
|
+
_logger.logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
1918
2126
|
function getCompilerContext(opts) {
|
|
1919
2127
|
const ctx = _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
|
|
1920
2128
|
opts,
|
|
@@ -1923,8 +2131,8 @@ function getCompilerContext(opts) {
|
|
|
1923
2131
|
);
|
|
1924
2132
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
1925
2133
|
applyLoggerLevel(ctx.logLevel);
|
|
1926
|
-
const twPatcher =
|
|
1927
|
-
if (_optionalChain([twPatcher, 'access',
|
|
2134
|
+
const twPatcher = _chunkGGD75A34js.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
2135
|
+
if (_optionalChain([twPatcher, 'access', _45 => _45.packageInfo, 'optionalAccess', _46 => _46.version])) {
|
|
1928
2136
|
_logger.logger.success(`\u5F53\u524D\u4F7F\u7528 ${_logger.pc.cyanBright("Tailwind CSS")} \u7248\u672C\u4E3A: ${_logger.pc.underline(_logger.pc.bold(_logger.pc.green(twPatcher.packageInfo.version)))}`);
|
|
1929
2137
|
} else {
|
|
1930
2138
|
_logger.logger.warn(`${_logger.pc.cyanBright("Tailwind CSS")} \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u7248\u672C\u68C0\u6D4B\u4E0E\u8865\u4E01\u5E94\u7528\u3002`);
|
|
@@ -1945,6 +2153,22 @@ function getCompilerContext(opts) {
|
|
|
1945
2153
|
ctx.templateHandler = templateHandler;
|
|
1946
2154
|
ctx.cache = initializeCache(ctx.cache);
|
|
1947
2155
|
ctx.twPatcher = twPatcher;
|
|
2156
|
+
const refreshTailwindcssPatcher = async (options) => {
|
|
2157
|
+
const previousPatcher = ctx.twPatcher;
|
|
2158
|
+
if (_optionalChain([options, 'optionalAccess', _47 => _47.clearCache]) !== false) {
|
|
2159
|
+
await clearTailwindcssPatcherCache(previousPatcher);
|
|
2160
|
+
}
|
|
2161
|
+
invalidateRuntimeClassSet(previousPatcher);
|
|
2162
|
+
const nextPatcher = _chunkGGD75A34js.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
2163
|
+
Object.assign(previousPatcher, nextPatcher);
|
|
2164
|
+
ctx.twPatcher = previousPatcher;
|
|
2165
|
+
return previousPatcher;
|
|
2166
|
+
};
|
|
2167
|
+
ctx.refreshTailwindcssPatcher = refreshTailwindcssPatcher;
|
|
2168
|
+
Object.defineProperty(ctx.twPatcher, refreshTailwindcssPatcherSymbol, {
|
|
2169
|
+
value: refreshTailwindcssPatcher,
|
|
2170
|
+
configurable: true
|
|
2171
|
+
});
|
|
1948
2172
|
return ctx;
|
|
1949
2173
|
}
|
|
1950
2174
|
|
|
@@ -1956,4 +2180,8 @@ function getCompilerContext(opts) {
|
|
|
1956
2180
|
|
|
1957
2181
|
|
|
1958
2182
|
|
|
1959
|
-
|
|
2183
|
+
|
|
2184
|
+
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
exports.createDebug = createDebug; exports.createTailwindPatchPromise = createTailwindPatchPromise; exports.refreshTailwindRuntimeState = refreshTailwindRuntimeState; exports.collectRuntimeClassSet = collectRuntimeClassSet; exports.toCustomAttributesEntities = toCustomAttributesEntities; exports.pluginName = pluginName; exports.vitePluginName = vitePluginName; exports.WEAPP_TW_REQUIRED_NODE_VERSION = WEAPP_TW_REQUIRED_NODE_VERSION; exports.createAttributeMatcher = createAttributeMatcher; exports.generateCode = generateCode; exports.getCompilerContext = getCompilerContext;
|