weapp-tailwindcss 4.6.1 → 4.6.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-KHILYAA4.mjs → chunk-4EUTRMUC.mjs} +1 -1
- package/dist/{chunk-7CGHD2TI.js → chunk-4HDADZ7K.js} +5 -7
- package/dist/{chunk-FVA7Y2YU.js → chunk-5BTN3KIR.js} +5 -7
- package/dist/{chunk-AXLRUW5H.js → chunk-C3CG4UUY.js} +4 -4
- package/dist/{chunk-M6DWZX4H.js → chunk-CONFDZCT.js} +2 -2
- package/dist/{chunk-JG5LBGLH.mjs → chunk-HHTWS62A.mjs} +1 -1
- package/dist/{chunk-TTDQ4TK2.mjs → chunk-M2DOZWMJ.mjs} +4 -6
- package/dist/{chunk-7PGHZOTU.mjs → chunk-MVB2TWHD.mjs} +153 -32
- package/dist/{chunk-E5PXIHDN.js → chunk-QXSBMK2W.js} +1 -1
- package/dist/{chunk-I7FYDXN6.js → chunk-SOBBYYQ5.js} +1 -0
- package/dist/{chunk-OVDIACVK.js → chunk-VATV3GLU.js} +159 -38
- package/dist/{chunk-YLNOOPZL.mjs → chunk-X4NG76HE.mjs} +1 -0
- package/dist/{chunk-MXVUK23K.mjs → chunk-XVE3N5ZL.mjs} +3 -5
- package/dist/cli.js +7 -9
- package/dist/cli.mjs +4 -6
- package/dist/core.js +5 -5
- 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 +3 -3
- package/dist/defaults.mjs +2 -2
- package/dist/escape.js +1 -1
- package/dist/escape.mjs +1 -1
- package/dist/gulp.js +6 -6
- package/dist/gulp.mjs +4 -4
- package/dist/index.js +8 -9
- package/dist/index.mjs +6 -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 +1 -1
- package/dist/types.d.mts +5 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +6 -7
- package/dist/vite.mjs +4 -5
- package/dist/webpack.js +6 -7
- package/dist/webpack.mjs +4 -5
- package/dist/webpack4.js +8 -10
- package/dist/webpack4.mjs +4 -6
- package/package.json +6 -12
- package/dist/chunk-CMUA5KCO.mjs +0 -10
- package/dist/chunk-OGROHM4L.js +0 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.53.1_@types+node@24.9.
|
|
1
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.53.1_@types+node@24.9.2__@swc+core@1.13.5_@swc+he_60071210c2c46d45864288786f4ed86d/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);
|
|
@@ -14,10 +14,8 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
|
14
14
|
var _chunkFB5P4TRHjs = require('./chunk-FB5P4TRH.js');
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
var _chunkOVDIACVKjs = require('./chunk-OVDIACVK.js');
|
|
18
|
+
var _chunkVATV3GLUjs = require('./chunk-VATV3GLU.js');
|
|
21
19
|
|
|
22
20
|
|
|
23
21
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -29,7 +27,7 @@ var _process = require('process'); var _process2 = _interopRequireDefault(_proce
|
|
|
29
27
|
var debug = _chunkFB5P4TRHjs.createDebug.call(void 0, );
|
|
30
28
|
var UnifiedWebpackPluginV5 = class {
|
|
31
29
|
constructor(options = {}) {
|
|
32
|
-
this.options =
|
|
30
|
+
this.options = _chunkVATV3GLUjs.getCompilerContext.call(void 0, options);
|
|
33
31
|
this.appType = this.options.appType;
|
|
34
32
|
}
|
|
35
33
|
apply(compiler) {
|
|
@@ -68,8 +66,8 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
68
66
|
ident: null,
|
|
69
67
|
type: null
|
|
70
68
|
};
|
|
71
|
-
compiler.hooks.compilation.tap(
|
|
72
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
69
|
+
compiler.hooks.compilation.tap(_chunkVATV3GLUjs.pluginName, (compilation) => {
|
|
70
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunkVATV3GLUjs.pluginName, (_loaderContext, module) => {
|
|
73
71
|
if (isExisted) {
|
|
74
72
|
const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
|
|
75
73
|
if (idx > -1) {
|
|
@@ -79,7 +77,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
79
77
|
});
|
|
80
78
|
compilation.hooks.processAssets.tapPromise(
|
|
81
79
|
{
|
|
82
|
-
name:
|
|
80
|
+
name: _chunkVATV3GLUjs.pluginName,
|
|
83
81
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
84
82
|
},
|
|
85
83
|
async (assets) => {
|
|
@@ -11,11 +11,9 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
|
11
11
|
var _chunkFB5P4TRHjs = require('./chunk-FB5P4TRH.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
var _chunkOVDIACVKjs = require('./chunk-OVDIACVK.js');
|
|
16
|
+
var _chunkVATV3GLUjs = require('./chunk-VATV3GLU.js');
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
var _chunkDWAEHRHNjs = require('./chunk-DWAEHRHN.js');
|
|
@@ -31,8 +29,8 @@ var _htmltransform = require('@weapp-tailwindcss/postcss/html-transform'); var _
|
|
|
31
29
|
|
|
32
30
|
// src/uni-app-x/index.ts
|
|
33
31
|
var _compilerdom = require('@vue/compiler-dom');
|
|
32
|
+
var _compilersfc = require('@vue/compiler-sfc');
|
|
34
33
|
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
|
|
35
|
-
var _compilersfc = require('vue/compiler-sfc');
|
|
36
34
|
function traverse(node, visitor) {
|
|
37
35
|
visitor(node);
|
|
38
36
|
if (Array.isArray(node.children)) {
|
|
@@ -53,7 +51,7 @@ function createClassAttributeUpdater(ms) {
|
|
|
53
51
|
function createClassDirectiveUpdater(ms, jsHandler, runtimeSet) {
|
|
54
52
|
return (prop) => {
|
|
55
53
|
if (_optionalChain([prop, 'access', _ => _.arg, 'optionalAccess', _2 => _2.type]) === _compilerdom.NodeTypes.SIMPLE_EXPRESSION && prop.arg.content === "class" && _optionalChain([prop, 'access', _3 => _3.exp, 'optionalAccess', _4 => _4.type]) === _compilerdom.NodeTypes.SIMPLE_EXPRESSION) {
|
|
56
|
-
const generated =
|
|
54
|
+
const generated = _chunkVATV3GLUjs.generateCode.call(void 0, prop.exp.content, {
|
|
57
55
|
jsHandler,
|
|
58
56
|
runtimeSet
|
|
59
57
|
});
|
|
@@ -239,7 +237,7 @@ function applyLinkedResults(linked, entries, onLinkedUpdate) {
|
|
|
239
237
|
}
|
|
240
238
|
}
|
|
241
239
|
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
242
|
-
const opts =
|
|
240
|
+
const opts = _chunkVATV3GLUjs.getCompilerContext.call(void 0, options);
|
|
243
241
|
const {
|
|
244
242
|
disabled,
|
|
245
243
|
onEnd,
|
|
@@ -264,7 +262,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
264
262
|
onLoad();
|
|
265
263
|
const plugins = [
|
|
266
264
|
{
|
|
267
|
-
name: `${
|
|
265
|
+
name: `${_chunkVATV3GLUjs.vitePluginName}:post`,
|
|
268
266
|
enforce: "post",
|
|
269
267
|
configResolved(config) {
|
|
270
268
|
resolvedConfig = config;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkQXSBMK2Wjs = require('./chunk-QXSBMK2W.js');
|
|
7
7
|
|
|
8
8
|
// src/context/tailwindcss.ts
|
|
9
9
|
var _module = require('module');
|
|
@@ -46,7 +46,7 @@ function resolveModuleFromPaths(specifier, paths) {
|
|
|
46
46
|
return void 0;
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
|
-
const req = _module.createRequire.call(void 0,
|
|
49
|
+
const req = _module.createRequire.call(void 0, _chunkQXSBMK2Wjs.importMetaUrl);
|
|
50
50
|
return req.resolve(specifier, { paths });
|
|
51
51
|
} catch (e) {
|
|
52
52
|
return void 0;
|
|
@@ -155,11 +155,11 @@ function createDefaultResolvePaths(basedir) {
|
|
|
155
155
|
const cwd = _process2.default.cwd();
|
|
156
156
|
appendNodeModules(paths, cwd);
|
|
157
157
|
try {
|
|
158
|
-
const modulePath = _url.fileURLToPath.call(void 0,
|
|
158
|
+
const modulePath = _url.fileURLToPath.call(void 0, _chunkQXSBMK2Wjs.importMetaUrl);
|
|
159
159
|
const candidate = _fs.existsSync.call(void 0, modulePath) && !_path2.default.extname(modulePath) ? modulePath : _path2.default.dirname(modulePath);
|
|
160
160
|
paths.add(candidate);
|
|
161
161
|
} catch (e2) {
|
|
162
|
-
paths.add(
|
|
162
|
+
paths.add(_chunkQXSBMK2Wjs.importMetaUrl);
|
|
163
163
|
}
|
|
164
164
|
if (paths.size === 0) {
|
|
165
165
|
fallbackCandidates = fallbackCandidates.filter(Boolean);
|
|
@@ -7,7 +7,7 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
|
7
7
|
var _chunkFB5P4TRHjs = require('./chunk-FB5P4TRH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkVATV3GLUjs = require('./chunk-VATV3GLU.js');
|
|
11
11
|
|
|
12
12
|
// src/bundlers/gulp/index.ts
|
|
13
13
|
var _buffer = require('buffer');
|
|
@@ -18,7 +18,7 @@ var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
|
|
|
18
18
|
var debug = _chunkFB5P4TRHjs.createDebug.call(void 0, );
|
|
19
19
|
var Transform = _stream2.default.Transform;
|
|
20
20
|
function createPlugins(options = {}) {
|
|
21
|
-
const opts =
|
|
21
|
+
const opts = _chunkVATV3GLUjs.getCompilerContext.call(void 0, options);
|
|
22
22
|
const { templateHandler, styleHandler, jsHandler, cache, twPatcher } = opts;
|
|
23
23
|
let runtimeSet = /* @__PURE__ */ new Set();
|
|
24
24
|
const patchPromise = Promise.resolve(twPatcher.patch());
|
|
@@ -9,13 +9,11 @@ import {
|
|
|
9
9
|
collectRuntimeClassSet,
|
|
10
10
|
createDebug
|
|
11
11
|
} from "./chunk-YPBRGP6K.mjs";
|
|
12
|
-
import {
|
|
13
|
-
vitePluginName
|
|
14
|
-
} from "./chunk-CMUA5KCO.mjs";
|
|
15
12
|
import {
|
|
16
13
|
generateCode,
|
|
17
|
-
getCompilerContext
|
|
18
|
-
|
|
14
|
+
getCompilerContext,
|
|
15
|
+
vitePluginName
|
|
16
|
+
} from "./chunk-MVB2TWHD.mjs";
|
|
19
17
|
import {
|
|
20
18
|
replaceWxml
|
|
21
19
|
} from "./chunk-VSRDBMDB.mjs";
|
|
@@ -31,8 +29,8 @@ import postcssHtmlTransform from "@weapp-tailwindcss/postcss/html-transform";
|
|
|
31
29
|
|
|
32
30
|
// src/uni-app-x/index.ts
|
|
33
31
|
import { NodeTypes } from "@vue/compiler-dom";
|
|
32
|
+
import { parse } from "@vue/compiler-sfc";
|
|
34
33
|
import MagicString from "magic-string";
|
|
35
|
-
import { parse } from "vue/compiler-sfc";
|
|
36
34
|
function traverse(node, visitor) {
|
|
37
35
|
visitor(node);
|
|
38
36
|
if (Array.isArray(node.children)) {
|
|
@@ -6,12 +6,22 @@ import {
|
|
|
6
6
|
} from "./chunk-IY2OKZE6.mjs";
|
|
7
7
|
import {
|
|
8
8
|
getDefaultOptions
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-X4NG76HE.mjs";
|
|
10
10
|
import {
|
|
11
11
|
defuOverrideArray,
|
|
12
12
|
isMap
|
|
13
13
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
14
14
|
|
|
15
|
+
// src/constants.ts
|
|
16
|
+
var pluginName = "weapp-tailwindcss-webpack-plugin";
|
|
17
|
+
var vitePluginName = "weapp-tailwindcss:adaptor";
|
|
18
|
+
var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
|
|
19
|
+
var DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
|
|
20
|
+
"tailwind-merge": "@weapp-tailwindcss/merge",
|
|
21
|
+
"class-variance-authority": "@weapp-tailwindcss/merge/cva",
|
|
22
|
+
"tailwind-variants": "@weapp-tailwindcss/merge/variants"
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
// src/context/index.ts
|
|
16
26
|
import { logger as logger2, pc } from "@weapp-tailwindcss/logger";
|
|
17
27
|
|
|
@@ -897,8 +907,65 @@ function createEvalReplacementToken(path, updated) {
|
|
|
897
907
|
path
|
|
898
908
|
};
|
|
899
909
|
}
|
|
900
|
-
function
|
|
901
|
-
const
|
|
910
|
+
function createModuleSpecifierReplacementToken(path, replacement) {
|
|
911
|
+
const node = path.node;
|
|
912
|
+
if (node.value === replacement) {
|
|
913
|
+
return void 0;
|
|
914
|
+
}
|
|
915
|
+
if (typeof node.start !== "number" || typeof node.end !== "number") {
|
|
916
|
+
return void 0;
|
|
917
|
+
}
|
|
918
|
+
const start = node.start + 1;
|
|
919
|
+
const end = node.end - 1;
|
|
920
|
+
if (start >= end) {
|
|
921
|
+
return void 0;
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
start,
|
|
925
|
+
end,
|
|
926
|
+
value: replacement,
|
|
927
|
+
path
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function collectModuleSpecifierReplacementTokens(analysis, replacements) {
|
|
931
|
+
const tokens = [];
|
|
932
|
+
const applyReplacement = (path) => {
|
|
933
|
+
const replacement = replacements[path.node.value];
|
|
934
|
+
if (!replacement) {
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
const token = createModuleSpecifierReplacementToken(path, replacement);
|
|
938
|
+
if (token) {
|
|
939
|
+
tokens.push(token);
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
for (const importPath of analysis.importDeclarations) {
|
|
943
|
+
const source = importPath.get("source");
|
|
944
|
+
if (source.isStringLiteral()) {
|
|
945
|
+
applyReplacement(source);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
for (const exportPath of analysis.exportDeclarations) {
|
|
949
|
+
if (exportPath.isExportNamedDeclaration() || exportPath.isExportAllDeclaration()) {
|
|
950
|
+
const source = exportPath.get("source");
|
|
951
|
+
if (source && !Array.isArray(source) && source.isStringLiteral()) {
|
|
952
|
+
applyReplacement(source);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
for (const literalPath of analysis.requireCallPaths) {
|
|
957
|
+
applyReplacement(literalPath);
|
|
958
|
+
}
|
|
959
|
+
for (const token of analysis.walker.imports) {
|
|
960
|
+
const replacement = replacements[token.source];
|
|
961
|
+
if (replacement) {
|
|
962
|
+
token.source = replacement;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return tokens;
|
|
966
|
+
}
|
|
967
|
+
function handleEvalStringLiteral(path, options, updater, handler) {
|
|
968
|
+
const { code } = handler(path.node.value, {
|
|
902
969
|
...options,
|
|
903
970
|
needEscaped: false,
|
|
904
971
|
generateMap: false
|
|
@@ -911,8 +978,8 @@ function handleEvalStringLiteral(path, options, updater) {
|
|
|
911
978
|
updater.addToken(token);
|
|
912
979
|
}
|
|
913
980
|
}
|
|
914
|
-
function handleEvalTemplateElement(path, options, updater) {
|
|
915
|
-
const { code } =
|
|
981
|
+
function handleEvalTemplateElement(path, options, updater, handler) {
|
|
982
|
+
const { code } = handler(path.node.value.raw, {
|
|
916
983
|
...options,
|
|
917
984
|
generateMap: false
|
|
918
985
|
});
|
|
@@ -924,17 +991,17 @@ function handleEvalTemplateElement(path, options, updater) {
|
|
|
924
991
|
updater.addToken(token);
|
|
925
992
|
}
|
|
926
993
|
}
|
|
927
|
-
function walkEvalExpression(path, options, updater) {
|
|
994
|
+
function walkEvalExpression(path, options, updater, handler) {
|
|
928
995
|
path.traverse({
|
|
929
996
|
StringLiteral(innerPath) {
|
|
930
|
-
handleEvalStringLiteral(innerPath, options, updater);
|
|
997
|
+
handleEvalStringLiteral(innerPath, options, updater, handler);
|
|
931
998
|
},
|
|
932
999
|
TemplateElement(innerPath) {
|
|
933
|
-
handleEvalTemplateElement(innerPath, options, updater);
|
|
1000
|
+
handleEvalTemplateElement(innerPath, options, updater, handler);
|
|
934
1001
|
}
|
|
935
1002
|
});
|
|
936
1003
|
}
|
|
937
|
-
function analyzeSource(ast, options) {
|
|
1004
|
+
function analyzeSource(ast, options, handler) {
|
|
938
1005
|
const jsTokenUpdater = new JsTokenUpdater();
|
|
939
1006
|
const ignoredPaths = /* @__PURE__ */ new WeakSet();
|
|
940
1007
|
const walker = new NodePathWalker(
|
|
@@ -951,6 +1018,8 @@ function analyzeSource(ast, options) {
|
|
|
951
1018
|
const targetPaths = [];
|
|
952
1019
|
const importDeclarations = /* @__PURE__ */ new Set();
|
|
953
1020
|
const exportDeclarations = /* @__PURE__ */ new Set();
|
|
1021
|
+
const requireCallPaths = [];
|
|
1022
|
+
const evalHandler = handler ?? jsHandler;
|
|
954
1023
|
const traverseOptions = {
|
|
955
1024
|
StringLiteral: {
|
|
956
1025
|
enter(p) {
|
|
@@ -981,9 +1050,19 @@ function analyzeSource(ast, options) {
|
|
|
981
1050
|
CallExpression: {
|
|
982
1051
|
enter(p) {
|
|
983
1052
|
if (isEvalPath(p)) {
|
|
984
|
-
walkEvalExpression(p, options, jsTokenUpdater);
|
|
1053
|
+
walkEvalExpression(p, options, jsTokenUpdater, evalHandler);
|
|
985
1054
|
return;
|
|
986
1055
|
}
|
|
1056
|
+
const calleePath = p.get("callee");
|
|
1057
|
+
if (calleePath.isIdentifier({ name: "require" }) && !p.scope.hasBinding("require")) {
|
|
1058
|
+
const args = p.get("arguments");
|
|
1059
|
+
if (Array.isArray(args) && args.length > 0) {
|
|
1060
|
+
const first = args[0];
|
|
1061
|
+
if (first?.isStringLiteral()) {
|
|
1062
|
+
requireCallPaths.push(first);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
987
1066
|
walker.walkCallExpression(p);
|
|
988
1067
|
}
|
|
989
1068
|
},
|
|
@@ -1006,6 +1085,7 @@ function analyzeSource(ast, options) {
|
|
|
1006
1085
|
targetPaths,
|
|
1007
1086
|
importDeclarations,
|
|
1008
1087
|
exportDeclarations,
|
|
1088
|
+
requireCallPaths,
|
|
1009
1089
|
ignoredPaths
|
|
1010
1090
|
};
|
|
1011
1091
|
}
|
|
@@ -1028,6 +1108,11 @@ function processUpdatedSource(rawSource, options, analysis) {
|
|
|
1028
1108
|
replacementTokens.push(token);
|
|
1029
1109
|
}
|
|
1030
1110
|
}
|
|
1111
|
+
if (options.moduleSpecifierReplacements) {
|
|
1112
|
+
replacementTokens.push(
|
|
1113
|
+
...collectModuleSpecifierReplacementTokens(analysis, options.moduleSpecifierReplacements)
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1031
1116
|
jsTokenUpdater.push(...replacementTokens).filter((token) => !ignoredPaths.has(token.path)).updateMagicString(ms);
|
|
1032
1117
|
return ms;
|
|
1033
1118
|
}
|
|
@@ -1041,7 +1126,7 @@ function jsHandler(rawSource, options) {
|
|
|
1041
1126
|
error
|
|
1042
1127
|
};
|
|
1043
1128
|
}
|
|
1044
|
-
const analysis = analyzeSource(ast, options);
|
|
1129
|
+
const analysis = analyzeSource(ast, options, jsHandler);
|
|
1045
1130
|
const ms = processUpdatedSource(rawSource, options, analysis);
|
|
1046
1131
|
const result = {
|
|
1047
1132
|
code: ms.toString(),
|
|
@@ -1080,7 +1165,8 @@ function createJsHandler(options) {
|
|
|
1080
1165
|
babelParserOptions,
|
|
1081
1166
|
ignoreCallExpressionIdentifiers,
|
|
1082
1167
|
ignoreTaggedTemplateExpressionIdentifiers,
|
|
1083
|
-
uniAppX
|
|
1168
|
+
uniAppX,
|
|
1169
|
+
moduleSpecifierReplacements
|
|
1084
1170
|
} = options;
|
|
1085
1171
|
function handler(rawSource, classNameSet, options2) {
|
|
1086
1172
|
const overrideOptions = options2 ?? {};
|
|
@@ -1101,7 +1187,8 @@ function createJsHandler(options) {
|
|
|
1101
1187
|
babelParserOptions,
|
|
1102
1188
|
ignoreCallExpressionIdentifiers,
|
|
1103
1189
|
ignoreTaggedTemplateExpressionIdentifiers,
|
|
1104
|
-
uniAppX
|
|
1190
|
+
uniAppX,
|
|
1191
|
+
moduleSpecifierReplacements
|
|
1105
1192
|
}
|
|
1106
1193
|
);
|
|
1107
1194
|
return jsHandler(rawSource, resolvedOptions);
|
|
@@ -1514,6 +1601,20 @@ function createTemplateHandler(options = {}) {
|
|
|
1514
1601
|
}
|
|
1515
1602
|
|
|
1516
1603
|
// src/context/handlers.ts
|
|
1604
|
+
function resolveRuntimePackageReplacements(option) {
|
|
1605
|
+
if (!option) {
|
|
1606
|
+
return void 0;
|
|
1607
|
+
}
|
|
1608
|
+
const mapping = option === true ? DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS : option;
|
|
1609
|
+
const normalized = {};
|
|
1610
|
+
for (const [from, to] of Object.entries(mapping)) {
|
|
1611
|
+
if (!from || typeof to !== "string" || to.length === 0) {
|
|
1612
|
+
continue;
|
|
1613
|
+
}
|
|
1614
|
+
normalized[from] = to;
|
|
1615
|
+
}
|
|
1616
|
+
return Object.keys(normalized).length > 0 ? normalized : void 0;
|
|
1617
|
+
}
|
|
1517
1618
|
function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions) {
|
|
1518
1619
|
const {
|
|
1519
1620
|
cssPreflight,
|
|
@@ -1536,8 +1637,10 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
|
|
|
1536
1637
|
ignoreCallExpressionIdentifiers,
|
|
1537
1638
|
ignoreTaggedTemplateExpressionIdentifiers,
|
|
1538
1639
|
inlineWxs,
|
|
1539
|
-
disabledDefaultTemplateHandler
|
|
1640
|
+
disabledDefaultTemplateHandler,
|
|
1641
|
+
replaceRuntimePackages
|
|
1540
1642
|
} = ctx;
|
|
1643
|
+
const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
|
|
1541
1644
|
const styleHandler = createStyleHandler({
|
|
1542
1645
|
cssPreflight,
|
|
1543
1646
|
customRuleCallback,
|
|
@@ -1563,7 +1666,8 @@ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions
|
|
|
1563
1666
|
babelParserOptions,
|
|
1564
1667
|
ignoreCallExpressionIdentifiers,
|
|
1565
1668
|
ignoreTaggedTemplateExpressionIdentifiers,
|
|
1566
|
-
uniAppX
|
|
1669
|
+
uniAppX,
|
|
1670
|
+
moduleSpecifierReplacements
|
|
1567
1671
|
});
|
|
1568
1672
|
const templateHandler = createTemplateHandler({
|
|
1569
1673
|
customAttributesEntities,
|
|
@@ -1592,38 +1696,52 @@ function applyLoggerLevel(logLevel) {
|
|
|
1592
1696
|
}
|
|
1593
1697
|
|
|
1594
1698
|
// src/context/index.ts
|
|
1595
|
-
var
|
|
1596
|
-
function
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1699
|
+
var DEFAULT_CSS_CALC_CUSTOM_PROPERTIES = [];
|
|
1700
|
+
function includesToken(list, token) {
|
|
1701
|
+
return list.some((candidate) => {
|
|
1702
|
+
if (typeof token === "string") {
|
|
1703
|
+
if (typeof candidate === "string") {
|
|
1704
|
+
return candidate === token;
|
|
1705
|
+
}
|
|
1706
|
+
candidate.lastIndex = 0;
|
|
1707
|
+
return candidate.test(token);
|
|
1708
|
+
}
|
|
1709
|
+
if (typeof candidate === "string") {
|
|
1710
|
+
token.lastIndex = 0;
|
|
1711
|
+
return token.test(candidate);
|
|
1712
|
+
}
|
|
1713
|
+
return candidate.source === token.source && candidate.flags === token.flags;
|
|
1714
|
+
});
|
|
1602
1715
|
}
|
|
1603
|
-
function
|
|
1716
|
+
function ensureDefaultsIncluded(value) {
|
|
1604
1717
|
if (value === true) {
|
|
1605
1718
|
return {
|
|
1606
|
-
includeCustomProperties: [
|
|
1719
|
+
includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
|
|
1607
1720
|
};
|
|
1608
1721
|
}
|
|
1609
1722
|
if (Array.isArray(value)) {
|
|
1610
|
-
|
|
1723
|
+
if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
|
|
1724
|
+
return value;
|
|
1725
|
+
}
|
|
1726
|
+
const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(value, token));
|
|
1727
|
+
return missing.length > 0 ? [...value, ...missing] : value;
|
|
1611
1728
|
}
|
|
1612
1729
|
if (value && typeof value === "object") {
|
|
1613
1730
|
const include = value.includeCustomProperties;
|
|
1614
|
-
if (!Array.isArray(include)
|
|
1731
|
+
if (!Array.isArray(include)) {
|
|
1615
1732
|
return {
|
|
1616
1733
|
...value,
|
|
1617
|
-
includeCustomProperties: [
|
|
1734
|
+
includeCustomProperties: [...DEFAULT_CSS_CALC_CUSTOM_PROPERTIES]
|
|
1618
1735
|
};
|
|
1619
1736
|
}
|
|
1620
|
-
if (
|
|
1737
|
+
if (!DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.length) {
|
|
1621
1738
|
return value;
|
|
1622
1739
|
}
|
|
1623
|
-
|
|
1740
|
+
const missing = DEFAULT_CSS_CALC_CUSTOM_PROPERTIES.filter((token) => !includesToken(include, token));
|
|
1741
|
+
return missing.length > 0 ? {
|
|
1624
1742
|
...value,
|
|
1625
|
-
includeCustomProperties: [...include,
|
|
1626
|
-
};
|
|
1743
|
+
includeCustomProperties: [...include, ...missing]
|
|
1744
|
+
} : value;
|
|
1627
1745
|
}
|
|
1628
1746
|
return value;
|
|
1629
1747
|
}
|
|
@@ -1643,7 +1761,7 @@ function getCompilerContext(opts) {
|
|
|
1643
1761
|
}
|
|
1644
1762
|
let cssCalcOptions = ctx.cssCalc ?? twPatcher.majorVersion === 4;
|
|
1645
1763
|
if (twPatcher.majorVersion === 4 && cssCalcOptions) {
|
|
1646
|
-
cssCalcOptions =
|
|
1764
|
+
cssCalcOptions = ensureDefaultsIncluded(cssCalcOptions);
|
|
1647
1765
|
}
|
|
1648
1766
|
ctx.cssCalc = cssCalcOptions;
|
|
1649
1767
|
const customAttributesEntities = toCustomAttributesEntities(ctx.customAttributes);
|
|
@@ -1661,6 +1779,9 @@ function getCompilerContext(opts) {
|
|
|
1661
1779
|
}
|
|
1662
1780
|
|
|
1663
1781
|
export {
|
|
1782
|
+
pluginName,
|
|
1783
|
+
vitePluginName,
|
|
1784
|
+
WEAPP_TW_REQUIRED_NODE_VERSION,
|
|
1664
1785
|
generateCode,
|
|
1665
1786
|
getCompilerContext
|
|
1666
1787
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.53.1_@types+node@24.9.
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.53.1_@types+node@24.9.2__@swc+core@1.13.5_@swc+he_60071210c2c46d45864288786f4ed86d/node_modules/tsup/assets/cjs_shims.js
|
|
2
2
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
3
3
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
4
4
|
|
|
@@ -105,6 +105,7 @@ function getDefaultOptions() {
|
|
|
105
105
|
cssRemoveHoverPseudoClass: true,
|
|
106
106
|
ignoreCallExpressionIdentifiers: _localpkg.isPackageExists.call(void 0, "@weapp-tailwindcss/merge") ? ["twMerge", "twJoin", "cva", "tv"] : [],
|
|
107
107
|
ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"],
|
|
108
|
+
replaceRuntimePackages: false,
|
|
108
109
|
tailwindcssPatcherOptions: {
|
|
109
110
|
filter(className) {
|
|
110
111
|
return !_escape.isAllowedClassName.call(void 0, className);
|