weapp-tailwindcss 4.3.2 → 4.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2F7HOQQY.mjs +8 -0
- package/dist/chunk-2NRTWL47.js +43 -0
- package/dist/{chunk-YNMM5ZP5.mjs → chunk-3MSGCIVH.mjs} +128 -138
- package/dist/chunk-6GP37C26.js +8 -0
- package/dist/{chunk-GRWK73SM.js → chunk-AEJDBNAX.js} +567 -309
- package/dist/{chunk-IDYXPWF6.mjs → chunk-AXYGCCZW.mjs} +51 -63
- package/dist/chunk-E2LRXNZ3.js +122 -0
- package/dist/{chunk-BXPTS6UP.mjs → chunk-FBGUUXQV.mjs} +1 -1
- package/dist/{chunk-72PXDJ7I.js → chunk-FOSGDQZ7.js} +34 -43
- package/dist/chunk-H4JTYYOI.mjs +43 -0
- package/dist/{chunk-3YIQPUK7.mjs → chunk-IHKVNALD.mjs} +29 -38
- package/dist/chunk-KAKRCCPX.mjs +122 -0
- package/dist/{chunk-AMSF25MI.js → chunk-NZ7VALIM.js} +130 -140
- package/dist/{chunk-YSVQIZ4W.js → chunk-PPTSD6TQ.js} +51 -63
- package/dist/{chunk-K6IPKJSY.js → chunk-RBRSMHFS.js} +1 -1
- package/dist/chunk-UW3WHSZ5.js +39 -0
- package/dist/{chunk-DGVVFKNF.mjs → chunk-WCIVXE2D.mjs} +566 -308
- package/dist/chunk-ZNKIYZRQ.mjs +39 -0
- package/dist/cli.js +5 -8
- package/dist/cli.mjs +4 -7
- package/dist/core.js +5 -5
- package/dist/core.mjs +4 -4
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/css-macro.js +3 -3
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.js +4 -4
- package/dist/defaults.mjs +3 -3
- package/dist/escape.js +1 -1
- package/dist/escape.mjs +1 -1
- package/dist/gulp.js +7 -7
- package/dist/gulp.mjs +6 -6
- package/dist/index.js +10 -9
- package/dist/index.mjs +9 -8
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss-html-transform.mjs +1 -1
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +2 -2
- package/dist/types.d.mts +248 -194
- package/dist/types.d.ts +248 -194
- package/dist/types.js +1 -1
- package/dist/types.mjs +1 -1
- package/dist/vite.js +7 -7
- package/dist/vite.mjs +6 -6
- package/dist/webpack.js +8 -7
- package/dist/webpack.mjs +7 -6
- package/dist/webpack4.js +53 -68
- package/dist/webpack4.mjs +52 -67
- package/package.json +10 -12
- package/dist/chunk-3AUX4FGE.mjs +0 -13
- package/dist/chunk-JXBLHLFR.mjs +0 -27
- package/dist/chunk-K3KFCISK.js +0 -145
- package/dist/chunk-LSSLYD6B.js +0 -13
- package/dist/chunk-O335YLYH.js +0 -27
- package/dist/chunk-RC2KZ2LO.mjs +0 -145
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
getCacheKey
|
|
3
|
+
} from "./chunk-2F7HOQQY.mjs";
|
|
4
|
+
import {
|
|
5
|
+
createDebug,
|
|
6
|
+
processCachedTask
|
|
7
|
+
} from "./chunk-H4JTYYOI.mjs";
|
|
4
8
|
import {
|
|
5
9
|
pluginName
|
|
6
10
|
} from "./chunk-CMUA5KCO.mjs";
|
|
7
11
|
import {
|
|
8
12
|
getCompilerContext
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WCIVXE2D.mjs";
|
|
10
14
|
import {
|
|
11
|
-
getGroupedEntries
|
|
12
|
-
|
|
13
|
-
} from "./chunk-JXBLHLFR.mjs";
|
|
15
|
+
getGroupedEntries
|
|
16
|
+
} from "./chunk-ZNKIYZRQ.mjs";
|
|
14
17
|
import {
|
|
15
18
|
__dirname
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-FBGUUXQV.mjs";
|
|
17
20
|
|
|
18
21
|
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
19
22
|
import fs from "fs";
|
|
@@ -89,74 +92,64 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
89
92
|
const runtimeSet = await twPatcher.getClassSet();
|
|
90
93
|
setMangleRuntimeSet(runtimeSet);
|
|
91
94
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
92
|
-
const
|
|
95
|
+
const tasks = [];
|
|
93
96
|
if (Array.isArray(groupedEntries.html)) {
|
|
94
97
|
for (const element of groupedEntries.html) {
|
|
95
98
|
const [file, originalSource] = element;
|
|
96
99
|
const rawSource = originalSource.source().toString();
|
|
97
|
-
const hash = cache.computeHash(rawSource);
|
|
98
100
|
const cacheKey = file;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
tasks.push(
|
|
102
|
+
processCachedTask({
|
|
103
|
+
cache,
|
|
102
104
|
cacheKey,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
105
|
+
rawSource,
|
|
106
|
+
applyResult(source) {
|
|
107
|
+
compilation.updateAsset(file, source);
|
|
108
|
+
},
|
|
109
|
+
onCacheHit() {
|
|
110
|
+
debug("html cache hit: %s", file);
|
|
111
111
|
},
|
|
112
|
-
async () => {
|
|
112
|
+
transform: async () => {
|
|
113
113
|
const wxml = await templateHandler(rawSource, {
|
|
114
114
|
runtimeSet
|
|
115
115
|
});
|
|
116
116
|
const source = new ConcatSource(wxml);
|
|
117
|
-
compilation.updateAsset(file, source);
|
|
118
117
|
onUpdate(file, rawSource, wxml);
|
|
119
118
|
debug("html handle: %s", file);
|
|
120
119
|
return {
|
|
121
|
-
|
|
122
|
-
source
|
|
120
|
+
result: source
|
|
123
121
|
};
|
|
124
122
|
}
|
|
125
|
-
)
|
|
123
|
+
})
|
|
126
124
|
);
|
|
127
125
|
}
|
|
128
126
|
}
|
|
129
127
|
if (Array.isArray(groupedEntries.js)) {
|
|
130
128
|
for (const element of groupedEntries.js) {
|
|
131
129
|
const [file, originalSource] = element;
|
|
132
|
-
const cacheKey =
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
const cacheKey = getCacheKey(file);
|
|
131
|
+
const rawSource = originalSource.source().toString();
|
|
132
|
+
tasks.push(
|
|
133
|
+
processCachedTask({
|
|
134
|
+
cache,
|
|
135
135
|
cacheKey,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
compilation.updateAsset(file, source);
|
|
140
|
-
debug("js cache hit: %s", file);
|
|
141
|
-
} else {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
136
|
+
rawSource,
|
|
137
|
+
applyResult(source) {
|
|
138
|
+
compilation.updateAsset(file, source);
|
|
144
139
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
140
|
+
onCacheHit() {
|
|
141
|
+
debug("js cache hit: %s", file);
|
|
142
|
+
},
|
|
143
|
+
transform: async () => {
|
|
144
|
+
const { code } = await jsHandler(rawSource, runtimeSet);
|
|
150
145
|
const source = new ConcatSource(code);
|
|
151
|
-
compilation.updateAsset(file, source);
|
|
152
146
|
onUpdate(file, rawSource, code);
|
|
153
147
|
debug("js handle: %s", file);
|
|
154
148
|
return {
|
|
155
|
-
|
|
156
|
-
source
|
|
149
|
+
result: source
|
|
157
150
|
};
|
|
158
151
|
}
|
|
159
|
-
)
|
|
152
|
+
})
|
|
160
153
|
);
|
|
161
154
|
}
|
|
162
155
|
}
|
|
@@ -164,22 +157,19 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
164
157
|
for (const element of groupedEntries.css) {
|
|
165
158
|
const [file, originalSource] = element;
|
|
166
159
|
const rawSource = originalSource.source().toString();
|
|
167
|
-
const hash = cache.computeHash(rawSource);
|
|
168
160
|
const cacheKey = file;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
161
|
+
tasks.push(
|
|
162
|
+
processCachedTask({
|
|
163
|
+
cache,
|
|
172
164
|
cacheKey,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
165
|
+
rawSource,
|
|
166
|
+
applyResult(source) {
|
|
167
|
+
compilation.updateAsset(file, source);
|
|
168
|
+
},
|
|
169
|
+
onCacheHit() {
|
|
170
|
+
debug("css cache hit: %s", file);
|
|
181
171
|
},
|
|
182
|
-
async () => {
|
|
172
|
+
transform: async () => {
|
|
183
173
|
const { css } = await styleHandler(rawSource, {
|
|
184
174
|
isMainChunk: mainCssChunkMatcher(file, this.appType),
|
|
185
175
|
postcssOptions: {
|
|
@@ -190,19 +180,17 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
190
180
|
majorVersion: twPatcher.majorVersion
|
|
191
181
|
});
|
|
192
182
|
const source = new ConcatSource(css);
|
|
193
|
-
compilation.updateAsset(file, source);
|
|
194
183
|
onUpdate(file, rawSource, css);
|
|
195
184
|
debug("css handle: %s", file);
|
|
196
185
|
return {
|
|
197
|
-
|
|
198
|
-
source
|
|
186
|
+
result: source
|
|
199
187
|
};
|
|
200
188
|
}
|
|
201
|
-
)
|
|
189
|
+
})
|
|
202
190
|
);
|
|
203
191
|
}
|
|
204
192
|
}
|
|
205
|
-
await Promise.all(
|
|
193
|
+
await Promise.all(tasks);
|
|
206
194
|
debug("end");
|
|
207
195
|
onEnd();
|
|
208
196
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunk2NRTWL47js = require('./chunk-2NRTWL47.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkAEJDBNAXjs = require('./chunk-AEJDBNAX.js');
|
|
8
|
+
|
|
9
|
+
// src/bundlers/gulp/index.ts
|
|
10
|
+
var _buffer = require('buffer');
|
|
11
|
+
var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
|
|
12
|
+
var debug = _chunk2NRTWL47js.createDebug.call(void 0, );
|
|
13
|
+
var Transform = _stream2.default.Transform;
|
|
14
|
+
function createPlugins(options = {}) {
|
|
15
|
+
const opts = _chunkAEJDBNAXjs.getCompilerContext.call(void 0, options);
|
|
16
|
+
const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
|
|
17
|
+
let runtimeSet = /* @__PURE__ */ new Set();
|
|
18
|
+
twPatcher.patch();
|
|
19
|
+
function createVinylTransform(handler) {
|
|
20
|
+
return new Transform({
|
|
21
|
+
objectMode: true,
|
|
22
|
+
async transform(file, _encoding, callback) {
|
|
23
|
+
try {
|
|
24
|
+
await handler(file);
|
|
25
|
+
callback(null, file);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
callback(error, file);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const transformWxss = (options2 = {}) => createVinylTransform(async (file) => {
|
|
33
|
+
if (!file.contents) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
runtimeSet = await twPatcher.getClassSet();
|
|
37
|
+
setMangleRuntimeSet(runtimeSet);
|
|
38
|
+
const rawSource = file.contents.toString();
|
|
39
|
+
await _chunk2NRTWL47js.processCachedTask.call(void 0, {
|
|
40
|
+
cache,
|
|
41
|
+
cacheKey: file.path,
|
|
42
|
+
rawSource,
|
|
43
|
+
applyResult(source) {
|
|
44
|
+
file.contents = _buffer.Buffer.from(source);
|
|
45
|
+
},
|
|
46
|
+
onCacheHit() {
|
|
47
|
+
debug("css cache hit: %s", file.path);
|
|
48
|
+
},
|
|
49
|
+
async transform() {
|
|
50
|
+
const { css } = await styleHandler(rawSource, {
|
|
51
|
+
isMainChunk: true,
|
|
52
|
+
majorVersion: twPatcher.majorVersion,
|
|
53
|
+
...options2
|
|
54
|
+
});
|
|
55
|
+
debug("css handle: %s", file.path);
|
|
56
|
+
return {
|
|
57
|
+
result: css
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const transformJs = (options2 = {}) => createVinylTransform(async (file) => {
|
|
63
|
+
if (!file.contents) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const rawSource = file.contents.toString();
|
|
67
|
+
await _chunk2NRTWL47js.processCachedTask.call(void 0, {
|
|
68
|
+
cache,
|
|
69
|
+
cacheKey: file.path,
|
|
70
|
+
rawSource,
|
|
71
|
+
applyResult(source) {
|
|
72
|
+
file.contents = _buffer.Buffer.from(source);
|
|
73
|
+
},
|
|
74
|
+
onCacheHit() {
|
|
75
|
+
debug("js cache hit: %s", file.path);
|
|
76
|
+
},
|
|
77
|
+
async transform() {
|
|
78
|
+
const { code } = await jsHandler(rawSource, runtimeSet, options2);
|
|
79
|
+
debug("js handle: %s", file.path);
|
|
80
|
+
return {
|
|
81
|
+
result: code
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
const transformWxml = (options2 = {}) => createVinylTransform(async (file) => {
|
|
87
|
+
if (!file.contents) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const rawSource = file.contents.toString();
|
|
91
|
+
await _chunk2NRTWL47js.processCachedTask.call(void 0, {
|
|
92
|
+
cache,
|
|
93
|
+
cacheKey: file.path,
|
|
94
|
+
rawSource,
|
|
95
|
+
applyResult(source) {
|
|
96
|
+
file.contents = _buffer.Buffer.from(source);
|
|
97
|
+
},
|
|
98
|
+
onCacheHit() {
|
|
99
|
+
debug("html cache hit: %s", file.path);
|
|
100
|
+
},
|
|
101
|
+
async transform() {
|
|
102
|
+
const code = await templateHandler(rawSource, {
|
|
103
|
+
runtimeSet,
|
|
104
|
+
...options2
|
|
105
|
+
});
|
|
106
|
+
debug("html handle: %s", file.path);
|
|
107
|
+
return {
|
|
108
|
+
result: code
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
transformWxss,
|
|
115
|
+
transformWxml,
|
|
116
|
+
transformJs
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
exports.createPlugins = createPlugins;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.5_jiti@2.
|
|
1
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.5_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
4
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
4
4
|
|
|
5
5
|
// src/defaults.ts
|
|
6
6
|
var _escape = require('@weapp-core/escape');
|
|
7
7
|
var _localpkg = require('local-pkg');
|
|
8
|
+
var CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
|
|
9
|
+
var HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
|
|
10
|
+
var JS_FILE_PATTERN = /.+\.[cm]?js?$/;
|
|
11
|
+
var MAIN_CSS_CHUNK_MATCHERS = {
|
|
12
|
+
"uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
|
|
13
|
+
"uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
|
|
14
|
+
"mpx": (file) => file.startsWith("app"),
|
|
15
|
+
"taro": (file) => file.startsWith("app"),
|
|
16
|
+
"remax": (file) => file.startsWith("app"),
|
|
17
|
+
"rax": (file) => file.startsWith("bundle"),
|
|
18
|
+
"native": (file) => file.startsWith("app"),
|
|
19
|
+
"kbone": (file) => /^(?:common\/)?miniprogram-app/.test(file)
|
|
20
|
+
};
|
|
21
|
+
var alwaysFalse = () => false;
|
|
22
|
+
function createMainCssChunkMatcher() {
|
|
23
|
+
return (file, appType) => {
|
|
24
|
+
if (!appType) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
const matcher = MAIN_CSS_CHUNK_MATCHERS[appType];
|
|
28
|
+
return matcher ? matcher(file) : true;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
8
31
|
function getDefaultOptions() {
|
|
9
32
|
return {
|
|
10
33
|
/**
|
|
@@ -16,7 +39,7 @@ function getDefaultOptions() {
|
|
|
16
39
|
* css 最正常的样式文件
|
|
17
40
|
* tyss 涂鸦小程序
|
|
18
41
|
*/
|
|
19
|
-
cssMatcher: (file) =>
|
|
42
|
+
cssMatcher: (file) => CSS_FILE_PATTERN.test(file),
|
|
20
43
|
/**
|
|
21
44
|
* wxml 微信小程序
|
|
22
45
|
* axml 支付宝小程序
|
|
@@ -28,47 +51,15 @@ function getDefaultOptions() {
|
|
|
28
51
|
* xhsml 小红书小程序
|
|
29
52
|
* swan 百度小程序
|
|
30
53
|
*/
|
|
31
|
-
htmlMatcher: (file) =>
|
|
54
|
+
htmlMatcher: (file) => HTML_FILE_PATTERN.test(file),
|
|
32
55
|
jsMatcher: (file) => {
|
|
33
56
|
if (file.includes("node_modules")) {
|
|
34
57
|
return false;
|
|
35
58
|
}
|
|
36
|
-
return
|
|
37
|
-
},
|
|
38
|
-
mainCssChunkMatcher: (file, appType) => {
|
|
39
|
-
switch (appType) {
|
|
40
|
-
case "uni-app": {
|
|
41
|
-
return file.startsWith("common/main") || file.startsWith("app");
|
|
42
|
-
}
|
|
43
|
-
case "uni-app-vite": {
|
|
44
|
-
return file.startsWith("app") || file.startsWith("common/main");
|
|
45
|
-
}
|
|
46
|
-
case "mpx": {
|
|
47
|
-
return file.startsWith("app");
|
|
48
|
-
}
|
|
49
|
-
case "taro": {
|
|
50
|
-
return file.startsWith("app");
|
|
51
|
-
}
|
|
52
|
-
case "remax": {
|
|
53
|
-
return file.startsWith("app");
|
|
54
|
-
}
|
|
55
|
-
case "rax": {
|
|
56
|
-
return file.startsWith("bundle");
|
|
57
|
-
}
|
|
58
|
-
case "native": {
|
|
59
|
-
return file.startsWith("app");
|
|
60
|
-
}
|
|
61
|
-
case "kbone": {
|
|
62
|
-
return /^(?:common\/)?miniprogram-app/.test(file);
|
|
63
|
-
}
|
|
64
|
-
default: {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
wxsMatcher: () => {
|
|
70
|
-
return false;
|
|
59
|
+
return JS_FILE_PATTERN.test(file);
|
|
71
60
|
},
|
|
61
|
+
mainCssChunkMatcher: createMainCssChunkMatcher(),
|
|
62
|
+
wxsMatcher: alwaysFalse,
|
|
72
63
|
// https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
|
|
73
64
|
cssPreflight: {
|
|
74
65
|
"box-sizing": "border-box",
|
|
@@ -77,11 +68,11 @@ function getDefaultOptions() {
|
|
|
77
68
|
"border-color": "currentColor"
|
|
78
69
|
},
|
|
79
70
|
disabled: false,
|
|
80
|
-
customRuleCallback:
|
|
81
|
-
onLoad:
|
|
82
|
-
onStart:
|
|
83
|
-
onEnd:
|
|
84
|
-
onUpdate:
|
|
71
|
+
customRuleCallback: _chunkUW3WHSZ5js.noop,
|
|
72
|
+
onLoad: _chunkUW3WHSZ5js.noop,
|
|
73
|
+
onStart: _chunkUW3WHSZ5js.noop,
|
|
74
|
+
onEnd: _chunkUW3WHSZ5js.noop,
|
|
75
|
+
onUpdate: _chunkUW3WHSZ5js.noop,
|
|
85
76
|
customAttributes: {},
|
|
86
77
|
customReplaceDictionary: _escape.MappingChars2String,
|
|
87
78
|
appType: void 0,
|
|
@@ -0,0 +1,43 @@
|
|
|
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 ?? "") + formatter, ...args);
|
|
7
|
+
}
|
|
8
|
+
return debug;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/bundlers/shared/cache.ts
|
|
12
|
+
async function processCachedTask({
|
|
13
|
+
cache,
|
|
14
|
+
cacheKey,
|
|
15
|
+
hashKey = cacheKey,
|
|
16
|
+
rawSource,
|
|
17
|
+
readCache,
|
|
18
|
+
applyResult,
|
|
19
|
+
transform,
|
|
20
|
+
onCacheHit
|
|
21
|
+
}) {
|
|
22
|
+
let cacheHit = false;
|
|
23
|
+
const result = await cache.process({
|
|
24
|
+
key: cacheKey,
|
|
25
|
+
hashKey,
|
|
26
|
+
rawSource,
|
|
27
|
+
resolveCache: readCache,
|
|
28
|
+
async onCacheHit(value) {
|
|
29
|
+
cacheHit = true;
|
|
30
|
+
await applyResult(value);
|
|
31
|
+
onCacheHit?.();
|
|
32
|
+
},
|
|
33
|
+
transform
|
|
34
|
+
});
|
|
35
|
+
if (!cacheHit) {
|
|
36
|
+
await applyResult(result);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
createDebug,
|
|
42
|
+
processCachedTask
|
|
43
|
+
};
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
noop
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZNKIYZRQ.mjs";
|
|
4
4
|
|
|
5
5
|
// src/defaults.ts
|
|
6
6
|
import { isAllowedClassName, MappingChars2String } from "@weapp-core/escape";
|
|
7
7
|
import { isPackageExists } from "local-pkg";
|
|
8
|
+
var CSS_FILE_PATTERN = /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/;
|
|
9
|
+
var HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
|
|
10
|
+
var JS_FILE_PATTERN = /.+\.[cm]?js?$/;
|
|
11
|
+
var MAIN_CSS_CHUNK_MATCHERS = {
|
|
12
|
+
"uni-app": (file) => file.startsWith("common/main") || file.startsWith("app"),
|
|
13
|
+
"uni-app-vite": (file) => file.startsWith("app") || file.startsWith("common/main"),
|
|
14
|
+
"mpx": (file) => file.startsWith("app"),
|
|
15
|
+
"taro": (file) => file.startsWith("app"),
|
|
16
|
+
"remax": (file) => file.startsWith("app"),
|
|
17
|
+
"rax": (file) => file.startsWith("bundle"),
|
|
18
|
+
"native": (file) => file.startsWith("app"),
|
|
19
|
+
"kbone": (file) => /^(?:common\/)?miniprogram-app/.test(file)
|
|
20
|
+
};
|
|
21
|
+
var alwaysFalse = () => false;
|
|
22
|
+
function createMainCssChunkMatcher() {
|
|
23
|
+
return (file, appType) => {
|
|
24
|
+
if (!appType) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
const matcher = MAIN_CSS_CHUNK_MATCHERS[appType];
|
|
28
|
+
return matcher ? matcher(file) : true;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
8
31
|
function getDefaultOptions() {
|
|
9
32
|
return {
|
|
10
33
|
/**
|
|
@@ -16,7 +39,7 @@ function getDefaultOptions() {
|
|
|
16
39
|
* css 最正常的样式文件
|
|
17
40
|
* tyss 涂鸦小程序
|
|
18
41
|
*/
|
|
19
|
-
cssMatcher: (file) =>
|
|
42
|
+
cssMatcher: (file) => CSS_FILE_PATTERN.test(file),
|
|
20
43
|
/**
|
|
21
44
|
* wxml 微信小程序
|
|
22
45
|
* axml 支付宝小程序
|
|
@@ -28,47 +51,15 @@ function getDefaultOptions() {
|
|
|
28
51
|
* xhsml 小红书小程序
|
|
29
52
|
* swan 百度小程序
|
|
30
53
|
*/
|
|
31
|
-
htmlMatcher: (file) =>
|
|
54
|
+
htmlMatcher: (file) => HTML_FILE_PATTERN.test(file),
|
|
32
55
|
jsMatcher: (file) => {
|
|
33
56
|
if (file.includes("node_modules")) {
|
|
34
57
|
return false;
|
|
35
58
|
}
|
|
36
|
-
return
|
|
37
|
-
},
|
|
38
|
-
mainCssChunkMatcher: (file, appType) => {
|
|
39
|
-
switch (appType) {
|
|
40
|
-
case "uni-app": {
|
|
41
|
-
return file.startsWith("common/main") || file.startsWith("app");
|
|
42
|
-
}
|
|
43
|
-
case "uni-app-vite": {
|
|
44
|
-
return file.startsWith("app") || file.startsWith("common/main");
|
|
45
|
-
}
|
|
46
|
-
case "mpx": {
|
|
47
|
-
return file.startsWith("app");
|
|
48
|
-
}
|
|
49
|
-
case "taro": {
|
|
50
|
-
return file.startsWith("app");
|
|
51
|
-
}
|
|
52
|
-
case "remax": {
|
|
53
|
-
return file.startsWith("app");
|
|
54
|
-
}
|
|
55
|
-
case "rax": {
|
|
56
|
-
return file.startsWith("bundle");
|
|
57
|
-
}
|
|
58
|
-
case "native": {
|
|
59
|
-
return file.startsWith("app");
|
|
60
|
-
}
|
|
61
|
-
case "kbone": {
|
|
62
|
-
return /^(?:common\/)?miniprogram-app/.test(file);
|
|
63
|
-
}
|
|
64
|
-
default: {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
wxsMatcher: () => {
|
|
70
|
-
return false;
|
|
59
|
+
return JS_FILE_PATTERN.test(file);
|
|
71
60
|
},
|
|
61
|
+
mainCssChunkMatcher: createMainCssChunkMatcher(),
|
|
62
|
+
wxsMatcher: alwaysFalse,
|
|
72
63
|
// https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
|
|
73
64
|
cssPreflight: {
|
|
74
65
|
"box-sizing": "border-box",
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDebug,
|
|
3
|
+
processCachedTask
|
|
4
|
+
} from "./chunk-H4JTYYOI.mjs";
|
|
5
|
+
import {
|
|
6
|
+
getCompilerContext
|
|
7
|
+
} from "./chunk-WCIVXE2D.mjs";
|
|
8
|
+
|
|
9
|
+
// src/bundlers/gulp/index.ts
|
|
10
|
+
import { Buffer } from "buffer";
|
|
11
|
+
import stream from "stream";
|
|
12
|
+
var debug = createDebug();
|
|
13
|
+
var Transform = stream.Transform;
|
|
14
|
+
function createPlugins(options = {}) {
|
|
15
|
+
const opts = getCompilerContext(options);
|
|
16
|
+
const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
|
|
17
|
+
let runtimeSet = /* @__PURE__ */ new Set();
|
|
18
|
+
twPatcher.patch();
|
|
19
|
+
function createVinylTransform(handler) {
|
|
20
|
+
return new Transform({
|
|
21
|
+
objectMode: true,
|
|
22
|
+
async transform(file, _encoding, callback) {
|
|
23
|
+
try {
|
|
24
|
+
await handler(file);
|
|
25
|
+
callback(null, file);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
callback(error, file);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const transformWxss = (options2 = {}) => createVinylTransform(async (file) => {
|
|
33
|
+
if (!file.contents) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
runtimeSet = await twPatcher.getClassSet();
|
|
37
|
+
setMangleRuntimeSet(runtimeSet);
|
|
38
|
+
const rawSource = file.contents.toString();
|
|
39
|
+
await processCachedTask({
|
|
40
|
+
cache,
|
|
41
|
+
cacheKey: file.path,
|
|
42
|
+
rawSource,
|
|
43
|
+
applyResult(source) {
|
|
44
|
+
file.contents = Buffer.from(source);
|
|
45
|
+
},
|
|
46
|
+
onCacheHit() {
|
|
47
|
+
debug("css cache hit: %s", file.path);
|
|
48
|
+
},
|
|
49
|
+
async transform() {
|
|
50
|
+
const { css } = await styleHandler(rawSource, {
|
|
51
|
+
isMainChunk: true,
|
|
52
|
+
majorVersion: twPatcher.majorVersion,
|
|
53
|
+
...options2
|
|
54
|
+
});
|
|
55
|
+
debug("css handle: %s", file.path);
|
|
56
|
+
return {
|
|
57
|
+
result: css
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const transformJs = (options2 = {}) => createVinylTransform(async (file) => {
|
|
63
|
+
if (!file.contents) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const rawSource = file.contents.toString();
|
|
67
|
+
await processCachedTask({
|
|
68
|
+
cache,
|
|
69
|
+
cacheKey: file.path,
|
|
70
|
+
rawSource,
|
|
71
|
+
applyResult(source) {
|
|
72
|
+
file.contents = Buffer.from(source);
|
|
73
|
+
},
|
|
74
|
+
onCacheHit() {
|
|
75
|
+
debug("js cache hit: %s", file.path);
|
|
76
|
+
},
|
|
77
|
+
async transform() {
|
|
78
|
+
const { code } = await jsHandler(rawSource, runtimeSet, options2);
|
|
79
|
+
debug("js handle: %s", file.path);
|
|
80
|
+
return {
|
|
81
|
+
result: code
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
const transformWxml = (options2 = {}) => createVinylTransform(async (file) => {
|
|
87
|
+
if (!file.contents) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const rawSource = file.contents.toString();
|
|
91
|
+
await processCachedTask({
|
|
92
|
+
cache,
|
|
93
|
+
cacheKey: file.path,
|
|
94
|
+
rawSource,
|
|
95
|
+
applyResult(source) {
|
|
96
|
+
file.contents = Buffer.from(source);
|
|
97
|
+
},
|
|
98
|
+
onCacheHit() {
|
|
99
|
+
debug("html cache hit: %s", file.path);
|
|
100
|
+
},
|
|
101
|
+
async transform() {
|
|
102
|
+
const code = await templateHandler(rawSource, {
|
|
103
|
+
runtimeSet,
|
|
104
|
+
...options2
|
|
105
|
+
});
|
|
106
|
+
debug("html handle: %s", file.path);
|
|
107
|
+
return {
|
|
108
|
+
result: code
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
transformWxss,
|
|
115
|
+
transformWxml,
|
|
116
|
+
transformJs
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
createPlugins
|
|
122
|
+
};
|