weapp-tailwindcss 4.8.1 → 4.8.3
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-MYNTKRVT.js → chunk-26ZRX6OH.js} +33 -25
- package/dist/{chunk-KMCQEHJM.js → chunk-2ZEOKKVA.js} +159 -41
- package/dist/{chunk-YW5YW5D4.mjs → chunk-7KTLLGAG.mjs} +164 -46
- package/dist/{chunk-MSFAEBH6.mjs → chunk-E3GZQTOH.mjs} +17 -9
- package/dist/{chunk-U7OMIV3S.js → chunk-H34KPZQW.js} +2 -2
- package/dist/{chunk-YHZB3KHY.mjs → chunk-KSHK56CW.mjs} +1 -1
- package/dist/{chunk-QNGB574L.js → chunk-N2ZUYGKA.js} +6 -6
- package/dist/{chunk-3RXY3OXF.mjs → chunk-NLLCK6RM.mjs} +1 -1
- package/dist/{chunk-X7QD7NUX.js → chunk-PLV4QGF4.js} +76 -28
- package/dist/{chunk-BTPDRSHI.mjs → chunk-QGH4JZRW.mjs} +1 -1
- package/dist/{chunk-NQTLEEK5.js → chunk-UCA2DMVN.js} +5 -5
- package/dist/{chunk-XGRBCPBI.js → chunk-UJIUFWXE.js} +1 -1
- package/dist/{chunk-DHHTSM3K.mjs → chunk-UUVGNRUM.mjs} +1 -1
- package/dist/{chunk-5XFZ2DUB.js → chunk-W5Z3I3S2.js} +21 -21
- package/dist/{chunk-TTCMOWCO.mjs → chunk-WTOLVORM.mjs} +74 -26
- package/dist/cli.js +14 -14
- package/dist/cli.mjs +5 -5
- package/dist/core.js +9 -9
- package/dist/core.mjs +3 -3
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +4 -4
- package/dist/index.js +9 -9
- package/dist/index.mjs +7 -7
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +2 -2
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +6 -6
- package/dist/vite.mjs +4 -4
- package/dist/weapp-tw-runtime-loader.js +66 -2
- package/dist/webpack.js +7 -7
- package/dist/webpack.mjs +5 -5
- package/dist/webpack4.js +34 -27
- package/dist/webpack4.mjs +17 -10
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkUCA2DMVNjs = require('./chunk-UCA2DMVN.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkH34KPZQWjs = require('./chunk-H34KPZQW.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
@@ -18,7 +18,7 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkPLV4QGF4js = require('./chunk-PLV4QGF4.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -27,11 +27,11 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
|
27
27
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
28
28
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
29
29
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
30
|
-
var debug =
|
|
31
|
-
var weappTailwindcssPackageDir =
|
|
30
|
+
var debug = _chunkPLV4QGF4js.createDebug.call(void 0, );
|
|
31
|
+
var weappTailwindcssPackageDir = _chunkH34KPZQWjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
32
32
|
var UnifiedWebpackPluginV5 = class {
|
|
33
33
|
constructor(options = {}) {
|
|
34
|
-
this.options =
|
|
34
|
+
this.options = _chunkPLV4QGF4js.getCompilerContext.call(void 0, options);
|
|
35
35
|
this.userSpecifiedRewriteCssImports = Object.prototype.hasOwnProperty.call(options, "rewriteCssImports");
|
|
36
36
|
this.appType = this.options.appType;
|
|
37
37
|
}
|
|
@@ -56,49 +56,57 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
56
56
|
}
|
|
57
57
|
const shouldRewriteCssImports = this.options.rewriteCssImports !== false && (this.userSpecifiedRewriteCssImports || (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4);
|
|
58
58
|
if (shouldRewriteCssImports) {
|
|
59
|
-
|
|
59
|
+
_chunkUCA2DMVNjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
|
|
60
60
|
pkgDir: weappTailwindcssPackageDir,
|
|
61
61
|
enabled: true
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
const runtimeState = {
|
|
65
65
|
twPatcher: initialTwPatcher,
|
|
66
|
-
patchPromise:
|
|
66
|
+
patchPromise: _chunkPLV4QGF4js.createTailwindPatchPromise.call(void 0, initialTwPatcher),
|
|
67
67
|
refreshTailwindcssPatcher
|
|
68
68
|
};
|
|
69
69
|
const refreshRuntimeState = async (force) => {
|
|
70
|
-
await
|
|
70
|
+
await _chunkPLV4QGF4js.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
71
71
|
};
|
|
72
72
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
73
73
|
const { ConcatSource } = sources;
|
|
74
74
|
async function getClassSetInLoader() {
|
|
75
75
|
await refreshRuntimeState(true);
|
|
76
76
|
await runtimeState.patchPromise;
|
|
77
|
-
await
|
|
77
|
+
await _chunkPLV4QGF4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
78
78
|
}
|
|
79
79
|
onLoad();
|
|
80
80
|
const loader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js")));
|
|
81
81
|
const isExisted = _fs2.default.existsSync(loader);
|
|
82
|
-
const
|
|
82
|
+
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
83
|
+
pkgDir: weappTailwindcssPackageDir
|
|
84
|
+
} : void 0;
|
|
85
|
+
const runtimeLoaderOptions = {
|
|
86
|
+
getClassSet: getClassSetInLoader,
|
|
87
|
+
rewriteCssImports: runtimeLoaderRewriteOptions
|
|
88
|
+
};
|
|
89
|
+
const createRuntimeLoaderEntry = () => ({
|
|
83
90
|
loader,
|
|
84
|
-
options:
|
|
85
|
-
getClassSet: getClassSetInLoader
|
|
86
|
-
},
|
|
91
|
+
options: runtimeLoaderOptions,
|
|
87
92
|
ident: null,
|
|
88
93
|
type: null
|
|
89
|
-
};
|
|
90
|
-
compiler.hooks.compilation.tap(
|
|
91
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
94
|
+
});
|
|
95
|
+
compiler.hooks.compilation.tap(_chunkPLV4QGF4js.pluginName, (compilation) => {
|
|
96
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunkPLV4QGF4js.pluginName, (_loaderContext, module) => {
|
|
92
97
|
if (isExisted) {
|
|
93
98
|
const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
|
|
99
|
+
const runtimeLoaderEntry = createRuntimeLoaderEntry();
|
|
94
100
|
if (idx > -1) {
|
|
95
|
-
module.loaders.
|
|
101
|
+
module.loaders.splice(idx + 1, 0, runtimeLoaderEntry);
|
|
102
|
+
} else {
|
|
103
|
+
module.loaders.push(runtimeLoaderEntry);
|
|
96
104
|
}
|
|
97
105
|
}
|
|
98
106
|
});
|
|
99
107
|
compilation.hooks.processAssets.tapPromise(
|
|
100
108
|
{
|
|
101
|
-
name:
|
|
109
|
+
name: _chunkPLV4QGF4js.pluginName,
|
|
102
110
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
103
111
|
},
|
|
104
112
|
async (assets) => {
|
|
@@ -116,13 +124,13 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
116
124
|
const jsAssets = /* @__PURE__ */ new Map();
|
|
117
125
|
for (const [file] of entries) {
|
|
118
126
|
if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
|
|
119
|
-
const absolute =
|
|
127
|
+
const absolute = _chunkH34KPZQWjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
120
128
|
jsAssets.set(absolute, file);
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
const moduleGraphOptions = {
|
|
124
132
|
resolve(specifier, importer) {
|
|
125
|
-
return
|
|
133
|
+
return _chunkH34KPZQWjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
126
134
|
},
|
|
127
135
|
load: (id) => {
|
|
128
136
|
const assetName = jsAssets.get(id);
|
|
@@ -167,7 +175,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
167
175
|
const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
|
|
168
176
|
await refreshRuntimeState(true);
|
|
169
177
|
await runtimeState.patchPromise;
|
|
170
|
-
const runtimeSet = await
|
|
178
|
+
const runtimeSet = await _chunkPLV4QGF4js.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
171
179
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
172
180
|
const tasks = [];
|
|
173
181
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -204,12 +212,12 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
204
212
|
const jsTaskFactories = [];
|
|
205
213
|
if (Array.isArray(groupedEntries.js)) {
|
|
206
214
|
for (const [file] of groupedEntries.js) {
|
|
207
|
-
const cacheKey =
|
|
215
|
+
const cacheKey = _chunkUCA2DMVNjs.getCacheKey.call(void 0, file);
|
|
208
216
|
const asset = compilation.getAsset(file);
|
|
209
217
|
if (!asset) {
|
|
210
218
|
continue;
|
|
211
219
|
}
|
|
212
|
-
const absoluteFile =
|
|
220
|
+
const absoluteFile = _chunkH34KPZQWjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
213
221
|
const initialSource = asset.source.source();
|
|
214
222
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
215
223
|
jsTaskFactories.push(async () => {
|
|
@@ -284,7 +292,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
284
292
|
);
|
|
285
293
|
}
|
|
286
294
|
}
|
|
287
|
-
|
|
295
|
+
_chunkH34KPZQWjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
288
296
|
await Promise.all(tasks);
|
|
289
297
|
debug("end");
|
|
290
298
|
onEnd();
|
|
@@ -3,20 +3,88 @@
|
|
|
3
3
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkUJIUFWXEjs = require('./chunk-UJIUFWXE.js');
|
|
7
7
|
|
|
8
8
|
// src/context/tailwindcss.ts
|
|
9
|
+
var _fs = require('fs');
|
|
9
10
|
var _module = require('module');
|
|
10
11
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
11
12
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
12
13
|
var _url = require('url');
|
|
13
14
|
var _logger = require('@weapp-tailwindcss/logger');
|
|
14
15
|
|
|
16
|
+
// src/context/workspace.ts
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
|
|
20
|
+
"node_modules",
|
|
21
|
+
".git",
|
|
22
|
+
".hg",
|
|
23
|
+
".svn",
|
|
24
|
+
".turbo",
|
|
25
|
+
".output",
|
|
26
|
+
".next",
|
|
27
|
+
"dist",
|
|
28
|
+
"build"
|
|
29
|
+
]);
|
|
30
|
+
function findWorkspaceRoot(startDir) {
|
|
31
|
+
if (!startDir) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
let current = _path2.default.resolve(startDir);
|
|
35
|
+
while (true) {
|
|
36
|
+
const workspaceFile = _path2.default.join(current, "pnpm-workspace.yaml");
|
|
37
|
+
if (_fs.existsSync.call(void 0, workspaceFile)) {
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
const parent = _path2.default.dirname(current);
|
|
41
|
+
if (parent === current) {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
current = parent;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function findWorkspacePackageDir(rootDir, packageName) {
|
|
48
|
+
const visited = /* @__PURE__ */ new Set();
|
|
49
|
+
const queue = [_path2.default.resolve(rootDir)];
|
|
50
|
+
while (queue.length > 0) {
|
|
51
|
+
const current = queue.shift();
|
|
52
|
+
const normalized = _path2.default.normalize(current);
|
|
53
|
+
if (visited.has(normalized)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
visited.add(normalized);
|
|
57
|
+
try {
|
|
58
|
+
const pkgPath = _path2.default.join(normalized, "package.json");
|
|
59
|
+
if (_fs.existsSync.call(void 0, pkgPath)) {
|
|
60
|
+
const pkg = JSON.parse(_fs.readFileSync.call(void 0, pkgPath, "utf8"));
|
|
61
|
+
if (_optionalChain([pkg, 'optionalAccess', _ => _.name]) === packageName) {
|
|
62
|
+
return normalized;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
}
|
|
67
|
+
let entries;
|
|
68
|
+
try {
|
|
69
|
+
entries = _fs.readdirSync.call(void 0, normalized, { withFileTypes: true });
|
|
70
|
+
} catch (e2) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || _optionalChain([entry, 'access', _2 => _2.isSymbolicLink, 'optionalCall', _3 => _3()])) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
queue.push(_path2.default.join(normalized, entry.name));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
15
83
|
// src/tailwindcss/index.ts
|
|
16
84
|
var _localpkg = require('local-pkg');
|
|
17
85
|
|
|
18
86
|
// src/tailwindcss/patcher.ts
|
|
19
|
-
|
|
87
|
+
|
|
20
88
|
|
|
21
89
|
|
|
22
90
|
|
|
@@ -46,9 +114,9 @@ function resolveModuleFromPaths(specifier, paths) {
|
|
|
46
114
|
return void 0;
|
|
47
115
|
}
|
|
48
116
|
try {
|
|
49
|
-
const req = _module.createRequire.call(void 0,
|
|
117
|
+
const req = _module.createRequire.call(void 0, _chunkUJIUFWXEjs.importMetaUrl);
|
|
50
118
|
return req.resolve(specifier, { paths });
|
|
51
|
-
} catch (
|
|
119
|
+
} catch (e3) {
|
|
52
120
|
return void 0;
|
|
53
121
|
}
|
|
54
122
|
}
|
|
@@ -163,11 +231,11 @@ function createDefaultResolvePaths(basedir) {
|
|
|
163
231
|
const cwd = _process2.default.cwd();
|
|
164
232
|
appendNodeModules(paths, cwd);
|
|
165
233
|
try {
|
|
166
|
-
const modulePath = _url.fileURLToPath.call(void 0,
|
|
234
|
+
const modulePath = _url.fileURLToPath.call(void 0, _chunkUJIUFWXEjs.importMetaUrl);
|
|
167
235
|
const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
|
|
168
236
|
paths.add(candidate);
|
|
169
|
-
} catch (
|
|
170
|
-
paths.add(
|
|
237
|
+
} catch (e4) {
|
|
238
|
+
paths.add(_chunkUJIUFWXEjs.importMetaUrl);
|
|
171
239
|
}
|
|
172
240
|
if (paths.size === 0) {
|
|
173
241
|
fallbackCandidates = fallbackCandidates.filter(Boolean);
|
|
@@ -205,28 +273,28 @@ function normalizeTailwindcssPatcherOptions(options) {
|
|
|
205
273
|
if (cache !== void 0) {
|
|
206
274
|
normalized.cache = cache;
|
|
207
275
|
}
|
|
208
|
-
if (_optionalChain([patch, 'optionalAccess',
|
|
276
|
+
if (_optionalChain([patch, 'optionalAccess', _4 => _4.overwrite]) !== void 0) {
|
|
209
277
|
normalized.overwrite = patch.overwrite;
|
|
210
278
|
}
|
|
211
|
-
if (_optionalChain([patch, 'optionalAccess',
|
|
279
|
+
if (_optionalChain([patch, 'optionalAccess', _5 => _5.filter])) {
|
|
212
280
|
normalized.filter = patch.filter;
|
|
213
281
|
}
|
|
214
|
-
const extendLengthUnits = normalizeExtendLengthUnits(_optionalChain([patch, 'optionalAccess',
|
|
215
|
-
const exposeContext = _optionalChain([patch, 'optionalAccess',
|
|
282
|
+
const extendLengthUnits = normalizeExtendLengthUnits(_optionalChain([patch, 'optionalAccess', _6 => _6.applyPatches, 'optionalAccess', _7 => _7.extendLengthUnits]));
|
|
283
|
+
const exposeContext = _optionalChain([patch, 'optionalAccess', _8 => _8.applyPatches, 'optionalAccess', _9 => _9.exportContext]);
|
|
216
284
|
if (extendLengthUnits !== void 0 || exposeContext !== void 0) {
|
|
217
285
|
normalized.features = {
|
|
218
286
|
exposeContext,
|
|
219
287
|
extendLengthUnits
|
|
220
288
|
};
|
|
221
289
|
}
|
|
222
|
-
const cwd = _nullishCoalesce(_optionalChain([patch, 'optionalAccess',
|
|
290
|
+
const cwd = _nullishCoalesce(_optionalChain([patch, 'optionalAccess', _10 => _10.cwd]), () => ( _optionalChain([patch, 'optionalAccess', _11 => _11.basedir])));
|
|
223
291
|
if (cwd) {
|
|
224
292
|
normalized.cwd = cwd;
|
|
225
293
|
}
|
|
226
|
-
const tailwindOptions = _optionalChain([patch, 'optionalAccess',
|
|
227
|
-
const legacyResolve = _optionalChain([patch, 'optionalAccess',
|
|
294
|
+
const tailwindOptions = _optionalChain([patch, 'optionalAccess', _12 => _12.tailwindcss]) ? { ...patch.tailwindcss } : void 0;
|
|
295
|
+
const legacyResolve = _optionalChain([patch, 'optionalAccess', _13 => _13.resolve]);
|
|
228
296
|
let nextTailwindOptions = tailwindOptions;
|
|
229
|
-
if (_optionalChain([nextTailwindOptions, 'optionalAccess',
|
|
297
|
+
if (_optionalChain([nextTailwindOptions, 'optionalAccess', _14 => _14.version]) === 2 && !nextTailwindOptions.packageName) {
|
|
230
298
|
nextTailwindOptions = {
|
|
231
299
|
...nextTailwindOptions,
|
|
232
300
|
packageName: "@tailwindcss/postcss7-compat",
|
|
@@ -237,7 +305,7 @@ function normalizeTailwindcssPatcherOptions(options) {
|
|
|
237
305
|
}
|
|
238
306
|
}
|
|
239
307
|
if (nextTailwindOptions || legacyResolve) {
|
|
240
|
-
const resolveOptions = _optionalChain([nextTailwindOptions, 'optionalAccess',
|
|
308
|
+
const resolveOptions = _optionalChain([nextTailwindOptions, 'optionalAccess', _15 => _15.resolve]);
|
|
241
309
|
const mergedResolve = legacyResolve || resolveOptions ? {
|
|
242
310
|
..._nullishCoalesce(resolveOptions, () => ( {})),
|
|
243
311
|
..._nullishCoalesce(legacyResolve, () => ( {}))
|
|
@@ -331,7 +399,7 @@ function createTailwindcssPatcher(options) {
|
|
|
331
399
|
if (typeof resolvedOptions.tailwind.postcssPlugin === "string") {
|
|
332
400
|
const resolvedPlugin = resolveModuleFromPaths(
|
|
333
401
|
resolvedOptions.tailwind.postcssPlugin,
|
|
334
|
-
_nullishCoalesce(_optionalChain([resolvedOptions, 'access',
|
|
402
|
+
_nullishCoalesce(_optionalChain([resolvedOptions, 'access', _16 => _16.tailwind, 'access', _17 => _17.resolve, 'optionalAccess', _18 => _18.paths]), () => ( resolvePaths))
|
|
335
403
|
);
|
|
336
404
|
if (resolvedPlugin) {
|
|
337
405
|
resolvedOptions.tailwind.postcssPlugin = resolvedPlugin;
|
|
@@ -341,7 +409,7 @@ function createTailwindcssPatcher(options) {
|
|
|
341
409
|
if (resolvedOptions.tailwind.cwd) {
|
|
342
410
|
searchRoots.add(resolvedOptions.tailwind.cwd);
|
|
343
411
|
}
|
|
344
|
-
for (const resolvePath of _nullishCoalesce(_optionalChain([resolvedOptions, 'access',
|
|
412
|
+
for (const resolvePath of _nullishCoalesce(_optionalChain([resolvedOptions, 'access', _19 => _19.tailwind, 'access', _20 => _20.resolve, 'optionalAccess', _21 => _21.paths]), () => ( []))) {
|
|
345
413
|
const parentDir = _path2.default.dirname(resolvePath);
|
|
346
414
|
searchRoots.add(parentDir);
|
|
347
415
|
}
|
|
@@ -366,7 +434,7 @@ function createTailwindcssPatcher(options) {
|
|
|
366
434
|
try {
|
|
367
435
|
return new (0, _tailwindcsspatch.TailwindcssPatcher)(resolvedOptions);
|
|
368
436
|
} catch (error) {
|
|
369
|
-
const searchPaths = _optionalChain([resolvedOptions, 'access',
|
|
437
|
+
const searchPaths = _optionalChain([resolvedOptions, 'access', _22 => _22.tailwind, 'optionalAccess', _23 => _23.resolve, 'optionalAccess', _24 => _24.paths]);
|
|
370
438
|
if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
|
|
371
439
|
if (!hasLoggedMissingTailwind) {
|
|
372
440
|
_logger.logger.warn("Tailwind CSS \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7 Tailwind \u76F8\u5173\u8865\u4E01\u3002\u82E5\u9700\u4F7F\u7528 Tailwind \u80FD\u529B\uFF0C\u8BF7\u5B89\u88C5 tailwindcss\u3002");
|
|
@@ -375,7 +443,7 @@ function createTailwindcssPatcher(options) {
|
|
|
375
443
|
return createFallbackTailwindcssPatcher();
|
|
376
444
|
}
|
|
377
445
|
if (error instanceof Error && /unable to locate tailwind css package/i.test(error.message)) {
|
|
378
|
-
_logger.logger.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', _optionalChain([resolvedOptions, 'access',
|
|
446
|
+
_logger.logger.error('\u65E0\u6CD5\u5B9A\u4F4D Tailwind CSS \u5305 "%s"\uFF0C\u5DF2\u5C1D\u8BD5\u8DEF\u5F84: %O', _optionalChain([resolvedOptions, 'access', _25 => _25.tailwind, 'optionalAccess', _26 => _26.packageName]), searchPaths);
|
|
379
447
|
}
|
|
380
448
|
throw error;
|
|
381
449
|
}
|
|
@@ -435,7 +503,7 @@ function detectCallerBasedir() {
|
|
|
435
503
|
const lines = stack.split("\n");
|
|
436
504
|
for (const line of lines) {
|
|
437
505
|
const match = _nullishCoalesce(line.match(/\(([^)]+)\)/u), () => ( line.match(/at\s+(\S.*)$/u)));
|
|
438
|
-
const location = _optionalChain([match, 'optionalAccess',
|
|
506
|
+
const location = _optionalChain([match, 'optionalAccess', _27 => _27[1]]);
|
|
439
507
|
if (!location) {
|
|
440
508
|
continue;
|
|
441
509
|
}
|
|
@@ -443,7 +511,7 @@ function detectCallerBasedir() {
|
|
|
443
511
|
if (filePath.startsWith("file://")) {
|
|
444
512
|
try {
|
|
445
513
|
filePath = _url.fileURLToPath.call(void 0, filePath);
|
|
446
|
-
} catch (
|
|
514
|
+
} catch (e5) {
|
|
447
515
|
continue;
|
|
448
516
|
}
|
|
449
517
|
}
|
|
@@ -457,21 +525,21 @@ function detectCallerBasedir() {
|
|
|
457
525
|
}
|
|
458
526
|
try {
|
|
459
527
|
return _path2.default.dirname(resolvedPath);
|
|
460
|
-
} catch (
|
|
528
|
+
} catch (e6) {
|
|
461
529
|
continue;
|
|
462
530
|
}
|
|
463
531
|
}
|
|
464
532
|
return void 0;
|
|
465
533
|
}
|
|
466
|
-
function resolveTailwindcssBasedir(basedir) {
|
|
534
|
+
function resolveTailwindcssBasedir(basedir, fallback) {
|
|
467
535
|
const envBasedirResult = pickEnvBasedir();
|
|
468
|
-
const envBasedir = _optionalChain([envBasedirResult, 'optionalAccess',
|
|
469
|
-
const envBasedirKey = _optionalChain([envBasedirResult, 'optionalAccess',
|
|
536
|
+
const envBasedir = _optionalChain([envBasedirResult, 'optionalAccess', _28 => _28.value]);
|
|
537
|
+
const envBasedirKey = _optionalChain([envBasedirResult, 'optionalAccess', _29 => _29.key]);
|
|
470
538
|
const envBasedirIsGeneric = envBasedirKey ? GENERIC_ENV_BASEDIR_KEYS.has(envBasedirKey) : false;
|
|
471
539
|
const packageEnvBasedir = pickPackageEnvBasedir();
|
|
472
540
|
const shouldDetectCaller = !envBasedir || envBasedirIsGeneric;
|
|
473
541
|
const callerBasedir = shouldDetectCaller ? detectCallerBasedir() : void 0;
|
|
474
|
-
const anchor = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(envBasedir, () => ( packageEnvBasedir)), () => ( callerBasedir)), () => ( _process2.default.cwd()));
|
|
542
|
+
const anchor = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(envBasedir, () => ( packageEnvBasedir)), () => ( fallback)), () => ( callerBasedir)), () => ( _process2.default.cwd()));
|
|
475
543
|
if (_process2.default.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
476
544
|
_logger.logger.debug("resolveTailwindcssBasedir anchor %O", {
|
|
477
545
|
basedir,
|
|
@@ -479,6 +547,7 @@ function resolveTailwindcssBasedir(basedir) {
|
|
|
479
547
|
envBasedirKey,
|
|
480
548
|
envBasedirIsGeneric,
|
|
481
549
|
packageEnvBasedir,
|
|
550
|
+
fallback,
|
|
482
551
|
callerBasedir,
|
|
483
552
|
npm_package_json: _process2.default.env.npm_package_json,
|
|
484
553
|
cwd: _process2.default.cwd(),
|
|
@@ -494,6 +563,10 @@ function resolveTailwindcssBasedir(basedir) {
|
|
|
494
563
|
if (envBasedir && !envBasedirIsGeneric) {
|
|
495
564
|
return _path2.default.normalize(envBasedir);
|
|
496
565
|
}
|
|
566
|
+
if (fallback && fallback.trim().length > 0) {
|
|
567
|
+
const resolvedFallback = _path2.default.isAbsolute(fallback) ? fallback : _path2.default.resolve(anchor, fallback);
|
|
568
|
+
return _path2.default.normalize(resolvedFallback);
|
|
569
|
+
}
|
|
497
570
|
if (packageEnvBasedir) {
|
|
498
571
|
return _path2.default.normalize(packageEnvBasedir);
|
|
499
572
|
}
|
|
@@ -504,9 +577,6 @@ function resolveTailwindcssBasedir(basedir) {
|
|
|
504
577
|
return normalizedCaller;
|
|
505
578
|
}
|
|
506
579
|
}
|
|
507
|
-
if (envBasedir) {
|
|
508
|
-
return _path2.default.normalize(envBasedir);
|
|
509
|
-
}
|
|
510
580
|
const packageName = _process2.default.env.PNPM_PACKAGE_NAME;
|
|
511
581
|
if (packageName) {
|
|
512
582
|
try {
|
|
@@ -516,14 +586,61 @@ function resolveTailwindcssBasedir(basedir) {
|
|
|
516
586
|
_logger.logger.debug("package basedir resolved from PNPM_PACKAGE_NAME: %s", packageJsonPath);
|
|
517
587
|
}
|
|
518
588
|
return _path2.default.normalize(_path2.default.dirname(packageJsonPath));
|
|
519
|
-
} catch (
|
|
589
|
+
} catch (e7) {
|
|
520
590
|
if (_process2.default.env.WEAPP_TW_DEBUG_STACK === "1") {
|
|
521
591
|
_logger.logger.debug("failed to resolve package json for %s", packageName);
|
|
522
592
|
}
|
|
593
|
+
const workspaceRoot = findWorkspaceRoot(anchor);
|
|
594
|
+
if (workspaceRoot) {
|
|
595
|
+
const packageDir = findWorkspacePackageDir(workspaceRoot, packageName);
|
|
596
|
+
if (packageDir) {
|
|
597
|
+
return packageDir;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
523
600
|
}
|
|
524
601
|
}
|
|
602
|
+
if (envBasedir) {
|
|
603
|
+
return _path2.default.normalize(envBasedir);
|
|
604
|
+
}
|
|
525
605
|
return _path2.default.normalize(_process2.default.cwd());
|
|
526
606
|
}
|
|
607
|
+
function findNearestPackageRootFromDir(startDir) {
|
|
608
|
+
if (!startDir) {
|
|
609
|
+
return void 0;
|
|
610
|
+
}
|
|
611
|
+
let current = _path2.default.resolve(startDir);
|
|
612
|
+
while (true) {
|
|
613
|
+
const pkgPath = _path2.default.join(current, "package.json");
|
|
614
|
+
if (_fs.existsSync.call(void 0, pkgPath)) {
|
|
615
|
+
return current;
|
|
616
|
+
}
|
|
617
|
+
const parent = _path2.default.dirname(current);
|
|
618
|
+
if (parent === current) {
|
|
619
|
+
return void 0;
|
|
620
|
+
}
|
|
621
|
+
current = parent;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function guessBasedirFromEntries(entries) {
|
|
625
|
+
if (!entries) {
|
|
626
|
+
return void 0;
|
|
627
|
+
}
|
|
628
|
+
for (const entry of entries) {
|
|
629
|
+
if (typeof entry !== "string") {
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
const trimmed = entry.trim();
|
|
633
|
+
if (!trimmed || !_path2.default.isAbsolute(trimmed)) {
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
const entryDir = _path2.default.dirname(trimmed);
|
|
637
|
+
const resolved = _nullishCoalesce(findNearestPackageRootFromDir(entryDir), () => ( entryDir));
|
|
638
|
+
if (resolved) {
|
|
639
|
+
return resolved;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return void 0;
|
|
643
|
+
}
|
|
527
644
|
function normalizeCssEntries(entries, anchor) {
|
|
528
645
|
if (!entries || entries.length === 0) {
|
|
529
646
|
return void 0;
|
|
@@ -622,7 +739,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
622
739
|
cssEntries
|
|
623
740
|
}
|
|
624
741
|
};
|
|
625
|
-
if (_optionalChain([cssEntries, 'optionalAccess',
|
|
742
|
+
if (_optionalChain([cssEntries, 'optionalAccess', _30 => _30.length]) && (tailwindcss == null || tailwindcss.version == null)) {
|
|
626
743
|
defaultTailwindcssConfig.version = 4;
|
|
627
744
|
}
|
|
628
745
|
const mergedTailwindOptions = _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
|
|
@@ -636,7 +753,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
636
753
|
};
|
|
637
754
|
} else {
|
|
638
755
|
mergedTailwindOptions.v4.base = baseDir;
|
|
639
|
-
if (_optionalChain([cssEntries, 'optionalAccess',
|
|
756
|
+
if (_optionalChain([cssEntries, 'optionalAccess', _31 => _31.length])) {
|
|
640
757
|
mergedTailwindOptions.v4.cssEntries = cssEntries;
|
|
641
758
|
} else if (!mergedTailwindOptions.v4.cssEntries) {
|
|
642
759
|
mergedTailwindOptions.v4.cssEntries = [];
|
|
@@ -661,18 +778,18 @@ function createMultiTailwindcssPatcher(patchers) {
|
|
|
661
778
|
}
|
|
662
779
|
const [first] = patchers;
|
|
663
780
|
const multiPatcher = {
|
|
664
|
-
packageInfo: _optionalChain([first, 'optionalAccess',
|
|
665
|
-
majorVersion: _optionalChain([first, 'optionalAccess',
|
|
666
|
-
options: _optionalChain([first, 'optionalAccess',
|
|
781
|
+
packageInfo: _optionalChain([first, 'optionalAccess', _32 => _32.packageInfo]),
|
|
782
|
+
majorVersion: _optionalChain([first, 'optionalAccess', _33 => _33.majorVersion]),
|
|
783
|
+
options: _optionalChain([first, 'optionalAccess', _34 => _34.options]),
|
|
667
784
|
async patch() {
|
|
668
785
|
let exposeContext;
|
|
669
786
|
let extendLengthUnits;
|
|
670
787
|
for (const patcher of patchers) {
|
|
671
788
|
const result = await patcher.patch();
|
|
672
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
789
|
+
if (_optionalChain([result, 'optionalAccess', _35 => _35.exposeContext]) && exposeContext == null) {
|
|
673
790
|
exposeContext = result.exposeContext;
|
|
674
791
|
}
|
|
675
|
-
if (_optionalChain([result, 'optionalAccess',
|
|
792
|
+
if (_optionalChain([result, 'optionalAccess', _36 => _36.extendLengthUnits]) && extendLengthUnits == null) {
|
|
676
793
|
extendLengthUnits = result.extendLengthUnits;
|
|
677
794
|
}
|
|
678
795
|
}
|
|
@@ -728,7 +845,7 @@ function createMultiTailwindcssPatcher(patchers) {
|
|
|
728
845
|
multiPatcher.getClassSetSync = () => {
|
|
729
846
|
const aggregated = /* @__PURE__ */ new Set();
|
|
730
847
|
for (const patcher of patchers) {
|
|
731
|
-
const current = _optionalChain([patcher, 'access',
|
|
848
|
+
const current = _optionalChain([patcher, 'access', _37 => _37.getClassSetSync, 'optionalCall', _38 => _38()]);
|
|
732
849
|
if (!current) {
|
|
733
850
|
continue;
|
|
734
851
|
}
|
|
@@ -761,7 +878,8 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
761
878
|
cssEntries: rawCssEntries,
|
|
762
879
|
appType
|
|
763
880
|
} = ctx;
|
|
764
|
-
const
|
|
881
|
+
const absoluteCssEntryBasedir = guessBasedirFromEntries(rawCssEntries);
|
|
882
|
+
const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir, absoluteCssEntryBasedir);
|
|
765
883
|
ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
|
|
766
884
|
_logger.logger.debug("tailwindcss basedir resolved: %s", resolvedTailwindcssBasedir);
|
|
767
885
|
const normalizedCssEntries = normalizeCssEntries(rawCssEntries, resolvedTailwindcssBasedir);
|
|
@@ -779,7 +897,7 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
779
897
|
if (multiPatcher) {
|
|
780
898
|
return multiPatcher;
|
|
781
899
|
}
|
|
782
|
-
if (_optionalChain([groupedCssEntries, 'optionalAccess',
|
|
900
|
+
if (_optionalChain([groupedCssEntries, 'optionalAccess', _39 => _39.size]) === 1) {
|
|
783
901
|
const firstGroup = groupedCssEntries.entries().next().value;
|
|
784
902
|
if (firstGroup) {
|
|
785
903
|
const [baseDir, entries] = firstGroup;
|