weapp-tailwindcss 4.4.0 → 4.5.0-alpha.0
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-34T2BFTJ.mjs +59 -0
- package/dist/{chunk-D25XJJMP.mjs → chunk-3KKB4FSY.mjs} +341 -10
- package/dist/{chunk-D2AKCBDU.mjs → chunk-6L7B4COX.mjs} +75 -2
- package/dist/{chunk-QXCC745G.js → chunk-AMP5MSHS.js} +99 -28
- package/dist/{chunk-GQAB52GE.js → chunk-BMXULECQ.js} +344 -13
- package/dist/{chunk-FBGUUXQV.mjs → chunk-FWIGQ4RY.mjs} +1 -1
- package/dist/{chunk-NDHL3P32.mjs → chunk-JLKUUNWL.mjs} +156 -55
- package/dist/{chunk-RBRSMHFS.js → chunk-NHB7NFQC.js} +1 -1
- package/dist/{chunk-VN2BU7ON.js → chunk-RELKXSH6.js} +160 -59
- package/dist/{chunk-L3HOZDIV.mjs → chunk-RWW76EBW.mjs} +98 -27
- package/dist/chunk-V4SEPP3F.js +195 -0
- package/dist/chunk-WVKK6TBL.js +59 -0
- package/dist/cli.js +3 -3
- package/dist/cli.mjs +2 -2
- package/dist/core.js +3 -3
- package/dist/core.mjs +2 -2
- 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/escape.js +1 -1
- package/dist/escape.mjs +1 -1
- package/dist/gulp.js +4 -4
- package/dist/gulp.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -6
- package/dist/index.mjs +6 -5
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/types.d.mts +48 -2
- package/dist/types.d.ts +48 -2
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +5 -4
- package/dist/vite.mjs +4 -3
- package/dist/webpack.js +5 -4
- package/dist/webpack.mjs +4 -3
- package/dist/webpack4.js +99 -29
- package/dist/webpack4.mjs +97 -27
- package/package.json +5 -5
- package/dist/chunk-H2Y5VNOJ.js +0 -122
|
@@ -1,16 +1,20 @@
|
|
|
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(); } }
|
|
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
|
var _chunk6GP37C26js = require('./chunk-6GP37C26.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
var _chunkWVKK6TBLjs = require('./chunk-WVKK6TBL.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
7
11
|
var _chunk2NRTWL47js = require('./chunk-2NRTWL47.js');
|
|
8
12
|
|
|
9
13
|
|
|
10
14
|
var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
|
|
11
15
|
|
|
12
16
|
|
|
13
|
-
var
|
|
17
|
+
var _chunkBMXULECQjs = require('./chunk-BMXULECQ.js');
|
|
14
18
|
|
|
15
19
|
|
|
16
20
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -18,10 +22,11 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
|
18
22
|
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
19
23
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
20
24
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
25
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
21
26
|
var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
|
|
22
27
|
var UnifiedWebpackPluginV5 = class {
|
|
23
28
|
constructor(options = {}) {
|
|
24
|
-
this.options =
|
|
29
|
+
this.options = _chunkBMXULECQjs.getCompilerContext.call(void 0, options);
|
|
25
30
|
this.appType = this.options.appType;
|
|
26
31
|
}
|
|
27
32
|
apply(compiler) {
|
|
@@ -85,6 +90,59 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
const entries = Object.entries(assets);
|
|
93
|
+
const compilerOutputPath = _nullishCoalesce(_optionalChain([compilation, 'access', _ => _.compiler, 'optionalAccess', _2 => _2.outputPath]), () => ( compiler.outputPath));
|
|
94
|
+
const outputDir = compilerOutputPath ? _path2.default.resolve(compilerOutputPath) : _nullishCoalesce(_optionalChain([compilation, 'access', _3 => _3.outputOptions, 'optionalAccess', _4 => _4.path]), () => ( _process2.default.cwd()));
|
|
95
|
+
const jsAssets = /* @__PURE__ */ new Map();
|
|
96
|
+
for (const [file] of entries) {
|
|
97
|
+
if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
|
|
98
|
+
const absolute = _chunkWVKK6TBLjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
99
|
+
jsAssets.set(absolute, file);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const moduleGraphOptions = {
|
|
103
|
+
resolve(specifier, importer) {
|
|
104
|
+
return _chunkWVKK6TBLjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
105
|
+
},
|
|
106
|
+
load: (id) => {
|
|
107
|
+
const assetName = jsAssets.get(id);
|
|
108
|
+
if (!assetName) {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
const asset = compilation.getAsset(assetName);
|
|
112
|
+
if (!asset) {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
const source = asset.source.source();
|
|
116
|
+
return typeof source === "string" ? source : source.toString();
|
|
117
|
+
},
|
|
118
|
+
filter(id) {
|
|
119
|
+
return jsAssets.has(id);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const applyLinkedResults = (linked) => {
|
|
123
|
+
if (!linked) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
for (const [id, { code }] of Object.entries(linked)) {
|
|
127
|
+
const assetName = jsAssets.get(id);
|
|
128
|
+
if (!assetName) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const asset = compilation.getAsset(assetName);
|
|
132
|
+
if (!asset) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const previousSource = asset.source.source();
|
|
136
|
+
const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
|
|
137
|
+
if (previous === code) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const source = new ConcatSource(code);
|
|
141
|
+
compilation.updateAsset(assetName, source);
|
|
142
|
+
onUpdate(assetName, previous, code);
|
|
143
|
+
debug("js linked handle: %s", assetName);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
88
146
|
const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
|
|
89
147
|
const runtimeSet = await twPatcher.getClassSet();
|
|
90
148
|
setMangleRuntimeSet(runtimeSet);
|
|
@@ -122,32 +180,45 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
122
180
|
}
|
|
123
181
|
}
|
|
124
182
|
if (Array.isArray(groupedEntries.js)) {
|
|
125
|
-
for (const
|
|
126
|
-
const [file, originalSource] = element;
|
|
183
|
+
for (const [file] of groupedEntries.js) {
|
|
127
184
|
const cacheKey = _chunk6GP37C26js.getCacheKey.call(void 0, file);
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
185
|
+
const asset = compilation.getAsset(file);
|
|
186
|
+
if (!asset) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const absoluteFile = _chunkWVKK6TBLjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
190
|
+
const initialSource = asset.source.source();
|
|
191
|
+
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
192
|
+
await _chunk2NRTWL47js.processCachedTask.call(void 0, {
|
|
193
|
+
cache,
|
|
194
|
+
cacheKey,
|
|
195
|
+
rawSource: initialRawSource,
|
|
196
|
+
applyResult(source) {
|
|
197
|
+
compilation.updateAsset(file, source);
|
|
198
|
+
},
|
|
199
|
+
onCacheHit() {
|
|
200
|
+
debug("js cache hit: %s", file);
|
|
201
|
+
},
|
|
202
|
+
transform: async () => {
|
|
203
|
+
const currentAsset = compilation.getAsset(file);
|
|
204
|
+
const currentSourceValue = _optionalChain([currentAsset, 'optionalAccess', _5 => _5.source, 'access', _6 => _6.source, 'call', _7 => _7()]);
|
|
205
|
+
const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : _nullishCoalesce(_optionalChain([currentSourceValue, 'optionalAccess', _8 => _8.toString, 'call', _9 => _9()]), () => ( ""));
|
|
206
|
+
const { code, linked } = await jsHandler(currentSource, runtimeSet, {
|
|
207
|
+
filename: absoluteFile,
|
|
208
|
+
moduleGraph: moduleGraphOptions,
|
|
209
|
+
babelParserOptions: {
|
|
210
|
+
sourceFilename: absoluteFile
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
const source = new ConcatSource(code);
|
|
214
|
+
onUpdate(file, currentSource, code);
|
|
215
|
+
debug("js handle: %s", file);
|
|
216
|
+
applyLinkedResults(linked);
|
|
217
|
+
return {
|
|
218
|
+
result: source
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
151
222
|
}
|
|
152
223
|
}
|
|
153
224
|
if (Array.isArray(groupedEntries.css)) {
|
|
@@ -10,7 +10,7 @@ var _chunkFOSGDQZ7js = require('./chunk-FOSGDQZ7.js');
|
|
|
10
10
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkNHB7NFQCjs = require('./chunk-NHB7NFQC.js');
|
|
14
14
|
|
|
15
15
|
// src/context/index.ts
|
|
16
16
|
var _logger = require('@weapp-tailwindcss/logger');
|
|
@@ -20,10 +20,7 @@ var _mangle = require('@weapp-tailwindcss/mangle');
|
|
|
20
20
|
var _lrucache = require('lru-cache');
|
|
21
21
|
|
|
22
22
|
// src/cache/md5.ts
|
|
23
|
-
var
|
|
24
|
-
function md5Hash(data) {
|
|
25
|
-
return _crypto2.default.createHash("md5").update(data).digest("hex");
|
|
26
|
-
}
|
|
23
|
+
var _node = require('@weapp-tailwindcss/shared/node');
|
|
27
24
|
|
|
28
25
|
// src/cache/index.ts
|
|
29
26
|
function isProcessResult(value) {
|
|
@@ -57,7 +54,7 @@ function createCache(options) {
|
|
|
57
54
|
return instance.set(key, value);
|
|
58
55
|
},
|
|
59
56
|
computeHash(message) {
|
|
60
|
-
return
|
|
57
|
+
return _node.md5.call(void 0, message);
|
|
61
58
|
},
|
|
62
59
|
calcHashValueChanged(key, hash) {
|
|
63
60
|
const hit = hashMap.get(key);
|
|
@@ -398,6 +395,274 @@ var JsTokenUpdater = class {
|
|
|
398
395
|
}
|
|
399
396
|
};
|
|
400
397
|
|
|
398
|
+
// src/js/ModuleGraph.ts
|
|
399
|
+
var JsModuleGraph = class {
|
|
400
|
+
constructor(entry, graphOptions) {
|
|
401
|
+
this.modules = /* @__PURE__ */ new Map();
|
|
402
|
+
this.queue = [];
|
|
403
|
+
this.ignoredExportNames = /* @__PURE__ */ new Map();
|
|
404
|
+
this.resolve = graphOptions.resolve;
|
|
405
|
+
this.load = graphOptions.load;
|
|
406
|
+
this.filter = graphOptions.filter;
|
|
407
|
+
this.maxDepth = _nullishCoalesce(graphOptions.maxDepth, () => ( Number.POSITIVE_INFINITY));
|
|
408
|
+
const { moduleGraph: _moduleGraph, filename: _ignoredFilename, ...rest } = entry.handlerOptions;
|
|
409
|
+
this.baseOptions = {
|
|
410
|
+
...rest,
|
|
411
|
+
filename: entry.filename
|
|
412
|
+
};
|
|
413
|
+
this.parserOptions = entry.handlerOptions.babelParserOptions;
|
|
414
|
+
this.rootFilename = entry.filename;
|
|
415
|
+
this.modules.set(entry.filename, {
|
|
416
|
+
filename: entry.filename,
|
|
417
|
+
source: entry.source,
|
|
418
|
+
analysis: entry.analysis
|
|
419
|
+
});
|
|
420
|
+
this.queue.push({ filename: entry.filename, depth: 0 });
|
|
421
|
+
}
|
|
422
|
+
build() {
|
|
423
|
+
this.collectDependencies();
|
|
424
|
+
const linked = {};
|
|
425
|
+
for (const [filename, state] of this.modules) {
|
|
426
|
+
if (filename === this.rootFilename) {
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
const childOptions = {
|
|
430
|
+
...this.baseOptions,
|
|
431
|
+
filename
|
|
432
|
+
};
|
|
433
|
+
const ms = processUpdatedSource(state.source, childOptions, state.analysis);
|
|
434
|
+
const code = ms.toString();
|
|
435
|
+
if (code !== state.source) {
|
|
436
|
+
linked[filename] = { code };
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return linked;
|
|
440
|
+
}
|
|
441
|
+
addIgnoredExport(filename, exportName) {
|
|
442
|
+
if (!exportName) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
let pending = this.ignoredExportNames.get(filename);
|
|
446
|
+
if (!pending) {
|
|
447
|
+
pending = /* @__PURE__ */ new Set();
|
|
448
|
+
this.ignoredExportNames.set(filename, pending);
|
|
449
|
+
}
|
|
450
|
+
if (pending.has(exportName)) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
pending.add(exportName);
|
|
454
|
+
const existing = this.modules.get(filename);
|
|
455
|
+
if (existing) {
|
|
456
|
+
this.applyIgnoredExportsToAnalysis(filename, existing.analysis);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
registerIgnoredExportsFromTokens(resolved, tokens) {
|
|
460
|
+
for (const token of tokens) {
|
|
461
|
+
if (token.type === "ImportSpecifier") {
|
|
462
|
+
this.addIgnoredExport(resolved, token.imported);
|
|
463
|
+
} else if (token.type === "ImportDefaultSpecifier") {
|
|
464
|
+
this.addIgnoredExport(resolved, "default");
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
applyIgnoredExportsToAnalysis(filename, analysis) {
|
|
469
|
+
const pending = this.ignoredExportNames.get(filename);
|
|
470
|
+
if (!pending || pending.size === 0) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const names = new Set(pending);
|
|
474
|
+
pending.clear();
|
|
475
|
+
const propagate = [];
|
|
476
|
+
for (const exportPath of analysis.exportDeclarations) {
|
|
477
|
+
if (names.size === 0) {
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
if (exportPath.isExportDefaultDeclaration()) {
|
|
481
|
+
if (names.has("default")) {
|
|
482
|
+
analysis.walker.walkExportDefaultDeclaration(exportPath);
|
|
483
|
+
names.delete("default");
|
|
484
|
+
}
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (exportPath.isExportNamedDeclaration()) {
|
|
488
|
+
const source = _optionalChain([exportPath, 'access', _9 => _9.node, 'access', _10 => _10.source, 'optionalAccess', _11 => _11.value]);
|
|
489
|
+
if (typeof source === "string") {
|
|
490
|
+
for (const spec of exportPath.get("specifiers")) {
|
|
491
|
+
if (!spec.isExportSpecifier()) {
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
const exported = spec.get("exported");
|
|
495
|
+
let exportedName;
|
|
496
|
+
if (exported.isIdentifier()) {
|
|
497
|
+
exportedName = exported.node.name;
|
|
498
|
+
} else if (exported.isStringLiteral()) {
|
|
499
|
+
exportedName = exported.node.value;
|
|
500
|
+
}
|
|
501
|
+
if (!exportedName || !names.has(exportedName)) {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
const local = spec.get("local");
|
|
505
|
+
if (local.isIdentifier()) {
|
|
506
|
+
propagate.push({
|
|
507
|
+
specifier: source,
|
|
508
|
+
exportName: local.node.name
|
|
509
|
+
});
|
|
510
|
+
names.delete(exportedName);
|
|
511
|
+
} else if (local.isStringLiteral()) {
|
|
512
|
+
propagate.push({
|
|
513
|
+
specifier: source,
|
|
514
|
+
exportName: local.node.value
|
|
515
|
+
});
|
|
516
|
+
names.delete(exportedName);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
const declaration = exportPath.get("declaration");
|
|
522
|
+
if (declaration.isVariableDeclaration()) {
|
|
523
|
+
for (const decl of declaration.get("declarations")) {
|
|
524
|
+
const id = decl.get("id");
|
|
525
|
+
if (id.isIdentifier()) {
|
|
526
|
+
const exportName = id.node.name;
|
|
527
|
+
if (names.has(exportName)) {
|
|
528
|
+
analysis.walker.walkVariableDeclarator(decl);
|
|
529
|
+
names.delete(exportName);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
for (const spec of exportPath.get("specifiers")) {
|
|
535
|
+
if (!spec.isExportSpecifier()) {
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
const exported = spec.get("exported");
|
|
539
|
+
let exportedName;
|
|
540
|
+
if (exported.isIdentifier()) {
|
|
541
|
+
exportedName = exported.node.name;
|
|
542
|
+
} else if (exported.isStringLiteral()) {
|
|
543
|
+
exportedName = exported.node.value;
|
|
544
|
+
}
|
|
545
|
+
if (!exportedName || !names.has(exportedName)) {
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
const local = spec.get("local");
|
|
549
|
+
analysis.walker.walkNode(local);
|
|
550
|
+
names.delete(exportedName);
|
|
551
|
+
}
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
if (exportPath.isExportAllDeclaration()) {
|
|
555
|
+
const source = _optionalChain([exportPath, 'access', _12 => _12.node, 'access', _13 => _13.source, 'optionalAccess', _14 => _14.value]);
|
|
556
|
+
if (typeof source === "string") {
|
|
557
|
+
for (const exportName of names) {
|
|
558
|
+
propagate.push({
|
|
559
|
+
specifier: source,
|
|
560
|
+
exportName
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
names.clear();
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
for (const { specifier, exportName } of propagate) {
|
|
568
|
+
let resolved;
|
|
569
|
+
try {
|
|
570
|
+
resolved = this.resolve(specifier, filename);
|
|
571
|
+
} catch (e2) {
|
|
572
|
+
resolved = void 0;
|
|
573
|
+
}
|
|
574
|
+
if (!resolved) {
|
|
575
|
+
pending.add(exportName);
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
if (this.filter && !this.filter(resolved, specifier, filename)) {
|
|
579
|
+
pending.add(exportName);
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
this.addIgnoredExport(resolved, exportName);
|
|
583
|
+
}
|
|
584
|
+
for (const name of names) {
|
|
585
|
+
pending.add(name);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
collectDependencies() {
|
|
589
|
+
while (this.queue.length > 0) {
|
|
590
|
+
const { filename, depth } = this.queue.shift();
|
|
591
|
+
if (depth >= this.maxDepth) {
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
const state = this.modules.get(filename);
|
|
595
|
+
if (!state) {
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
const dependencySpecifiers = /* @__PURE__ */ new Map();
|
|
599
|
+
for (const token of state.analysis.walker.imports) {
|
|
600
|
+
if (!dependencySpecifiers.has(token.source)) {
|
|
601
|
+
dependencySpecifiers.set(token.source, []);
|
|
602
|
+
}
|
|
603
|
+
dependencySpecifiers.get(token.source).push(token);
|
|
604
|
+
}
|
|
605
|
+
for (const exportPath of state.analysis.exportDeclarations) {
|
|
606
|
+
if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
|
|
607
|
+
const source = _optionalChain([exportPath, 'access', _15 => _15.node, 'access', _16 => _16.source, 'optionalAccess', _17 => _17.value]);
|
|
608
|
+
if (typeof source === "string" && !dependencySpecifiers.has(source)) {
|
|
609
|
+
dependencySpecifiers.set(source, []);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
for (const [specifier, tokens] of dependencySpecifiers) {
|
|
614
|
+
let resolved;
|
|
615
|
+
try {
|
|
616
|
+
resolved = this.resolve(specifier, filename);
|
|
617
|
+
} catch (e3) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
if (!resolved) {
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
if (this.filter && !this.filter(resolved, specifier, filename)) {
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
if (tokens.length > 0) {
|
|
627
|
+
this.registerIgnoredExportsFromTokens(resolved, tokens);
|
|
628
|
+
}
|
|
629
|
+
if (this.modules.has(resolved)) {
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
let source;
|
|
633
|
+
try {
|
|
634
|
+
source = this.load(resolved);
|
|
635
|
+
} catch (e4) {
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (typeof source !== "string") {
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
let analysis;
|
|
642
|
+
try {
|
|
643
|
+
const ast = babelParse(source, {
|
|
644
|
+
...this.parserOptions,
|
|
645
|
+
sourceFilename: resolved
|
|
646
|
+
});
|
|
647
|
+
analysis = analyzeSource(ast, {
|
|
648
|
+
...this.baseOptions,
|
|
649
|
+
filename: resolved
|
|
650
|
+
});
|
|
651
|
+
this.applyIgnoredExportsToAnalysis(resolved, analysis);
|
|
652
|
+
} catch (e5) {
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
this.modules.set(resolved, {
|
|
656
|
+
filename: resolved,
|
|
657
|
+
source,
|
|
658
|
+
analysis
|
|
659
|
+
});
|
|
660
|
+
this.queue.push({ filename: resolved, depth: depth + 1 });
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
|
|
401
666
|
// src/js/NodePathWalker.ts
|
|
402
667
|
var NodePathWalker = class {
|
|
403
668
|
constructor({ ignoreCallExpressionIdentifiers, callback } = {}) {
|
|
@@ -497,6 +762,7 @@ var NodePathWalker = class {
|
|
|
497
762
|
declaration: importDeclaration,
|
|
498
763
|
specifier: arg,
|
|
499
764
|
imported: imported.node.name,
|
|
765
|
+
local: arg.node.local.name,
|
|
500
766
|
source: importDeclaration.node.source.value,
|
|
501
767
|
type: "ImportSpecifier"
|
|
502
768
|
}
|
|
@@ -507,6 +773,7 @@ var NodePathWalker = class {
|
|
|
507
773
|
{
|
|
508
774
|
declaration: importDeclaration,
|
|
509
775
|
specifier: arg,
|
|
776
|
+
local: arg.node.local.name,
|
|
510
777
|
source: importDeclaration.node.source.value,
|
|
511
778
|
type: "ImportDefaultSpecifier"
|
|
512
779
|
}
|
|
@@ -558,6 +825,8 @@ var NodePathWalker = class {
|
|
|
558
825
|
const decl = path2.get("declaration");
|
|
559
826
|
if (decl.isIdentifier()) {
|
|
560
827
|
this.walkNode(decl);
|
|
828
|
+
} else {
|
|
829
|
+
this.walkNode(decl);
|
|
561
830
|
}
|
|
562
831
|
}
|
|
563
832
|
walkExportAllDeclaration(path2) {
|
|
@@ -785,12 +1054,28 @@ function jsHandler(rawSource, options) {
|
|
|
785
1054
|
}
|
|
786
1055
|
const analysis = analyzeSource(ast, options);
|
|
787
1056
|
const ms = processUpdatedSource(rawSource, options, analysis);
|
|
788
|
-
|
|
1057
|
+
const result = {
|
|
789
1058
|
code: ms.toString(),
|
|
790
1059
|
get map() {
|
|
791
1060
|
return ms.generateMap();
|
|
792
1061
|
}
|
|
793
1062
|
};
|
|
1063
|
+
if (options.moduleGraph && options.filename) {
|
|
1064
|
+
const graph = new JsModuleGraph(
|
|
1065
|
+
{
|
|
1066
|
+
filename: options.filename,
|
|
1067
|
+
source: rawSource,
|
|
1068
|
+
analysis,
|
|
1069
|
+
handlerOptions: options
|
|
1070
|
+
},
|
|
1071
|
+
options.moduleGraph
|
|
1072
|
+
);
|
|
1073
|
+
const linked = graph.build();
|
|
1074
|
+
if (Object.keys(linked).length > 0) {
|
|
1075
|
+
result.linked = linked;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
return result;
|
|
794
1079
|
}
|
|
795
1080
|
|
|
796
1081
|
// src/js/index.ts
|
|
@@ -1003,7 +1288,7 @@ function generateCode(match, options = {}) {
|
|
|
1003
1288
|
if (t.isMemberExpression(path2.parent)) {
|
|
1004
1289
|
return;
|
|
1005
1290
|
}
|
|
1006
|
-
if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression(_optionalChain([path2, 'access',
|
|
1291
|
+
if (t.isBinaryExpression(path2.parent) && (t.isConditionalExpression(_optionalChain([path2, 'access', _18 => _18.parentPath, 'optionalAccess', _19 => _19.parent])) || t.isLogicalExpression(_optionalChain([path2, 'access', _20 => _20.parentPath, 'optionalAccess', _21 => _21.parent])))) {
|
|
1007
1292
|
return;
|
|
1008
1293
|
}
|
|
1009
1294
|
jsTokenUpdater.addToken(
|
|
@@ -1024,7 +1309,7 @@ function generateCode(match, options = {}) {
|
|
|
1024
1309
|
jsTokenUpdater.updateMagicString(ms);
|
|
1025
1310
|
return ms.toString();
|
|
1026
1311
|
}
|
|
1027
|
-
} catch (
|
|
1312
|
+
} catch (e6) {
|
|
1028
1313
|
return match;
|
|
1029
1314
|
}
|
|
1030
1315
|
}
|
|
@@ -1328,8 +1613,38 @@ var _localpkg = require('local-pkg');
|
|
|
1328
1613
|
// src/tailwindcss/patcher.ts
|
|
1329
1614
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
1330
1615
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
1616
|
+
|
|
1331
1617
|
var _shared = require('@weapp-tailwindcss/shared');
|
|
1332
1618
|
var _tailwindcsspatch = require('tailwindcss-patch');
|
|
1619
|
+
function createFallbackTailwindcssPatcher() {
|
|
1620
|
+
const packageInfo = {
|
|
1621
|
+
name: "tailwindcss",
|
|
1622
|
+
version: void 0,
|
|
1623
|
+
rootPath: "",
|
|
1624
|
+
packageJsonPath: "",
|
|
1625
|
+
packageJson: {}
|
|
1626
|
+
};
|
|
1627
|
+
return {
|
|
1628
|
+
packageInfo,
|
|
1629
|
+
majorVersion: 0,
|
|
1630
|
+
patch() {
|
|
1631
|
+
},
|
|
1632
|
+
async getClassSet() {
|
|
1633
|
+
return /* @__PURE__ */ new Set();
|
|
1634
|
+
},
|
|
1635
|
+
getClassSetV3() {
|
|
1636
|
+
return /* @__PURE__ */ new Set();
|
|
1637
|
+
},
|
|
1638
|
+
async extract(_options) {
|
|
1639
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
1640
|
+
return {
|
|
1641
|
+
classList: [],
|
|
1642
|
+
classSet
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
var hasLoggedMissingTailwind = false;
|
|
1333
1648
|
function createTailwindcssPatcher(options) {
|
|
1334
1649
|
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
1335
1650
|
const cache = {};
|
|
@@ -1342,7 +1657,7 @@ function createTailwindcssPatcher(options) {
|
|
|
1342
1657
|
cache.dir = _path2.default.resolve(_process2.default.cwd(), cacheDir);
|
|
1343
1658
|
}
|
|
1344
1659
|
}
|
|
1345
|
-
|
|
1660
|
+
const resolvedOptions = _shared.defuOverrideArray.call(void 0,
|
|
1346
1661
|
tailwindcssPatcherOptions,
|
|
1347
1662
|
{
|
|
1348
1663
|
cache,
|
|
@@ -1355,12 +1670,24 @@ function createTailwindcssPatcher(options) {
|
|
|
1355
1670
|
tailwindcss,
|
|
1356
1671
|
resolve: {
|
|
1357
1672
|
paths: [
|
|
1358
|
-
|
|
1673
|
+
_chunkNHB7NFQCjs.importMetaUrl
|
|
1359
1674
|
]
|
|
1360
1675
|
}
|
|
1361
1676
|
}
|
|
1362
1677
|
}
|
|
1363
|
-
)
|
|
1678
|
+
);
|
|
1679
|
+
try {
|
|
1680
|
+
return new (0, _tailwindcsspatch.TailwindcssPatcher)(resolvedOptions);
|
|
1681
|
+
} catch (error) {
|
|
1682
|
+
if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
|
|
1683
|
+
if (!hasLoggedMissingTailwind) {
|
|
1684
|
+
_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");
|
|
1685
|
+
hasLoggedMissingTailwind = true;
|
|
1686
|
+
}
|
|
1687
|
+
return createFallbackTailwindcssPatcher();
|
|
1688
|
+
}
|
|
1689
|
+
throw error;
|
|
1690
|
+
}
|
|
1364
1691
|
}
|
|
1365
1692
|
|
|
1366
1693
|
// src/context/tailwindcss.ts
|
|
@@ -1402,7 +1729,11 @@ function getCompilerContext(opts) {
|
|
|
1402
1729
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
1403
1730
|
applyLoggerLevel(ctx.logLevel);
|
|
1404
1731
|
const twPatcher = createTailwindcssPatcherFromContext(ctx);
|
|
1405
|
-
|
|
1732
|
+
if (_optionalChain([twPatcher, 'access', _22 => _22.packageInfo, 'optionalAccess', _23 => _23.version])) {
|
|
1733
|
+
_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)))}`);
|
|
1734
|
+
} else {
|
|
1735
|
+
_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`);
|
|
1736
|
+
}
|
|
1406
1737
|
const cssCalcOptions = _nullishCoalesce(ctx.cssCalc, () => ( twPatcher.majorVersion === 4));
|
|
1407
1738
|
const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
|
|
1408
1739
|
const { initMangle, mangleContext, setMangleRuntimeSet } = _mangle.useMangleStore.call(void 0, );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/tsup@8.5.0_@
|
|
1
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.53.1_@types+node@24.8.1__@swc+core@1.13.5_jiti@2._cec5ee635e8b2932d274eae561437dbd/node_modules/tsup/assets/esm_shims.js
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
4
|
var getFilename = () => fileURLToPath(import.meta.url);
|