weapp-tailwindcss 4.8.7 → 4.8.9
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-JYHBNTYH.mjs → chunk-3BMQ6ZWL.mjs} +2 -2
- package/dist/{chunk-ZB6MFKXJ.mjs → chunk-3IP5JCFZ.mjs} +1 -1
- package/dist/{chunk-ZSTF2AEN.js → chunk-3URI7W6X.js} +11 -1
- package/dist/chunk-4KBHUV2C.js +136 -0
- package/dist/{chunk-KRRIFURM.mjs → chunk-5ROWVF7O.mjs} +191 -127
- package/dist/{chunk-MIC6E7DV.mjs → chunk-6OE4Q2BC.mjs} +100 -29
- package/dist/{chunk-5F64FE7K.js → chunk-6UW6DOPI.js} +5 -5
- package/dist/chunk-AGWNHP3C.mjs +136 -0
- package/dist/chunk-BYXBJQAS.js +1 -0
- package/dist/{chunk-BMUQ4OAB.mjs → chunk-FYYIFZ36.mjs} +13 -107
- package/dist/{chunk-YQQ3HDQD.mjs → chunk-H6YMPVI6.mjs} +2 -2
- package/dist/{chunk-JW7P34IH.mjs → chunk-HXYNNE6Q.mjs} +178 -59
- package/dist/{chunk-3XGTIDA6.mjs → chunk-IXK4ZWFR.mjs} +337 -169
- package/dist/{chunk-322IEI2K.js → chunk-J25ZFRYM.js} +172 -53
- package/dist/{chunk-GORSBZA2.js → chunk-M4NERJO7.js} +1 -1
- package/dist/{chunk-VONLQCG7.js → chunk-PBUQRF6F.js} +211 -147
- package/dist/{chunk-DKPIYG24.mjs → chunk-QF65JGNW.mjs} +11 -1
- package/dist/{chunk-ESYZLHZI.js → chunk-S2YGU6BU.js} +354 -186
- package/dist/{chunk-U4WEDSBF.js → chunk-XQKBWIFI.js} +7 -7
- package/dist/{chunk-WUJAJ42W.js → chunk-Z366CKKB.js} +118 -47
- package/dist/{chunk-7BASRP3P.js → chunk-ZTGB2D5W.js} +24 -118
- package/dist/cli.js +39 -32
- package/dist/cli.mjs +12 -5
- package/dist/core.js +11 -11
- package/dist/core.mjs +5 -5
- 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/gulp.js +7 -7
- package/dist/gulp.mjs +6 -6
- package/dist/index.js +11 -11
- package/dist/index.mjs +10 -10
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +4 -4
- package/dist/presets.mjs +2 -2
- package/dist/reset.js +1 -1
- package/dist/reset.mjs +1 -1
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +8 -8
- package/dist/vite.mjs +7 -7
- package/dist/{weapp-tw-runtime-loader.js → weapp-tw-css-import-rewrite-loader.js} +49 -18
- package/dist/weapp-tw-runtime-classset-loader.js +23 -0
- package/dist/webpack.d.mts +0 -1
- package/dist/webpack.d.ts +0 -1
- package/dist/webpack.js +9 -9
- package/dist/webpack.mjs +8 -8
- package/dist/webpack4.d.mts +0 -1
- package/dist/webpack4.d.ts +0 -1
- package/dist/webpack4.js +123 -48
- package/dist/webpack4.mjs +105 -30
- package/package.json +4 -4
- package/dist/chunk-PFUB74BL.mjs +0 -61
- package/dist/chunk-WYXD5IW7.js +0 -61
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkJ25ZFRYMjs = require('./chunk-J25ZFRYM.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunk6UW6DOPIjs = require('./chunk-6UW6DOPI.js');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -22,7 +22,7 @@ var _chunk5F64FE7Kjs = require('./chunk-5F64FE7K.js');
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var _chunkZTGB2D5Wjs = require('./chunk-ZTGB2D5W.js');
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -33,7 +33,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
|
33
33
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
34
34
|
var _htmltransform = require('@weapp-tailwindcss/postcss/html-transform'); var _htmltransform2 = _interopRequireDefault(_htmltransform);
|
|
35
35
|
|
|
36
|
-
// src/uni-app-x/
|
|
36
|
+
// src/uni-app-x/transform.ts
|
|
37
37
|
var _compilerdom = require('@vue/compiler-dom');
|
|
38
38
|
var _compilersfc = require('@vue/compiler-sfc');
|
|
39
39
|
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
|
|
@@ -54,7 +54,7 @@ function updateStaticAttribute(ms, prop) {
|
|
|
54
54
|
const start = prop.value.loc.start.offset + 1;
|
|
55
55
|
const end = prop.value.loc.end.offset - 1;
|
|
56
56
|
if (start < end) {
|
|
57
|
-
ms.update(start, end,
|
|
57
|
+
ms.update(start, end, _chunkZTGB2D5Wjs.replaceWxml.call(void 0, prop.value.content));
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
|
|
@@ -66,7 +66,7 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
|
|
|
66
66
|
if (start >= end) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
const generated =
|
|
69
|
+
const generated = _chunkZTGB2D5Wjs.generateCode.call(void 0, prop.exp.content, {
|
|
70
70
|
jsHandler,
|
|
71
71
|
runtimeSet,
|
|
72
72
|
wrapExpression: true
|
|
@@ -95,7 +95,7 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
97
|
const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
|
|
98
|
-
const matchCustomAttribute =
|
|
98
|
+
const matchCustomAttribute = _chunkZTGB2D5Wjs.createAttributeMatcher.call(void 0, customAttributesEntities);
|
|
99
99
|
const ms = new (0, _magicstring2.default)(code);
|
|
100
100
|
const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
|
|
101
101
|
if (errors.length === 0) {
|
|
@@ -217,9 +217,152 @@ async function formatPostcssSourceMap(rawMap, file) {
|
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
// src/uni-app-x/vite.ts
|
|
221
|
+
function createUniAppXPlugins(options) {
|
|
222
|
+
const {
|
|
223
|
+
appType,
|
|
224
|
+
customAttributesEntities,
|
|
225
|
+
disabledDefaultTemplateHandler,
|
|
226
|
+
mainCssChunkMatcher,
|
|
227
|
+
runtimeState,
|
|
228
|
+
styleHandler,
|
|
229
|
+
jsHandler,
|
|
230
|
+
ensureRuntimeClassSet,
|
|
231
|
+
getResolvedConfig
|
|
232
|
+
} = options;
|
|
233
|
+
const cssPlugins = [void 0, "pre"].map((enforce) => ({
|
|
234
|
+
name: `weapp-tailwindcss:uni-app-x:css${enforce ? `:${enforce}` : ""}`,
|
|
235
|
+
enforce,
|
|
236
|
+
async transform(code, id) {
|
|
237
|
+
await runtimeState.patchPromise;
|
|
238
|
+
const { query } = parseVueRequest(id);
|
|
239
|
+
if (isCSSRequest(id) || query.vue && query.type === "style") {
|
|
240
|
+
const postcssResult = await styleHandler(code, {
|
|
241
|
+
isMainChunk: mainCssChunkMatcher(id, appType),
|
|
242
|
+
postcssOptions: {
|
|
243
|
+
options: {
|
|
244
|
+
from: id,
|
|
245
|
+
map: {
|
|
246
|
+
inline: false,
|
|
247
|
+
annotation: false,
|
|
248
|
+
// PostCSS 可能返回虚拟文件,因此需要启用这一项以获取源内容
|
|
249
|
+
sourcesContent: true
|
|
250
|
+
// 若上游预处理器已经生成 source map,sources 中可能出现重复条目
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
const rawPostcssMap = postcssResult.map.toJSON();
|
|
256
|
+
const postcssMap = await formatPostcssSourceMap(
|
|
257
|
+
rawPostcssMap,
|
|
258
|
+
cleanUrl(id)
|
|
259
|
+
);
|
|
260
|
+
return {
|
|
261
|
+
code: postcssResult.css,
|
|
262
|
+
map: postcssMap
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
const nvuePlugin = {
|
|
268
|
+
name: "weapp-tailwindcss:uni-app-x:nvue",
|
|
269
|
+
enforce: "pre",
|
|
270
|
+
async buildStart() {
|
|
271
|
+
await ensureRuntimeClassSet(true);
|
|
272
|
+
},
|
|
273
|
+
async transform(code, id) {
|
|
274
|
+
if (!/\.(?:uvue|nvue)(?:\?.*)?$/.test(id)) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const resolvedConfig = getResolvedConfig();
|
|
278
|
+
const isServeCommand = _optionalChain([resolvedConfig, 'optionalAccess', _8 => _8.command]) === "serve";
|
|
279
|
+
const isWatchBuild = _optionalChain([resolvedConfig, 'optionalAccess', _9 => _9.command]) === "build" && !!_optionalChain([resolvedConfig, 'access', _10 => _10.build, 'optionalAccess', _11 => _11.watch]);
|
|
280
|
+
const isNonWatchBuild = _optionalChain([resolvedConfig, 'optionalAccess', _12 => _12.command]) === "build" && !_optionalChain([resolvedConfig, 'access', _13 => _13.build, 'optionalAccess', _14 => _14.watch]);
|
|
281
|
+
const shouldForceRefresh = isServeCommand || isWatchBuild || isNonWatchBuild;
|
|
282
|
+
const currentRuntimeSet = shouldForceRefresh ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
283
|
+
const extraOptions = customAttributesEntities.length > 0 || disabledDefaultTemplateHandler ? {
|
|
284
|
+
customAttributesEntities,
|
|
285
|
+
disabledDefaultTemplateHandler
|
|
286
|
+
} : void 0;
|
|
287
|
+
if (extraOptions) {
|
|
288
|
+
return transformUVue(code, id, jsHandler, currentRuntimeSet, extraOptions);
|
|
289
|
+
}
|
|
290
|
+
return transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
291
|
+
},
|
|
292
|
+
async handleHotUpdate(ctx) {
|
|
293
|
+
const resolvedConfig = getResolvedConfig();
|
|
294
|
+
if (_optionalChain([resolvedConfig, 'optionalAccess', _15 => _15.command]) !== "serve") {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (!/\.(?:uvue|nvue)$/.test(ctx.file)) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
await ensureRuntimeClassSet(true);
|
|
301
|
+
},
|
|
302
|
+
async watchChange(id) {
|
|
303
|
+
const resolvedConfig = getResolvedConfig();
|
|
304
|
+
if (_optionalChain([resolvedConfig, 'optionalAccess', _16 => _16.command]) !== "build" || !_optionalChain([resolvedConfig, 'access', _17 => _17.build, 'optionalAccess', _18 => _18.watch])) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (!/\.(?:uvue|nvue)(?:\?.*)?$/.test(id)) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
await ensureRuntimeClassSet(true);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
return [
|
|
314
|
+
...cssPlugins,
|
|
315
|
+
nvuePlugin
|
|
316
|
+
];
|
|
317
|
+
}
|
|
318
|
+
function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
319
|
+
return async () => {
|
|
320
|
+
const {
|
|
321
|
+
cache,
|
|
322
|
+
createHandlerOptions,
|
|
323
|
+
debug: debug2,
|
|
324
|
+
jsHandler,
|
|
325
|
+
onUpdate,
|
|
326
|
+
runtimeSet,
|
|
327
|
+
applyLinkedResults: applyLinkedResults2
|
|
328
|
+
} = options;
|
|
329
|
+
const absoluteFile = _chunkJ25ZFRYMjs.toAbsoluteOutputPath.call(void 0, file, outDir);
|
|
330
|
+
const rawSource = originalSource.source.toString();
|
|
331
|
+
await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
332
|
+
cache,
|
|
333
|
+
cacheKey: file,
|
|
334
|
+
rawSource,
|
|
335
|
+
applyResult(source) {
|
|
336
|
+
originalSource.source = source;
|
|
337
|
+
},
|
|
338
|
+
onCacheHit() {
|
|
339
|
+
debug2("js cache hit: %s", file);
|
|
340
|
+
},
|
|
341
|
+
async transform() {
|
|
342
|
+
const currentSource = originalSource.source.toString();
|
|
343
|
+
const { code, linked } = await jsHandler(currentSource, runtimeSet, createHandlerOptions(absoluteFile, {
|
|
344
|
+
uniAppX: _nullishCoalesce(options.uniAppX, () => ( true)),
|
|
345
|
+
babelParserOptions: {
|
|
346
|
+
plugins: [
|
|
347
|
+
"typescript"
|
|
348
|
+
],
|
|
349
|
+
sourceType: "unambiguous"
|
|
350
|
+
}
|
|
351
|
+
}));
|
|
352
|
+
onUpdate(file, currentSource, code);
|
|
353
|
+
debug2("js handle: %s", file);
|
|
354
|
+
applyLinkedResults2(linked);
|
|
355
|
+
return {
|
|
356
|
+
result: code
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
220
363
|
// src/bundlers/vite/index.ts
|
|
221
|
-
var debug =
|
|
222
|
-
var weappTailwindcssPackageDir =
|
|
364
|
+
var debug = _chunkZTGB2D5Wjs.createDebug.call(void 0, );
|
|
365
|
+
var weappTailwindcssPackageDir = _chunkJ25ZFRYMjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
223
366
|
var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
224
367
|
function joinPosixPath(base, subpath) {
|
|
225
368
|
if (base.endsWith("/")) {
|
|
@@ -263,7 +406,7 @@ function isJavaScriptEntry(entry) {
|
|
|
263
406
|
function createBundleModuleGraphOptions(outputDir, entries) {
|
|
264
407
|
return {
|
|
265
408
|
resolve(specifier, importer) {
|
|
266
|
-
return
|
|
409
|
+
return _chunkJ25ZFRYMjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => entries.has(candidate));
|
|
267
410
|
},
|
|
268
411
|
load(id) {
|
|
269
412
|
const entry = entries.get(id);
|
|
@@ -295,13 +438,13 @@ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
|
|
|
295
438
|
} else {
|
|
296
439
|
entry.output.source = code;
|
|
297
440
|
}
|
|
298
|
-
_optionalChain([onApplied, 'optionalCall',
|
|
441
|
+
_optionalChain([onApplied, 'optionalCall', _19 => _19(entry, code)]);
|
|
299
442
|
onLinkedUpdate(entry.fileName, previous, code);
|
|
300
443
|
}
|
|
301
444
|
}
|
|
302
445
|
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
303
446
|
const rewriteCssImportsSpecified = Object.prototype.hasOwnProperty.call(options, "rewriteCssImports");
|
|
304
|
-
const opts =
|
|
447
|
+
const opts = _chunkZTGB2D5Wjs.getCompilerContext.call(void 0, options);
|
|
305
448
|
const {
|
|
306
449
|
disabled,
|
|
307
450
|
customAttributes,
|
|
@@ -323,8 +466,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
323
466
|
if (disabled) {
|
|
324
467
|
return;
|
|
325
468
|
}
|
|
326
|
-
const customAttributesEntities =
|
|
327
|
-
const patchRecorderState =
|
|
469
|
+
const customAttributesEntities = _chunkZTGB2D5Wjs.toCustomAttributesEntities.call(void 0, customAttributes);
|
|
470
|
+
const patchRecorderState = _chunk6UW6DOPIjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
328
471
|
source: "runtime",
|
|
329
472
|
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
330
473
|
});
|
|
@@ -338,7 +481,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
338
481
|
let runtimeSetPromise;
|
|
339
482
|
let resolvedConfig;
|
|
340
483
|
async function refreshRuntimeState(force) {
|
|
341
|
-
const refreshed = await
|
|
484
|
+
const refreshed = await _chunkZTGB2D5Wjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
342
485
|
if (refreshed) {
|
|
343
486
|
runtimeSet = void 0;
|
|
344
487
|
runtimeSetPromise = void 0;
|
|
@@ -351,7 +494,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
351
494
|
return runtimeSet;
|
|
352
495
|
}
|
|
353
496
|
if (force || !runtimeSetPromise) {
|
|
354
|
-
const task2 =
|
|
497
|
+
const task2 = _chunkZTGB2D5Wjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
|
|
355
498
|
force: force || !runtimeSet,
|
|
356
499
|
skipRefresh: force
|
|
357
500
|
});
|
|
@@ -371,12 +514,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
371
514
|
const shouldRewriteCssImports = opts.rewriteCssImports !== false && (rewriteCssImportsSpecified || (_nullishCoalesce(runtimeState.twPatcher.majorVersion, () => ( 0))) >= 4);
|
|
372
515
|
const rewritePlugins = !shouldRewriteCssImports ? [] : [
|
|
373
516
|
{
|
|
374
|
-
name: `${
|
|
517
|
+
name: `${_chunkZTGB2D5Wjs.vitePluginName}:rewrite-css-imports`,
|
|
375
518
|
enforce: "pre",
|
|
376
519
|
resolveId: {
|
|
377
520
|
order: "pre",
|
|
378
521
|
handler(id, importer) {
|
|
379
|
-
const replacement =
|
|
522
|
+
const replacement = _chunkJ25ZFRYMjs.resolveTailwindcssImport.call(void 0, id, weappTailwindcssDirPosix, {
|
|
523
|
+
join: joinPosixPath,
|
|
524
|
+
appType
|
|
525
|
+
});
|
|
380
526
|
if (!replacement) {
|
|
381
527
|
return null;
|
|
382
528
|
}
|
|
@@ -392,7 +538,10 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
392
538
|
if (!isCSSRequest(id)) {
|
|
393
539
|
return null;
|
|
394
540
|
}
|
|
395
|
-
const rewritten =
|
|
541
|
+
const rewritten = _chunkJ25ZFRYMjs.rewriteTailwindcssImportsInCode.call(void 0, code, weappTailwindcssDirPosix, {
|
|
542
|
+
join: joinPosixPath,
|
|
543
|
+
appType
|
|
544
|
+
});
|
|
396
545
|
if (!rewritten) {
|
|
397
546
|
return null;
|
|
398
547
|
}
|
|
@@ -404,10 +553,22 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
404
553
|
}
|
|
405
554
|
}
|
|
406
555
|
];
|
|
556
|
+
const getResolvedConfig = () => resolvedConfig;
|
|
557
|
+
const uniAppXPlugins = uniAppX ? createUniAppXPlugins({
|
|
558
|
+
appType,
|
|
559
|
+
customAttributesEntities,
|
|
560
|
+
disabledDefaultTemplateHandler,
|
|
561
|
+
mainCssChunkMatcher,
|
|
562
|
+
runtimeState,
|
|
563
|
+
styleHandler,
|
|
564
|
+
jsHandler,
|
|
565
|
+
ensureRuntimeClassSet,
|
|
566
|
+
getResolvedConfig
|
|
567
|
+
}) : void 0;
|
|
407
568
|
const plugins = [
|
|
408
569
|
...rewritePlugins,
|
|
409
570
|
{
|
|
410
|
-
name: `${
|
|
571
|
+
name: `${_chunkZTGB2D5Wjs.vitePluginName}:post`,
|
|
411
572
|
enforce: "post",
|
|
412
573
|
configResolved(config) {
|
|
413
574
|
resolvedConfig = config;
|
|
@@ -427,13 +588,13 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
427
588
|
debug("start");
|
|
428
589
|
onStart();
|
|
429
590
|
const entries = Object.entries(bundle);
|
|
430
|
-
const rootDir = _optionalChain([resolvedConfig, 'optionalAccess',
|
|
431
|
-
const outDir = _optionalChain([resolvedConfig, 'optionalAccess',
|
|
591
|
+
const rootDir = _optionalChain([resolvedConfig, 'optionalAccess', _20 => _20.root]) ? _path2.default.resolve(resolvedConfig.root) : _process2.default.cwd();
|
|
592
|
+
const outDir = _optionalChain([resolvedConfig, 'optionalAccess', _21 => _21.build, 'optionalAccess', _22 => _22.outDir]) ? _path2.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
432
593
|
const jsEntries = /* @__PURE__ */ new Map();
|
|
433
594
|
for (const [fileName, output] of entries) {
|
|
434
595
|
const entry = { fileName, output };
|
|
435
596
|
if (isJavaScriptEntry(entry)) {
|
|
436
|
-
const absolute =
|
|
597
|
+
const absolute = _chunkJ25ZFRYMjs.toAbsoluteOutputPath.call(void 0, fileName, outDir);
|
|
437
598
|
jsEntries.set(absolute, entry);
|
|
438
599
|
}
|
|
439
600
|
}
|
|
@@ -455,12 +616,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
455
616
|
}
|
|
456
617
|
});
|
|
457
618
|
};
|
|
619
|
+
const applyLinkedUpdates = (linked) => {
|
|
620
|
+
applyLinkedResults(linked, jsEntries, handleLinkedUpdate, scheduleLinkedApply);
|
|
621
|
+
};
|
|
458
622
|
const createHandlerOptions = (absoluteFilename, extra) => ({
|
|
459
623
|
...extra,
|
|
460
624
|
filename: absoluteFilename,
|
|
461
625
|
moduleGraph: moduleGraphOptions,
|
|
462
626
|
babelParserOptions: {
|
|
463
|
-
..._nullishCoalesce(_optionalChain([extra, 'optionalAccess',
|
|
627
|
+
..._nullishCoalesce(_optionalChain([extra, 'optionalAccess', _23 => _23.babelParserOptions]), () => ( {})),
|
|
464
628
|
sourceFilename: absoluteFilename
|
|
465
629
|
}
|
|
466
630
|
});
|
|
@@ -481,7 +645,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
481
645
|
},
|
|
482
646
|
async transform() {
|
|
483
647
|
const transformed = await templateHandler(rawSource, {
|
|
484
|
-
runtimeSet
|
|
648
|
+
runtimeSet: runtime
|
|
485
649
|
});
|
|
486
650
|
onUpdate(file, rawSource, transformed);
|
|
487
651
|
debug("html handle: %s", file);
|
|
@@ -497,7 +661,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
497
661
|
if (Array.isArray(groupedEntries.js)) {
|
|
498
662
|
for (const [file, originalSource] of groupedEntries.js) {
|
|
499
663
|
if (originalSource.type === "chunk") {
|
|
500
|
-
const absoluteFile =
|
|
664
|
+
const absoluteFile = _chunkJ25ZFRYMjs.toAbsoluteOutputPath.call(void 0, file, outDir);
|
|
501
665
|
const initialRawSource = originalSource.code;
|
|
502
666
|
jsTaskFactories.push(async () => {
|
|
503
667
|
await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
|
|
@@ -512,10 +676,10 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
512
676
|
},
|
|
513
677
|
async transform() {
|
|
514
678
|
const rawSource = originalSource.code;
|
|
515
|
-
const { code, linked } = await jsHandler(rawSource,
|
|
679
|
+
const { code, linked } = await jsHandler(rawSource, runtime, createHandlerOptions(absoluteFile));
|
|
516
680
|
onUpdate(file, rawSource, code);
|
|
517
681
|
debug("js handle: %s", file);
|
|
518
|
-
|
|
682
|
+
applyLinkedUpdates(linked);
|
|
519
683
|
return {
|
|
520
684
|
result: code
|
|
521
685
|
};
|
|
@@ -523,39 +687,23 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
523
687
|
});
|
|
524
688
|
});
|
|
525
689
|
} else if (uniAppX && originalSource.type === "asset") {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
const currentSource = originalSource.source.toString();
|
|
541
|
-
const { code, linked } = await jsHandler(currentSource, runtimeSet, createHandlerOptions(absoluteFile, {
|
|
542
|
-
uniAppX,
|
|
543
|
-
babelParserOptions: {
|
|
544
|
-
plugins: [
|
|
545
|
-
"typescript"
|
|
546
|
-
],
|
|
547
|
-
sourceType: "unambiguous"
|
|
548
|
-
}
|
|
549
|
-
}));
|
|
550
|
-
onUpdate(file, currentSource, code);
|
|
551
|
-
debug("js handle: %s", file);
|
|
552
|
-
applyLinkedResults(linked, jsEntries, handleLinkedUpdate, scheduleLinkedApply);
|
|
553
|
-
return {
|
|
554
|
-
result: code
|
|
555
|
-
};
|
|
690
|
+
jsTaskFactories.push(
|
|
691
|
+
createUniAppXAssetTask(
|
|
692
|
+
file,
|
|
693
|
+
originalSource,
|
|
694
|
+
outDir,
|
|
695
|
+
{
|
|
696
|
+
cache,
|
|
697
|
+
createHandlerOptions,
|
|
698
|
+
debug,
|
|
699
|
+
jsHandler,
|
|
700
|
+
onUpdate,
|
|
701
|
+
runtimeSet: runtime,
|
|
702
|
+
applyLinkedResults: applyLinkedUpdates,
|
|
703
|
+
uniAppX
|
|
556
704
|
}
|
|
557
|
-
|
|
558
|
-
|
|
705
|
+
)
|
|
706
|
+
);
|
|
559
707
|
}
|
|
560
708
|
}
|
|
561
709
|
}
|
|
@@ -594,7 +742,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
594
742
|
);
|
|
595
743
|
}
|
|
596
744
|
}
|
|
597
|
-
|
|
745
|
+
_chunkJ25ZFRYMjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
598
746
|
await Promise.all(tasks);
|
|
599
747
|
for (const apply of pendingLinkedUpdates) {
|
|
600
748
|
apply();
|
|
@@ -604,92 +752,8 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
604
752
|
}
|
|
605
753
|
}
|
|
606
754
|
];
|
|
607
|
-
if (
|
|
608
|
-
;
|
|
609
|
-
[void 0, "pre"].forEach((enforce) => {
|
|
610
|
-
plugins.push(
|
|
611
|
-
{
|
|
612
|
-
name: `weapp-tailwindcss:uni-app-x:css${enforce ? `:${enforce}` : ""}`,
|
|
613
|
-
enforce,
|
|
614
|
-
async transform(code, id) {
|
|
615
|
-
await runtimeState.patchPromise;
|
|
616
|
-
const { query } = parseVueRequest(id);
|
|
617
|
-
if (isCSSRequest(id) || query.vue && query.type === "style") {
|
|
618
|
-
const postcssResult = await styleHandler(code, {
|
|
619
|
-
isMainChunk: mainCssChunkMatcher(id, appType),
|
|
620
|
-
postcssOptions: {
|
|
621
|
-
options: {
|
|
622
|
-
from: id,
|
|
623
|
-
map: {
|
|
624
|
-
inline: false,
|
|
625
|
-
annotation: false,
|
|
626
|
-
// PostCSS 可能返回虚拟文件,因此需要启用这一项以获取源内容
|
|
627
|
-
sourcesContent: true
|
|
628
|
-
// 若上游预处理器已经生成 source map,sources 中可能出现重复条目
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
});
|
|
633
|
-
const rawPostcssMap = postcssResult.map.toJSON();
|
|
634
|
-
const postcssMap = await formatPostcssSourceMap(
|
|
635
|
-
// rawPostcssMap.version 类型声明为字符串,实际需要数值
|
|
636
|
-
rawPostcssMap,
|
|
637
|
-
cleanUrl(id)
|
|
638
|
-
);
|
|
639
|
-
return {
|
|
640
|
-
code: postcssResult.css,
|
|
641
|
-
map: postcssMap
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
);
|
|
647
|
-
});
|
|
648
|
-
plugins.push(
|
|
649
|
-
{
|
|
650
|
-
name: "weapp-tailwindcss:uni-app-x:nvue",
|
|
651
|
-
enforce: "pre",
|
|
652
|
-
async buildStart() {
|
|
653
|
-
await ensureRuntimeClassSet(true);
|
|
654
|
-
},
|
|
655
|
-
async transform(code, id) {
|
|
656
|
-
if (!/\.(?:uvue|nvue)(?:\?.*)?$/.test(id)) {
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
const isServeCommand = _optionalChain([resolvedConfig, 'optionalAccess', _13 => _13.command]) === "serve";
|
|
660
|
-
const isWatchBuild = _optionalChain([resolvedConfig, 'optionalAccess', _14 => _14.command]) === "build" && !!_optionalChain([resolvedConfig, 'access', _15 => _15.build, 'optionalAccess', _16 => _16.watch]);
|
|
661
|
-
const isNonWatchBuild = _optionalChain([resolvedConfig, 'optionalAccess', _17 => _17.command]) === "build" && !_optionalChain([resolvedConfig, 'access', _18 => _18.build, 'optionalAccess', _19 => _19.watch]);
|
|
662
|
-
const shouldForceRefresh = isServeCommand || isWatchBuild || isNonWatchBuild;
|
|
663
|
-
const currentRuntimeSet = shouldForceRefresh ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
664
|
-
const extraOptions = customAttributesEntities.length > 0 || disabledDefaultTemplateHandler ? {
|
|
665
|
-
customAttributesEntities,
|
|
666
|
-
disabledDefaultTemplateHandler
|
|
667
|
-
} : void 0;
|
|
668
|
-
if (extraOptions) {
|
|
669
|
-
return transformUVue(code, id, jsHandler, currentRuntimeSet, extraOptions);
|
|
670
|
-
}
|
|
671
|
-
return transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
672
|
-
},
|
|
673
|
-
async handleHotUpdate(ctx) {
|
|
674
|
-
if (_optionalChain([resolvedConfig, 'optionalAccess', _20 => _20.command]) !== "serve") {
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
if (!/\.(?:uvue|nvue)$/.test(ctx.file)) {
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
await ensureRuntimeClassSet(true);
|
|
681
|
-
},
|
|
682
|
-
async watchChange(id) {
|
|
683
|
-
if (_optionalChain([resolvedConfig, 'optionalAccess', _21 => _21.command]) !== "build" || !_optionalChain([resolvedConfig, 'access', _22 => _22.build, 'optionalAccess', _23 => _23.watch])) {
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
if (!/\.(?:uvue|nvue)(?:\?.*)?$/.test(id)) {
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
await ensureRuntimeClassSet(true);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
);
|
|
755
|
+
if (uniAppXPlugins) {
|
|
756
|
+
plugins.push(...uniAppXPlugins);
|
|
693
757
|
}
|
|
694
758
|
return plugins;
|
|
695
759
|
}
|
|
@@ -7,10 +7,20 @@ import { isAllowedClassName, MappingChars2String } from "@weapp-core/escape";
|
|
|
7
7
|
var CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
|
|
8
8
|
var HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
|
|
9
9
|
var JS_FILE_PATTERN = /.+\.[cm]?js?$/;
|
|
10
|
+
function normalizePath(p) {
|
|
11
|
+
return p.replace(/\\/g, "/");
|
|
12
|
+
}
|
|
13
|
+
var MPX_STYLES_DIR_PATTERN = /(?:^|\/)styles\/.*\.(?:wx|ac|jx|tt|q|c|ty)ss$/i;
|
|
10
14
|
var MAIN_CSS_CHUNK_MATCHERS = {
|
|
11
15
|
"uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
|
|
12
16
|
"uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
|
|
13
|
-
"mpx": (file) =>
|
|
17
|
+
"mpx": (file) => {
|
|
18
|
+
const normalized = normalizePath(file);
|
|
19
|
+
if (normalized.startsWith("app")) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return MPX_STYLES_DIR_PATTERN.test(normalized);
|
|
23
|
+
},
|
|
14
24
|
"taro": (file) => file.startsWith("app"),
|
|
15
25
|
"remax": (file) => file.startsWith("app"),
|
|
16
26
|
"rax": (file) => file.startsWith("bundle"),
|