weapp-tailwindcss 4.5.1 → 4.5.2
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-VJKW7COS.js → chunk-A3TJT6B6.js} +78 -194
- package/dist/{chunk-3ICGFLVO.mjs → chunk-CKTI35D3.mjs} +1 -1
- package/dist/{chunk-CCXN3K4T.js → chunk-FOUWGCIJ.js} +2 -2
- package/dist/{chunk-4JDQJ2K4.mjs → chunk-GGIH6WLF.mjs} +1 -1
- package/dist/chunk-KBR4YB6N.js +178 -0
- package/dist/{chunk-P54HILYW.mjs → chunk-L4AXTSIM.mjs} +79 -192
- package/dist/chunk-S2WEN6NJ.mjs +175 -0
- package/dist/{chunk-QOHOLLWR.js → chunk-TGTFIOJU.js} +2 -2
- package/dist/{chunk-7KER5VQX.mjs → chunk-WFZ73Q6S.mjs} +1 -1
- package/dist/{chunk-7NGYHFX4.js → chunk-ZUH5ZA7D.js} +3 -3
- package/dist/cli.js +3 -2
- package/dist/cli.mjs +2 -1
- package/dist/core.js +3 -2
- package/dist/core.mjs +2 -1
- package/dist/gulp.js +4 -3
- package/dist/gulp.mjs +3 -2
- package/dist/index.js +6 -5
- package/dist/index.mjs +5 -4
- package/dist/presets.d.mts +9 -1
- package/dist/presets.d.ts +9 -1
- package/dist/presets.js +62 -2
- package/dist/presets.mjs +60 -0
- package/dist/vite.js +4 -3
- package/dist/vite.mjs +3 -2
- package/dist/webpack.js +4 -3
- package/dist/webpack.mjs +3 -2
- package/dist/webpack4.js +3 -2
- package/dist/webpack4.mjs +2 -1
- package/package.json +1 -1
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
var _chunkPLMJW644js = require('./chunk-PLMJW644.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkKBR4YB6Njs = require('./chunk-KBR4YB6N.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
var _chunkFOSGDQZ7js = require('./chunk-FOSGDQZ7.js');
|
|
9
10
|
|
|
10
|
-
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
14
14
|
|
|
15
15
|
// src/context/index.ts
|
|
16
16
|
var _logger = require('@weapp-tailwindcss/logger');
|
|
@@ -280,15 +280,15 @@ function shouldTransformClassName(candidate, {
|
|
|
280
280
|
}
|
|
281
281
|
return !_optionalChain([jsPreserveClass, 'optionalCall', _7 => _7(candidate)]);
|
|
282
282
|
}
|
|
283
|
-
function extractLiteralValue(
|
|
283
|
+
function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
|
|
284
284
|
const allowDoubleQuotes = _optionalChain([arbitraryValues, 'optionalAccess', _8 => _8.allowDoubleQuotes]);
|
|
285
285
|
let offset = 0;
|
|
286
286
|
let original;
|
|
287
|
-
if (
|
|
287
|
+
if (path.isStringLiteral()) {
|
|
288
288
|
offset = 1;
|
|
289
|
-
original =
|
|
290
|
-
} else if (
|
|
291
|
-
original =
|
|
289
|
+
original = path.node.value;
|
|
290
|
+
} else if (path.isTemplateElement()) {
|
|
291
|
+
original = path.node.value.raw;
|
|
292
292
|
} else {
|
|
293
293
|
original = "";
|
|
294
294
|
}
|
|
@@ -303,7 +303,7 @@ function extractLiteralValue(path2, { unescapeUnicode, arbitraryValues }) {
|
|
|
303
303
|
original
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
|
-
function replaceHandleValue(
|
|
306
|
+
function replaceHandleValue(path, options) {
|
|
307
307
|
const {
|
|
308
308
|
escapeMap,
|
|
309
309
|
mangleContext,
|
|
@@ -313,8 +313,8 @@ function replaceHandleValue(path2, options) {
|
|
|
313
313
|
if (!alwaysEscape && (!classNameSet || classNameSet.size === 0)) {
|
|
314
314
|
return void 0;
|
|
315
315
|
}
|
|
316
|
-
const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(
|
|
317
|
-
if (hasIgnoreComment(
|
|
316
|
+
const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path, options);
|
|
317
|
+
if (hasIgnoreComment(path.node)) {
|
|
318
318
|
return void 0;
|
|
319
319
|
}
|
|
320
320
|
const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
|
|
@@ -347,7 +347,7 @@ function replaceHandleValue(path2, options) {
|
|
|
347
347
|
mutated = true;
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
const node =
|
|
350
|
+
const node = path.node;
|
|
351
351
|
if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") {
|
|
352
352
|
return void 0;
|
|
353
353
|
}
|
|
@@ -361,7 +361,7 @@ function replaceHandleValue(path2, options) {
|
|
|
361
361
|
start,
|
|
362
362
|
end,
|
|
363
363
|
value,
|
|
364
|
-
path
|
|
364
|
+
path
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
367
|
|
|
@@ -673,35 +673,35 @@ var NodePathWalker = class {
|
|
|
673
673
|
this.visited = /* @__PURE__ */ new WeakSet();
|
|
674
674
|
this.isIgnoredCallIdentifier = createNameMatcher(this.ignoreCallExpressionIdentifiers, { exact: true });
|
|
675
675
|
}
|
|
676
|
-
walkVariableDeclarator(
|
|
677
|
-
const init =
|
|
676
|
+
walkVariableDeclarator(path) {
|
|
677
|
+
const init = path.get("init");
|
|
678
678
|
this.walkNode(init);
|
|
679
679
|
}
|
|
680
|
-
walkTemplateLiteral(
|
|
681
|
-
for (const exp of
|
|
680
|
+
walkTemplateLiteral(path) {
|
|
681
|
+
for (const exp of path.get("expressions")) {
|
|
682
682
|
this.walkNode(exp);
|
|
683
683
|
}
|
|
684
|
-
for (const quasis of
|
|
684
|
+
for (const quasis of path.get("quasis")) {
|
|
685
685
|
this.callback(quasis);
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
|
-
walkStringLiteral(
|
|
689
|
-
this.callback(
|
|
688
|
+
walkStringLiteral(path) {
|
|
689
|
+
this.callback(path);
|
|
690
690
|
}
|
|
691
|
-
walkBinaryExpression(
|
|
692
|
-
const left =
|
|
691
|
+
walkBinaryExpression(path) {
|
|
692
|
+
const left = path.get("left");
|
|
693
693
|
this.walkNode(left);
|
|
694
|
-
const right =
|
|
694
|
+
const right = path.get("right");
|
|
695
695
|
this.walkNode(right);
|
|
696
696
|
}
|
|
697
|
-
walkLogicalExpression(
|
|
698
|
-
const left =
|
|
697
|
+
walkLogicalExpression(path) {
|
|
698
|
+
const left = path.get("left");
|
|
699
699
|
this.walkNode(left);
|
|
700
|
-
const right =
|
|
700
|
+
const right = path.get("right");
|
|
701
701
|
this.walkNode(right);
|
|
702
702
|
}
|
|
703
|
-
walkObjectExpression(
|
|
704
|
-
const props =
|
|
703
|
+
walkObjectExpression(path) {
|
|
704
|
+
const props = path.get("properties");
|
|
705
705
|
for (const prop of props) {
|
|
706
706
|
if (prop.isObjectProperty()) {
|
|
707
707
|
const key = prop.get("key");
|
|
@@ -711,8 +711,8 @@ var NodePathWalker = class {
|
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
|
-
walkArrayExpression(
|
|
715
|
-
const elements =
|
|
714
|
+
walkArrayExpression(path) {
|
|
715
|
+
const elements = path.get("elements");
|
|
716
716
|
for (const element of elements) {
|
|
717
717
|
this.walkNode(element);
|
|
718
718
|
}
|
|
@@ -785,33 +785,33 @@ var NodePathWalker = class {
|
|
|
785
785
|
/**
|
|
786
786
|
* Walk the arguments of a desired call expression so their bindings can be analysed.
|
|
787
787
|
*/
|
|
788
|
-
walkCallExpression(
|
|
789
|
-
const calleePath =
|
|
788
|
+
walkCallExpression(path) {
|
|
789
|
+
const calleePath = path.get("callee");
|
|
790
790
|
if (calleePath.isIdentifier() && this.isIgnoredCallIdentifier(calleePath.node.name)) {
|
|
791
|
-
for (const arg of
|
|
791
|
+
for (const arg of path.get("arguments")) {
|
|
792
792
|
this.walkNode(arg);
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
|
-
walkExportDeclaration(
|
|
797
|
-
if (
|
|
798
|
-
if (
|
|
799
|
-
this.walkExportNamedDeclaration(
|
|
800
|
-
} else if (
|
|
801
|
-
this.walkExportDefaultDeclaration(
|
|
802
|
-
} else if (
|
|
803
|
-
this.walkExportAllDeclaration(
|
|
796
|
+
walkExportDeclaration(path) {
|
|
797
|
+
if (path.isExportDeclaration()) {
|
|
798
|
+
if (path.isExportNamedDeclaration()) {
|
|
799
|
+
this.walkExportNamedDeclaration(path);
|
|
800
|
+
} else if (path.isExportDefaultDeclaration()) {
|
|
801
|
+
this.walkExportDefaultDeclaration(path);
|
|
802
|
+
} else if (path.isExportAllDeclaration()) {
|
|
803
|
+
this.walkExportAllDeclaration(path);
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
|
-
walkExportNamedDeclaration(
|
|
808
|
-
const declaration =
|
|
807
|
+
walkExportNamedDeclaration(path) {
|
|
808
|
+
const declaration = path.get("declaration");
|
|
809
809
|
if (declaration.isVariableDeclaration()) {
|
|
810
810
|
for (const decl of declaration.get("declarations")) {
|
|
811
811
|
this.walkNode(decl);
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
|
-
const specifiers =
|
|
814
|
+
const specifiers = path.get("specifiers");
|
|
815
815
|
for (const spec of specifiers) {
|
|
816
816
|
if (spec.isExportSpecifier()) {
|
|
817
817
|
const local = spec.get("local");
|
|
@@ -821,20 +821,20 @@ var NodePathWalker = class {
|
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
|
-
walkExportDefaultDeclaration(
|
|
825
|
-
const decl =
|
|
824
|
+
walkExportDefaultDeclaration(path) {
|
|
825
|
+
const decl = path.get("declaration");
|
|
826
826
|
if (decl.isIdentifier()) {
|
|
827
827
|
this.walkNode(decl);
|
|
828
828
|
} else {
|
|
829
829
|
this.walkNode(decl);
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
|
-
walkExportAllDeclaration(
|
|
833
|
-
const source =
|
|
832
|
+
walkExportAllDeclaration(path) {
|
|
833
|
+
const source = path.get("source");
|
|
834
834
|
if (source.isStringLiteral()) {
|
|
835
835
|
this.imports.add(
|
|
836
836
|
{
|
|
837
|
-
declaration:
|
|
837
|
+
declaration: path,
|
|
838
838
|
source: source.node.value,
|
|
839
839
|
type: "ExportAllDeclaration"
|
|
840
840
|
}
|
|
@@ -877,15 +877,15 @@ function isEvalPath(p) {
|
|
|
877
877
|
}
|
|
878
878
|
return false;
|
|
879
879
|
}
|
|
880
|
-
function createEvalReplacementToken(
|
|
881
|
-
const node =
|
|
880
|
+
function createEvalReplacementToken(path, updated) {
|
|
881
|
+
const node = path.node;
|
|
882
882
|
let offset = 0;
|
|
883
883
|
let original;
|
|
884
|
-
if (
|
|
884
|
+
if (path.isStringLiteral()) {
|
|
885
885
|
offset = 1;
|
|
886
|
-
original =
|
|
887
|
-
} else if (
|
|
888
|
-
original =
|
|
886
|
+
original = path.node.value;
|
|
887
|
+
} else if (path.isTemplateElement()) {
|
|
888
|
+
original = path.node.value.raw;
|
|
889
889
|
} else {
|
|
890
890
|
original = "";
|
|
891
891
|
}
|
|
@@ -900,16 +900,16 @@ function createEvalReplacementToken(path2, updated) {
|
|
|
900
900
|
if (original === updated) {
|
|
901
901
|
return void 0;
|
|
902
902
|
}
|
|
903
|
-
const value =
|
|
903
|
+
const value = path.isStringLiteral() ? _escape.jsStringEscape.call(void 0, updated) : updated;
|
|
904
904
|
return {
|
|
905
905
|
start,
|
|
906
906
|
end,
|
|
907
907
|
value,
|
|
908
|
-
path
|
|
908
|
+
path
|
|
909
909
|
};
|
|
910
910
|
}
|
|
911
|
-
function handleEvalStringLiteral(
|
|
912
|
-
const { code } = jsHandler(
|
|
911
|
+
function handleEvalStringLiteral(path, options, updater) {
|
|
912
|
+
const { code } = jsHandler(path.node.value, {
|
|
913
913
|
...options,
|
|
914
914
|
needEscaped: false,
|
|
915
915
|
generateMap: false
|
|
@@ -917,26 +917,26 @@ function handleEvalStringLiteral(path2, options, updater) {
|
|
|
917
917
|
if (!code) {
|
|
918
918
|
return;
|
|
919
919
|
}
|
|
920
|
-
const token = createEvalReplacementToken(
|
|
920
|
+
const token = createEvalReplacementToken(path, code);
|
|
921
921
|
if (token) {
|
|
922
922
|
updater.addToken(token);
|
|
923
923
|
}
|
|
924
924
|
}
|
|
925
|
-
function handleEvalTemplateElement(
|
|
926
|
-
const { code } = jsHandler(
|
|
925
|
+
function handleEvalTemplateElement(path, options, updater) {
|
|
926
|
+
const { code } = jsHandler(path.node.value.raw, {
|
|
927
927
|
...options,
|
|
928
928
|
generateMap: false
|
|
929
929
|
});
|
|
930
930
|
if (!code) {
|
|
931
931
|
return;
|
|
932
932
|
}
|
|
933
|
-
const token = createEvalReplacementToken(
|
|
933
|
+
const token = createEvalReplacementToken(path, code);
|
|
934
934
|
if (token) {
|
|
935
935
|
updater.addToken(token);
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
|
-
function walkEvalExpression(
|
|
939
|
-
|
|
938
|
+
function walkEvalExpression(path, options, updater) {
|
|
939
|
+
path.traverse({
|
|
940
940
|
StringLiteral(innerPath) {
|
|
941
941
|
handleEvalStringLiteral(innerPath, options, updater);
|
|
942
942
|
},
|
|
@@ -951,9 +951,9 @@ function analyzeSource(ast, options) {
|
|
|
951
951
|
const walker = new NodePathWalker(
|
|
952
952
|
{
|
|
953
953
|
ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
|
|
954
|
-
callback(
|
|
955
|
-
if (
|
|
956
|
-
ignoredPaths.add(
|
|
954
|
+
callback(path) {
|
|
955
|
+
if (path.isStringLiteral() || path.isTemplateElement()) {
|
|
956
|
+
ignoredPaths.add(path);
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
}
|
|
@@ -1024,15 +1024,15 @@ function processUpdatedSource(rawSource, options, analysis) {
|
|
|
1024
1024
|
const ms = new (0, _magicstring2.default)(rawSource);
|
|
1025
1025
|
const { targetPaths, jsTokenUpdater, ignoredPaths } = analysis;
|
|
1026
1026
|
const replacementTokens = [];
|
|
1027
|
-
for (const
|
|
1028
|
-
if (ignoredPaths.has(
|
|
1027
|
+
for (const path of targetPaths) {
|
|
1028
|
+
if (ignoredPaths.has(path)) {
|
|
1029
1029
|
continue;
|
|
1030
1030
|
}
|
|
1031
1031
|
const token = replaceHandleValue(
|
|
1032
|
-
|
|
1032
|
+
path,
|
|
1033
1033
|
{
|
|
1034
1034
|
...options,
|
|
1035
|
-
needEscaped:
|
|
1035
|
+
needEscaped: path.isStringLiteral() ? _nullishCoalesce(options.needEscaped, () => ( true)) : false
|
|
1036
1036
|
}
|
|
1037
1037
|
);
|
|
1038
1038
|
if (token) {
|
|
@@ -1284,16 +1284,16 @@ function generateCode(match, options = {}) {
|
|
|
1284
1284
|
const ast = _parser.parseExpression.call(void 0, match);
|
|
1285
1285
|
const jsTokenUpdater = new JsTokenUpdater();
|
|
1286
1286
|
traverse(ast, {
|
|
1287
|
-
StringLiteral(
|
|
1288
|
-
if (t.isMemberExpression(
|
|
1287
|
+
StringLiteral(path) {
|
|
1288
|
+
if (t.isMemberExpression(path.parent)) {
|
|
1289
1289
|
return;
|
|
1290
1290
|
}
|
|
1291
|
-
if (t.isBinaryExpression(
|
|
1291
|
+
if (t.isBinaryExpression(path.parent) && (t.isConditionalExpression(_optionalChain([path, 'access', _18 => _18.parentPath, 'optionalAccess', _19 => _19.parent])) || t.isLogicalExpression(_optionalChain([path, 'access', _20 => _20.parentPath, 'optionalAccess', _21 => _21.parent])))) {
|
|
1292
1292
|
return;
|
|
1293
1293
|
}
|
|
1294
1294
|
jsTokenUpdater.addToken(
|
|
1295
1295
|
replaceHandleValue(
|
|
1296
|
-
|
|
1296
|
+
path,
|
|
1297
1297
|
{
|
|
1298
1298
|
mangleContext: options.mangleContext,
|
|
1299
1299
|
escapeMap: options.escapeMap,
|
|
@@ -1607,122 +1607,6 @@ function applyLoggerLevel(logLevel) {
|
|
|
1607
1607
|
_logger.logger.level = _nullishCoalesce(loggerLevelMap[_nullishCoalesce(logLevel, () => ( "info"))], () => ( loggerLevelMap.info));
|
|
1608
1608
|
}
|
|
1609
1609
|
|
|
1610
|
-
// src/tailwindcss/index.ts
|
|
1611
|
-
var _localpkg = require('local-pkg');
|
|
1612
|
-
|
|
1613
|
-
// src/tailwindcss/patcher.ts
|
|
1614
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
1615
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
1616
|
-
|
|
1617
|
-
var _shared = require('@weapp-tailwindcss/shared');
|
|
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;
|
|
1648
|
-
function createTailwindcssPatcher(options) {
|
|
1649
|
-
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
1650
|
-
const cache = {};
|
|
1651
|
-
if (cacheDir) {
|
|
1652
|
-
if (_path2.default.isAbsolute(cacheDir)) {
|
|
1653
|
-
cache.dir = cacheDir;
|
|
1654
|
-
} else if (basedir) {
|
|
1655
|
-
cache.dir = _path2.default.resolve(basedir, cacheDir);
|
|
1656
|
-
} else {
|
|
1657
|
-
cache.dir = _path2.default.resolve(_process2.default.cwd(), cacheDir);
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
const resolvedOptions = _shared.defuOverrideArray.call(void 0,
|
|
1661
|
-
tailwindcssPatcherOptions,
|
|
1662
|
-
{
|
|
1663
|
-
cache,
|
|
1664
|
-
patch: {
|
|
1665
|
-
basedir,
|
|
1666
|
-
applyPatches: {
|
|
1667
|
-
exportContext: true,
|
|
1668
|
-
extendLengthUnits: supportCustomLengthUnitsPatch
|
|
1669
|
-
},
|
|
1670
|
-
tailwindcss,
|
|
1671
|
-
resolve: {
|
|
1672
|
-
paths: [
|
|
1673
|
-
_chunkNHB7NFQCjs.importMetaUrl
|
|
1674
|
-
]
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
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
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
// src/context/tailwindcss.ts
|
|
1694
|
-
function createTailwindcssPatcherFromContext(ctx) {
|
|
1695
|
-
const {
|
|
1696
|
-
tailwindcssBasedir,
|
|
1697
|
-
supportCustomLengthUnitsPatch,
|
|
1698
|
-
tailwindcss,
|
|
1699
|
-
tailwindcssPatcherOptions,
|
|
1700
|
-
cssEntries,
|
|
1701
|
-
appType
|
|
1702
|
-
} = ctx;
|
|
1703
|
-
const defaultTailwindcssConfig = {
|
|
1704
|
-
v4: {
|
|
1705
|
-
base: tailwindcssBasedir,
|
|
1706
|
-
cssEntries
|
|
1707
|
-
}
|
|
1708
|
-
};
|
|
1709
|
-
if (_optionalChain([cssEntries, 'optionalAccess', _22 => _22.length]) && (tailwindcss == null || tailwindcss.version == null)) {
|
|
1710
|
-
defaultTailwindcssConfig.version = 4;
|
|
1711
|
-
}
|
|
1712
|
-
return createTailwindcssPatcher(
|
|
1713
|
-
{
|
|
1714
|
-
basedir: tailwindcssBasedir,
|
|
1715
|
-
cacheDir: appType === "mpx" ? "node_modules/tailwindcss-patch/.cache" : void 0,
|
|
1716
|
-
supportCustomLengthUnitsPatch: _nullishCoalesce(supportCustomLengthUnitsPatch, () => ( true)),
|
|
1717
|
-
tailwindcss: _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
|
|
1718
|
-
tailwindcss,
|
|
1719
|
-
defaultTailwindcssConfig
|
|
1720
|
-
),
|
|
1721
|
-
tailwindcssPatcherOptions
|
|
1722
|
-
}
|
|
1723
|
-
);
|
|
1724
|
-
}
|
|
1725
|
-
|
|
1726
1610
|
// src/context/index.ts
|
|
1727
1611
|
var DEFAULT_SPACING_VARIABLE = "--spacing";
|
|
1728
1612
|
function matchesSpacingToken(token) {
|
|
@@ -1767,8 +1651,8 @@ function getCompilerContext(opts) {
|
|
|
1767
1651
|
);
|
|
1768
1652
|
ctx.escapeMap = ctx.customReplaceDictionary;
|
|
1769
1653
|
applyLoggerLevel(ctx.logLevel);
|
|
1770
|
-
const twPatcher = createTailwindcssPatcherFromContext(ctx);
|
|
1771
|
-
if (_optionalChain([twPatcher, 'access',
|
|
1654
|
+
const twPatcher = _chunkKBR4YB6Njs.createTailwindcssPatcherFromContext.call(void 0, ctx);
|
|
1655
|
+
if (_optionalChain([twPatcher, 'access', _22 => _22.packageInfo, 'optionalAccess', _23 => _23.version])) {
|
|
1772
1656
|
_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)))}`);
|
|
1773
1657
|
} else {
|
|
1774
1658
|
_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`);
|
|
@@ -14,7 +14,7 @@ var _chunk2NRTWL47js = require('./chunk-2NRTWL47.js');
|
|
|
14
14
|
var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkA3TJT6B6js = require('./chunk-A3TJT6B6.js');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -26,7 +26,7 @@ var _process = require('process'); var _process2 = _interopRequireDefault(_proce
|
|
|
26
26
|
var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
|
|
27
27
|
var UnifiedWebpackPluginV5 = class {
|
|
28
28
|
constructor(options = {}) {
|
|
29
|
-
this.options =
|
|
29
|
+
this.options = _chunkA3TJT6B6js.getCompilerContext.call(void 0, options);
|
|
30
30
|
this.appType = this.options.appType;
|
|
31
31
|
}
|
|
32
32
|
apply(compiler) {
|
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
|
|
3
|
+
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkNHB7NFQCjs = require('./chunk-NHB7NFQC.js');
|
|
7
|
+
|
|
8
|
+
// src/context/tailwindcss.ts
|
|
9
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
10
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
11
|
+
|
|
12
|
+
// src/tailwindcss/index.ts
|
|
13
|
+
var _localpkg = require('local-pkg');
|
|
14
|
+
|
|
15
|
+
// src/tailwindcss/patcher.ts
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _logger = require('@weapp-tailwindcss/logger');
|
|
19
|
+
var _shared = require('@weapp-tailwindcss/shared');
|
|
20
|
+
var _tailwindcsspatch = require('tailwindcss-patch');
|
|
21
|
+
function createFallbackTailwindcssPatcher() {
|
|
22
|
+
const packageInfo = {
|
|
23
|
+
name: "tailwindcss",
|
|
24
|
+
version: void 0,
|
|
25
|
+
rootPath: "",
|
|
26
|
+
packageJsonPath: "",
|
|
27
|
+
packageJson: {}
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
packageInfo,
|
|
31
|
+
majorVersion: 0,
|
|
32
|
+
patch() {
|
|
33
|
+
},
|
|
34
|
+
async getClassSet() {
|
|
35
|
+
return /* @__PURE__ */ new Set();
|
|
36
|
+
},
|
|
37
|
+
getClassSetV3() {
|
|
38
|
+
return /* @__PURE__ */ new Set();
|
|
39
|
+
},
|
|
40
|
+
async extract(_options) {
|
|
41
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
42
|
+
return {
|
|
43
|
+
classList: [],
|
|
44
|
+
classSet
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var hasLoggedMissingTailwind = false;
|
|
50
|
+
function createTailwindcssPatcher(options) {
|
|
51
|
+
const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
|
|
52
|
+
const cache = {};
|
|
53
|
+
if (cacheDir) {
|
|
54
|
+
if (_path2.default.isAbsolute(cacheDir)) {
|
|
55
|
+
cache.dir = cacheDir;
|
|
56
|
+
} else if (basedir) {
|
|
57
|
+
cache.dir = _path2.default.resolve(basedir, cacheDir);
|
|
58
|
+
} else {
|
|
59
|
+
cache.dir = _path2.default.resolve(_process2.default.cwd(), cacheDir);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (basedir) {
|
|
63
|
+
cache.cwd = basedir;
|
|
64
|
+
}
|
|
65
|
+
const resolvedOptions = _shared.defuOverrideArray.call(void 0,
|
|
66
|
+
tailwindcssPatcherOptions,
|
|
67
|
+
{
|
|
68
|
+
cache,
|
|
69
|
+
patch: {
|
|
70
|
+
basedir,
|
|
71
|
+
cwd: basedir,
|
|
72
|
+
applyPatches: {
|
|
73
|
+
exportContext: true,
|
|
74
|
+
extendLengthUnits: supportCustomLengthUnitsPatch
|
|
75
|
+
},
|
|
76
|
+
tailwindcss,
|
|
77
|
+
resolve: {
|
|
78
|
+
paths: [
|
|
79
|
+
_chunkNHB7NFQCjs.importMetaUrl
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
try {
|
|
86
|
+
return new (0, _tailwindcsspatch.TailwindcssPatcher)(resolvedOptions);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error instanceof Error && /tailwindcss not found/i.test(error.message)) {
|
|
89
|
+
if (!hasLoggedMissingTailwind) {
|
|
90
|
+
_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");
|
|
91
|
+
hasLoggedMissingTailwind = true;
|
|
92
|
+
}
|
|
93
|
+
return createFallbackTailwindcssPatcher();
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/context/tailwindcss.ts
|
|
100
|
+
var ENV_BASEDIR_KEYS = [
|
|
101
|
+
"WEAPP_TAILWINDCSS_BASEDIR",
|
|
102
|
+
"WEAPP_TAILWINDCSS_BASE_DIR",
|
|
103
|
+
"TAILWINDCSS_BASEDIR",
|
|
104
|
+
"TAILWINDCSS_BASE_DIR",
|
|
105
|
+
"UNI_INPUT_DIR",
|
|
106
|
+
"UNI_INPUT_ROOT",
|
|
107
|
+
"UNI_CLI_ROOT",
|
|
108
|
+
"UNI_APP_INPUT_DIR",
|
|
109
|
+
"INIT_CWD",
|
|
110
|
+
"PWD"
|
|
111
|
+
];
|
|
112
|
+
function pickEnvBasedir() {
|
|
113
|
+
for (const key of ENV_BASEDIR_KEYS) {
|
|
114
|
+
const value = _process2.default.env[key];
|
|
115
|
+
if (value && _path2.default.isAbsolute(value)) {
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return void 0;
|
|
120
|
+
}
|
|
121
|
+
function resolveTailwindcssBasedir(basedir) {
|
|
122
|
+
const envBasedir = pickEnvBasedir();
|
|
123
|
+
const anchor = _nullishCoalesce(envBasedir, () => ( _process2.default.cwd()));
|
|
124
|
+
if (basedir && basedir.trim().length > 0) {
|
|
125
|
+
if (_path2.default.isAbsolute(basedir)) {
|
|
126
|
+
return _path2.default.normalize(basedir);
|
|
127
|
+
}
|
|
128
|
+
return _path2.default.resolve(anchor, basedir);
|
|
129
|
+
}
|
|
130
|
+
if (envBasedir) {
|
|
131
|
+
return _path2.default.normalize(envBasedir);
|
|
132
|
+
}
|
|
133
|
+
return _path2.default.normalize(_process2.default.cwd());
|
|
134
|
+
}
|
|
135
|
+
function createTailwindcssPatcherFromContext(ctx) {
|
|
136
|
+
const {
|
|
137
|
+
tailwindcssBasedir,
|
|
138
|
+
supportCustomLengthUnitsPatch,
|
|
139
|
+
tailwindcss,
|
|
140
|
+
tailwindcssPatcherOptions,
|
|
141
|
+
cssEntries,
|
|
142
|
+
appType
|
|
143
|
+
} = ctx;
|
|
144
|
+
const resolvedTailwindcssBasedir = resolveTailwindcssBasedir(tailwindcssBasedir);
|
|
145
|
+
ctx.tailwindcssBasedir = resolvedTailwindcssBasedir;
|
|
146
|
+
const defaultTailwindcssConfig = {
|
|
147
|
+
v2: {
|
|
148
|
+
cwd: resolvedTailwindcssBasedir
|
|
149
|
+
},
|
|
150
|
+
v3: {
|
|
151
|
+
cwd: resolvedTailwindcssBasedir
|
|
152
|
+
},
|
|
153
|
+
v4: {
|
|
154
|
+
base: resolvedTailwindcssBasedir,
|
|
155
|
+
cssEntries
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
if (_optionalChain([cssEntries, 'optionalAccess', _ => _.length]) && (tailwindcss == null || tailwindcss.version == null)) {
|
|
159
|
+
defaultTailwindcssConfig.version = 4;
|
|
160
|
+
}
|
|
161
|
+
return createTailwindcssPatcher(
|
|
162
|
+
{
|
|
163
|
+
basedir: resolvedTailwindcssBasedir,
|
|
164
|
+
cacheDir: appType === "mpx" ? "node_modules/tailwindcss-patch/.cache" : void 0,
|
|
165
|
+
supportCustomLengthUnitsPatch: _nullishCoalesce(supportCustomLengthUnitsPatch, () => ( true)),
|
|
166
|
+
tailwindcss: _chunkUW3WHSZ5js.defuOverrideArray.call(void 0,
|
|
167
|
+
tailwindcss,
|
|
168
|
+
defaultTailwindcssConfig
|
|
169
|
+
),
|
|
170
|
+
tailwindcssPatcherOptions
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
exports.resolveTailwindcssBasedir = resolveTailwindcssBasedir; exports.createTailwindcssPatcherFromContext = createTailwindcssPatcherFromContext;
|