weapp-tailwindcss 2.11.2 → 2.11.3
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 +5 -5
- package/dist/cli.mjs +5 -5
- package/dist/core.js +5 -5
- package/dist/core.mjs +5 -5
- package/dist/css-macro/index.js +3 -3
- package/dist/css-macro/index.mjs +2 -2
- package/dist/css-macro/postcss.js +1 -1
- package/dist/css-macro/postcss.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{defu-NLkZUlr9.mjs → defu-D2_bzAv0.mjs} +19 -9
- package/dist/{defu-VMJMz2AB.js → defu-JkbfvVKI.js} +19 -9
- package/dist/gulp.js +8 -69
- package/dist/gulp.mjs +7 -68
- package/dist/index-C70Rgk3g.js +142 -0
- package/dist/{index-z25r_Htj.js → index-CKXO21Qe.js} +1 -1
- package/dist/index-D3TDwy2Y.mjs +140 -0
- package/dist/index-De0cmOEK.js +70 -0
- package/dist/index-QLyv-Fcp.mjs +64 -0
- package/dist/index.js +12 -12
- package/dist/index.mjs +9 -9
- package/dist/{options-QwNnkDpt.mjs → options-B5UOFsZN.mjs} +24 -36
- package/dist/{options-GnoWW1lR.js → options-BAFFNEBI.js} +25 -37
- package/dist/{postcss-Et8j4ugT.js → plugin-Bxt3oO75.js} +2 -2
- package/dist/{postcss-W8i3cl5I.mjs → plugin-Du3zrk3S.mjs} +1 -1
- package/dist/postcss.js +5 -5
- package/dist/postcss.mjs +2 -2
- package/dist/replace.js +6 -6
- package/dist/replace.mjs +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/v5-Crbh5I-S.js +187 -0
- package/dist/v5-V8LlDF1a.mjs +180 -0
- package/dist/vite.js +10 -141
- package/dist/vite.mjs +8 -143
- package/dist/weapp-tw-runtime-loader.js +1 -1
- package/dist/webpack.js +11 -185
- package/dist/webpack.mjs +10 -183
- package/package.json +53 -52
- /package/dist/{constants-ol1NPf7z.mjs → constants-CcqTvLgQ.mjs} +0 -0
- /package/dist/{constants-EVxkHOXL.js → constants-D-YMDg7M.js} +0 -0
- /package/dist/{defaults-dz6xGhOP.mjs → defaults-DMBtD8TO.mjs} +0 -0
- /package/dist/{defaults-0O-zKoXE.js → defaults-qX2VLo8u.js} +0 -0
- /package/dist/{index-06BoOZig.mjs → index-CLxBL7MC.mjs} +0 -0
- /package/dist/{shared-S0v7ZvWs.mjs → shared-D4ZM_mI-.mjs} +0 -0
- /package/dist/{shared-nXoJWFdz.js → shared-DtRIj-D_.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var selectorParser = require('postcss-selector-parser');
|
|
4
|
-
var shared = require('./shared-
|
|
4
|
+
var shared = require('./shared-DtRIj-D_.js');
|
|
5
5
|
var postcss = require('postcss');
|
|
6
6
|
require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
|
|
8
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : {
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
9
|
|
|
10
10
|
var selectorParser__default = /*#__PURE__*/_interopDefaultCompat(selectorParser);
|
|
11
11
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import selectorParser from 'postcss-selector-parser';
|
|
2
|
-
import { i as internalCssSelectorReplacer } from './shared-
|
|
2
|
+
import { i as internalCssSelectorReplacer } from './shared-D4ZM_mI-.mjs';
|
|
3
3
|
import { Declaration, Rule } from 'postcss';
|
|
4
4
|
import '@csstools/postcss-is-pseudo-class';
|
|
5
5
|
|
package/dist/postcss.js
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var plugin = require('./plugin-Bxt3oO75.js');
|
|
6
6
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
require('postcss-selector-parser');
|
|
8
|
-
require('./shared-
|
|
8
|
+
require('./shared-DtRIj-D_.js');
|
|
9
9
|
require('@weapp-core/escape');
|
|
10
10
|
require('@ast-core/escape');
|
|
11
11
|
require('postcss');
|
|
12
12
|
|
|
13
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : {
|
|
13
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
14
|
|
|
15
15
|
var postcssIsPseudoClass__default = /*#__PURE__*/_interopDefaultCompat(postcssIsPseudoClass);
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
exports.postcssWeappTailwindcss =
|
|
20
|
-
Object.defineProperty(exports,
|
|
19
|
+
exports.postcssWeappTailwindcss = plugin.postcssWeappTailwindcss;
|
|
20
|
+
Object.defineProperty(exports, "postcssIsPseudoClass", {
|
|
21
21
|
enumerable: true,
|
|
22
22
|
get: function () { return postcssIsPseudoClass__default["default"]; }
|
|
23
23
|
});
|
package/dist/postcss.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { p as postcssWeappTailwindcss } from './
|
|
1
|
+
export { p as postcssWeappTailwindcss } from './plugin-Du3zrk3S.mjs';
|
|
2
2
|
export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
|
|
3
3
|
import 'postcss-selector-parser';
|
|
4
|
-
import './shared-
|
|
4
|
+
import './shared-D4ZM_mI-.mjs';
|
|
5
5
|
import '@weapp-core/escape';
|
|
6
6
|
import '@ast-core/escape';
|
|
7
7
|
import 'postcss';
|
package/dist/replace.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var escape = require('@weapp-core/escape');
|
|
6
6
|
require('@ast-core/escape');
|
|
7
|
-
var shared = require('./shared-
|
|
7
|
+
var shared = require('./shared-DtRIj-D_.js');
|
|
8
8
|
|
|
9
9
|
function replaceWxml(original, options = {
|
|
10
10
|
keepEOL: false,
|
|
@@ -25,23 +25,23 @@ function replaceWxml(original, options = {
|
|
|
25
25
|
return res;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
Object.defineProperty(exports,
|
|
28
|
+
Object.defineProperty(exports, "MappingChars2String", {
|
|
29
29
|
enumerable: true,
|
|
30
30
|
get: function () { return escape.MappingChars2String; }
|
|
31
31
|
});
|
|
32
|
-
Object.defineProperty(exports,
|
|
32
|
+
Object.defineProperty(exports, "MappingChars2StringEntries", {
|
|
33
33
|
enumerable: true,
|
|
34
34
|
get: function () { return escape.MappingChars2StringEntries; }
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports,
|
|
36
|
+
Object.defineProperty(exports, "SYMBOL_TABLE", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () { return escape.SYMBOL_TABLE; }
|
|
39
39
|
});
|
|
40
|
-
Object.defineProperty(exports,
|
|
40
|
+
Object.defineProperty(exports, "SimpleMappingChars2String", {
|
|
41
41
|
enumerable: true,
|
|
42
42
|
get: function () { return escape.SimpleMappingChars2String; }
|
|
43
43
|
});
|
|
44
|
-
Object.defineProperty(exports,
|
|
44
|
+
Object.defineProperty(exports, "SimpleMappingChars2StringEntries", {
|
|
45
45
|
enumerable: true,
|
|
46
46
|
get: function () { return escape.SimpleMappingChars2StringEntries; }
|
|
47
47
|
});
|
package/dist/replace.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { escape, SimpleMappingChars2String } from '@weapp-core/escape';
|
|
2
2
|
export { MappingChars2String, MappingChars2StringEntries, SYMBOL_TABLE, SimpleMappingChars2String, SimpleMappingChars2StringEntries } from '@weapp-core/escape';
|
|
3
3
|
import '@ast-core/escape';
|
|
4
|
-
export { i as replaceCss } from './shared-
|
|
4
|
+
export { i as replaceCss } from './shared-D4ZM_mI-.mjs';
|
|
5
5
|
|
|
6
6
|
function replaceWxml(original, options = {
|
|
7
7
|
keepEOL: false,
|
package/dist/types.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type ICustomAttributes = Record<string, ItemOrItemArray<string | RegExp>>
|
|
|
37
37
|
export type ICustomAttributesEntities = [string | RegExp, ItemOrItemArray<string | RegExp>][];
|
|
38
38
|
export type IJsHandlerOptions = {
|
|
39
39
|
escapeMap?: Record<string, string>;
|
|
40
|
-
classNameSet
|
|
40
|
+
classNameSet?: Set<string>;
|
|
41
41
|
minifiedJs?: boolean;
|
|
42
42
|
arbitraryValues?: IArbitraryValues;
|
|
43
43
|
mangleContext?: IMangleScopeContext;
|
|
@@ -45,6 +45,7 @@ export type IJsHandlerOptions = {
|
|
|
45
45
|
strategy?: UserDefinedOptions['jsEscapeStrategy'];
|
|
46
46
|
needEscaped?: boolean;
|
|
47
47
|
generateMap?: boolean;
|
|
48
|
+
always?: boolean;
|
|
48
49
|
};
|
|
49
50
|
export interface RawSource {
|
|
50
51
|
start: number;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var options = require('./options-BAFFNEBI.js');
|
|
4
|
+
var path = require('node:path');
|
|
5
|
+
var fs = require('node:fs');
|
|
6
|
+
var plugin = require('./plugin-Bxt3oO75.js');
|
|
7
|
+
var defaults = require('./defaults-qX2VLo8u.js');
|
|
8
|
+
var index = require('./index-CKXO21Qe.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
13
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
14
|
+
|
|
15
|
+
const debug = index.createDebug('processAssets: ');
|
|
16
|
+
class UnifiedWebpackPluginV5 {
|
|
17
|
+
constructor(options$1 = {}) {
|
|
18
|
+
if (options$1.customReplaceDictionary === undefined) {
|
|
19
|
+
options$1.customReplaceDictionary = 'simple';
|
|
20
|
+
}
|
|
21
|
+
this.options = options.getOptions(options$1);
|
|
22
|
+
this.appType = this.options.appType;
|
|
23
|
+
}
|
|
24
|
+
apply(compiler) {
|
|
25
|
+
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, tailwindcssBasedir } = this.options;
|
|
26
|
+
if (disabled) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
30
|
+
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
31
|
+
const { ConcatSource, RawSource } = sources;
|
|
32
|
+
const twPatcher = options.createTailwindcssPatcher();
|
|
33
|
+
function getClassSet() {
|
|
34
|
+
return twPatcher.getClassSet({
|
|
35
|
+
basedir: tailwindcssBasedir
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
onLoad();
|
|
39
|
+
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path__default["default"].resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
40
|
+
const isExisted = fs__default["default"].existsSync(loader);
|
|
41
|
+
const WeappTwRuntimeAopLoader = {
|
|
42
|
+
loader,
|
|
43
|
+
options: {
|
|
44
|
+
getClassSet
|
|
45
|
+
},
|
|
46
|
+
ident: null,
|
|
47
|
+
type: null
|
|
48
|
+
};
|
|
49
|
+
compiler.hooks.compilation.tap(plugin.pluginName, (compilation) => {
|
|
50
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(plugin.pluginName, (loaderContext, module) => {
|
|
51
|
+
if (isExisted) {
|
|
52
|
+
const idx = module.loaders.findIndex((x) => x.loader.includes('postcss-loader'));
|
|
53
|
+
if (idx > -1) {
|
|
54
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
compilation.hooks.processAssets.tapPromise({
|
|
59
|
+
name: plugin.pluginName,
|
|
60
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
61
|
+
}, (assets) => options.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
onStart();
|
|
63
|
+
debug('start');
|
|
64
|
+
for (const chunk of compilation.chunks) {
|
|
65
|
+
if (chunk.id && chunk.hash) {
|
|
66
|
+
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const entries = Object.entries(assets);
|
|
70
|
+
const groupedEntries = defaults.getGroupedEntries(entries, this.options);
|
|
71
|
+
const runtimeSet = getClassSet();
|
|
72
|
+
setMangleRuntimeSet(runtimeSet);
|
|
73
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
74
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
75
|
+
let noCachedCount = 0;
|
|
76
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
77
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
78
|
+
const rawSource = originalSource.source().toString();
|
|
79
|
+
const hash = cache.computeHash(rawSource);
|
|
80
|
+
const cacheKey = file;
|
|
81
|
+
cache.calcHashValueChanged(cacheKey, hash);
|
|
82
|
+
yield cache.process(cacheKey, () => {
|
|
83
|
+
const source = cache.get(cacheKey);
|
|
84
|
+
if (source) {
|
|
85
|
+
compilation.updateAsset(file, source);
|
|
86
|
+
debug('html cache hit: %s', file);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}, () => {
|
|
92
|
+
const wxml = templateHandler(rawSource, {
|
|
93
|
+
runtimeSet
|
|
94
|
+
});
|
|
95
|
+
const source = new ConcatSource(wxml);
|
|
96
|
+
compilation.updateAsset(file, source);
|
|
97
|
+
onUpdate(file, rawSource, wxml);
|
|
98
|
+
debug('html handle: %s', file);
|
|
99
|
+
noCachedCount++;
|
|
100
|
+
return {
|
|
101
|
+
key: cacheKey,
|
|
102
|
+
source
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
109
|
+
let noCachedCount = 0;
|
|
110
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
111
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
112
|
+
const cacheKey = defaults.removeExt(file);
|
|
113
|
+
yield cache.process(cacheKey, () => {
|
|
114
|
+
const source = cache.get(cacheKey);
|
|
115
|
+
if (source) {
|
|
116
|
+
compilation.updateAsset(file, source);
|
|
117
|
+
debug('js cache hit: %s', file);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}, () => {
|
|
123
|
+
const rawSource = originalSource.source().toString();
|
|
124
|
+
const mapFilename = file + '.map';
|
|
125
|
+
const hasMap = Boolean(assets[mapFilename]);
|
|
126
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
127
|
+
generateMap: hasMap
|
|
128
|
+
});
|
|
129
|
+
const source = new ConcatSource(code);
|
|
130
|
+
compilation.updateAsset(file, source);
|
|
131
|
+
onUpdate(file, rawSource, code);
|
|
132
|
+
debug('js handle: %s', file);
|
|
133
|
+
noCachedCount++;
|
|
134
|
+
if (hasMap && map) {
|
|
135
|
+
const source = new RawSource(map.toString());
|
|
136
|
+
compilation.updateAsset(mapFilename, source);
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
key: cacheKey,
|
|
140
|
+
source
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
145
|
+
}
|
|
146
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
147
|
+
let noCachedCount = 0;
|
|
148
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
149
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
150
|
+
const rawSource = originalSource.source().toString();
|
|
151
|
+
const hash = cache.computeHash(rawSource);
|
|
152
|
+
const cacheKey = file;
|
|
153
|
+
cache.calcHashValueChanged(cacheKey, hash);
|
|
154
|
+
yield cache.process(cacheKey, () => {
|
|
155
|
+
const source = cache.get(cacheKey);
|
|
156
|
+
if (source) {
|
|
157
|
+
compilation.updateAsset(file, source);
|
|
158
|
+
debug('css cache hit: %s', file);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const css = yield styleHandler(rawSource, {
|
|
165
|
+
isMainChunk: mainCssChunkMatcher(file, this.appType)
|
|
166
|
+
});
|
|
167
|
+
const source = new ConcatSource(css);
|
|
168
|
+
compilation.updateAsset(file, source);
|
|
169
|
+
onUpdate(file, rawSource, css);
|
|
170
|
+
debug('css handle: %s', file);
|
|
171
|
+
noCachedCount++;
|
|
172
|
+
return {
|
|
173
|
+
key: cacheKey,
|
|
174
|
+
source
|
|
175
|
+
};
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
179
|
+
}
|
|
180
|
+
debug('end');
|
|
181
|
+
onEnd();
|
|
182
|
+
}));
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-B5UOFsZN.mjs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { a as pluginName } from './plugin-Du3zrk3S.mjs';
|
|
5
|
+
import { g as getGroupedEntries, r as removeExt } from './defaults-DMBtD8TO.mjs';
|
|
6
|
+
import { c as createDebug } from './index-CLxBL7MC.mjs';
|
|
7
|
+
|
|
8
|
+
const debug = createDebug('processAssets: ');
|
|
9
|
+
class UnifiedWebpackPluginV5 {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
if (options.customReplaceDictionary === undefined) {
|
|
12
|
+
options.customReplaceDictionary = 'simple';
|
|
13
|
+
}
|
|
14
|
+
this.options = getOptions(options);
|
|
15
|
+
this.appType = this.options.appType;
|
|
16
|
+
}
|
|
17
|
+
apply(compiler) {
|
|
18
|
+
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, tailwindcssBasedir } = this.options;
|
|
19
|
+
if (disabled) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
23
|
+
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
24
|
+
const { ConcatSource, RawSource } = sources;
|
|
25
|
+
const twPatcher = createTailwindcssPatcher();
|
|
26
|
+
function getClassSet() {
|
|
27
|
+
return twPatcher.getClassSet({
|
|
28
|
+
basedir: tailwindcssBasedir
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
onLoad();
|
|
32
|
+
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path.resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
33
|
+
const isExisted = fs.existsSync(loader);
|
|
34
|
+
const WeappTwRuntimeAopLoader = {
|
|
35
|
+
loader,
|
|
36
|
+
options: {
|
|
37
|
+
getClassSet
|
|
38
|
+
},
|
|
39
|
+
ident: null,
|
|
40
|
+
type: null
|
|
41
|
+
};
|
|
42
|
+
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
43
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (loaderContext, module) => {
|
|
44
|
+
if (isExisted) {
|
|
45
|
+
const idx = module.loaders.findIndex((x) => x.loader.includes('postcss-loader'));
|
|
46
|
+
if (idx > -1) {
|
|
47
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
compilation.hooks.processAssets.tapPromise({
|
|
52
|
+
name: pluginName,
|
|
53
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
54
|
+
}, (assets) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
onStart();
|
|
56
|
+
debug('start');
|
|
57
|
+
for (const chunk of compilation.chunks) {
|
|
58
|
+
if (chunk.id && chunk.hash) {
|
|
59
|
+
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const entries = Object.entries(assets);
|
|
63
|
+
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
64
|
+
const runtimeSet = getClassSet();
|
|
65
|
+
setMangleRuntimeSet(runtimeSet);
|
|
66
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
67
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
68
|
+
let noCachedCount = 0;
|
|
69
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
70
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
71
|
+
const rawSource = originalSource.source().toString();
|
|
72
|
+
const hash = cache.computeHash(rawSource);
|
|
73
|
+
const cacheKey = file;
|
|
74
|
+
cache.calcHashValueChanged(cacheKey, hash);
|
|
75
|
+
yield cache.process(cacheKey, () => {
|
|
76
|
+
const source = cache.get(cacheKey);
|
|
77
|
+
if (source) {
|
|
78
|
+
compilation.updateAsset(file, source);
|
|
79
|
+
debug('html cache hit: %s', file);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}, () => {
|
|
85
|
+
const wxml = templateHandler(rawSource, {
|
|
86
|
+
runtimeSet
|
|
87
|
+
});
|
|
88
|
+
const source = new ConcatSource(wxml);
|
|
89
|
+
compilation.updateAsset(file, source);
|
|
90
|
+
onUpdate(file, rawSource, wxml);
|
|
91
|
+
debug('html handle: %s', file);
|
|
92
|
+
noCachedCount++;
|
|
93
|
+
return {
|
|
94
|
+
key: cacheKey,
|
|
95
|
+
source
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
102
|
+
let noCachedCount = 0;
|
|
103
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
104
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
105
|
+
const cacheKey = removeExt(file);
|
|
106
|
+
yield cache.process(cacheKey, () => {
|
|
107
|
+
const source = cache.get(cacheKey);
|
|
108
|
+
if (source) {
|
|
109
|
+
compilation.updateAsset(file, source);
|
|
110
|
+
debug('js cache hit: %s', file);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}, () => {
|
|
116
|
+
const rawSource = originalSource.source().toString();
|
|
117
|
+
const mapFilename = file + '.map';
|
|
118
|
+
const hasMap = Boolean(assets[mapFilename]);
|
|
119
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
120
|
+
generateMap: hasMap
|
|
121
|
+
});
|
|
122
|
+
const source = new ConcatSource(code);
|
|
123
|
+
compilation.updateAsset(file, source);
|
|
124
|
+
onUpdate(file, rawSource, code);
|
|
125
|
+
debug('js handle: %s', file);
|
|
126
|
+
noCachedCount++;
|
|
127
|
+
if (hasMap && map) {
|
|
128
|
+
const source = new RawSource(map.toString());
|
|
129
|
+
compilation.updateAsset(mapFilename, source);
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
key: cacheKey,
|
|
133
|
+
source
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
138
|
+
}
|
|
139
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
140
|
+
let noCachedCount = 0;
|
|
141
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
142
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
143
|
+
const rawSource = originalSource.source().toString();
|
|
144
|
+
const hash = cache.computeHash(rawSource);
|
|
145
|
+
const cacheKey = file;
|
|
146
|
+
cache.calcHashValueChanged(cacheKey, hash);
|
|
147
|
+
yield cache.process(cacheKey, () => {
|
|
148
|
+
const source = cache.get(cacheKey);
|
|
149
|
+
if (source) {
|
|
150
|
+
compilation.updateAsset(file, source);
|
|
151
|
+
debug('css cache hit: %s', file);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const css = yield styleHandler(rawSource, {
|
|
158
|
+
isMainChunk: mainCssChunkMatcher(file, this.appType)
|
|
159
|
+
});
|
|
160
|
+
const source = new ConcatSource(css);
|
|
161
|
+
compilation.updateAsset(file, source);
|
|
162
|
+
onUpdate(file, rawSource, css);
|
|
163
|
+
debug('css handle: %s', file);
|
|
164
|
+
noCachedCount++;
|
|
165
|
+
return {
|
|
166
|
+
key: cacheKey,
|
|
167
|
+
source
|
|
168
|
+
};
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
172
|
+
}
|
|
173
|
+
debug('end');
|
|
174
|
+
onEnd();
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { UnifiedWebpackPluginV5 as U };
|
package/dist/vite.js
CHANGED
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var defaults = require('./defaults-0O-zKoXE.js');
|
|
8
|
-
var index = require('./index-z25r_Htj.js');
|
|
5
|
+
var index = require('./index-C70Rgk3g.js');
|
|
6
|
+
require('./options-BAFFNEBI.js');
|
|
9
7
|
require('micromatch');
|
|
10
8
|
require('magic-string');
|
|
11
9
|
require('./replace.js');
|
|
12
10
|
require('@weapp-core/escape');
|
|
13
11
|
require('@ast-core/escape');
|
|
14
|
-
require('./shared-
|
|
12
|
+
require('./shared-DtRIj-D_.js');
|
|
15
13
|
require('@weapp-core/regex');
|
|
16
14
|
require('@babel/generator');
|
|
17
15
|
require('@babel/parser');
|
|
18
16
|
require('@babel/traverse');
|
|
19
|
-
require('./defu-
|
|
17
|
+
require('./defu-JkbfvVKI.js');
|
|
18
|
+
require('./defaults-qX2VLo8u.js');
|
|
20
19
|
require('@babel/types');
|
|
21
20
|
require('htmlparser2');
|
|
22
21
|
require('postcss');
|
|
22
|
+
require('./plugin-Bxt3oO75.js');
|
|
23
|
+
require('postcss-selector-parser');
|
|
23
24
|
require('@csstools/postcss-is-pseudo-class');
|
|
24
25
|
require('node:path');
|
|
25
26
|
require('node:fs');
|
|
@@ -28,141 +29,9 @@ require('tailwindcss-patch');
|
|
|
28
29
|
require('@tailwindcss-mangle/shared');
|
|
29
30
|
require('lru-cache');
|
|
30
31
|
require('md5');
|
|
31
|
-
require('
|
|
32
|
+
require('./index-CKXO21Qe.js');
|
|
32
33
|
require('debug');
|
|
33
34
|
|
|
34
|
-
const debug = index.createDebug('generateBundle: ');
|
|
35
|
-
function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
36
|
-
if (options$1.customReplaceDictionary === undefined) {
|
|
37
|
-
options$1.customReplaceDictionary = 'simple';
|
|
38
|
-
}
|
|
39
|
-
const opts = options.getOptions(options$1);
|
|
40
|
-
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
|
|
41
|
-
if (disabled) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
patch === null || patch === void 0 ? void 0 : patch();
|
|
45
|
-
const twPatcher = options.createTailwindcssPatcher();
|
|
46
|
-
onLoad();
|
|
47
|
-
return {
|
|
48
|
-
name: postcss.vitePluginName,
|
|
49
|
-
enforce: 'post',
|
|
50
|
-
generateBundle(opt, bundle) {
|
|
51
|
-
return options.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
debug('start');
|
|
53
|
-
onStart();
|
|
54
|
-
const entries = Object.entries(bundle);
|
|
55
|
-
const groupedEntries = defaults.getGroupedEntries(entries, opts);
|
|
56
|
-
const runtimeSet = twPatcher.getClassSet({
|
|
57
|
-
basedir: tailwindcssBasedir
|
|
58
|
-
});
|
|
59
|
-
setMangleRuntimeSet(runtimeSet);
|
|
60
|
-
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
61
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
62
|
-
let noCachedCount = 0;
|
|
63
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
64
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
65
|
-
const oldVal = originalSource.source.toString();
|
|
66
|
-
const hash = cache.computeHash(oldVal);
|
|
67
|
-
cache.calcHashValueChanged(file, hash);
|
|
68
|
-
yield cache.process(file, () => {
|
|
69
|
-
const source = cache.get(file);
|
|
70
|
-
if (source) {
|
|
71
|
-
originalSource.source = source;
|
|
72
|
-
debug('html cache hit: %s', file);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}, () => {
|
|
78
|
-
originalSource.source = templateHandler(oldVal, {
|
|
79
|
-
runtimeSet
|
|
80
|
-
});
|
|
81
|
-
onUpdate(file, oldVal, originalSource.source);
|
|
82
|
-
debug('html handle: %s', file);
|
|
83
|
-
noCachedCount++;
|
|
84
|
-
return {
|
|
85
|
-
key: file,
|
|
86
|
-
source: originalSource.source
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
91
|
-
}
|
|
92
|
-
if (Array.isArray(groupedEntries.js)) {
|
|
93
|
-
let noCachedCount = 0;
|
|
94
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
95
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
96
|
-
const rawSource = originalSource.code;
|
|
97
|
-
const hash = cache.computeHash(rawSource);
|
|
98
|
-
cache.calcHashValueChanged(file, hash);
|
|
99
|
-
yield cache.process(file, () => {
|
|
100
|
-
const source = cache.get(file);
|
|
101
|
-
if (source) {
|
|
102
|
-
originalSource.code = source;
|
|
103
|
-
debug('js cache hit: %s', file);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
}, () => {
|
|
109
|
-
const mapFilename = file + '.map';
|
|
110
|
-
const hasMap = Boolean(bundle[mapFilename]);
|
|
111
|
-
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
112
|
-
generateMap: hasMap
|
|
113
|
-
});
|
|
114
|
-
originalSource.code = code;
|
|
115
|
-
onUpdate(file, rawSource, code);
|
|
116
|
-
debug('js handle: %s', file);
|
|
117
|
-
noCachedCount++;
|
|
118
|
-
if (hasMap && map) {
|
|
119
|
-
bundle[mapFilename].source = map.toString();
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
key: file,
|
|
123
|
-
source: code
|
|
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(file, () => {
|
|
137
|
-
const source = cache.get(file);
|
|
138
|
-
if (source) {
|
|
139
|
-
originalSource.source = source;
|
|
140
|
-
debug('css cache hit: %s', file);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
const css = yield styleHandler(rawSource, {
|
|
147
|
-
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
148
|
-
});
|
|
149
|
-
originalSource.source = css;
|
|
150
|
-
onUpdate(file, rawSource, css);
|
|
151
|
-
debug('css handle: %s', file);
|
|
152
|
-
noCachedCount++;
|
|
153
|
-
return {
|
|
154
|
-
key: file,
|
|
155
|
-
source: css
|
|
156
|
-
};
|
|
157
|
-
}));
|
|
158
|
-
}
|
|
159
|
-
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
160
|
-
}
|
|
161
|
-
onEnd();
|
|
162
|
-
debug('end');
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
35
|
|
|
168
|
-
|
|
36
|
+
|
|
37
|
+
exports.UnifiedViteWeappTailwindcssPlugin = index.UnifiedViteWeappTailwindcssPlugin;
|