weapp-tailwindcss 3.4.0-alpha.0 → 3.4.0-alpha.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/babel/index.d.ts +16 -0
- package/dist/bundlers/gulp/index.d.ts +8 -0
- package/dist/bundlers/vite/index.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +8 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +8 -0
- package/dist/bundlers/webpack/index.d.ts +1 -0
- package/dist/{weapp-tw-runtime-loader.d.ts → bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts} +2 -4
- package/dist/cache/index.d.ts +32 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +51 -1760
- package/dist/cli.mjs +45 -34
- package/dist/constants-CFM1J-h1.js +42 -0
- package/dist/constants-Dy2Dd3Fz.mjs +36 -0
- package/dist/constants.d.ts +7 -0
- package/dist/core.d.ts +2 -16
- package/dist/core.js +60 -1775
- package/dist/core.mjs +60 -46
- package/dist/css-macro/constants.d.ts +14 -0
- package/dist/css-macro/index.d.ts +4 -7
- package/dist/css-macro/index.js +30 -140
- package/dist/css-macro/index.mjs +28 -35
- package/dist/css-macro/postcss.d.ts +3 -5
- package/dist/css-macro/postcss.js +46 -99
- package/dist/css-macro/postcss.mjs +45 -54
- package/dist/debug/index.d.ts +2 -0
- package/dist/defaults-DW-EahCC.js +145 -0
- package/dist/defaults-w3rlKQwe.mjs +139 -0
- package/dist/defaults.d.ts +2 -16
- package/dist/defaults.js +7 -208
- package/dist/defaults.mjs +4 -9
- package/dist/defu-Cdz2PomB.js +60 -0
- package/dist/defu-n46TJT6t.mjs +57 -0
- package/dist/env.d.ts +2 -0
- package/dist/escape.d.ts +4 -0
- package/dist/extractors/split.d.ts +3 -0
- package/dist/gulp.d.ts +1 -26
- package/dist/gulp.js +38 -1898
- package/dist/gulp.mjs +30 -15
- package/dist/index-B2TNoaOv.mjs +134 -0
- package/dist/index-B5NiRecR.js +130 -0
- package/dist/index-BEIjgKpF.mjs +11 -0
- package/dist/index-BPzIdybK.mjs +513 -0
- package/dist/index-DeW_zXzo.mjs +124 -0
- package/dist/index-DmzxhHCX.js +136 -0
- package/dist/index-DwZHOkK3.js +526 -0
- package/dist/index-HC-Qkn0i.js +17 -0
- package/dist/index.d.ts +4 -17
- package/dist/index.js +43 -2291
- package/dist/index.mjs +33 -23
- package/dist/js/handlers.d.ts +13 -0
- package/dist/js/index.d.ts +7 -0
- package/dist/mangle/index.d.ts +8 -0
- package/dist/options-7EjuAISl.mjs +869 -0
- package/dist/options-C-rvBixk.js +901 -0
- package/dist/options.d.ts +2 -0
- package/dist/postcss/cssVars.d.ts +5 -0
- package/dist/postcss/index.d.ts +3 -0
- package/dist/postcss/mp.d.ts +8 -0
- package/dist/postcss/plugins/ctx.d.ts +6 -0
- package/dist/postcss/plugins/index.d.ts +7 -0
- package/dist/postcss/plugins/post.d.ts +5 -0
- package/dist/postcss/plugins/pre.d.ts +5 -0
- package/dist/postcss/preflight.d.ts +3 -0
- package/dist/postcss/selectorParser.d.ts +6 -0
- package/dist/postcss/shared.d.ts +3 -0
- package/dist/postcss/symbols.d.ts +1 -0
- package/dist/postcss.d.ts +1 -23
- package/dist/postcss.js +22 -598
- package/dist/postcss.mjs +8 -17
- package/dist/reg.d.ts +1 -0
- package/dist/replace.d.ts +3 -19
- package/dist/replace.js +42 -93
- package/dist/replace.mjs +26 -30
- package/dist/shared-DbJl6i6a.mjs +25 -0
- package/dist/shared-hzYeE1wX.js +28 -0
- package/dist/tailwindcss/patcher.d.ts +3 -0
- package/dist/types.d.ts +165 -0
- package/dist/utils.d.ts +18 -0
- package/dist/v5-BD9-sqra.mjs +174 -0
- package/dist/v5-Ch6783yy.js +181 -0
- package/dist/vite.d.ts +1 -22
- package/dist/vite.js +36 -1947
- package/dist/vite.mjs +28 -15
- package/dist/weapp-tw-runtime-loader.js +14 -41
- package/dist/weapp-tw-runtime-loader.mjs +8 -12
- package/dist/webpack.d.ts +1 -26
- package/dist/webpack.js +37 -1994
- package/dist/webpack.mjs +29 -15
- package/dist/webpack4.d.ts +1 -27
- package/dist/webpack4.js +190 -1979
- package/dist/webpack4.mjs +188 -211
- package/dist/wxml/Tokenizer.d.ts +31 -0
- package/dist/wxml/index.d.ts +2 -0
- package/dist/wxml/shared.d.ts +2 -0
- package/dist/wxml/utils.d.ts +13 -0
- package/package.json +3 -3
- package/dist/chunk-257YPDSI.mjs +0 -173
- package/dist/chunk-75EWCRQW.mjs +0 -13
- package/dist/chunk-AB467PG7.mjs +0 -43
- package/dist/chunk-E7XGHGC7.mjs +0 -62
- package/dist/chunk-GUE4UCRJ.mjs +0 -126
- package/dist/chunk-IOYI6MSW.mjs +0 -533
- package/dist/chunk-LDWI65M5.mjs +0 -152
- package/dist/chunk-NVFWRLOI.mjs +0 -27
- package/dist/chunk-ORMKM6ZA.mjs +0 -30
- package/dist/chunk-PC4B5JJB.mjs +0 -953
- package/dist/chunk-SRLZU2YE.mjs +0 -95
- package/dist/chunk-VECXHWWG.mjs +0 -31
- package/dist/chunk-VN37QGSM.mjs +0 -216
- package/dist/cli.d.mts +0 -2
- package/dist/core.d.mts +0 -22
- package/dist/css-macro/index.d.mts +0 -18
- package/dist/css-macro/postcss.d.mts +0 -7
- package/dist/defaults.d.mts +0 -16
- package/dist/gulp.d.mts +0 -26
- package/dist/index.d.mts +0 -17
- package/dist/postcss.d.mts +0 -23
- package/dist/replace.d.mts +0 -19
- package/dist/types-DSNuiOhH.d.mts +0 -519
- package/dist/types-DSNuiOhH.d.ts +0 -519
- package/dist/vite.d.mts +0 -22
- package/dist/weapp-tw-runtime-loader.d.mts +0 -7
- package/dist/webpack.d.mts +0 -26
- package/dist/webpack4.d.mts +0 -27
package/dist/webpack4.mjs
CHANGED
|
@@ -1,216 +1,193 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
} from
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { g as getOptions, _ as __awaiter } from './options-7EjuAISl.mjs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { ConcatSource, RawSource } from 'webpack-sources';
|
|
5
|
+
import { b as pluginName } from './index-BPzIdybK.mjs';
|
|
6
|
+
import { g as getGroupedEntries, r as removeExt } from './defaults-w3rlKQwe.mjs';
|
|
7
|
+
import { c as createDebug } from './index-BEIjgKpF.mjs';
|
|
8
|
+
import 'magic-string';
|
|
9
|
+
import './replace.mjs';
|
|
10
|
+
import '@weapp-core/escape';
|
|
11
|
+
import '@ast-core/escape';
|
|
12
|
+
import './shared-DbJl6i6a.mjs';
|
|
13
|
+
import '@weapp-core/regex';
|
|
14
|
+
import '@babel/generator';
|
|
15
|
+
import '@babel/traverse';
|
|
16
|
+
import '@babel/parser';
|
|
17
|
+
import '@babel/types';
|
|
18
|
+
import 'htmlparser2';
|
|
19
|
+
import 'postcss';
|
|
20
|
+
import 'node:process';
|
|
21
|
+
import 'tailwindcss-patch';
|
|
22
|
+
import '@tailwindcss-mangle/shared';
|
|
23
|
+
import 'lru-cache';
|
|
24
|
+
import 'md5';
|
|
25
|
+
import '@csstools/postcss-is-pseudo-class';
|
|
26
|
+
import 'postcss-rem-to-responsive-pixel';
|
|
27
|
+
import 'postcss-selector-parser';
|
|
28
|
+
import './defu-n46TJT6t.mjs';
|
|
29
|
+
import 'debug';
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var UnifiedWebpackPluginV4 = class {
|
|
28
|
-
constructor(options = {}) {
|
|
29
|
-
this.options = getOptions(options);
|
|
30
|
-
this.appType = this.options.appType;
|
|
31
|
-
}
|
|
32
|
-
apply(compiler) {
|
|
33
|
-
const {
|
|
34
|
-
mainCssChunkMatcher,
|
|
35
|
-
disabled,
|
|
36
|
-
onLoad,
|
|
37
|
-
onUpdate,
|
|
38
|
-
onEnd,
|
|
39
|
-
onStart,
|
|
40
|
-
styleHandler,
|
|
41
|
-
patch,
|
|
42
|
-
templateHandler,
|
|
43
|
-
jsHandler,
|
|
44
|
-
setMangleRuntimeSet,
|
|
45
|
-
runtimeLoaderPath,
|
|
46
|
-
cache,
|
|
47
|
-
twPatcher
|
|
48
|
-
} = this.options;
|
|
49
|
-
if (disabled) {
|
|
50
|
-
return;
|
|
31
|
+
const debug = createDebug();
|
|
32
|
+
class UnifiedWebpackPluginV4 {
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
this.options = getOptions(options);
|
|
35
|
+
this.appType = this.options.appType;
|
|
51
36
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
onLoad();
|
|
57
|
-
const loader = runtimeLoaderPath != null ? runtimeLoaderPath : path.resolve(__dirname, "./weapp-tw-runtime-loader.js");
|
|
58
|
-
const isExisted = fs.existsSync(loader);
|
|
59
|
-
const WeappTwRuntimeAopLoader = {
|
|
60
|
-
loader,
|
|
61
|
-
options: {
|
|
62
|
-
getClassSet
|
|
63
|
-
},
|
|
64
|
-
ident: null,
|
|
65
|
-
type: null
|
|
66
|
-
};
|
|
67
|
-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
68
|
-
compilation.hooks.normalModuleLoader.tap(pluginName, (_loaderContext, module) => {
|
|
69
|
-
if (isExisted) {
|
|
70
|
-
const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
|
|
71
|
-
if (idx > -1) {
|
|
72
|
-
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
compiler.hooks.emit.tapPromise(pluginName, (compilation) => __async(this, null, function* () {
|
|
78
|
-
onStart();
|
|
79
|
-
debug("start");
|
|
80
|
-
for (const chunk of compilation.chunks) {
|
|
81
|
-
if (chunk.id && chunk.hash) {
|
|
82
|
-
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const assets = compilation.assets;
|
|
86
|
-
const entries = Object.entries(assets);
|
|
87
|
-
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
88
|
-
const runtimeSet = getClassSet();
|
|
89
|
-
setMangleRuntimeSet(runtimeSet);
|
|
90
|
-
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
91
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
92
|
-
let noCachedCount = 0;
|
|
93
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
94
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
95
|
-
const rawSource = originalSource.source().toString();
|
|
96
|
-
const hash = cache.computeHash(rawSource);
|
|
97
|
-
const cacheKey = file;
|
|
98
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
99
|
-
yield cache.process(
|
|
100
|
-
cacheKey,
|
|
101
|
-
() => {
|
|
102
|
-
const source = cache.get(cacheKey);
|
|
103
|
-
if (source) {
|
|
104
|
-
compilation.updateAsset(file, source);
|
|
105
|
-
debug("html cache hit: %s", file);
|
|
106
|
-
} else {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
// @ts-ignore
|
|
111
|
-
() => __async(this, null, function* () {
|
|
112
|
-
const wxml = yield templateHandler(rawSource, {
|
|
113
|
-
runtimeSet
|
|
114
|
-
});
|
|
115
|
-
const source = new ConcatSource(wxml);
|
|
116
|
-
compilation.updateAsset(file, source);
|
|
117
|
-
onUpdate(file, rawSource, wxml);
|
|
118
|
-
debug("html handle: %s", file);
|
|
119
|
-
noCachedCount++;
|
|
120
|
-
return {
|
|
121
|
-
key: cacheKey,
|
|
122
|
-
source
|
|
123
|
-
};
|
|
124
|
-
})
|
|
125
|
-
);
|
|
37
|
+
apply(compiler) {
|
|
38
|
+
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, twPatcher, } = this.options;
|
|
39
|
+
if (disabled) {
|
|
40
|
+
return;
|
|
126
41
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
let noCachedCount = 0;
|
|
131
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
132
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
133
|
-
const cacheKey = removeExt(file);
|
|
134
|
-
yield cache.process(
|
|
135
|
-
cacheKey,
|
|
136
|
-
() => {
|
|
137
|
-
const source = cache.get(cacheKey);
|
|
138
|
-
if (source) {
|
|
139
|
-
compilation.updateAsset(file, source);
|
|
140
|
-
debug("js cache hit: %s", file);
|
|
141
|
-
} else {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
// @ts-ignore
|
|
146
|
-
() => __async(this, null, function* () {
|
|
147
|
-
const rawSource = originalSource.source().toString();
|
|
148
|
-
const mapFilename = `${file}.map`;
|
|
149
|
-
const hasMap = Boolean(assets[mapFilename]);
|
|
150
|
-
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
151
|
-
generateMap: hasMap
|
|
152
|
-
});
|
|
153
|
-
const source = new ConcatSource(code);
|
|
154
|
-
compilation.updateAsset(file, source);
|
|
155
|
-
onUpdate(file, rawSource, code);
|
|
156
|
-
debug("js handle: %s", file);
|
|
157
|
-
noCachedCount++;
|
|
158
|
-
if (hasMap && map) {
|
|
159
|
-
const source2 = new RawSource(map.toString());
|
|
160
|
-
compilation.updateAsset(mapFilename, source2);
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
key: cacheKey,
|
|
164
|
-
source
|
|
165
|
-
};
|
|
166
|
-
})
|
|
167
|
-
);
|
|
42
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
43
|
+
function getClassSet() {
|
|
44
|
+
return twPatcher.getClassSet();
|
|
168
45
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const hash = cache.computeHash(rawSource);
|
|
177
|
-
const cacheKey = file;
|
|
178
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
179
|
-
yield cache.process(
|
|
180
|
-
cacheKey,
|
|
181
|
-
() => {
|
|
182
|
-
const source = cache.get(cacheKey);
|
|
183
|
-
if (source) {
|
|
184
|
-
compilation.updateAsset(file, source);
|
|
185
|
-
debug("css cache hit: %s", file);
|
|
186
|
-
} else {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
46
|
+
onLoad();
|
|
47
|
+
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path.resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
48
|
+
const isExisted = fs.existsSync(loader);
|
|
49
|
+
const WeappTwRuntimeAopLoader = {
|
|
50
|
+
loader,
|
|
51
|
+
options: {
|
|
52
|
+
getClassSet,
|
|
189
53
|
},
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
54
|
+
ident: null,
|
|
55
|
+
type: null,
|
|
56
|
+
};
|
|
57
|
+
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
58
|
+
compilation.hooks.normalModuleLoader.tap(pluginName, (_loaderContext, module) => {
|
|
59
|
+
if (isExisted) {
|
|
60
|
+
const idx = module.loaders.findIndex(x => x.loader.includes('postcss-loader'));
|
|
61
|
+
if (idx > -1) {
|
|
62
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
compiler.hooks.emit.tapPromise(pluginName, (compilation) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
onStart();
|
|
69
|
+
debug('start');
|
|
70
|
+
for (const chunk of compilation.chunks) {
|
|
71
|
+
if (chunk.id && chunk.hash) {
|
|
72
|
+
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const assets = compilation.assets;
|
|
76
|
+
const entries = Object.entries(assets);
|
|
77
|
+
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
78
|
+
const runtimeSet = getClassSet();
|
|
79
|
+
setMangleRuntimeSet(runtimeSet);
|
|
80
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
81
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
82
|
+
let noCachedCount = 0;
|
|
83
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
84
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
85
|
+
const rawSource = originalSource.source().toString();
|
|
86
|
+
const hash = cache.computeHash(rawSource);
|
|
87
|
+
const cacheKey = file;
|
|
88
|
+
cache.calcHashValueChanged(cacheKey, hash);
|
|
89
|
+
yield cache.process(cacheKey, () => {
|
|
90
|
+
const source = cache.get(cacheKey);
|
|
91
|
+
if (source) {
|
|
92
|
+
compilation.updateAsset(file, source);
|
|
93
|
+
debug('html cache hit: %s', file);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const wxml = yield templateHandler(rawSource, {
|
|
100
|
+
runtimeSet,
|
|
101
|
+
});
|
|
102
|
+
const source = new ConcatSource(wxml);
|
|
103
|
+
compilation.updateAsset(file, source);
|
|
104
|
+
onUpdate(file, rawSource, wxml);
|
|
105
|
+
debug('html handle: %s', file);
|
|
106
|
+
noCachedCount++;
|
|
107
|
+
return {
|
|
108
|
+
key: cacheKey,
|
|
109
|
+
source,
|
|
110
|
+
};
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
114
|
+
}
|
|
115
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
116
|
+
let noCachedCount = 0;
|
|
117
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
118
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
119
|
+
const cacheKey = removeExt(file);
|
|
120
|
+
yield cache.process(cacheKey, () => {
|
|
121
|
+
const source = cache.get(cacheKey);
|
|
122
|
+
if (source) {
|
|
123
|
+
compilation.updateAsset(file, source);
|
|
124
|
+
debug('js cache hit: %s', file);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const rawSource = originalSource.source().toString();
|
|
131
|
+
const mapFilename = `${file}.map`;
|
|
132
|
+
const hasMap = Boolean(assets[mapFilename]);
|
|
133
|
+
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
134
|
+
generateMap: hasMap,
|
|
135
|
+
});
|
|
136
|
+
const source = new ConcatSource(code);
|
|
137
|
+
compilation.updateAsset(file, source);
|
|
138
|
+
onUpdate(file, rawSource, code);
|
|
139
|
+
debug('js handle: %s', file);
|
|
140
|
+
noCachedCount++;
|
|
141
|
+
if (hasMap && map) {
|
|
142
|
+
const source = new RawSource(map.toString());
|
|
143
|
+
compilation.updateAsset(mapFilename, source);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
key: cacheKey,
|
|
147
|
+
source,
|
|
148
|
+
};
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
152
|
+
}
|
|
153
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
154
|
+
let noCachedCount = 0;
|
|
155
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
156
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
157
|
+
const rawSource = originalSource.source().toString();
|
|
158
|
+
const hash = cache.computeHash(rawSource);
|
|
159
|
+
const cacheKey = file;
|
|
160
|
+
cache.calcHashValueChanged(cacheKey, hash);
|
|
161
|
+
yield cache.process(cacheKey, () => {
|
|
162
|
+
const source = cache.get(cacheKey);
|
|
163
|
+
if (source) {
|
|
164
|
+
compilation.updateAsset(file, source);
|
|
165
|
+
debug('css cache hit: %s', file);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const css = yield styleHandler(rawSource, {
|
|
172
|
+
isMainChunk: mainCssChunkMatcher(file, this.appType),
|
|
173
|
+
});
|
|
174
|
+
const source = new ConcatSource(css);
|
|
175
|
+
compilation.updateAsset(file, source);
|
|
176
|
+
onUpdate(file, rawSource, css);
|
|
177
|
+
debug('css handle: %s', file);
|
|
178
|
+
noCachedCount++;
|
|
179
|
+
return {
|
|
180
|
+
key: cacheKey,
|
|
181
|
+
source,
|
|
182
|
+
};
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
186
|
+
}
|
|
187
|
+
debug('end');
|
|
188
|
+
onEnd();
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export { UnifiedWebpackPluginV4 };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare enum State {
|
|
2
|
+
START = 0,
|
|
3
|
+
TEXT = 1,
|
|
4
|
+
OPEN_BRACE = 2,
|
|
5
|
+
POTENTIAL_CLOSE = 3,
|
|
6
|
+
BRACES_COMPLETE = 4
|
|
7
|
+
}
|
|
8
|
+
export interface Expression {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Token {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
value: string;
|
|
17
|
+
expressions: Expression[];
|
|
18
|
+
}
|
|
19
|
+
export declare class Tokenizer {
|
|
20
|
+
private state;
|
|
21
|
+
private buffer;
|
|
22
|
+
private tokens;
|
|
23
|
+
private bufferStartIndex;
|
|
24
|
+
private expressionStartIndex;
|
|
25
|
+
private expressionBuffer;
|
|
26
|
+
private expressions;
|
|
27
|
+
constructor();
|
|
28
|
+
private processChar;
|
|
29
|
+
run(input: string): Token[];
|
|
30
|
+
reset(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import MagicString from 'magic-string';
|
|
2
|
+
import type { Token } from './Tokenizer';
|
|
3
|
+
import type { ItemOrItemArray } from '@/reg';
|
|
4
|
+
import type { ITemplateHandlerOptions, RawSource } from '@/types';
|
|
5
|
+
export declare function generateCode(match: string, options?: ITemplateHandlerOptions): string;
|
|
6
|
+
export declare function extractSource(original: string): RawSource[];
|
|
7
|
+
export declare function handleEachClassFragment(original: string, options?: ITemplateHandlerOptions): string;
|
|
8
|
+
export declare function handleEachClassFragment2(ms: MagicString, tokens: Token[], options?: ITemplateHandlerOptions): void;
|
|
9
|
+
export declare function templateReplacer(original: string, options?: ITemplateHandlerOptions): string;
|
|
10
|
+
export declare function templateReplacer2(original: string, options?: ITemplateHandlerOptions): string;
|
|
11
|
+
export declare function isPropsMatch(props: ItemOrItemArray<string | RegExp>, attr: string): boolean;
|
|
12
|
+
export declare function customTemplateHandler(rawSource: string, options: Required<ITemplateHandlerOptions>): Promise<string>;
|
|
13
|
+
export declare function createTemplateHandler(options?: Omit<ITemplateHandlerOptions, 'runtimeSet'>): (rawSource: string, opt?: Pick<ITemplateHandlerOptions, 'runtimeSet'>) => Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "3.4.0-alpha.
|
|
3
|
+
"version": "3.4.0-alpha.2",
|
|
4
4
|
"description": "把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!",
|
|
5
5
|
"author": "SonOfMagic <qq1324318532@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -148,8 +148,8 @@
|
|
|
148
148
|
"webpack-sources": "3.2.3"
|
|
149
149
|
},
|
|
150
150
|
"scripts": {
|
|
151
|
-
"dev": "
|
|
152
|
-
"build": "
|
|
151
|
+
"dev": "pnpm clean && pnpm dts && cross-env NODE_ENV=development rollup -c rollup.config.ts --configPlugin typescript -w",
|
|
152
|
+
"build": "pnpm clean && cross-env NODE_ENV=production rollup -c rollup.config.ts --configPlugin typescript && pnpm dts",
|
|
153
153
|
"build:tsc": "cross-env NODE_ENV=development tsc --build tsconfig.json",
|
|
154
154
|
"build:cli": "cd plugins/cli && pnpm run build",
|
|
155
155
|
"dts": "tsc --emitDeclarationOnly -p tsconfig.dts.json",
|
package/dist/chunk-257YPDSI.mjs
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDebug
|
|
3
|
-
} from "./chunk-75EWCRQW.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getOptions
|
|
6
|
-
} from "./chunk-PC4B5JJB.mjs";
|
|
7
|
-
import {
|
|
8
|
-
getGroupedEntries
|
|
9
|
-
} from "./chunk-GUE4UCRJ.mjs";
|
|
10
|
-
import {
|
|
11
|
-
vitePluginName
|
|
12
|
-
} from "./chunk-IOYI6MSW.mjs";
|
|
13
|
-
import {
|
|
14
|
-
__async
|
|
15
|
-
} from "./chunk-E7XGHGC7.mjs";
|
|
16
|
-
|
|
17
|
-
// src/bundlers/vite/index.ts
|
|
18
|
-
var debug = createDebug();
|
|
19
|
-
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
20
|
-
const opts = getOptions(options);
|
|
21
|
-
const {
|
|
22
|
-
disabled,
|
|
23
|
-
onEnd,
|
|
24
|
-
onLoad,
|
|
25
|
-
onStart,
|
|
26
|
-
onUpdate,
|
|
27
|
-
templateHandler,
|
|
28
|
-
styleHandler,
|
|
29
|
-
patch,
|
|
30
|
-
jsHandler,
|
|
31
|
-
mainCssChunkMatcher,
|
|
32
|
-
appType,
|
|
33
|
-
setMangleRuntimeSet,
|
|
34
|
-
cache,
|
|
35
|
-
twPatcher
|
|
36
|
-
} = opts;
|
|
37
|
-
if (disabled) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
patch == null ? void 0 : patch();
|
|
41
|
-
onLoad();
|
|
42
|
-
return {
|
|
43
|
-
name: vitePluginName,
|
|
44
|
-
enforce: "post",
|
|
45
|
-
generateBundle(opt, bundle) {
|
|
46
|
-
return __async(this, null, function* () {
|
|
47
|
-
debug("start");
|
|
48
|
-
onStart();
|
|
49
|
-
const entries = Object.entries(bundle);
|
|
50
|
-
const groupedEntries = getGroupedEntries(entries, opts);
|
|
51
|
-
const runtimeSet = twPatcher.getClassSet();
|
|
52
|
-
setMangleRuntimeSet(runtimeSet);
|
|
53
|
-
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
54
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
55
|
-
let noCachedCount = 0;
|
|
56
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
57
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
58
|
-
const oldVal = originalSource.source.toString();
|
|
59
|
-
const hash = cache.computeHash(oldVal);
|
|
60
|
-
cache.calcHashValueChanged(file, hash);
|
|
61
|
-
yield cache.process(
|
|
62
|
-
file,
|
|
63
|
-
() => {
|
|
64
|
-
const source = cache.get(file);
|
|
65
|
-
if (source) {
|
|
66
|
-
originalSource.source = source;
|
|
67
|
-
debug("html cache hit: %s", file);
|
|
68
|
-
} else {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
() => __async(this, null, function* () {
|
|
73
|
-
originalSource.source = yield templateHandler(oldVal, {
|
|
74
|
-
runtimeSet
|
|
75
|
-
});
|
|
76
|
-
onUpdate(file, oldVal, originalSource.source);
|
|
77
|
-
debug("html handle: %s", file);
|
|
78
|
-
noCachedCount++;
|
|
79
|
-
return {
|
|
80
|
-
key: file,
|
|
81
|
-
source: originalSource.source
|
|
82
|
-
};
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
|
|
87
|
-
}
|
|
88
|
-
if (Array.isArray(groupedEntries.js)) {
|
|
89
|
-
let noCachedCount = 0;
|
|
90
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
91
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
92
|
-
const rawSource = originalSource.code;
|
|
93
|
-
const hash = cache.computeHash(rawSource);
|
|
94
|
-
cache.calcHashValueChanged(file, hash);
|
|
95
|
-
yield cache.process(
|
|
96
|
-
file,
|
|
97
|
-
() => {
|
|
98
|
-
const source = cache.get(file);
|
|
99
|
-
if (source) {
|
|
100
|
-
originalSource.code = source;
|
|
101
|
-
debug("js cache hit: %s", file);
|
|
102
|
-
} else {
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
() => __async(this, null, function* () {
|
|
107
|
-
const mapFilename = `${file}.map`;
|
|
108
|
-
const hasMap = Boolean(bundle[mapFilename]);
|
|
109
|
-
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
110
|
-
generateMap: hasMap
|
|
111
|
-
});
|
|
112
|
-
originalSource.code = code;
|
|
113
|
-
onUpdate(file, rawSource, code);
|
|
114
|
-
debug("js handle: %s", file);
|
|
115
|
-
noCachedCount++;
|
|
116
|
-
if (hasMap && map) {
|
|
117
|
-
;
|
|
118
|
-
bundle[mapFilename].source = map.toString();
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
key: file,
|
|
122
|
-
source: code
|
|
123
|
-
};
|
|
124
|
-
})
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
|
|
128
|
-
}
|
|
129
|
-
if (Array.isArray(groupedEntries.css)) {
|
|
130
|
-
let noCachedCount = 0;
|
|
131
|
-
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
132
|
-
const [file, originalSource] = groupedEntries.css[i];
|
|
133
|
-
const rawSource = originalSource.source.toString();
|
|
134
|
-
const hash = cache.computeHash(rawSource);
|
|
135
|
-
cache.calcHashValueChanged(file, hash);
|
|
136
|
-
yield cache.process(
|
|
137
|
-
file,
|
|
138
|
-
() => {
|
|
139
|
-
const source = cache.get(file);
|
|
140
|
-
if (source) {
|
|
141
|
-
originalSource.source = source;
|
|
142
|
-
debug("css cache hit: %s", file);
|
|
143
|
-
} else {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
() => __async(this, null, function* () {
|
|
148
|
-
const css = yield styleHandler(rawSource, {
|
|
149
|
-
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
150
|
-
});
|
|
151
|
-
originalSource.source = css;
|
|
152
|
-
onUpdate(file, rawSource, css);
|
|
153
|
-
debug("css handle: %s", file);
|
|
154
|
-
noCachedCount++;
|
|
155
|
-
return {
|
|
156
|
-
key: file,
|
|
157
|
-
source: css
|
|
158
|
-
};
|
|
159
|
-
})
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
|
|
163
|
-
}
|
|
164
|
-
onEnd();
|
|
165
|
-
debug("end");
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export {
|
|
172
|
-
UnifiedViteWeappTailwindcssPlugin
|
|
173
|
-
};
|
package/dist/chunk-75EWCRQW.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// src/debug/index.ts
|
|
2
|
-
import _createDebug from "debug";
|
|
3
|
-
var _debug = _createDebug("weapp-tw");
|
|
4
|
-
function createDebug(prefix) {
|
|
5
|
-
function debug(formatter, ...args) {
|
|
6
|
-
return _debug((prefix != null ? prefix : "") + formatter, ...args);
|
|
7
|
-
}
|
|
8
|
-
return debug;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
createDebug
|
|
13
|
-
};
|