weapp-tailwindcss 4.12.0-next.0 → 4.12.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/bin/weapp-tailwindcss.js +21 -1
- package/dist/{chunk-GMKSBLNY.js → chunk-24AGZQVR.js} +15 -7
- package/dist/{chunk-F2CKKG6Q.mjs → chunk-3VQKDHGP.mjs} +12 -4
- package/dist/{chunk-F5XJWJYO.mjs → chunk-57SOQCAU.mjs} +5 -5
- package/dist/{chunk-GD4SQMVF.mjs → chunk-5ZYHNDEK.mjs} +98 -37
- package/dist/{chunk-FMK6SFQQ.js → chunk-DUHYLR2R.js} +7 -7
- package/dist/{chunk-OYSABARD.js → chunk-E7I5TW5K.js} +3 -2
- package/dist/{chunk-WSS26HZS.js → chunk-FS2NOOEB.js} +5 -5
- package/dist/{chunk-GC7WXUOW.js → chunk-HVNGIKLS.js} +55 -31
- package/dist/{chunk-LVSUBDJC.js → chunk-JZQBZHN5.js} +39 -39
- package/dist/{chunk-QNRJCEZN.mjs → chunk-KGTVD4EP.mjs} +66 -42
- package/dist/{chunk-HL3US2OT.mjs → chunk-NNOQDMUP.mjs} +1 -1
- package/dist/{chunk-5ONE75V7.js → chunk-OFB2KBRP.js} +175 -114
- package/dist/{chunk-AYJ4HLWZ.mjs → chunk-PCDYXXSK.mjs} +11 -4
- package/dist/{chunk-ONLKZIRQ.js → chunk-RKISS72P.js} +1 -1
- package/dist/{chunk-ZR3KN3FG.mjs → chunk-RRQZL7FQ.mjs} +2 -2
- package/dist/{chunk-UUJWDME4.mjs → chunk-XZP3MREK.mjs} +1 -1
- package/dist/{chunk-NIS74SI6.js → chunk-ZAA5ZG3D.js} +60 -53
- package/dist/{chunk-2LH6PZH3.mjs → chunk-ZCH4YINE.mjs} +3 -2
- package/dist/cli.js +2241 -169
- package/dist/cli.mjs +2246 -174
- package/dist/core.js +9 -9
- package/dist/core.mjs +3 -3
- package/dist/css-macro/postcss.js +4 -4
- package/dist/css-macro/postcss.mjs +2 -2
- package/dist/css-macro.js +5 -5
- package/dist/css-macro.mjs +2 -2
- 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 +8 -8
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +6 -6
- package/dist/presets.mjs +2 -2
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +6 -6
- package/dist/vite.mjs +5 -5
- package/dist/weapp-tw-css-import-rewrite-loader.js +10 -5
- package/dist/weapp-tw-runtime-classset-loader.js +9 -4
- package/dist/webpack.js +7 -7
- package/dist/webpack.mjs +6 -6
- package/dist/webpack4.js +59 -55
- package/dist/webpack4.mjs +28 -24
- package/package.json +11 -10
- package/scripts/postinstall.mjs +59 -0
package/bin/weapp-tailwindcss.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const fs = require('node:fs')
|
|
3
3
|
const path = require('node:path')
|
|
4
|
+
const process = require('node:process')
|
|
5
|
+
|
|
6
|
+
function isInstallLifecycle() {
|
|
7
|
+
return process.env.npm_lifecycle_event === 'postinstall' || process.env.npm_lifecycle_event === 'prepare'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isMissingRuntimeModuleError(error) {
|
|
11
|
+
return error && error.code === 'MODULE_NOT_FOUND'
|
|
12
|
+
}
|
|
4
13
|
|
|
5
14
|
const cliPath = path.resolve(__dirname, '../dist/cli.js')
|
|
6
15
|
if (fs.existsSync(cliPath)) {
|
|
7
|
-
|
|
16
|
+
try {
|
|
17
|
+
require(cliPath)
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (isInstallLifecycle() && isMissingRuntimeModuleError(error)) {
|
|
21
|
+
console.error('[weapp-tailwindcss] install lifecycle patch skipped because a runtime module is missing.')
|
|
22
|
+
console.error('Run `pnpm --filter weapp-tailwindcss build` before strict CLI validation.')
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw error
|
|
26
|
+
}
|
|
27
|
+
}
|
|
8
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
-
var
|
|
3
|
+
var _chunkRKISS72Pjs = require('./chunk-RKISS72P.js');
|
|
4
4
|
|
|
5
5
|
// src/utils/disabled.ts
|
|
6
6
|
function resolveDisabledOptions(disabled) {
|
|
@@ -19,7 +19,7 @@ function resolveDisabledOptions(disabled) {
|
|
|
19
19
|
// src/utils/resolve-package.ts
|
|
20
20
|
var _module = require('module');
|
|
21
21
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
22
|
-
var require2 = _module.createRequire.call(void 0,
|
|
22
|
+
var require2 = _module.createRequire.call(void 0, _chunkRKISS72Pjs.importMetaUrl);
|
|
23
23
|
function resolvePackageDir(name) {
|
|
24
24
|
const pkgPath = require2.resolve(`${name}/package.json`);
|
|
25
25
|
return _path2.default.dirname(pkgPath);
|
|
@@ -29,8 +29,12 @@ function resolvePackageDir(name) {
|
|
|
29
29
|
|
|
30
30
|
var QUERY_HASH_RE = /[?#].*$/u;
|
|
31
31
|
var PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
|
|
32
|
+
var WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
|
|
32
33
|
var VIRTUAL_PREFIX = "\0";
|
|
33
34
|
var JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
|
|
35
|
+
function normalizeOutputPathKey(value) {
|
|
36
|
+
return _path2.default.normalize(value).replace(/\\/g, "/");
|
|
37
|
+
}
|
|
34
38
|
function stripQueryAndHash(specifier) {
|
|
35
39
|
return specifier.replace(QUERY_HASH_RE, "");
|
|
36
40
|
}
|
|
@@ -42,11 +46,14 @@ function isResolvableSpecifier(specifier) {
|
|
|
42
46
|
if (normalized.startsWith(VIRTUAL_PREFIX)) {
|
|
43
47
|
return false;
|
|
44
48
|
}
|
|
49
|
+
if (_path2.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
45
52
|
return !PROTOCOL_RE.test(normalized);
|
|
46
53
|
}
|
|
47
54
|
function toAbsoluteOutputPath(fileName, outDir) {
|
|
48
|
-
if (_path2.default.isAbsolute(fileName)) {
|
|
49
|
-
return fileName;
|
|
55
|
+
if (_path2.default.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) {
|
|
56
|
+
return _path2.default.normalize(fileName);
|
|
50
57
|
}
|
|
51
58
|
return _path2.default.resolve(outDir, fileName);
|
|
52
59
|
}
|
|
@@ -70,8 +77,8 @@ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
|
70
77
|
}
|
|
71
78
|
const normalized = stripQueryAndHash(specifier);
|
|
72
79
|
let candidate;
|
|
73
|
-
if (_path2.default.isAbsolute(normalized)) {
|
|
74
|
-
candidate = normalized;
|
|
80
|
+
if (_path2.default.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
|
|
81
|
+
candidate = _path2.default.normalize(normalized);
|
|
75
82
|
} else if (normalized.startsWith("/")) {
|
|
76
83
|
candidate = _path2.default.resolve(outDir, normalized.slice(1));
|
|
77
84
|
} else {
|
|
@@ -172,4 +179,5 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
|
172
179
|
|
|
173
180
|
|
|
174
181
|
|
|
175
|
-
|
|
182
|
+
|
|
183
|
+
exports.normalizeOutputPathKey = normalizeOutputPathKey; exports.toAbsoluteOutputPath = toAbsoluteOutputPath; exports.resolveOutputSpecifier = resolveOutputSpecifier; exports.resolveDisabledOptions = resolveDisabledOptions; exports.resolvePackageDir = resolvePackageDir; exports.pushConcurrentTaskFactories = pushConcurrentTaskFactories; exports.resolveTailwindcssImport = resolveTailwindcssImport; exports.rewriteTailwindcssImportsInCode = rewriteTailwindcssImportsInCode;
|
|
@@ -25,8 +25,12 @@ function resolvePackageDir(name) {
|
|
|
25
25
|
import path2 from "path";
|
|
26
26
|
var QUERY_HASH_RE = /[?#].*$/u;
|
|
27
27
|
var PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
|
|
28
|
+
var WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
|
|
28
29
|
var VIRTUAL_PREFIX = "\0";
|
|
29
30
|
var JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
|
|
31
|
+
function normalizeOutputPathKey(value) {
|
|
32
|
+
return path2.normalize(value).replace(/\\/g, "/");
|
|
33
|
+
}
|
|
30
34
|
function stripQueryAndHash(specifier) {
|
|
31
35
|
return specifier.replace(QUERY_HASH_RE, "");
|
|
32
36
|
}
|
|
@@ -38,11 +42,14 @@ function isResolvableSpecifier(specifier) {
|
|
|
38
42
|
if (normalized.startsWith(VIRTUAL_PREFIX)) {
|
|
39
43
|
return false;
|
|
40
44
|
}
|
|
45
|
+
if (path2.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
41
48
|
return !PROTOCOL_RE.test(normalized);
|
|
42
49
|
}
|
|
43
50
|
function toAbsoluteOutputPath(fileName, outDir) {
|
|
44
|
-
if (path2.isAbsolute(fileName)) {
|
|
45
|
-
return fileName;
|
|
51
|
+
if (path2.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) {
|
|
52
|
+
return path2.normalize(fileName);
|
|
46
53
|
}
|
|
47
54
|
return path2.resolve(outDir, fileName);
|
|
48
55
|
}
|
|
@@ -66,8 +73,8 @@ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
|
66
73
|
}
|
|
67
74
|
const normalized = stripQueryAndHash(specifier);
|
|
68
75
|
let candidate;
|
|
69
|
-
if (path2.isAbsolute(normalized)) {
|
|
70
|
-
candidate = normalized;
|
|
76
|
+
if (path2.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) {
|
|
77
|
+
candidate = path2.normalize(normalized);
|
|
71
78
|
} else if (normalized.startsWith("/")) {
|
|
72
79
|
candidate = path2.resolve(outDir, normalized.slice(1));
|
|
73
80
|
} else {
|
|
@@ -161,6 +168,7 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
|
161
168
|
}
|
|
162
169
|
|
|
163
170
|
export {
|
|
171
|
+
normalizeOutputPathKey,
|
|
164
172
|
toAbsoluteOutputPath,
|
|
165
173
|
resolveOutputSpecifier,
|
|
166
174
|
resolveDisabledOptions,
|
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
isMpx,
|
|
12
12
|
patchMpxLoaderResolve,
|
|
13
13
|
setupMpxTailwindcssRedirect
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-RRQZL7FQ.mjs";
|
|
15
15
|
import {
|
|
16
16
|
pushConcurrentTaskFactories,
|
|
17
17
|
resolveDisabledOptions,
|
|
18
18
|
resolveOutputSpecifier,
|
|
19
19
|
resolvePackageDir,
|
|
20
20
|
toAbsoluteOutputPath
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-3VQKDHGP.mjs";
|
|
22
22
|
import {
|
|
23
23
|
processCachedTask
|
|
24
24
|
} from "./chunk-76S2EME4.mjs";
|
|
@@ -29,17 +29,17 @@ import {
|
|
|
29
29
|
pluginName,
|
|
30
30
|
setupPatchRecorder,
|
|
31
31
|
shouldSkipJsTransform
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-KGTVD4EP.mjs";
|
|
33
33
|
import {
|
|
34
34
|
getRuntimeClassSetSignature,
|
|
35
35
|
resolveTailwindcssOptions
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-PCDYXXSK.mjs";
|
|
37
37
|
import {
|
|
38
38
|
getGroupedEntries
|
|
39
39
|
} from "./chunk-OOHJLO5M.mjs";
|
|
40
40
|
import {
|
|
41
41
|
__dirname
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-NNOQDMUP.mjs";
|
|
43
43
|
|
|
44
44
|
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
45
45
|
import process3 from "process";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
normalizeOutputPathKey,
|
|
2
3
|
pushConcurrentTaskFactories,
|
|
3
4
|
resolveDisabledOptions,
|
|
4
5
|
resolveOutputSpecifier,
|
|
@@ -6,7 +7,7 @@ import {
|
|
|
6
7
|
resolveTailwindcssImport,
|
|
7
8
|
rewriteTailwindcssImportsInCode,
|
|
8
9
|
toAbsoluteOutputPath
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3VQKDHGP.mjs";
|
|
10
11
|
import {
|
|
11
12
|
processCachedTask
|
|
12
13
|
} from "./chunk-76S2EME4.mjs";
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
toCustomAttributesEntities,
|
|
28
29
|
traverse,
|
|
29
30
|
vitePluginName
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-KGTVD4EP.mjs";
|
|
31
32
|
import {
|
|
32
33
|
findNearestPackageRoot,
|
|
33
34
|
findTailwindConfig,
|
|
@@ -36,7 +37,7 @@ import {
|
|
|
36
37
|
logger,
|
|
37
38
|
resolveTailwindcssOptions,
|
|
38
39
|
resolveUniAppXOptions
|
|
39
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-PCDYXXSK.mjs";
|
|
40
41
|
import {
|
|
41
42
|
resolveUniUtsPlatform
|
|
42
43
|
} from "./chunk-OOHJLO5M.mjs";
|
|
@@ -78,7 +79,7 @@ function extractLiteralValue(path7) {
|
|
|
78
79
|
}
|
|
79
80
|
return {
|
|
80
81
|
allowDoubleQuotes,
|
|
81
|
-
literal: path7.node.value.raw,
|
|
82
|
+
literal: typeof path7.node.value === "string" ? path7.node.value : path7.node.value.raw,
|
|
82
83
|
offset: 0
|
|
83
84
|
};
|
|
84
85
|
}
|
|
@@ -261,10 +262,11 @@ function updateStaticAttributeWithLocalStyle(ms, prop, collector, content = prop
|
|
|
261
262
|
ms.update(start, end, collector.collectAndRewriteStaticClass(content ?? ""));
|
|
262
263
|
}
|
|
263
264
|
}
|
|
264
|
-
function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet
|
|
265
|
-
if (prop.exp?.type !== NodeTypes.SIMPLE_EXPRESSION
|
|
265
|
+
function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
|
|
266
|
+
if (prop.exp?.type !== NodeTypes.SIMPLE_EXPRESSION) {
|
|
266
267
|
return;
|
|
267
268
|
}
|
|
269
|
+
const expression = prop.exp.content;
|
|
268
270
|
const start = prop.exp.loc.start.offset;
|
|
269
271
|
const end = prop.exp.loc.end.offset;
|
|
270
272
|
if (start >= end) {
|
|
@@ -277,10 +279,11 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet, expression =
|
|
|
277
279
|
});
|
|
278
280
|
ms.update(start, end, generated);
|
|
279
281
|
}
|
|
280
|
-
function updateDirectiveExpressionWithLocalStyle(ms, prop, jsHandler, collector, runtimeSet
|
|
281
|
-
if (prop.exp?.type !== NodeTypes.SIMPLE_EXPRESSION
|
|
282
|
+
function updateDirectiveExpressionWithLocalStyle(ms, prop, jsHandler, collector, runtimeSet) {
|
|
283
|
+
if (prop.exp?.type !== NodeTypes.SIMPLE_EXPRESSION) {
|
|
282
284
|
return;
|
|
283
285
|
}
|
|
286
|
+
const expression = prop.exp.content;
|
|
284
287
|
const start = prop.exp.loc.start.offset;
|
|
285
288
|
const end = prop.exp.loc.end.offset;
|
|
286
289
|
if (start >= end) {
|
|
@@ -398,13 +401,18 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
|
398
401
|
${localStyleCollector.toStyleBlock()}`);
|
|
399
402
|
}
|
|
400
403
|
}
|
|
401
|
-
|
|
404
|
+
const result = {
|
|
402
405
|
code: ms.toString(),
|
|
403
|
-
|
|
404
|
-
|
|
406
|
+
map: null
|
|
407
|
+
};
|
|
408
|
+
Object.defineProperty(result, "map", {
|
|
409
|
+
configurable: true,
|
|
410
|
+
enumerable: true,
|
|
411
|
+
get() {
|
|
405
412
|
return ms.generateMap();
|
|
406
413
|
}
|
|
407
|
-
};
|
|
414
|
+
});
|
|
415
|
+
return result;
|
|
408
416
|
}
|
|
409
417
|
|
|
410
418
|
// src/bundlers/vite/query.ts
|
|
@@ -520,6 +528,9 @@ function isPreprocessorRequest(id, lang) {
|
|
|
520
528
|
function resolveUniAppXCssTarget(id) {
|
|
521
529
|
return UVUE_NVUE_RE2.test(cleanUrl(id)) ? "uvue" : void 0;
|
|
522
530
|
}
|
|
531
|
+
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
532
|
+
return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
|
|
533
|
+
}
|
|
523
534
|
function createUniAppXPlugins(options) {
|
|
524
535
|
const {
|
|
525
536
|
appType,
|
|
@@ -703,7 +714,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
703
714
|
async transform() {
|
|
704
715
|
const currentSource = originalSource.source.toString();
|
|
705
716
|
const { code, linked } = await jsHandler(currentSource, runtimeSet, createHandlerOptions(absoluteFile, {
|
|
706
|
-
uniAppX: options.uniAppX
|
|
717
|
+
uniAppX: resolveUniAppXJsTransformEnabled(options.uniAppX),
|
|
707
718
|
babelParserOptions: {
|
|
708
719
|
plugins: [
|
|
709
720
|
"typescript"
|
|
@@ -757,19 +768,24 @@ function isJavaScriptEntry(entry) {
|
|
|
757
768
|
return entry.fileName.endsWith(".js");
|
|
758
769
|
}
|
|
759
770
|
function createBundleModuleGraphOptions(outputDir, entries) {
|
|
771
|
+
const normalizedEntries = /* @__PURE__ */ new Map();
|
|
772
|
+
for (const [id, entry] of entries) {
|
|
773
|
+
normalizedEntries.set(normalizeOutputPathKey(id), entry);
|
|
774
|
+
}
|
|
775
|
+
const getEntry = (id) => entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
|
|
760
776
|
return {
|
|
761
777
|
resolve(specifier, importer) {
|
|
762
|
-
return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) =>
|
|
778
|
+
return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
|
|
763
779
|
},
|
|
764
780
|
load(id) {
|
|
765
|
-
const entry =
|
|
781
|
+
const entry = getEntry(id);
|
|
766
782
|
if (!entry) {
|
|
767
783
|
return void 0;
|
|
768
784
|
}
|
|
769
785
|
return readOutputEntry(entry);
|
|
770
786
|
},
|
|
771
787
|
filter(id) {
|
|
772
|
-
return
|
|
788
|
+
return Boolean(getEntry(id));
|
|
773
789
|
}
|
|
774
790
|
};
|
|
775
791
|
}
|
|
@@ -777,8 +793,12 @@ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
|
|
|
777
793
|
if (!linked) {
|
|
778
794
|
return;
|
|
779
795
|
}
|
|
796
|
+
const normalizedEntries = /* @__PURE__ */ new Map();
|
|
797
|
+
for (const [entryId, entry] of entries) {
|
|
798
|
+
normalizedEntries.set(normalizeOutputPathKey(entryId), entry);
|
|
799
|
+
}
|
|
780
800
|
for (const [id, { code }] of Object.entries(linked)) {
|
|
781
|
-
const entry = entries.get(id);
|
|
801
|
+
const entry = entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
|
|
782
802
|
if (!entry) {
|
|
783
803
|
continue;
|
|
784
804
|
}
|
|
@@ -889,6 +909,7 @@ function createBundleBuildState() {
|
|
|
889
909
|
return {
|
|
890
910
|
iteration: 0,
|
|
891
911
|
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
912
|
+
runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
|
|
892
913
|
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
893
914
|
linkedByEntry: /* @__PURE__ */ new Map(),
|
|
894
915
|
dependentsByLinkedFile: /* @__PURE__ */ new Map()
|
|
@@ -956,16 +977,18 @@ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
|
|
|
956
977
|
const source = readEntrySource(output);
|
|
957
978
|
const hash = opts.cache.computeHash(source);
|
|
958
979
|
sourceHashByFile.set(file, hash);
|
|
959
|
-
const runtimeAffectingSignature = createRuntimeAffectingSourceSignature(source, type);
|
|
960
|
-
runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
|
|
961
|
-
const runtimeAffectingHash = opts.cache.computeHash(runtimeAffectingSignature);
|
|
962
|
-
runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
|
|
963
980
|
const previousHash = state.sourceHashByFile.get(file);
|
|
964
981
|
const changed = previousHash == null || previousHash !== hash;
|
|
982
|
+
const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
|
|
983
|
+
const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
|
|
984
|
+
const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
|
|
985
|
+
const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
|
|
986
|
+
const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
|
|
987
|
+
runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
|
|
988
|
+
runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
|
|
965
989
|
if (changed) {
|
|
966
990
|
changedByType[type].add(file);
|
|
967
991
|
}
|
|
968
|
-
const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
|
|
969
992
|
const runtimeAffectingChanged = previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash;
|
|
970
993
|
if (runtimeAffectingChanged) {
|
|
971
994
|
runtimeAffectingChangedByType[type].add(file);
|
|
@@ -1035,6 +1058,7 @@ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
|
|
|
1035
1058
|
...state.sourceHashByFile,
|
|
1036
1059
|
...snapshot.sourceHashByFile
|
|
1037
1060
|
]) : snapshot.sourceHashByFile;
|
|
1061
|
+
state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
|
|
1038
1062
|
state.runtimeAffectingHashByFile = incremental ? new Map([
|
|
1039
1063
|
...state.runtimeAffectingHashByFile,
|
|
1040
1064
|
...snapshot.runtimeAffectingHashByFile
|
|
@@ -1076,6 +1100,9 @@ function createEmptyMetrics() {
|
|
|
1076
1100
|
function measureElapsed(start) {
|
|
1077
1101
|
return performance.now() - start;
|
|
1078
1102
|
}
|
|
1103
|
+
function resolveUniAppXJsTransformEnabled2(uniAppX) {
|
|
1104
|
+
return uniAppX === void 0 ? true : isUniAppXEnabled(uniAppX);
|
|
1105
|
+
}
|
|
1079
1106
|
function formatCacheHitRate(metric) {
|
|
1080
1107
|
if (metric.total === 0) {
|
|
1081
1108
|
return "0.00%";
|
|
@@ -1123,11 +1150,36 @@ function createJsHashSalt(runtimeSignature, linkedImpactSignature) {
|
|
|
1123
1150
|
}
|
|
1124
1151
|
return `${runtimeSignature}:linked:${linkedImpactSignature}`;
|
|
1125
1152
|
}
|
|
1153
|
+
function getSnapshotHash(snapshotMap, file, fallback) {
|
|
1154
|
+
return snapshotMap.get(file) ?? fallback;
|
|
1155
|
+
}
|
|
1126
1156
|
function hasRuntimeAffectingSourceChanges(changedByType) {
|
|
1127
1157
|
return changedByType.html.size > 0 || changedByType.js.size > 0;
|
|
1128
1158
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1159
|
+
var CSS_URL_FUNCTION_RE = /url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/gi;
|
|
1160
|
+
var CSS_PATH_INDEPENDENT_URL_RE = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/|#)/i;
|
|
1161
|
+
var CSS_IMPORT_RE = /@import\b/i;
|
|
1162
|
+
function isPathIndependentCssUrl(value) {
|
|
1163
|
+
const normalized = value.trim();
|
|
1164
|
+
return normalized.length > 0 && CSS_PATH_INDEPENDENT_URL_RE.test(normalized);
|
|
1165
|
+
}
|
|
1166
|
+
function hasPathDependentCssUrl(rawSource) {
|
|
1167
|
+
CSS_URL_FUNCTION_RE.lastIndex = 0;
|
|
1168
|
+
let match = CSS_URL_FUNCTION_RE.exec(rawSource);
|
|
1169
|
+
while (match !== null) {
|
|
1170
|
+
const value = match[1] ?? match[2] ?? match[3] ?? "";
|
|
1171
|
+
if (!isPathIndependentCssUrl(value)) {
|
|
1172
|
+
return true;
|
|
1173
|
+
}
|
|
1174
|
+
match = CSS_URL_FUNCTION_RE.exec(rawSource);
|
|
1175
|
+
}
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
1178
|
+
function createCssTransformShareScope(file, rawSource) {
|
|
1179
|
+
if (CSS_IMPORT_RE.test(rawSource) || hasPathDependentCssUrl(rawSource)) {
|
|
1180
|
+
return `dir:${normalizeOutputPathKey(path3.dirname(file))}`;
|
|
1181
|
+
}
|
|
1182
|
+
return "global";
|
|
1131
1183
|
}
|
|
1132
1184
|
function hasOmittedKnownBundleFiles(currentBundleFiles, previousBundleFiles) {
|
|
1133
1185
|
const currentFileSet = new Set(currentBundleFiles);
|
|
@@ -1258,6 +1310,11 @@ function createGenerateBundleHook(context) {
|
|
|
1258
1310
|
);
|
|
1259
1311
|
}
|
|
1260
1312
|
const jsEntries = snapshot.jsEntries;
|
|
1313
|
+
const normalizedJsEntries = /* @__PURE__ */ new Map();
|
|
1314
|
+
for (const [id, entry] of jsEntries) {
|
|
1315
|
+
normalizedJsEntries.set(normalizeOutputPathKey(id), entry);
|
|
1316
|
+
}
|
|
1317
|
+
const getJsEntry = (id) => jsEntries.get(id) ?? normalizedJsEntries.get(normalizeOutputPathKey(id));
|
|
1261
1318
|
const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
|
|
1262
1319
|
const runtimeStart = performance.now();
|
|
1263
1320
|
const runtime = useBundleRuntimeClassSet ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv) : await context.ensureRuntimeClassSet(forceRuntimeRefreshByEnv);
|
|
@@ -1317,8 +1374,8 @@ function createGenerateBundleHook(context) {
|
|
|
1317
1374
|
processCachedTask({
|
|
1318
1375
|
cache,
|
|
1319
1376
|
cacheKey: file,
|
|
1320
|
-
rawSource,
|
|
1321
1377
|
hashKey: `${file}:html:${runtimeSignature}`,
|
|
1378
|
+
hash: getSnapshotHash(snapshot.sourceHashByFile, file, rawSource),
|
|
1322
1379
|
applyResult(source) {
|
|
1323
1380
|
originalSource.source = source;
|
|
1324
1381
|
},
|
|
@@ -1365,14 +1422,15 @@ function createGenerateBundleHook(context) {
|
|
|
1365
1422
|
metrics.css.total++;
|
|
1366
1423
|
const rawSource = originalEntrySource;
|
|
1367
1424
|
const cssRuntimeAffectingSignature = snapshot.runtimeAffectingSignatureByFile.get(file) ?? rawSource;
|
|
1368
|
-
const
|
|
1369
|
-
const
|
|
1425
|
+
const cssShareScope = createCssTransformShareScope(file, rawSource);
|
|
1426
|
+
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
1427
|
+
const cssSharedCacheKey = `${cssShareScope}:${runtimeSignature}:${runtimeState.twPatcher.majorVersion ?? "unknown"}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingSignature}`;
|
|
1370
1428
|
tasks.push(
|
|
1371
1429
|
processCachedTask({
|
|
1372
1430
|
cache,
|
|
1373
1431
|
cacheKey: file,
|
|
1374
1432
|
hashKey: `${file}:css:${runtimeSignature}:${runtimeState.twPatcher.majorVersion ?? "unknown"}`,
|
|
1375
|
-
|
|
1433
|
+
hash: getSnapshotHash(snapshot.runtimeAffectingHashByFile, file, cssRuntimeAffectingSignature),
|
|
1376
1434
|
applyResult(source) {
|
|
1377
1435
|
originalSource.source = source;
|
|
1378
1436
|
},
|
|
@@ -1445,8 +1503,7 @@ function createGenerateBundleHook(context) {
|
|
|
1445
1503
|
cache,
|
|
1446
1504
|
cacheKey: file,
|
|
1447
1505
|
hashKey: `${file}:js`,
|
|
1448
|
-
|
|
1449
|
-
/*${hashSalt}*/`,
|
|
1506
|
+
hash: `${getSnapshotHash(snapshot.sourceHashByFile, file, initialRawSource)}:${hashSalt}`,
|
|
1450
1507
|
applyResult(source) {
|
|
1451
1508
|
originalSource.code = source;
|
|
1452
1509
|
},
|
|
@@ -1475,7 +1532,7 @@ function createGenerateBundleHook(context) {
|
|
|
1475
1532
|
debug3("js handle: %s", file);
|
|
1476
1533
|
if (linked) {
|
|
1477
1534
|
for (const id of Object.keys(linked)) {
|
|
1478
|
-
const linkedEntry =
|
|
1535
|
+
const linkedEntry = getJsEntry(id);
|
|
1479
1536
|
if (linkedEntry && linkedSet) {
|
|
1480
1537
|
linkedSet.add(linkedEntry.fileName);
|
|
1481
1538
|
}
|
|
@@ -1497,7 +1554,7 @@ function createGenerateBundleHook(context) {
|
|
|
1497
1554
|
const wrappedApplyLinkedUpdates = (linked) => {
|
|
1498
1555
|
if (linked) {
|
|
1499
1556
|
for (const id of Object.keys(linked)) {
|
|
1500
|
-
const linkedEntry =
|
|
1557
|
+
const linkedEntry = getJsEntry(id);
|
|
1501
1558
|
if (linkedEntry && linkedSet) {
|
|
1502
1559
|
linkedSet.add(linkedEntry.fileName);
|
|
1503
1560
|
}
|
|
@@ -1541,7 +1598,7 @@ function createGenerateBundleHook(context) {
|
|
|
1541
1598
|
const currentSource = originalEntrySource;
|
|
1542
1599
|
const absoluteFile = path3.resolve(outDir, file);
|
|
1543
1600
|
const precheckOptions = createHandlerOptions(absoluteFile, {
|
|
1544
|
-
uniAppX: uniAppX
|
|
1601
|
+
uniAppX: resolveUniAppXJsTransformEnabled2(uniAppX),
|
|
1545
1602
|
babelParserOptions: {
|
|
1546
1603
|
plugins: ["typescript"],
|
|
1547
1604
|
sourceType: "unambiguous"
|
|
@@ -2114,6 +2171,13 @@ var debug2 = createDebug();
|
|
|
2114
2171
|
var weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
2115
2172
|
var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
2116
2173
|
var PACKAGE_JSON_FILE2 = "package.json";
|
|
2174
|
+
function getPostcssPluginName(plugin) {
|
|
2175
|
+
if (!plugin || typeof plugin !== "object" || !("postcssPlugin" in plugin)) {
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
const { postcssPlugin } = plugin;
|
|
2179
|
+
return typeof postcssPlugin === "string" ? postcssPlugin : void 0;
|
|
2180
|
+
}
|
|
2117
2181
|
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
2118
2182
|
const resolvedRoot = path6.resolve(root);
|
|
2119
2183
|
if (!existsSync2(resolvedRoot)) {
|
|
@@ -2344,10 +2408,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
2344
2408
|
}
|
|
2345
2409
|
if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
|
|
2346
2410
|
const postcssPlugins = config.css.postcss.plugins;
|
|
2347
|
-
const idx = postcssPlugins.findIndex((x) => (
|
|
2348
|
-
// @ts-ignore
|
|
2349
|
-
x.postcssPlugin === "postcss-html-transform"
|
|
2350
|
-
));
|
|
2411
|
+
const idx = postcssPlugins.findIndex((x) => getPostcssPluginName(x) === "postcss-html-transform");
|
|
2351
2412
|
if (idx > -1) {
|
|
2352
2413
|
postcssPlugins.splice(idx, 1, postcssHtmlTransform());
|
|
2353
2414
|
debug2("remove postcss-html-transform plugin from vite config");
|
|
@@ -8,7 +8,7 @@ var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkHVNGIKLSjs = require('./chunk-HVNGIKLS.js');
|
|
12
12
|
|
|
13
13
|
// src/bundlers/gulp/index.ts
|
|
14
14
|
var _buffer = require('buffer');
|
|
@@ -16,12 +16,12 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
|
16
16
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
17
17
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
18
18
|
var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
|
|
19
|
-
var debug =
|
|
19
|
+
var debug = _chunkHVNGIKLSjs.createDebug.call(void 0, );
|
|
20
20
|
var Transform = _stream2.default.Transform;
|
|
21
21
|
function createPlugins(options = {}) {
|
|
22
|
-
const opts =
|
|
22
|
+
const opts = _chunkHVNGIKLSjs.getCompilerContext.call(void 0, options);
|
|
23
23
|
const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
|
|
24
|
-
const patchRecorderState =
|
|
24
|
+
const patchRecorderState = _chunkHVNGIKLSjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
25
25
|
source: "runtime",
|
|
26
26
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
27
27
|
});
|
|
@@ -39,13 +39,13 @@ function createPlugins(options = {}) {
|
|
|
39
39
|
const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
|
|
40
40
|
let runtimeSetInitialized = false;
|
|
41
41
|
async function refreshRuntimeState(force) {
|
|
42
|
-
await
|
|
42
|
+
await _chunkHVNGIKLSjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
43
43
|
}
|
|
44
44
|
async function refreshRuntimeSet(force = false) {
|
|
45
45
|
if (!force && runtimeSetInitialized) {
|
|
46
46
|
return runtimeSet;
|
|
47
47
|
}
|
|
48
|
-
runtimeSet = await
|
|
48
|
+
runtimeSet = await _chunkHVNGIKLSjs.ensureRuntimeClassSet.call(void 0, runtimeState, {
|
|
49
49
|
forceRefresh: force,
|
|
50
50
|
forceCollect: force,
|
|
51
51
|
clearCache: force,
|
|
@@ -226,7 +226,7 @@ function createPlugins(options = {}) {
|
|
|
226
226
|
async transform() {
|
|
227
227
|
await runtimeState.patchPromise;
|
|
228
228
|
const currentSource = _nullishCoalesce(_optionalChain([file, 'access', _2 => _2.contents, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]), () => ( rawSource));
|
|
229
|
-
if (
|
|
229
|
+
if (_chunkHVNGIKLSjs.shouldSkipJsTransform.call(void 0, currentSource, handlerOptions)) {
|
|
230
230
|
return { result: currentSource };
|
|
231
231
|
}
|
|
232
232
|
const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
@@ -33,12 +33,13 @@ function ifndef(text) {
|
|
|
33
33
|
}
|
|
34
34
|
var QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
35
35
|
function matchCustomPropertyFromValue(str, cb) {
|
|
36
|
-
let arr;
|
|
37
36
|
let index = 0;
|
|
38
37
|
QUERY_KEY_REGEX.lastIndex = 0;
|
|
39
|
-
|
|
38
|
+
let arr = QUERY_KEY_REGEX.exec(str);
|
|
39
|
+
while (arr !== null) {
|
|
40
40
|
cb(arr, index);
|
|
41
41
|
index++;
|
|
42
|
+
arr = QUERY_KEY_REGEX.exec(str);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
var
|
|
3
|
+
var _chunk24AGZQVRjs = require('./chunk-24AGZQVR.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkHVNGIKLSjs = require('./chunk-HVNGIKLS.js');
|
|
7
7
|
|
|
8
8
|
// src/shared/mpx.ts
|
|
9
9
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
@@ -145,7 +145,7 @@ function rewriteTailwindcssRequestForCss(data, pkgDir, appType) {
|
|
|
145
145
|
if (!CSS_EXT_RE2.test(normalizedIssuer)) {
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
const resolved =
|
|
148
|
+
const resolved = _chunk24AGZQVRjs.resolveTailwindcssImport.call(void 0, request, pkgDir, { appType });
|
|
149
149
|
if (!resolved) {
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
@@ -155,8 +155,8 @@ function applyTailwindcssCssImportRewrite(compiler, options) {
|
|
|
155
155
|
if (!options.enabled) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
compiler.hooks.normalModuleFactory.tap(
|
|
159
|
-
factory.hooks.beforeResolve.tap(
|
|
158
|
+
compiler.hooks.normalModuleFactory.tap(_chunkHVNGIKLSjs.pluginName, (factory) => {
|
|
159
|
+
factory.hooks.beforeResolve.tap(_chunkHVNGIKLSjs.pluginName, (data) => {
|
|
160
160
|
rewriteTailwindcssRequestForCss(data, options.pkgDir, options.appType);
|
|
161
161
|
});
|
|
162
162
|
});
|