weapp-tailwindcss 2.4.4 → 2.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/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/constants.d.ts +1 -1
- package/dist/gulp.js +9 -7
- package/dist/gulp.mjs +9 -7
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{options-879de0a2.mjs → options-1e3a224a.mjs} +47 -35
- package/dist/{options-887b74ca.js → options-ad127e0c.js} +47 -35
- package/dist/{postcss-ea625621.mjs → postcss-9a63df9d.mjs} +1 -2
- package/dist/{postcss-33ef0bd0.js → postcss-fbdc673b.js} +0 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/reg.d.ts +1 -1
- package/dist/types.d.ts +6 -3
- package/dist/vite.js +8 -6
- package/dist/vite.mjs +8 -6
- package/dist/weapp-tw-runtime-loader.js +16 -0
- package/dist/weapp-tw-runtime-loader.mjs +10 -0
- package/dist/webpack/BaseUnifiedPlugin/v5.d.ts +0 -1
- package/dist/webpack/loaders/weapp-tw-runtime-loader.d.ts +5 -0
- package/dist/webpack.js +36 -19
- package/dist/webpack.mjs +31 -19
- package/dist/wxml/index.d.ts +1 -1
- package/dist/wxml/utils.d.ts +2 -2
- package/package.json +19 -13
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var options = require('./options-
|
|
3
|
+
var options = require('./options-ad127e0c.js');
|
|
4
4
|
require('micromatch');
|
|
5
5
|
require('@babel/types');
|
|
6
6
|
require('@babel/generator');
|
|
@@ -9,7 +9,7 @@ require('@babel/traverse');
|
|
|
9
9
|
require('./replace.js');
|
|
10
10
|
require('./shared-ae7dd073.js');
|
|
11
11
|
require('postcss');
|
|
12
|
-
require('./postcss-
|
|
12
|
+
require('./postcss-fbdc673b.js');
|
|
13
13
|
require('postcss-selector-parser');
|
|
14
14
|
require('@csstools/postcss-is-pseudo-class');
|
|
15
15
|
require('node:path');
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getOptions, c as createPatch } from './options-
|
|
1
|
+
import { g as getOptions, c as createPatch } from './options-1e3a224a.mjs';
|
|
2
2
|
import 'micromatch';
|
|
3
3
|
import '@babel/types';
|
|
4
4
|
import '@babel/generator';
|
|
@@ -7,7 +7,7 @@ import '@babel/traverse';
|
|
|
7
7
|
import './replace.mjs';
|
|
8
8
|
import './shared-7c88fb94.mjs';
|
|
9
9
|
import 'postcss';
|
|
10
|
-
import './postcss-
|
|
10
|
+
import './postcss-9a63df9d.mjs';
|
|
11
11
|
import 'postcss-selector-parser';
|
|
12
12
|
import '@csstools/postcss-is-pseudo-class';
|
|
13
13
|
import 'node:path';
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const runtimeAopLoader = "weapp-tw-runtime-aop-loader";
|
|
2
2
|
export declare const postcssPlugin = "postcss-weapp-tailwindcss-rename-plugin";
|
|
3
3
|
export declare const ManglePluginHooks = "ManglePluginHooks";
|
|
4
4
|
export declare const WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks = "WeappTailwindcssWebpackPluginOptimizeChunkAssetsHooks";
|
package/dist/gulp.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var stream = require('node:stream');
|
|
6
|
-
var options = require('./options-
|
|
6
|
+
var options = require('./options-ad127e0c.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('@babel/types');
|
|
9
9
|
require('@babel/generator');
|
|
@@ -12,7 +12,7 @@ require('@babel/traverse');
|
|
|
12
12
|
require('./replace.js');
|
|
13
13
|
require('./shared-ae7dd073.js');
|
|
14
14
|
require('postcss');
|
|
15
|
-
require('./postcss-
|
|
15
|
+
require('./postcss-fbdc673b.js');
|
|
16
16
|
require('postcss-selector-parser');
|
|
17
17
|
require('@csstools/postcss-is-pseudo-class');
|
|
18
18
|
require('node:path');
|
|
@@ -32,14 +32,14 @@ function createPlugins(options$1 = {}) {
|
|
|
32
32
|
}
|
|
33
33
|
const opts = options.getOptions(options$1);
|
|
34
34
|
const { templeteHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
35
|
-
let
|
|
35
|
+
let runtimeSet = new Set();
|
|
36
36
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
37
37
|
const twPatcher = options.createTailwindcssPatcher();
|
|
38
38
|
function transformWxss() {
|
|
39
39
|
const transformStream = new Transform({ objectMode: true });
|
|
40
40
|
transformStream._transform = function (file, encoding, callback) {
|
|
41
|
-
|
|
42
|
-
setMangleRuntimeSet(
|
|
41
|
+
runtimeSet = twPatcher.getClassSet();
|
|
42
|
+
setMangleRuntimeSet(runtimeSet);
|
|
43
43
|
const error = null;
|
|
44
44
|
if (file.contents) {
|
|
45
45
|
const code = styleHandler(file.contents.toString(), {
|
|
@@ -56,7 +56,7 @@ function createPlugins(options$1 = {}) {
|
|
|
56
56
|
transformStream._transform = function (file, encoding, callback) {
|
|
57
57
|
const error = null;
|
|
58
58
|
if (file.contents) {
|
|
59
|
-
const { code } = jsHandler(file.contents.toString(),
|
|
59
|
+
const { code } = jsHandler(file.contents.toString(), runtimeSet);
|
|
60
60
|
file.contents = Buffer.from(code);
|
|
61
61
|
}
|
|
62
62
|
callback(error, file);
|
|
@@ -68,7 +68,9 @@ function createPlugins(options$1 = {}) {
|
|
|
68
68
|
transformStream._transform = function (file, encoding, callback) {
|
|
69
69
|
const error = null;
|
|
70
70
|
if (file.contents) {
|
|
71
|
-
const code = templeteHandler(file.contents.toString()
|
|
71
|
+
const code = templeteHandler(file.contents.toString(), {
|
|
72
|
+
runtimeSet
|
|
73
|
+
});
|
|
72
74
|
file.contents = Buffer.from(code);
|
|
73
75
|
}
|
|
74
76
|
callback(error, file);
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import stream from 'node:stream';
|
|
2
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-
|
|
2
|
+
import { g as getOptions, a as createTailwindcssPatcher } from './options-1e3a224a.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import '@babel/types';
|
|
5
5
|
import '@babel/generator';
|
|
@@ -8,7 +8,7 @@ import '@babel/traverse';
|
|
|
8
8
|
import './replace.mjs';
|
|
9
9
|
import './shared-7c88fb94.mjs';
|
|
10
10
|
import 'postcss';
|
|
11
|
-
import './postcss-
|
|
11
|
+
import './postcss-9a63df9d.mjs';
|
|
12
12
|
import 'postcss-selector-parser';
|
|
13
13
|
import '@csstools/postcss-is-pseudo-class';
|
|
14
14
|
import 'node:path';
|
|
@@ -24,14 +24,14 @@ function createPlugins(options = {}) {
|
|
|
24
24
|
}
|
|
25
25
|
const opts = getOptions(options);
|
|
26
26
|
const { templeteHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet } = opts;
|
|
27
|
-
let
|
|
27
|
+
let runtimeSet = new Set();
|
|
28
28
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
29
29
|
const twPatcher = createTailwindcssPatcher();
|
|
30
30
|
function transformWxss() {
|
|
31
31
|
const transformStream = new Transform({ objectMode: true });
|
|
32
32
|
transformStream._transform = function (file, encoding, callback) {
|
|
33
|
-
|
|
34
|
-
setMangleRuntimeSet(
|
|
33
|
+
runtimeSet = twPatcher.getClassSet();
|
|
34
|
+
setMangleRuntimeSet(runtimeSet);
|
|
35
35
|
const error = null;
|
|
36
36
|
if (file.contents) {
|
|
37
37
|
const code = styleHandler(file.contents.toString(), {
|
|
@@ -48,7 +48,7 @@ function createPlugins(options = {}) {
|
|
|
48
48
|
transformStream._transform = function (file, encoding, callback) {
|
|
49
49
|
const error = null;
|
|
50
50
|
if (file.contents) {
|
|
51
|
-
const { code } = jsHandler(file.contents.toString(),
|
|
51
|
+
const { code } = jsHandler(file.contents.toString(), runtimeSet);
|
|
52
52
|
file.contents = Buffer.from(code);
|
|
53
53
|
}
|
|
54
54
|
callback(error, file);
|
|
@@ -60,7 +60,9 @@ function createPlugins(options = {}) {
|
|
|
60
60
|
transformStream._transform = function (file, encoding, callback) {
|
|
61
61
|
const error = null;
|
|
62
62
|
if (file.contents) {
|
|
63
|
-
const code = templeteHandler(file.contents.toString()
|
|
63
|
+
const code = templeteHandler(file.contents.toString(), {
|
|
64
|
+
runtimeSet
|
|
65
|
+
});
|
|
64
66
|
file.contents = Buffer.from(code);
|
|
65
67
|
}
|
|
66
68
|
callback(error, file);
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var webpack = require('./webpack.js');
|
|
6
6
|
var vite = require('./vite.js');
|
|
7
7
|
var gulp = require('./gulp.js');
|
|
8
|
-
require('
|
|
8
|
+
require('node:path');
|
|
9
|
+
require('node:fs');
|
|
10
|
+
require('./options-ad127e0c.js');
|
|
9
11
|
require('micromatch');
|
|
10
12
|
require('@babel/types');
|
|
11
13
|
require('@babel/generator');
|
|
@@ -14,11 +16,9 @@ require('@babel/traverse');
|
|
|
14
16
|
require('./replace.js');
|
|
15
17
|
require('./shared-ae7dd073.js');
|
|
16
18
|
require('postcss');
|
|
17
|
-
require('./postcss-
|
|
19
|
+
require('./postcss-fbdc673b.js');
|
|
18
20
|
require('postcss-selector-parser');
|
|
19
21
|
require('@csstools/postcss-is-pseudo-class');
|
|
20
|
-
require('node:path');
|
|
21
|
-
require('node:fs');
|
|
22
22
|
require('semver');
|
|
23
23
|
require('tailwindcss-patch');
|
|
24
24
|
require('tailwindcss-mangle-shared');
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { UnifiedWebpackPluginV5 } from './webpack.mjs';
|
|
2
2
|
export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
3
3
|
export { createPlugins } from './gulp.mjs';
|
|
4
|
-
import '
|
|
4
|
+
import 'node:path';
|
|
5
|
+
import 'node:fs';
|
|
6
|
+
import './options-1e3a224a.mjs';
|
|
5
7
|
import 'micromatch';
|
|
6
8
|
import '@babel/types';
|
|
7
9
|
import '@babel/generator';
|
|
@@ -10,11 +12,9 @@ import '@babel/traverse';
|
|
|
10
12
|
import './replace.mjs';
|
|
11
13
|
import './shared-7c88fb94.mjs';
|
|
12
14
|
import 'postcss';
|
|
13
|
-
import './postcss-
|
|
15
|
+
import './postcss-9a63df9d.mjs';
|
|
14
16
|
import 'postcss-selector-parser';
|
|
15
17
|
import '@csstools/postcss-is-pseudo-class';
|
|
16
|
-
import 'node:path';
|
|
17
|
-
import 'node:fs';
|
|
18
18
|
import 'semver';
|
|
19
19
|
import 'tailwindcss-patch';
|
|
20
20
|
import 'tailwindcss-mangle-shared';
|
|
@@ -6,7 +6,7 @@ import traverse from '@babel/traverse';
|
|
|
6
6
|
import { replaceJs as replaceWxml } from './replace.mjs';
|
|
7
7
|
import { S as SimpleMappingChars2String, M as MappingChars2String } from './shared-7c88fb94.mjs';
|
|
8
8
|
import postcss from 'postcss';
|
|
9
|
-
import { p as postcssWeappTailwindcss } from './postcss-
|
|
9
|
+
import { p as postcssWeappTailwindcss } from './postcss-9a63df9d.mjs';
|
|
10
10
|
import postcssIsPseudoClass from '@csstools/postcss-is-pseudo-class';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import fs from 'node:fs';
|
|
@@ -84,7 +84,7 @@ function groupBy(arr, cb) {
|
|
|
84
84
|
return result;
|
|
85
85
|
}
|
|
86
86
|
function getGroupedEntries(entries, options) {
|
|
87
|
-
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
87
|
+
const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
|
|
88
88
|
const groupedEntries = groupBy(entries, ([file]) => {
|
|
89
89
|
if (cssMatcher(file)) {
|
|
90
90
|
return 'css';
|
|
@@ -92,7 +92,7 @@ function getGroupedEntries(entries, options) {
|
|
|
92
92
|
else if (htmlMatcher(file)) {
|
|
93
93
|
return 'html';
|
|
94
94
|
}
|
|
95
|
-
else if (jsMatcher(file)) {
|
|
95
|
+
else if (jsMatcher(file) || wxsMatcher(file)) {
|
|
96
96
|
return 'js';
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
@@ -180,9 +180,7 @@ function makeCustomAttributes(entries) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
const variableRegExp = /{{(.*?)}}/gs;
|
|
183
|
-
|
|
184
|
-
return variableRegExp.exec(original);
|
|
185
|
-
}
|
|
183
|
+
const wxsTagRegexp = /<wxs\s*(?:[a-z][a-z-]*[a-z]*(?:\s*=\s*".*?")?)*\s*>(.*?)<\/wxs>/gs;
|
|
186
184
|
|
|
187
185
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
188
186
|
function isValidSelector(selector = '') {
|
|
@@ -310,6 +308,9 @@ const defaultOptions = {
|
|
|
310
308
|
}
|
|
311
309
|
}
|
|
312
310
|
},
|
|
311
|
+
wxsMatcher: (file) => {
|
|
312
|
+
return false;
|
|
313
|
+
},
|
|
313
314
|
cssPreflight: {
|
|
314
315
|
'box-sizing': 'border-box',
|
|
315
316
|
'border-width': '0',
|
|
@@ -340,7 +341,8 @@ const defaultOptions = {
|
|
|
340
341
|
arbitraryValues: {
|
|
341
342
|
allowDoubleQuotes: false
|
|
342
343
|
},
|
|
343
|
-
cssChildCombinatorReplaceValue: 'view + view'
|
|
344
|
+
cssChildCombinatorReplaceValue: 'view + view',
|
|
345
|
+
inlineWxs: false
|
|
344
346
|
};
|
|
345
347
|
|
|
346
348
|
function generateCode(match, options = {}) {
|
|
@@ -368,23 +370,24 @@ function generateCode(match, options = {}) {
|
|
|
368
370
|
});
|
|
369
371
|
return code;
|
|
370
372
|
}
|
|
371
|
-
function
|
|
372
|
-
let match =
|
|
373
|
+
function extract(original, reg) {
|
|
374
|
+
let match = reg.exec(original);
|
|
373
375
|
const sources = [];
|
|
374
376
|
while (match !== null) {
|
|
375
377
|
const start = match.index;
|
|
376
|
-
const end =
|
|
378
|
+
const end = reg.lastIndex;
|
|
377
379
|
sources.push({
|
|
378
380
|
start,
|
|
379
381
|
end,
|
|
380
|
-
raw: match[1]
|
|
381
|
-
prevConcatenated: !/\s/.test(original[start - 1]),
|
|
382
|
-
nextConcatenated: !/\s/.test(original[end])
|
|
382
|
+
raw: match[1]
|
|
383
383
|
});
|
|
384
|
-
match =
|
|
384
|
+
match = reg.exec(original);
|
|
385
385
|
}
|
|
386
386
|
return sources;
|
|
387
387
|
}
|
|
388
|
+
function extractSource(original) {
|
|
389
|
+
return extract(original, variableRegExp);
|
|
390
|
+
}
|
|
388
391
|
function templeteReplacer(original, options = {}) {
|
|
389
392
|
const sources = extractSource(original);
|
|
390
393
|
if (sources.length > 0) {
|
|
@@ -435,24 +438,27 @@ function templeteHandler(rawSource, options = {}) {
|
|
|
435
438
|
});
|
|
436
439
|
});
|
|
437
440
|
}
|
|
438
|
-
function customTempleteHandler(rawSource, options
|
|
441
|
+
function customTempleteHandler(rawSource, options) {
|
|
442
|
+
const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
|
|
439
443
|
let source = templeteHandler(rawSource, options);
|
|
440
|
-
const regexps = makeCustomAttributes(
|
|
441
|
-
if (regexps) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
return
|
|
446
|
-
return m1.replace(className, templeteReplacer(className, options));
|
|
447
|
-
});
|
|
444
|
+
const regexps = makeCustomAttributes(customAttributesEntities);
|
|
445
|
+
if (regexps && Array.isArray(regexps)) {
|
|
446
|
+
for (const regexp of regexps) {
|
|
447
|
+
source = source.replace(regexp.tagRegexp, (m0) => {
|
|
448
|
+
return m0.replace(regexp.attrRegexp, (m1, className) => {
|
|
449
|
+
return m1.replace(className, templeteReplacer(className, options));
|
|
448
450
|
});
|
|
449
|
-
}
|
|
451
|
+
});
|
|
450
452
|
}
|
|
451
|
-
return source;
|
|
452
453
|
}
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
if (inlineWxs) {
|
|
455
|
+
const wxsTags = extract(source, wxsTagRegexp);
|
|
456
|
+
for (const x of wxsTags) {
|
|
457
|
+
const code = jsHandler(x.raw, runtimeSet).code;
|
|
458
|
+
source = source.replaceAll(x.raw, code);
|
|
459
|
+
}
|
|
455
460
|
}
|
|
461
|
+
return source;
|
|
456
462
|
}
|
|
457
463
|
function createTempleteHandler(options = {}) {
|
|
458
464
|
return (rawSource, opt = {}) => {
|
|
@@ -691,11 +697,12 @@ function getOptions(options = {}) {
|
|
|
691
697
|
normalizeMatcher(options, 'cssMatcher');
|
|
692
698
|
normalizeMatcher(options, 'htmlMatcher');
|
|
693
699
|
normalizeMatcher(options, 'jsMatcher');
|
|
700
|
+
normalizeMatcher(options, 'wxsMatcher');
|
|
694
701
|
normalizeMatcher(options, 'mainCssChunkMatcher');
|
|
695
702
|
const result = defu(options, defaultOptions, {
|
|
696
703
|
minifiedJs: isProd()
|
|
697
704
|
});
|
|
698
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue } = result;
|
|
705
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs } = result;
|
|
699
706
|
result.escapeMap = customReplaceDictionary;
|
|
700
707
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
701
708
|
const customAttributesEntities = isMap(options.customAttributes)
|
|
@@ -704,12 +711,7 @@ function getOptions(options = {}) {
|
|
|
704
711
|
const { escapeMap, minifiedJs } = result;
|
|
705
712
|
const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
|
|
706
713
|
initMangle(options.mangle);
|
|
707
|
-
|
|
708
|
-
customAttributesEntities,
|
|
709
|
-
escapeMap,
|
|
710
|
-
mangleContext
|
|
711
|
-
});
|
|
712
|
-
result.styleHandler = createStyleHandler({
|
|
714
|
+
const styleHandler = createStyleHandler({
|
|
713
715
|
cssInjectPreflight,
|
|
714
716
|
customRuleCallback,
|
|
715
717
|
cssPreflightRange,
|
|
@@ -718,12 +720,22 @@ function getOptions(options = {}) {
|
|
|
718
720
|
mangleContext,
|
|
719
721
|
cssChildCombinatorReplaceValue
|
|
720
722
|
});
|
|
721
|
-
result.
|
|
723
|
+
result.styleHandler = styleHandler;
|
|
724
|
+
const jsHandler = createjsHandler({
|
|
722
725
|
minifiedJs,
|
|
723
726
|
escapeMap,
|
|
724
727
|
mangleContext,
|
|
725
728
|
arbitraryValues
|
|
726
729
|
});
|
|
730
|
+
result.jsHandler = jsHandler;
|
|
731
|
+
const templeteHandler = createTempleteHandler({
|
|
732
|
+
customAttributesEntities,
|
|
733
|
+
escapeMap,
|
|
734
|
+
mangleContext,
|
|
735
|
+
inlineWxs,
|
|
736
|
+
jsHandler
|
|
737
|
+
});
|
|
738
|
+
result.templeteHandler = templeteHandler;
|
|
727
739
|
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
728
740
|
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
729
741
|
return result;
|
|
@@ -8,7 +8,7 @@ var traverse = require('@babel/traverse');
|
|
|
8
8
|
var replace = require('./replace.js');
|
|
9
9
|
var shared = require('./shared-ae7dd073.js');
|
|
10
10
|
var postcss = require('postcss');
|
|
11
|
-
var postcss$1 = require('./postcss-
|
|
11
|
+
var postcss$1 = require('./postcss-fbdc673b.js');
|
|
12
12
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
13
13
|
var path = require('node:path');
|
|
14
14
|
var fs = require('node:fs');
|
|
@@ -114,7 +114,7 @@ function groupBy(arr, cb) {
|
|
|
114
114
|
return result;
|
|
115
115
|
}
|
|
116
116
|
function getGroupedEntries(entries, options) {
|
|
117
|
-
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
117
|
+
const { cssMatcher, htmlMatcher, jsMatcher, wxsMatcher } = options;
|
|
118
118
|
const groupedEntries = groupBy(entries, ([file]) => {
|
|
119
119
|
if (cssMatcher(file)) {
|
|
120
120
|
return 'css';
|
|
@@ -122,7 +122,7 @@ function getGroupedEntries(entries, options) {
|
|
|
122
122
|
else if (htmlMatcher(file)) {
|
|
123
123
|
return 'html';
|
|
124
124
|
}
|
|
125
|
-
else if (jsMatcher(file)) {
|
|
125
|
+
else if (jsMatcher(file) || wxsMatcher(file)) {
|
|
126
126
|
return 'js';
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
@@ -210,9 +210,7 @@ function makeCustomAttributes(entries) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
const variableRegExp = /{{(.*?)}}/gs;
|
|
213
|
-
|
|
214
|
-
return variableRegExp.exec(original);
|
|
215
|
-
}
|
|
213
|
+
const wxsTagRegexp = /<wxs\s*(?:[a-z][a-z-]*[a-z]*(?:\s*=\s*".*?")?)*\s*>(.*?)<\/wxs>/gs;
|
|
216
214
|
|
|
217
215
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
218
216
|
function isValidSelector(selector = '') {
|
|
@@ -340,6 +338,9 @@ const defaultOptions = {
|
|
|
340
338
|
}
|
|
341
339
|
}
|
|
342
340
|
},
|
|
341
|
+
wxsMatcher: (file) => {
|
|
342
|
+
return false;
|
|
343
|
+
},
|
|
343
344
|
cssPreflight: {
|
|
344
345
|
'box-sizing': 'border-box',
|
|
345
346
|
'border-width': '0',
|
|
@@ -370,7 +371,8 @@ const defaultOptions = {
|
|
|
370
371
|
arbitraryValues: {
|
|
371
372
|
allowDoubleQuotes: false
|
|
372
373
|
},
|
|
373
|
-
cssChildCombinatorReplaceValue: 'view + view'
|
|
374
|
+
cssChildCombinatorReplaceValue: 'view + view',
|
|
375
|
+
inlineWxs: false
|
|
374
376
|
};
|
|
375
377
|
|
|
376
378
|
function generateCode(match, options = {}) {
|
|
@@ -398,23 +400,24 @@ function generateCode(match, options = {}) {
|
|
|
398
400
|
});
|
|
399
401
|
return code;
|
|
400
402
|
}
|
|
401
|
-
function
|
|
402
|
-
let match =
|
|
403
|
+
function extract(original, reg) {
|
|
404
|
+
let match = reg.exec(original);
|
|
403
405
|
const sources = [];
|
|
404
406
|
while (match !== null) {
|
|
405
407
|
const start = match.index;
|
|
406
|
-
const end =
|
|
408
|
+
const end = reg.lastIndex;
|
|
407
409
|
sources.push({
|
|
408
410
|
start,
|
|
409
411
|
end,
|
|
410
|
-
raw: match[1]
|
|
411
|
-
prevConcatenated: !/\s/.test(original[start - 1]),
|
|
412
|
-
nextConcatenated: !/\s/.test(original[end])
|
|
412
|
+
raw: match[1]
|
|
413
413
|
});
|
|
414
|
-
match =
|
|
414
|
+
match = reg.exec(original);
|
|
415
415
|
}
|
|
416
416
|
return sources;
|
|
417
417
|
}
|
|
418
|
+
function extractSource(original) {
|
|
419
|
+
return extract(original, variableRegExp);
|
|
420
|
+
}
|
|
418
421
|
function templeteReplacer(original, options = {}) {
|
|
419
422
|
const sources = extractSource(original);
|
|
420
423
|
if (sources.length > 0) {
|
|
@@ -465,24 +468,27 @@ function templeteHandler(rawSource, options = {}) {
|
|
|
465
468
|
});
|
|
466
469
|
});
|
|
467
470
|
}
|
|
468
|
-
function customTempleteHandler(rawSource, options
|
|
471
|
+
function customTempleteHandler(rawSource, options) {
|
|
472
|
+
const { customAttributesEntities, inlineWxs, runtimeSet, jsHandler } = options;
|
|
469
473
|
let source = templeteHandler(rawSource, options);
|
|
470
|
-
const regexps = makeCustomAttributes(
|
|
471
|
-
if (regexps) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return
|
|
476
|
-
return m1.replace(className, templeteReplacer(className, options));
|
|
477
|
-
});
|
|
474
|
+
const regexps = makeCustomAttributes(customAttributesEntities);
|
|
475
|
+
if (regexps && Array.isArray(regexps)) {
|
|
476
|
+
for (const regexp of regexps) {
|
|
477
|
+
source = source.replace(regexp.tagRegexp, (m0) => {
|
|
478
|
+
return m0.replace(regexp.attrRegexp, (m1, className) => {
|
|
479
|
+
return m1.replace(className, templeteReplacer(className, options));
|
|
478
480
|
});
|
|
479
|
-
}
|
|
481
|
+
});
|
|
480
482
|
}
|
|
481
|
-
return source;
|
|
482
483
|
}
|
|
483
|
-
|
|
484
|
-
|
|
484
|
+
if (inlineWxs) {
|
|
485
|
+
const wxsTags = extract(source, wxsTagRegexp);
|
|
486
|
+
for (const x of wxsTags) {
|
|
487
|
+
const code = jsHandler(x.raw, runtimeSet).code;
|
|
488
|
+
source = source.replaceAll(x.raw, code);
|
|
489
|
+
}
|
|
485
490
|
}
|
|
491
|
+
return source;
|
|
486
492
|
}
|
|
487
493
|
function createTempleteHandler(options = {}) {
|
|
488
494
|
return (rawSource, opt = {}) => {
|
|
@@ -721,11 +727,12 @@ function getOptions(options = {}) {
|
|
|
721
727
|
normalizeMatcher(options, 'cssMatcher');
|
|
722
728
|
normalizeMatcher(options, 'htmlMatcher');
|
|
723
729
|
normalizeMatcher(options, 'jsMatcher');
|
|
730
|
+
normalizeMatcher(options, 'wxsMatcher');
|
|
724
731
|
normalizeMatcher(options, 'mainCssChunkMatcher');
|
|
725
732
|
const result = defu(options, defaultOptions, {
|
|
726
733
|
minifiedJs: isProd()
|
|
727
734
|
});
|
|
728
|
-
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue } = result;
|
|
735
|
+
const { cssPreflight, customRuleCallback, cssPreflightRange, replaceUniversalSelectorWith, customAttributes, customReplaceDictionary, supportCustomLengthUnitsPatch, arbitraryValues, cssChildCombinatorReplaceValue, inlineWxs } = result;
|
|
729
736
|
result.escapeMap = customReplaceDictionary;
|
|
730
737
|
const cssInjectPreflight = createInjectPreflight(cssPreflight);
|
|
731
738
|
const customAttributesEntities = isMap(options.customAttributes)
|
|
@@ -734,12 +741,7 @@ function getOptions(options = {}) {
|
|
|
734
741
|
const { escapeMap, minifiedJs } = result;
|
|
735
742
|
const { initMangle, mangleContext, setMangleRuntimeSet } = useMangleStore();
|
|
736
743
|
initMangle(options.mangle);
|
|
737
|
-
|
|
738
|
-
customAttributesEntities,
|
|
739
|
-
escapeMap,
|
|
740
|
-
mangleContext
|
|
741
|
-
});
|
|
742
|
-
result.styleHandler = createStyleHandler({
|
|
744
|
+
const styleHandler = createStyleHandler({
|
|
743
745
|
cssInjectPreflight,
|
|
744
746
|
customRuleCallback,
|
|
745
747
|
cssPreflightRange,
|
|
@@ -748,12 +750,22 @@ function getOptions(options = {}) {
|
|
|
748
750
|
mangleContext,
|
|
749
751
|
cssChildCombinatorReplaceValue
|
|
750
752
|
});
|
|
751
|
-
result.
|
|
753
|
+
result.styleHandler = styleHandler;
|
|
754
|
+
const jsHandler = createjsHandler({
|
|
752
755
|
minifiedJs,
|
|
753
756
|
escapeMap,
|
|
754
757
|
mangleContext,
|
|
755
758
|
arbitraryValues
|
|
756
759
|
});
|
|
760
|
+
result.jsHandler = jsHandler;
|
|
761
|
+
const templeteHandler = createTempleteHandler({
|
|
762
|
+
customAttributesEntities,
|
|
763
|
+
escapeMap,
|
|
764
|
+
mangleContext,
|
|
765
|
+
inlineWxs,
|
|
766
|
+
jsHandler
|
|
767
|
+
});
|
|
768
|
+
result.templeteHandler = templeteHandler;
|
|
757
769
|
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
758
770
|
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
759
771
|
return result;
|
|
@@ -90,7 +90,6 @@ function commonChunkPreflight(node, options) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const NS = 'jsx-rename-loader';
|
|
94
93
|
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
95
94
|
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
96
95
|
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
@@ -113,4 +112,4 @@ const postcssWeappTailwindcss = (options = {
|
|
|
113
112
|
};
|
|
114
113
|
postcssWeappTailwindcss.postcss = true;
|
|
115
114
|
|
|
116
|
-
export {
|
|
115
|
+
export { pluginName as a, postcssWeappTailwindcss as p, vitePluginName as v };
|
|
@@ -96,7 +96,6 @@ function commonChunkPreflight(node, options) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
const NS = 'jsx-rename-loader';
|
|
100
99
|
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
101
100
|
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
102
101
|
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
@@ -119,7 +118,6 @@ const postcssWeappTailwindcss = (options = {
|
|
|
119
118
|
};
|
|
120
119
|
postcssWeappTailwindcss.postcss = true;
|
|
121
120
|
|
|
122
|
-
exports.NS = NS;
|
|
123
121
|
exports.pluginName = pluginName;
|
|
124
122
|
exports.postcssWeappTailwindcss = postcssWeappTailwindcss;
|
|
125
123
|
exports.vitePluginName = vitePluginName;
|
package/dist/postcss.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var postcss = require('./postcss-
|
|
5
|
+
var postcss = require('./postcss-fbdc673b.js');
|
|
6
6
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
require('postcss-selector-parser');
|
|
8
8
|
require('./shared-ae7dd073.js');
|
package/dist/postcss.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { p as postcssWeappTailwindcss } from './postcss-
|
|
1
|
+
export { p as postcssWeappTailwindcss } from './postcss-9a63df9d.mjs';
|
|
2
2
|
export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
|
|
3
3
|
import 'postcss-selector-parser';
|
|
4
4
|
import './shared-7c88fb94.mjs';
|
package/dist/reg.d.ts
CHANGED
|
@@ -12,13 +12,13 @@ export declare function createTempleteHandlerMatchRegexp(tag: string | RegExp, a
|
|
|
12
12
|
export declare function createTemplateClassRegexp(attrs: ItemOrItemArray<string | RegExp>, options?: ICreateRegexpOptions): RegExp;
|
|
13
13
|
export declare function makeCustomAttributes(entries?: [string | RegExp, ItemOrItemArray<string | RegExp>][]): ICustomRegexp[] | undefined;
|
|
14
14
|
export declare const variableRegExp: RegExp;
|
|
15
|
-
export declare function variableMatch(original: string): RegExpExecArray | null;
|
|
16
15
|
export declare const classRegexp: RegExp;
|
|
17
16
|
export declare const vueTemplateClassRegexp: RegExp;
|
|
18
17
|
export declare const tagRegexp: RegExp;
|
|
19
18
|
export declare const tagWithClassRegexp: RegExp;
|
|
20
19
|
export declare function classStringReplace(str: string, replacement: (substring: string, ...args: any[]) => string): string;
|
|
21
20
|
export declare function tagStringReplace(str: string, replacement: (substring: string, ...args: any[]) => string): string;
|
|
21
|
+
export declare const wxsTagRegexp: RegExp;
|
|
22
22
|
export declare const wxmlAllowClassCharsRegExp: RegExp;
|
|
23
23
|
export declare function createWxmlAllowClassCharsRegExp(): RegExp;
|
|
24
24
|
export declare const doubleQuoteRegexp: RegExp;
|
package/dist/types.d.ts
CHANGED
|
@@ -43,8 +43,6 @@ export interface RawSource {
|
|
|
43
43
|
end: number;
|
|
44
44
|
raw: string;
|
|
45
45
|
source?: string;
|
|
46
|
-
prevConcatenated: boolean;
|
|
47
|
-
nextConcatenated: boolean;
|
|
48
46
|
}
|
|
49
47
|
export interface ILengthUnitsPatchDangerousOptions {
|
|
50
48
|
packageName?: string;
|
|
@@ -89,6 +87,8 @@ export interface UserDefinedOptions {
|
|
|
89
87
|
mangle?: boolean | IMangleOptions;
|
|
90
88
|
arbitraryValues?: IArbitraryValues;
|
|
91
89
|
cssChildCombinatorReplaceValue?: string | string[];
|
|
90
|
+
wxsMatcher?: ((name: string) => boolean) | string | string[];
|
|
91
|
+
inlineWxs?: boolean;
|
|
92
92
|
}
|
|
93
93
|
export interface IMangleScopeContext {
|
|
94
94
|
rawOptions: UserDefinedOptions['mangle'];
|
|
@@ -113,8 +113,11 @@ export interface ITempleteHandlerOptions extends ICommonReplaceOptions {
|
|
|
113
113
|
customAttributesEntities?: ICustomAttributesEntities;
|
|
114
114
|
escapeMap?: Record<string, string>;
|
|
115
115
|
mangleContext?: IMangleScopeContext;
|
|
116
|
+
inlineWxs?: boolean;
|
|
117
|
+
jsHandler?: (rawSource: string, set: Set<string>) => GeneratorResult;
|
|
118
|
+
runtimeSet?: Set<string>;
|
|
116
119
|
}
|
|
117
|
-
export type GlobOrFunctionMatchers = 'htmlMatcher' | 'cssMatcher' | 'jsMatcher' | 'mainCssChunkMatcher';
|
|
120
|
+
export type GlobOrFunctionMatchers = 'htmlMatcher' | 'cssMatcher' | 'jsMatcher' | 'mainCssChunkMatcher' | 'wxsMatcher';
|
|
118
121
|
export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobOrFunctionMatchers | 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary'> & {
|
|
119
122
|
[K in GlobOrFunctionMatchers]: K extends 'mainCssChunkMatcher' ? (name: string, appType?: AppType) => boolean : (name: string) => boolean;
|
|
120
123
|
} & {
|
package/dist/vite.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var options = require('./options-
|
|
6
|
-
var postcss = require('./postcss-
|
|
5
|
+
var options = require('./options-ad127e0c.js');
|
|
6
|
+
var postcss = require('./postcss-fbdc673b.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('@babel/types');
|
|
9
9
|
require('@babel/generator');
|
|
@@ -41,13 +41,15 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
|
41
41
|
generateBundle(opt, bundle, isWrite) {
|
|
42
42
|
const entries = Object.entries(bundle);
|
|
43
43
|
const groupedEntries = options.getGroupedEntries(entries, opts);
|
|
44
|
-
const
|
|
45
|
-
setMangleRuntimeSet(
|
|
44
|
+
const runtimeSet = twPatcher.getClassSet();
|
|
45
|
+
setMangleRuntimeSet(runtimeSet);
|
|
46
46
|
if (Array.isArray(groupedEntries.html)) {
|
|
47
47
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
48
48
|
const [file, originalSource] = groupedEntries.html[i];
|
|
49
49
|
const oldVal = originalSource.source.toString();
|
|
50
|
-
originalSource.source = templeteHandler(oldVal
|
|
50
|
+
originalSource.source = templeteHandler(oldVal, {
|
|
51
|
+
runtimeSet
|
|
52
|
+
});
|
|
51
53
|
onUpdate(file, oldVal, originalSource.source);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -66,7 +68,7 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
|
66
68
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
67
69
|
const [file, originalSource] = groupedEntries.js[i];
|
|
68
70
|
const rawSource = originalSource.code;
|
|
69
|
-
const { code } = jsHandler(rawSource,
|
|
71
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
70
72
|
originalSource.code = code;
|
|
71
73
|
onUpdate(file, rawSource, code);
|
|
72
74
|
}
|
package/dist/vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-
|
|
2
|
-
import { v as vitePluginName } from './postcss-
|
|
1
|
+
import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-1e3a224a.mjs';
|
|
2
|
+
import { v as vitePluginName } from './postcss-9a63df9d.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import '@babel/types';
|
|
5
5
|
import '@babel/generator';
|
|
@@ -37,13 +37,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
37
37
|
generateBundle(opt, bundle, isWrite) {
|
|
38
38
|
const entries = Object.entries(bundle);
|
|
39
39
|
const groupedEntries = getGroupedEntries(entries, opts);
|
|
40
|
-
const
|
|
41
|
-
setMangleRuntimeSet(
|
|
40
|
+
const runtimeSet = twPatcher.getClassSet();
|
|
41
|
+
setMangleRuntimeSet(runtimeSet);
|
|
42
42
|
if (Array.isArray(groupedEntries.html)) {
|
|
43
43
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
44
44
|
const [file, originalSource] = groupedEntries.html[i];
|
|
45
45
|
const oldVal = originalSource.source.toString();
|
|
46
|
-
originalSource.source = templeteHandler(oldVal
|
|
46
|
+
originalSource.source = templeteHandler(oldVal, {
|
|
47
|
+
runtimeSet
|
|
48
|
+
});
|
|
47
49
|
onUpdate(file, oldVal, originalSource.source);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -62,7 +64,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
62
64
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
63
65
|
const [file, originalSource] = groupedEntries.js[i];
|
|
64
66
|
const rawSource = originalSource.code;
|
|
65
|
-
const { code } = jsHandler(rawSource,
|
|
67
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
66
68
|
originalSource.code = code;
|
|
67
69
|
onUpdate(file, rawSource, code);
|
|
68
70
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var loaderUtils = require('loader-utils');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var loaderUtils__default = /*#__PURE__*/_interopDefaultCompat(loaderUtils);
|
|
8
|
+
|
|
9
|
+
const WeappTwRuntimeAopLoader = function (source) {
|
|
10
|
+
var _a;
|
|
11
|
+
const opt = loaderUtils__default["default"].getOptions(this);
|
|
12
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.getClassSet) === null || _a === void 0 ? void 0 : _a.call(opt);
|
|
13
|
+
return source;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = WeappTwRuntimeAopLoader;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import loaderUtils from 'loader-utils';
|
|
2
|
+
|
|
3
|
+
const WeappTwRuntimeAopLoader = function (source) {
|
|
4
|
+
var _a;
|
|
5
|
+
const opt = loaderUtils.getOptions(this);
|
|
6
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.getClassSet) === null || _a === void 0 ? void 0 : _a.call(opt);
|
|
7
|
+
return source;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { WeappTwRuntimeAopLoader as default };
|
|
@@ -3,7 +3,6 @@ import type { AppType, UserDefinedOptions, InternalUserDefinedOptions, IBaseWebp
|
|
|
3
3
|
export declare class UnifiedWebpackPluginV5 implements IBaseWebpackPlugin {
|
|
4
4
|
options: InternalUserDefinedOptions;
|
|
5
5
|
appType?: AppType;
|
|
6
|
-
static NS: string;
|
|
7
6
|
constructor(options?: UserDefinedOptions);
|
|
8
7
|
apply(compiler: Compiler): void;
|
|
9
8
|
}
|
package/dist/webpack.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var path = require('node:path');
|
|
6
|
+
var fs = require('node:fs');
|
|
7
|
+
var options = require('./options-ad127e0c.js');
|
|
8
|
+
var postcss = require('./postcss-fbdc673b.js');
|
|
7
9
|
require('micromatch');
|
|
8
10
|
require('@babel/types');
|
|
9
11
|
require('@babel/generator');
|
|
@@ -13,13 +15,16 @@ require('./replace.js');
|
|
|
13
15
|
require('./shared-ae7dd073.js');
|
|
14
16
|
require('postcss');
|
|
15
17
|
require('@csstools/postcss-is-pseudo-class');
|
|
16
|
-
require('node:path');
|
|
17
|
-
require('node:fs');
|
|
18
18
|
require('semver');
|
|
19
19
|
require('tailwindcss-patch');
|
|
20
20
|
require('tailwindcss-mangle-shared');
|
|
21
21
|
require('postcss-selector-parser');
|
|
22
22
|
|
|
23
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
26
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
27
|
+
|
|
23
28
|
class UnifiedWebpackPluginV5 {
|
|
24
29
|
constructor(options$1 = {}) {
|
|
25
30
|
if (options$1.customReplaceDictionary === undefined) {
|
|
@@ -34,21 +39,32 @@ class UnifiedWebpackPluginV5 {
|
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
41
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
37
|
-
const Compilation = compiler.webpack
|
|
38
|
-
const { ConcatSource } =
|
|
42
|
+
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
43
|
+
const { ConcatSource } = sources;
|
|
39
44
|
const twPatcher = options.createTailwindcssPatcher();
|
|
40
45
|
function getClassSet() {
|
|
41
|
-
|
|
42
|
-
if (set.size === 0) {
|
|
43
|
-
const cacheSet = twPatcher.getCache();
|
|
44
|
-
if (cacheSet && cacheSet.size > 0) {
|
|
45
|
-
set = cacheSet;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return set;
|
|
46
|
+
return twPatcher.getClassSet();
|
|
49
47
|
}
|
|
50
48
|
onLoad();
|
|
49
|
+
const loader = path__default["default"].resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
50
|
+
const isExisted = fs__default["default"].existsSync(loader);
|
|
51
|
+
const WeappTwRuntimeAopLoader = {
|
|
52
|
+
loader,
|
|
53
|
+
options: {
|
|
54
|
+
getClassSet
|
|
55
|
+
},
|
|
56
|
+
ident: null,
|
|
57
|
+
type: null
|
|
58
|
+
};
|
|
51
59
|
compiler.hooks.compilation.tap(postcss.pluginName, (compilation) => {
|
|
60
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(postcss.pluginName, (loaderContext, module) => {
|
|
61
|
+
if (isExisted) {
|
|
62
|
+
const idx = module.loaders.findIndex((x) => x.loader.includes('postcss-loader'));
|
|
63
|
+
if (idx > -1) {
|
|
64
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
52
68
|
compilation.hooks.processAssets.tap({
|
|
53
69
|
name: postcss.pluginName,
|
|
54
70
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
@@ -56,13 +72,15 @@ class UnifiedWebpackPluginV5 {
|
|
|
56
72
|
onStart();
|
|
57
73
|
const entries = Object.entries(assets);
|
|
58
74
|
const groupedEntries = options.getGroupedEntries(entries, this.options);
|
|
59
|
-
const
|
|
60
|
-
setMangleRuntimeSet(
|
|
75
|
+
const runtimeSet = getClassSet();
|
|
76
|
+
setMangleRuntimeSet(runtimeSet);
|
|
61
77
|
if (Array.isArray(groupedEntries.html)) {
|
|
62
78
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
63
79
|
const [file, originalSource] = groupedEntries.html[i];
|
|
64
80
|
const rawSource = originalSource.source().toString();
|
|
65
|
-
const wxml = templeteHandler(rawSource
|
|
81
|
+
const wxml = templeteHandler(rawSource, {
|
|
82
|
+
runtimeSet
|
|
83
|
+
});
|
|
66
84
|
const source = new ConcatSource(wxml);
|
|
67
85
|
compilation.updateAsset(file, source);
|
|
68
86
|
onUpdate(file, rawSource, wxml);
|
|
@@ -72,7 +90,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
72
90
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
73
91
|
const [file, originalSource] = groupedEntries.js[i];
|
|
74
92
|
const rawSource = originalSource.source().toString();
|
|
75
|
-
const { code } = jsHandler(rawSource,
|
|
93
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
76
94
|
const source = new ConcatSource(code);
|
|
77
95
|
compilation.updateAsset(file, source);
|
|
78
96
|
onUpdate(file, rawSource, code);
|
|
@@ -95,6 +113,5 @@ class UnifiedWebpackPluginV5 {
|
|
|
95
113
|
});
|
|
96
114
|
}
|
|
97
115
|
}
|
|
98
|
-
UnifiedWebpackPluginV5.NS = postcss.NS;
|
|
99
116
|
|
|
100
117
|
exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-1e3a224a.mjs';
|
|
4
|
+
import { a as pluginName } from './postcss-9a63df9d.mjs';
|
|
3
5
|
import 'micromatch';
|
|
4
6
|
import '@babel/types';
|
|
5
7
|
import '@babel/generator';
|
|
@@ -9,8 +11,6 @@ import './replace.mjs';
|
|
|
9
11
|
import './shared-7c88fb94.mjs';
|
|
10
12
|
import 'postcss';
|
|
11
13
|
import '@csstools/postcss-is-pseudo-class';
|
|
12
|
-
import 'node:path';
|
|
13
|
-
import 'node:fs';
|
|
14
14
|
import 'semver';
|
|
15
15
|
import 'tailwindcss-patch';
|
|
16
16
|
import 'tailwindcss-mangle-shared';
|
|
@@ -30,21 +30,32 @@ class UnifiedWebpackPluginV5 {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
33
|
-
const Compilation = compiler.webpack
|
|
34
|
-
const { ConcatSource } =
|
|
33
|
+
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
34
|
+
const { ConcatSource } = sources;
|
|
35
35
|
const twPatcher = createTailwindcssPatcher();
|
|
36
36
|
function getClassSet() {
|
|
37
|
-
|
|
38
|
-
if (set.size === 0) {
|
|
39
|
-
const cacheSet = twPatcher.getCache();
|
|
40
|
-
if (cacheSet && cacheSet.size > 0) {
|
|
41
|
-
set = cacheSet;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return set;
|
|
37
|
+
return twPatcher.getClassSet();
|
|
45
38
|
}
|
|
46
39
|
onLoad();
|
|
40
|
+
const loader = path.resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
41
|
+
const isExisted = fs.existsSync(loader);
|
|
42
|
+
const WeappTwRuntimeAopLoader = {
|
|
43
|
+
loader,
|
|
44
|
+
options: {
|
|
45
|
+
getClassSet
|
|
46
|
+
},
|
|
47
|
+
ident: null,
|
|
48
|
+
type: null
|
|
49
|
+
};
|
|
47
50
|
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
51
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (loaderContext, module) => {
|
|
52
|
+
if (isExisted) {
|
|
53
|
+
const idx = module.loaders.findIndex((x) => x.loader.includes('postcss-loader'));
|
|
54
|
+
if (idx > -1) {
|
|
55
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
48
59
|
compilation.hooks.processAssets.tap({
|
|
49
60
|
name: pluginName,
|
|
50
61
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
@@ -52,13 +63,15 @@ class UnifiedWebpackPluginV5 {
|
|
|
52
63
|
onStart();
|
|
53
64
|
const entries = Object.entries(assets);
|
|
54
65
|
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
55
|
-
const
|
|
56
|
-
setMangleRuntimeSet(
|
|
66
|
+
const runtimeSet = getClassSet();
|
|
67
|
+
setMangleRuntimeSet(runtimeSet);
|
|
57
68
|
if (Array.isArray(groupedEntries.html)) {
|
|
58
69
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
59
70
|
const [file, originalSource] = groupedEntries.html[i];
|
|
60
71
|
const rawSource = originalSource.source().toString();
|
|
61
|
-
const wxml = templeteHandler(rawSource
|
|
72
|
+
const wxml = templeteHandler(rawSource, {
|
|
73
|
+
runtimeSet
|
|
74
|
+
});
|
|
62
75
|
const source = new ConcatSource(wxml);
|
|
63
76
|
compilation.updateAsset(file, source);
|
|
64
77
|
onUpdate(file, rawSource, wxml);
|
|
@@ -68,7 +81,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
68
81
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
69
82
|
const [file, originalSource] = groupedEntries.js[i];
|
|
70
83
|
const rawSource = originalSource.source().toString();
|
|
71
|
-
const { code } = jsHandler(rawSource,
|
|
84
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
72
85
|
const source = new ConcatSource(code);
|
|
73
86
|
compilation.updateAsset(file, source);
|
|
74
87
|
onUpdate(file, rawSource, code);
|
|
@@ -91,6 +104,5 @@ class UnifiedWebpackPluginV5 {
|
|
|
91
104
|
});
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
|
-
UnifiedWebpackPluginV5.NS = NS;
|
|
95
107
|
|
|
96
108
|
export { UnifiedWebpackPluginV5 };
|
package/dist/wxml/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { replaceWxml } from './shared';
|
|
2
|
-
export { generateCode, templeteHandler, templeteReplacer } from './utils';
|
|
2
|
+
export { generateCode, templeteHandler, templeteReplacer, customTempleteHandler, createTempleteHandler, extractSource } from './utils';
|
package/dist/wxml/utils.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare function generateCode(match: string, options?: ITempleteHandlerOp
|
|
|
3
3
|
export declare function extractSource(original: string): RawSource[];
|
|
4
4
|
export declare function templeteReplacer(original: string, options?: ITempleteHandlerOptions): string;
|
|
5
5
|
export declare function templeteHandler(rawSource: string, options?: ITempleteHandlerOptions): string;
|
|
6
|
-
export declare function customTempleteHandler(rawSource: string, options
|
|
7
|
-
export declare function createTempleteHandler(options?: ITempleteHandlerOptions): (rawSource: string, opt?: ITempleteHandlerOptions) => string;
|
|
6
|
+
export declare function customTempleteHandler(rawSource: string, options: Required<ITempleteHandlerOptions>): string;
|
|
7
|
+
export declare function createTempleteHandler(options?: Omit<ITempleteHandlerOptions, 'runtimeSet'>): (rawSource: string, opt?: Pick<ITempleteHandlerOptions, 'runtimeSet'>) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "把tailwindcss jit引擎,带给小程序开发者们\nbring tailwindcss jit engine to our miniprogram developers!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -112,6 +112,8 @@
|
|
|
112
112
|
"@types/gulp": "^4.0.11",
|
|
113
113
|
"@types/gulp-postcss": "^8.0.3",
|
|
114
114
|
"@types/jest": "^29.5.2",
|
|
115
|
+
"@types/klaw": "^3.0.3",
|
|
116
|
+
"@types/loader-utils": "^2.0.3",
|
|
115
117
|
"@types/lodash": "^4.14.195",
|
|
116
118
|
"@types/micromatch": "^4.0.2",
|
|
117
119
|
"@types/node": "^20.3.1",
|
|
@@ -119,7 +121,7 @@
|
|
|
119
121
|
"@types/vinyl": "^2.0.7",
|
|
120
122
|
"@types/webpack": "^5.28.1",
|
|
121
123
|
"@types/webpack-sources": "^3.2.0",
|
|
122
|
-
"@vitest/coverage-v8": "^0.32.
|
|
124
|
+
"@vitest/coverage-v8": "^0.32.2",
|
|
123
125
|
"autoprefixer": "^10.4.14",
|
|
124
126
|
"babel-loader": "^9.1.2",
|
|
125
127
|
"bumpp": "^9.1.1",
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
"css-loader": "^6.8.1",
|
|
129
131
|
"defu": "6.1.2",
|
|
130
132
|
"del": "^6.1.1",
|
|
131
|
-
"eslint": "8.
|
|
133
|
+
"eslint": "8.43.0",
|
|
132
134
|
"eslint-config-icebreaker": "^1.1.0",
|
|
133
135
|
"eslint-config-prettier": "^8.8.0",
|
|
134
136
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -139,7 +141,9 @@
|
|
|
139
141
|
"gulp-postcss": "^9.0.1",
|
|
140
142
|
"html-loader": "^4.2.0",
|
|
141
143
|
"jest": "^29.5.0",
|
|
144
|
+
"klaw": "^4.1.0",
|
|
142
145
|
"lodash": "^4.17.21",
|
|
146
|
+
"magic-string": "^0.30.0",
|
|
143
147
|
"mini-css-extract-plugin": "^2.7.6",
|
|
144
148
|
"miniprogram-automator": "^0.12.0",
|
|
145
149
|
"pkg-types": "^1.0.3",
|
|
@@ -147,6 +151,7 @@
|
|
|
147
151
|
"postcss-loader": "^7.3.3",
|
|
148
152
|
"postcss-rem-to-responsive-pixel": "^5.1.3",
|
|
149
153
|
"prettier": "^2.8.8",
|
|
154
|
+
"promisify-loader-runner": "^1.0.0",
|
|
150
155
|
"rollup": "^3.25.1",
|
|
151
156
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
152
157
|
"style-loader": "^3.3.3",
|
|
@@ -154,18 +159,17 @@
|
|
|
154
159
|
"tailwindcss": "^3.3.2",
|
|
155
160
|
"ts-jest": "^29.1.0",
|
|
156
161
|
"ts-node": "^10.9.1",
|
|
157
|
-
"ts-patch": "^
|
|
162
|
+
"ts-patch": "^3.0.0",
|
|
158
163
|
"tsd": "^0.28.1",
|
|
159
164
|
"tslib": "^2.5.3",
|
|
160
|
-
"
|
|
161
|
-
"typescript": "^4.9.5",
|
|
165
|
+
"typescript": "^5.1.3",
|
|
162
166
|
"typescript-transform-paths": "^3.4.6",
|
|
163
167
|
"vinyl": "^3.0.0",
|
|
164
168
|
"vite": "^4.3.9",
|
|
165
|
-
"vitest": "^0.32.
|
|
169
|
+
"vitest": "^0.32.2",
|
|
166
170
|
"weapp-tailwindcss-children": "^0.1.0",
|
|
167
|
-
"webpack": "^5.
|
|
168
|
-
"webpack-build-utils": "^0.0.
|
|
171
|
+
"webpack": "^5.87.0",
|
|
172
|
+
"webpack-build-utils": "^0.0.4"
|
|
169
173
|
},
|
|
170
174
|
"dependencies": {
|
|
171
175
|
"@babel/generator": "^7.21.4",
|
|
@@ -173,14 +177,15 @@
|
|
|
173
177
|
"@babel/traverse": "^7.21.4",
|
|
174
178
|
"@babel/types": "^7.21.4",
|
|
175
179
|
"@csstools/postcss-is-pseudo-class": "^3.2.1",
|
|
180
|
+
"loader-utils": "^2.0.3",
|
|
176
181
|
"micromatch": "^4.0.5",
|
|
177
182
|
"postcss": "8.4.24",
|
|
178
183
|
"postcss-selector-parser": "^6.0.13",
|
|
179
|
-
"semver": "^7.5.
|
|
180
|
-
"tailwindcss-mangle-shared": "^1.2.
|
|
181
|
-
"tailwindcss-patch": "^1.2.
|
|
184
|
+
"semver": "^7.5.2",
|
|
185
|
+
"tailwindcss-mangle-shared": "^1.2.6",
|
|
186
|
+
"tailwindcss-patch": "^1.2.6"
|
|
182
187
|
},
|
|
183
|
-
"packageManager": "pnpm@8.6.
|
|
188
|
+
"packageManager": "pnpm@8.6.2",
|
|
184
189
|
"scripts": {
|
|
185
190
|
"dev": "yarn clean && yarn dts && cross-env NODE_ENV=development rollup -c rollup.config.ts --configPlugin typescript -w",
|
|
186
191
|
"build": "yarn clean && cross-env NODE_ENV=production rollup -c rollup.config.ts --configPlugin typescript && yarn dts",
|
|
@@ -189,6 +194,7 @@
|
|
|
189
194
|
"dts": "tsc --emitDeclarationOnly -p tsconfig.dts.json",
|
|
190
195
|
"test": "jest && vitest run",
|
|
191
196
|
"jest-u": "jest -u",
|
|
197
|
+
"jest:u": "jest -u",
|
|
192
198
|
"test:dev": "vitest",
|
|
193
199
|
"vitest:coverage": "vitest run --coverage",
|
|
194
200
|
"e2e": "vitest run -c ./vitest.e2e.config.ts",
|