weapp-tailwindcss 3.7.0 → 3.8.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/README.md +1 -23
- package/dist/chunk-35CYTBPM.js +26 -0
- package/dist/chunk-6FNC3XMI.js +45 -0
- package/dist/chunk-6Z776ZWK.js +43 -0
- package/dist/chunk-75EWCRQW.mjs +13 -0
- package/dist/chunk-7J6ZENMS.js +216 -0
- package/dist/chunk-A2EDVNQK.mjs +173 -0
- package/dist/chunk-AB467PG7.mjs +43 -0
- package/dist/chunk-AXBFBHS2.mjs +45 -0
- package/dist/chunk-C7DFN4K3.js +152 -0
- package/dist/chunk-FYOOMUKL.js +115 -0
- package/dist/chunk-HBQASQKY.js +13 -0
- package/dist/chunk-JVPRWRPJ.mjs +115 -0
- package/dist/chunk-K7CL4YBQ.mjs +216 -0
- package/dist/chunk-KE7J6XFD.mjs +537 -0
- package/dist/chunk-LQN2VTMU.js +537 -0
- package/dist/chunk-MUJ65IQ3.mjs +26 -0
- package/dist/chunk-QJPVKPQS.js +1003 -0
- package/dist/chunk-RFNUATFD.js +24 -0
- package/dist/chunk-T4A3DCFN.mjs +152 -0
- package/dist/chunk-U7O2XXYR.mjs +24 -0
- package/dist/chunk-VFCTLSC3.mjs +1003 -0
- package/dist/chunk-VKSQ6BRD.mjs +27 -0
- package/dist/chunk-WMQLIT4T.js +173 -0
- package/dist/chunk-XSZXPWWL.js +27 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +23 -3400
- package/dist/cli.mjs +28 -3392
- package/dist/core.d.mts +27 -0
- package/dist/core.d.ts +23 -4
- package/dist/core.js +34 -56
- package/dist/core.mjs +36 -54
- package/dist/css-macro/postcss.d.mts +7 -0
- package/dist/css-macro/postcss.d.ts +5 -3
- package/dist/css-macro/postcss.js +54 -45
- package/dist/css-macro/postcss.mjs +54 -45
- package/dist/css-macro.d.mts +18 -0
- package/dist/css-macro.d.ts +18 -0
- package/dist/css-macro.js +40 -0
- package/dist/css-macro.mjs +38 -0
- package/dist/defaults.d.mts +16 -0
- package/dist/defaults.d.ts +16 -2
- package/dist/defaults.js +5 -9
- package/dist/defaults.mjs +8 -4
- package/dist/escape.d.mts +19 -0
- package/dist/escape.d.ts +19 -4
- package/dist/escape.js +11 -0
- package/dist/escape.mjs +11 -0
- package/dist/gulp.d.mts +26 -0
- package/dist/gulp.d.ts +26 -1
- package/dist/gulp.js +11 -36
- package/dist/gulp.mjs +14 -31
- package/dist/index-g4epDIUu.d.mts +534 -0
- package/dist/index-g4epDIUu.d.ts +534 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +22 -44
- package/dist/index.mjs +22 -34
- package/dist/postcss.d.mts +28 -0
- package/dist/postcss.d.ts +28 -1
- package/dist/postcss.js +9 -24
- package/dist/postcss.mjs +16 -8
- package/dist/replace.d.mts +22 -0
- package/dist/replace.d.ts +22 -3
- package/dist/replace.js +33 -50
- package/dist/replace.mjs +32 -25
- package/dist/shared-5ArEo9kL.d.mts +5 -0
- package/dist/shared-DI2Qz1ou.d.ts +5 -0
- package/dist/vite.d.mts +22 -0
- package/dist/vite.d.ts +22 -1
- package/dist/vite.js +11 -34
- package/dist/vite.mjs +14 -29
- package/dist/weapp-tw-runtime-loader.d.mts +7 -0
- package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
- package/dist/weapp-tw-runtime-loader.js +12 -12
- package/dist/weapp-tw-runtime-loader.mjs +12 -8
- package/dist/webpack.d.mts +26 -0
- package/dist/webpack.d.ts +26 -1
- package/dist/webpack.js +11 -35
- package/dist/webpack.mjs +14 -30
- package/dist/webpack4.d.mts +27 -0
- package/dist/webpack4.d.ts +27 -1
- package/dist/webpack4.js +204 -192
- package/dist/webpack4.mjs +210 -189
- package/package.json +26 -19
- package/dist/babel/index.d.ts +0 -5
- package/dist/bundlers/gulp/index.d.ts +0 -7
- package/dist/bundlers/vite/index.d.ts +0 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
- package/dist/bundlers/webpack/index.d.ts +0 -1
- package/dist/cache/index.d.ts +0 -31
- package/dist/constants-CFM1J-h1.js +0 -42
- package/dist/constants-Dy2Dd3Fz.mjs +0 -36
- package/dist/constants.d.ts +0 -7
- package/dist/css-macro/constants.d.ts +0 -14
- package/dist/css-macro/index.d.ts +0 -15
- package/dist/css-macro/index.js +0 -36
- package/dist/css-macro/index.mjs +0 -30
- package/dist/debug/index.d.ts +0 -2
- package/dist/defaults-5A8JI2hW.mjs +0 -139
- package/dist/defaults-CdqzSWsR.js +0 -145
- package/dist/defu-Cdz2PomB.js +0 -60
- package/dist/defu-n46TJT6t.mjs +0 -57
- package/dist/env.d.ts +0 -2
- package/dist/extractors/split.d.ts +0 -3
- package/dist/index-BEIjgKpF.mjs +0 -11
- package/dist/index-BF8k8rHr.mjs +0 -517
- package/dist/index-BTXkyxen.js +0 -136
- package/dist/index-C0QsyqD6.mjs +0 -134
- package/dist/index-ClSBbhnm.js +0 -130
- package/dist/index-DoMb0-xW.mjs +0 -124
- package/dist/index-HC-Qkn0i.js +0 -17
- package/dist/index-h2-ZMO3S.js +0 -530
- package/dist/init.d.ts +0 -34
- package/dist/js/ast-grep.d.ts +0 -1
- package/dist/js/babel.d.ts +0 -3
- package/dist/js/handlers.d.ts +0 -11
- package/dist/js/index.d.ts +0 -7
- package/dist/logger.d.ts +0 -1
- package/dist/mangle/index.d.ts +0 -8
- package/dist/npm.d.ts +0 -22
- package/dist/options-Bv-1GQJY.js +0 -891
- package/dist/options-yXyCFCtr.mjs +0 -858
- package/dist/options.d.ts +0 -2
- package/dist/postcss/cssVars.d.ts +0 -5
- package/dist/postcss/index.d.ts +0 -4
- package/dist/postcss/mp.d.ts +0 -8
- package/dist/postcss/plugins/ctx.d.ts +0 -6
- package/dist/postcss/plugins/index.d.ts +0 -7
- package/dist/postcss/plugins/post.d.ts +0 -5
- package/dist/postcss/plugins/pre.d.ts +0 -5
- package/dist/postcss/preflight.d.ts +0 -3
- package/dist/postcss/selectorParser.d.ts +0 -6
- package/dist/postcss/shared.d.ts +0 -3
- package/dist/postcss/symbols.d.ts +0 -1
- package/dist/reg.d.ts +0 -1
- package/dist/shared-COWjpokr.mjs +0 -25
- package/dist/shared-r_GpWheO.js +0 -28
- package/dist/tailwindcss/patcher.d.ts +0 -3
- package/dist/types.d.ts +0 -165
- package/dist/utils.d.ts +0 -18
- package/dist/v5-DwFXG7m_.js +0 -181
- package/dist/v5-N5BYJ5JY.mjs +0 -174
- package/dist/wxml/Tokenizer.d.ts +0 -31
- package/dist/wxml/index.d.ts +0 -2
- package/dist/wxml/shared.d.ts +0 -2
- package/dist/wxml/utils.d.ts +0 -10
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkHBQASQKYjs = require('./chunk-HBQASQKY.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkQJPVKPQSjs = require('./chunk-QJPVKPQS.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
|
|
11
|
+
|
|
12
|
+
// src/bundlers/gulp/index.ts
|
|
13
|
+
var _buffer = require('buffer');
|
|
14
|
+
var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
|
|
15
|
+
var debug = _chunkHBQASQKYjs.createDebug.call(void 0, );
|
|
16
|
+
var Transform = _stream2.default.Transform;
|
|
17
|
+
function createPlugins(options = {}) {
|
|
18
|
+
const opts = _chunkQJPVKPQSjs.getOptions.call(void 0, options);
|
|
19
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
|
|
20
|
+
let runtimeSet = /* @__PURE__ */ new Set();
|
|
21
|
+
patch == null ? void 0 : patch();
|
|
22
|
+
function transformWxss(options2 = {}) {
|
|
23
|
+
return new Transform({
|
|
24
|
+
objectMode: true,
|
|
25
|
+
transform(file, _encoding, callback) {
|
|
26
|
+
return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
27
|
+
runtimeSet = twPatcher.getClassSet();
|
|
28
|
+
setMangleRuntimeSet(runtimeSet);
|
|
29
|
+
const error = null;
|
|
30
|
+
if (file.contents) {
|
|
31
|
+
const rawSource = file.contents.toString();
|
|
32
|
+
const hash = cache.computeHash(rawSource);
|
|
33
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
34
|
+
yield cache.process(
|
|
35
|
+
file.path,
|
|
36
|
+
() => {
|
|
37
|
+
const source = cache.get(file.path);
|
|
38
|
+
if (source) {
|
|
39
|
+
file.contents = _buffer.Buffer.from(source);
|
|
40
|
+
debug("css cache hit: %s", file.path);
|
|
41
|
+
} else {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
() => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
46
|
+
const { css } = yield styleHandler(rawSource, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {
|
|
47
|
+
isMainChunk: true
|
|
48
|
+
}, options2));
|
|
49
|
+
file.contents = _buffer.Buffer.from(css);
|
|
50
|
+
debug("css handle: %s", file.path);
|
|
51
|
+
return {
|
|
52
|
+
key: file.path,
|
|
53
|
+
source: css
|
|
54
|
+
};
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
callback(error, file);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// construct(callback) {
|
|
62
|
+
// debug('transformWxss start')
|
|
63
|
+
// callback()
|
|
64
|
+
// }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function transformJs(options2 = {}) {
|
|
68
|
+
return new Transform({
|
|
69
|
+
objectMode: true,
|
|
70
|
+
transform(file, _encoding, callback) {
|
|
71
|
+
return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
72
|
+
const error = null;
|
|
73
|
+
if (file.contents) {
|
|
74
|
+
const rawSource = file.contents.toString();
|
|
75
|
+
const hash = cache.computeHash(rawSource);
|
|
76
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
77
|
+
yield cache.process(
|
|
78
|
+
file.path,
|
|
79
|
+
() => {
|
|
80
|
+
const source = cache.get(file.path);
|
|
81
|
+
if (source) {
|
|
82
|
+
file.contents = _buffer.Buffer.from(source);
|
|
83
|
+
debug("js cache hit: %s", file.path);
|
|
84
|
+
} else {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
() => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
89
|
+
const { code } = yield jsHandler(rawSource, runtimeSet, options2);
|
|
90
|
+
file.contents = _buffer.Buffer.from(code);
|
|
91
|
+
debug("js handle: %s", file.path);
|
|
92
|
+
return {
|
|
93
|
+
key: file.path,
|
|
94
|
+
source: code
|
|
95
|
+
};
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
callback(error, file);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function transformWxml(options2 = {}) {
|
|
105
|
+
return new Transform({
|
|
106
|
+
objectMode: true,
|
|
107
|
+
transform(file, _encoding, callback) {
|
|
108
|
+
return _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
109
|
+
const error = null;
|
|
110
|
+
if (file.contents) {
|
|
111
|
+
const rawSource = file.contents.toString();
|
|
112
|
+
const hash = cache.computeHash(rawSource);
|
|
113
|
+
cache.calcHashValueChanged(file.path, hash);
|
|
114
|
+
yield cache.process(
|
|
115
|
+
file.path,
|
|
116
|
+
() => {
|
|
117
|
+
const source = cache.get(file.path);
|
|
118
|
+
if (source) {
|
|
119
|
+
file.contents = _buffer.Buffer.from(source);
|
|
120
|
+
debug("html cache hit: %s", file.path);
|
|
121
|
+
} else {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
() => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
|
|
126
|
+
const code = yield templateHandler(rawSource, _chunk6FNC3XMIjs.__spreadValues.call(void 0, {
|
|
127
|
+
runtimeSet
|
|
128
|
+
}, options2));
|
|
129
|
+
file.contents = _buffer.Buffer.from(code);
|
|
130
|
+
debug("html handle: %s", file.path);
|
|
131
|
+
return {
|
|
132
|
+
key: file.path,
|
|
133
|
+
source: code
|
|
134
|
+
};
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
callback(error, file);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
transformWxss,
|
|
145
|
+
transformWxml,
|
|
146
|
+
transformJs
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
exports.createPlugins = createPlugins;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
|
|
4
|
+
|
|
5
|
+
// src/defaults.ts
|
|
6
|
+
var _escape = require('@weapp-core/escape');
|
|
7
|
+
var defaultOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* wxss 微信小程序
|
|
10
|
+
* acss 支付宝小程序
|
|
11
|
+
* jxss 京东小程序
|
|
12
|
+
* ttss 头条小程序
|
|
13
|
+
* qss QQ小程序
|
|
14
|
+
* css 最正常的样式文件
|
|
15
|
+
* tyss 涂鸦小程序
|
|
16
|
+
*/
|
|
17
|
+
cssMatcher: (file) => /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/.test(file),
|
|
18
|
+
/**
|
|
19
|
+
* wxml 微信小程序
|
|
20
|
+
* axml 支付宝小程序
|
|
21
|
+
* jxml 京东小程序
|
|
22
|
+
* ksml 快手小程序
|
|
23
|
+
* ttml 头条小程序
|
|
24
|
+
* qml QQ小程序
|
|
25
|
+
* tyml 涂鸦小程序
|
|
26
|
+
* xhsml 小红书小程序
|
|
27
|
+
* swan 百度小程序
|
|
28
|
+
*/
|
|
29
|
+
htmlMatcher: (file) => /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/.test(file),
|
|
30
|
+
jsMatcher: (file) => {
|
|
31
|
+
if (file.includes("node_modules")) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return /.+\.[cm]?js?$/.test(file);
|
|
35
|
+
},
|
|
36
|
+
mainCssChunkMatcher: (file, appType) => {
|
|
37
|
+
switch (appType) {
|
|
38
|
+
case "uni-app": {
|
|
39
|
+
return /^common\/main/.test(file);
|
|
40
|
+
}
|
|
41
|
+
case "uni-app-vite": {
|
|
42
|
+
return file.startsWith("app") || /^common\/main/.test(file);
|
|
43
|
+
}
|
|
44
|
+
case "mpx": {
|
|
45
|
+
return file.startsWith("app");
|
|
46
|
+
}
|
|
47
|
+
case "taro": {
|
|
48
|
+
return file.startsWith("app");
|
|
49
|
+
}
|
|
50
|
+
case "remax": {
|
|
51
|
+
return file.startsWith("app");
|
|
52
|
+
}
|
|
53
|
+
case "rax": {
|
|
54
|
+
return file.startsWith("bundle");
|
|
55
|
+
}
|
|
56
|
+
case "native": {
|
|
57
|
+
return file.startsWith("app");
|
|
58
|
+
}
|
|
59
|
+
case "kbone": {
|
|
60
|
+
return /^(?:common\/)?miniprogram-app/.test(file);
|
|
61
|
+
}
|
|
62
|
+
default: {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
wxsMatcher: () => {
|
|
68
|
+
return false;
|
|
69
|
+
},
|
|
70
|
+
// https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
|
|
71
|
+
cssPreflight: {
|
|
72
|
+
"box-sizing": "border-box",
|
|
73
|
+
"border-width": "0",
|
|
74
|
+
"border-style": "solid",
|
|
75
|
+
"border-color": "currentColor"
|
|
76
|
+
},
|
|
77
|
+
disabled: false,
|
|
78
|
+
customRuleCallback: _chunk35CYTBPMjs.noop,
|
|
79
|
+
onLoad: _chunk35CYTBPMjs.noop,
|
|
80
|
+
onStart: _chunk35CYTBPMjs.noop,
|
|
81
|
+
onEnd: _chunk35CYTBPMjs.noop,
|
|
82
|
+
onUpdate: _chunk35CYTBPMjs.noop,
|
|
83
|
+
customAttributes: {},
|
|
84
|
+
customReplaceDictionary: _escape.SimpleMappingChars2String,
|
|
85
|
+
appType: void 0,
|
|
86
|
+
arbitraryValues: {
|
|
87
|
+
allowDoubleQuotes: false
|
|
88
|
+
},
|
|
89
|
+
cssChildCombinatorReplaceValue: ["view"],
|
|
90
|
+
inlineWxs: false,
|
|
91
|
+
injectAdditionalCssVarScope: false,
|
|
92
|
+
jsPreserveClass: (keyword) => {
|
|
93
|
+
if (keyword === "*") {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
},
|
|
98
|
+
disabledDefaultTemplateHandler: false,
|
|
99
|
+
cssSelectorReplacement: {
|
|
100
|
+
root: "page",
|
|
101
|
+
universal: ["view", "text"]
|
|
102
|
+
},
|
|
103
|
+
babelParserOptions: {
|
|
104
|
+
sourceType: "unambiguous"
|
|
105
|
+
},
|
|
106
|
+
postcssOptions: {},
|
|
107
|
+
cssRemoveHoverPseudoClass: true,
|
|
108
|
+
ignoreCallExpressionIdentifiers: [],
|
|
109
|
+
ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"]
|
|
110
|
+
// jsAstTool: 'ast-grep'
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
exports.defaultOptions = defaultOptions;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/debug/index.ts
|
|
2
|
+
var _debug2 = require('debug'); var _debug3 = _interopRequireDefault(_debug2);
|
|
3
|
+
var _debug = _debug3.default.call(void 0, "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
|
+
|
|
12
|
+
|
|
13
|
+
exports.createDebug = createDebug;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
noop
|
|
3
|
+
} from "./chunk-MUJ65IQ3.mjs";
|
|
4
|
+
|
|
5
|
+
// src/defaults.ts
|
|
6
|
+
import { SimpleMappingChars2String } from "@weapp-core/escape";
|
|
7
|
+
var defaultOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* wxss 微信小程序
|
|
10
|
+
* acss 支付宝小程序
|
|
11
|
+
* jxss 京东小程序
|
|
12
|
+
* ttss 头条小程序
|
|
13
|
+
* qss QQ小程序
|
|
14
|
+
* css 最正常的样式文件
|
|
15
|
+
* tyss 涂鸦小程序
|
|
16
|
+
*/
|
|
17
|
+
cssMatcher: (file) => /.+\.(?:wx|ac|jx|tt|q|c|ty)ss$/.test(file),
|
|
18
|
+
/**
|
|
19
|
+
* wxml 微信小程序
|
|
20
|
+
* axml 支付宝小程序
|
|
21
|
+
* jxml 京东小程序
|
|
22
|
+
* ksml 快手小程序
|
|
23
|
+
* ttml 头条小程序
|
|
24
|
+
* qml QQ小程序
|
|
25
|
+
* tyml 涂鸦小程序
|
|
26
|
+
* xhsml 小红书小程序
|
|
27
|
+
* swan 百度小程序
|
|
28
|
+
*/
|
|
29
|
+
htmlMatcher: (file) => /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/.test(file),
|
|
30
|
+
jsMatcher: (file) => {
|
|
31
|
+
if (file.includes("node_modules")) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return /.+\.[cm]?js?$/.test(file);
|
|
35
|
+
},
|
|
36
|
+
mainCssChunkMatcher: (file, appType) => {
|
|
37
|
+
switch (appType) {
|
|
38
|
+
case "uni-app": {
|
|
39
|
+
return /^common\/main/.test(file);
|
|
40
|
+
}
|
|
41
|
+
case "uni-app-vite": {
|
|
42
|
+
return file.startsWith("app") || /^common\/main/.test(file);
|
|
43
|
+
}
|
|
44
|
+
case "mpx": {
|
|
45
|
+
return file.startsWith("app");
|
|
46
|
+
}
|
|
47
|
+
case "taro": {
|
|
48
|
+
return file.startsWith("app");
|
|
49
|
+
}
|
|
50
|
+
case "remax": {
|
|
51
|
+
return file.startsWith("app");
|
|
52
|
+
}
|
|
53
|
+
case "rax": {
|
|
54
|
+
return file.startsWith("bundle");
|
|
55
|
+
}
|
|
56
|
+
case "native": {
|
|
57
|
+
return file.startsWith("app");
|
|
58
|
+
}
|
|
59
|
+
case "kbone": {
|
|
60
|
+
return /^(?:common\/)?miniprogram-app/.test(file);
|
|
61
|
+
}
|
|
62
|
+
default: {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
wxsMatcher: () => {
|
|
68
|
+
return false;
|
|
69
|
+
},
|
|
70
|
+
// https://tailwindcss.com/docs/preflight#border-styles-are-reset-globally
|
|
71
|
+
cssPreflight: {
|
|
72
|
+
"box-sizing": "border-box",
|
|
73
|
+
"border-width": "0",
|
|
74
|
+
"border-style": "solid",
|
|
75
|
+
"border-color": "currentColor"
|
|
76
|
+
},
|
|
77
|
+
disabled: false,
|
|
78
|
+
customRuleCallback: noop,
|
|
79
|
+
onLoad: noop,
|
|
80
|
+
onStart: noop,
|
|
81
|
+
onEnd: noop,
|
|
82
|
+
onUpdate: noop,
|
|
83
|
+
customAttributes: {},
|
|
84
|
+
customReplaceDictionary: SimpleMappingChars2String,
|
|
85
|
+
appType: void 0,
|
|
86
|
+
arbitraryValues: {
|
|
87
|
+
allowDoubleQuotes: false
|
|
88
|
+
},
|
|
89
|
+
cssChildCombinatorReplaceValue: ["view"],
|
|
90
|
+
inlineWxs: false,
|
|
91
|
+
injectAdditionalCssVarScope: false,
|
|
92
|
+
jsPreserveClass: (keyword) => {
|
|
93
|
+
if (keyword === "*") {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
},
|
|
98
|
+
disabledDefaultTemplateHandler: false,
|
|
99
|
+
cssSelectorReplacement: {
|
|
100
|
+
root: "page",
|
|
101
|
+
universal: ["view", "text"]
|
|
102
|
+
},
|
|
103
|
+
babelParserOptions: {
|
|
104
|
+
sourceType: "unambiguous"
|
|
105
|
+
},
|
|
106
|
+
postcssOptions: {},
|
|
107
|
+
cssRemoveHoverPseudoClass: true,
|
|
108
|
+
ignoreCallExpressionIdentifiers: [],
|
|
109
|
+
ignoreTaggedTemplateExpressionIdentifiers: ["weappTwIgnore"]
|
|
110
|
+
// jsAstTool: 'ast-grep'
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
defaultOptions
|
|
115
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDebug
|
|
3
|
+
} from "./chunk-75EWCRQW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getOptions
|
|
6
|
+
} from "./chunk-VFCTLSC3.mjs";
|
|
7
|
+
import {
|
|
8
|
+
getGroupedEntries,
|
|
9
|
+
removeExt
|
|
10
|
+
} from "./chunk-MUJ65IQ3.mjs";
|
|
11
|
+
import {
|
|
12
|
+
pluginName
|
|
13
|
+
} from "./chunk-KE7J6XFD.mjs";
|
|
14
|
+
import {
|
|
15
|
+
__async
|
|
16
|
+
} from "./chunk-AXBFBHS2.mjs";
|
|
17
|
+
|
|
18
|
+
// src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
|
|
19
|
+
import fs from "node:fs";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
var debug = createDebug();
|
|
22
|
+
var UnifiedWebpackPluginV5 = class {
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.options = getOptions(options);
|
|
25
|
+
this.appType = this.options.appType;
|
|
26
|
+
}
|
|
27
|
+
apply(compiler) {
|
|
28
|
+
const {
|
|
29
|
+
mainCssChunkMatcher,
|
|
30
|
+
disabled,
|
|
31
|
+
onLoad,
|
|
32
|
+
onUpdate,
|
|
33
|
+
onEnd,
|
|
34
|
+
onStart,
|
|
35
|
+
styleHandler,
|
|
36
|
+
patch,
|
|
37
|
+
templateHandler,
|
|
38
|
+
jsHandler,
|
|
39
|
+
setMangleRuntimeSet,
|
|
40
|
+
runtimeLoaderPath,
|
|
41
|
+
cache,
|
|
42
|
+
twPatcher
|
|
43
|
+
} = this.options;
|
|
44
|
+
if (disabled) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
patch == null ? void 0 : patch();
|
|
48
|
+
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
49
|
+
const { ConcatSource, RawSource } = sources;
|
|
50
|
+
function getClassSet() {
|
|
51
|
+
return twPatcher.getClassSet();
|
|
52
|
+
}
|
|
53
|
+
onLoad();
|
|
54
|
+
const loader = runtimeLoaderPath != null ? runtimeLoaderPath : path.resolve(__dirname, "./weapp-tw-runtime-loader.js");
|
|
55
|
+
const isExisted = fs.existsSync(loader);
|
|
56
|
+
const WeappTwRuntimeAopLoader = {
|
|
57
|
+
loader,
|
|
58
|
+
options: {
|
|
59
|
+
getClassSet
|
|
60
|
+
},
|
|
61
|
+
ident: null,
|
|
62
|
+
type: null
|
|
63
|
+
};
|
|
64
|
+
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
65
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module) => {
|
|
66
|
+
if (isExisted) {
|
|
67
|
+
const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
|
|
68
|
+
if (idx > -1) {
|
|
69
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
compilation.hooks.processAssets.tapPromise(
|
|
74
|
+
{
|
|
75
|
+
name: pluginName,
|
|
76
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
77
|
+
},
|
|
78
|
+
(assets) => __async(this, null, function* () {
|
|
79
|
+
onStart();
|
|
80
|
+
debug("start");
|
|
81
|
+
for (const chunk of compilation.chunks) {
|
|
82
|
+
if (chunk.id && chunk.hash) {
|
|
83
|
+
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
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
|
+
() => __async(this, null, function* () {
|
|
111
|
+
const wxml = yield templateHandler(rawSource, {
|
|
112
|
+
runtimeSet
|
|
113
|
+
});
|
|
114
|
+
const source = new ConcatSource(wxml);
|
|
115
|
+
compilation.updateAsset(file, source);
|
|
116
|
+
onUpdate(file, rawSource, wxml);
|
|
117
|
+
debug("html handle: %s", file);
|
|
118
|
+
noCachedCount++;
|
|
119
|
+
return {
|
|
120
|
+
key: cacheKey,
|
|
121
|
+
source
|
|
122
|
+
};
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
129
|
+
let noCachedCount = 0;
|
|
130
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
131
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
132
|
+
const cacheKey = removeExt(file);
|
|
133
|
+
yield cache.process(
|
|
134
|
+
cacheKey,
|
|
135
|
+
() => {
|
|
136
|
+
const source = cache.get(cacheKey);
|
|
137
|
+
if (source) {
|
|
138
|
+
compilation.updateAsset(file, source);
|
|
139
|
+
debug("js cache hit: %s", file);
|
|
140
|
+
} else {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
() => __async(this, null, function* () {
|
|
145
|
+
const rawSource = originalSource.source().toString();
|
|
146
|
+
const mapFilename = `${file}.map`;
|
|
147
|
+
const hasMap = Boolean(assets[mapFilename]);
|
|
148
|
+
const { code, map } = yield jsHandler(rawSource, runtimeSet, {
|
|
149
|
+
generateMap: hasMap
|
|
150
|
+
});
|
|
151
|
+
const source = new ConcatSource(code);
|
|
152
|
+
compilation.updateAsset(file, source);
|
|
153
|
+
onUpdate(file, rawSource, code);
|
|
154
|
+
debug("js handle: %s", file);
|
|
155
|
+
noCachedCount++;
|
|
156
|
+
if (hasMap && map) {
|
|
157
|
+
const source2 = new RawSource(map.toString());
|
|
158
|
+
compilation.updateAsset(mapFilename, source2);
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
key: cacheKey,
|
|
162
|
+
source
|
|
163
|
+
};
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
|
|
168
|
+
}
|
|
169
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
170
|
+
let noCachedCount = 0;
|
|
171
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
172
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
173
|
+
const rawSource = originalSource.source().toString();
|
|
174
|
+
const hash = cache.computeHash(rawSource);
|
|
175
|
+
const cacheKey = file;
|
|
176
|
+
cache.calcHashValueChanged(cacheKey, hash);
|
|
177
|
+
yield cache.process(
|
|
178
|
+
cacheKey,
|
|
179
|
+
() => {
|
|
180
|
+
const source = cache.get(cacheKey);
|
|
181
|
+
if (source) {
|
|
182
|
+
compilation.updateAsset(file, source);
|
|
183
|
+
debug("css cache hit: %s", file);
|
|
184
|
+
} else {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
() => __async(this, null, function* () {
|
|
189
|
+
const { css } = yield styleHandler(rawSource, {
|
|
190
|
+
isMainChunk: mainCssChunkMatcher(file, this.appType)
|
|
191
|
+
});
|
|
192
|
+
const source = new ConcatSource(css);
|
|
193
|
+
compilation.updateAsset(file, source);
|
|
194
|
+
onUpdate(file, rawSource, css);
|
|
195
|
+
debug("css handle: %s", file);
|
|
196
|
+
noCachedCount++;
|
|
197
|
+
return {
|
|
198
|
+
key: cacheKey,
|
|
199
|
+
source
|
|
200
|
+
};
|
|
201
|
+
})
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
|
|
205
|
+
}
|
|
206
|
+
debug("end");
|
|
207
|
+
onEnd();
|
|
208
|
+
})
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
UnifiedWebpackPluginV5
|
|
216
|
+
};
|