weapp-tailwindcss 3.0.2 → 3.0.4
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 +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +8 -0
- package/dist/cli.js +16 -7
- package/dist/cli.mjs +12 -7
- package/dist/constants.d.ts +1 -0
- package/dist/core.js +2 -2
- package/dist/core.mjs +2 -2
- package/dist/css-macro/index.js +1 -1
- package/dist/gulp.js +5 -66
- package/dist/gulp.mjs +4 -65
- package/dist/index-8OJKpYld.js +70 -0
- package/dist/{postcss-zkCNv4BC.js → index-Fkmyt0Rc.js} +55 -26
- package/dist/index-KpA8Y68V.js +142 -0
- package/dist/index-O8jpXUxP.mjs +140 -0
- package/dist/{postcss-irzTcRfl.mjs → index-_74RBzwy.mjs} +54 -26
- package/dist/{index-z25r_Htj.js → index-juOeq2Kt.js} +1 -1
- package/dist/index-u-U9HdG6.mjs +64 -0
- package/dist/index.js +9 -9
- package/dist/index.mjs +5 -5
- package/dist/{options-UXRHB24i.mjs → options-6YPFqoRJ.mjs} +2 -2
- package/dist/{options-5eiKwcXx.js → options-N9g3FpWO.js} +3 -3
- package/dist/postcss/plugins/ctx.d.ts +2 -0
- package/dist/postcss/selectorParser.d.ts +4 -1
- package/dist/postcss.js +7 -7
- package/dist/postcss.mjs +1 -1
- package/dist/replace.js +5 -5
- package/dist/v5-RkdOexPP.js +187 -0
- package/dist/v5-UTJ5AaEA.mjs +180 -0
- package/dist/vite.js +11 -142
- package/dist/vite.mjs +9 -144
- package/dist/weapp-tw-runtime-loader.js +1 -1
- package/dist/webpack.js +12 -186
- package/dist/webpack.mjs +11 -184
- package/dist/webpack4.d.ts +1 -0
- package/dist/webpack4.js +208 -0
- package/dist/webpack4.mjs +199 -0
- package/package.json +35 -26
package/dist/postcss.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var index = require('./index-Fkmyt0Rc.js');
|
|
6
6
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
var postcssRem2rpx = require('postcss-rem-to-responsive-pixel');
|
|
8
8
|
require('postcss-selector-parser');
|
|
@@ -11,21 +11,21 @@ require('@weapp-core/escape');
|
|
|
11
11
|
require('@ast-core/escape');
|
|
12
12
|
require('postcss');
|
|
13
13
|
|
|
14
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : {
|
|
14
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
15
15
|
|
|
16
16
|
var postcssIsPseudoClass__default = /*#__PURE__*/_interopDefaultCompat(postcssIsPseudoClass);
|
|
17
17
|
var postcssRem2rpx__default = /*#__PURE__*/_interopDefaultCompat(postcssRem2rpx);
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
exports.getPlugins =
|
|
22
|
-
exports.postcssWeappTailwindcssPostPlugin =
|
|
23
|
-
exports.postcssWeappTailwindcssPrePlugin =
|
|
24
|
-
Object.defineProperty(exports,
|
|
21
|
+
exports.getPlugins = index.getPlugins;
|
|
22
|
+
exports.postcssWeappTailwindcssPostPlugin = index.postcssWeappTailwindcssPostPlugin;
|
|
23
|
+
exports.postcssWeappTailwindcssPrePlugin = index.postcssWeappTailwindcssPrePlugin;
|
|
24
|
+
Object.defineProperty(exports, "postcssIsPseudoClass", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () { return postcssIsPseudoClass__default["default"]; }
|
|
27
27
|
});
|
|
28
|
-
Object.defineProperty(exports,
|
|
28
|
+
Object.defineProperty(exports, "postcssRem2rpx", {
|
|
29
29
|
enumerable: true,
|
|
30
30
|
get: function () { return postcssRem2rpx__default["default"]; }
|
|
31
31
|
});
|
package/dist/postcss.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as getPlugins,
|
|
1
|
+
export { g as getPlugins, p as postcssWeappTailwindcssPostPlugin, a as postcssWeappTailwindcssPrePlugin } from './index-_74RBzwy.mjs';
|
|
2
2
|
export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
|
|
3
3
|
export { default as postcssRem2rpx } from 'postcss-rem-to-responsive-pixel';
|
|
4
4
|
import 'postcss-selector-parser';
|
package/dist/replace.js
CHANGED
|
@@ -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
|
});
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var options = require('./options-N9g3FpWO.js');
|
|
4
|
+
var path = require('node:path');
|
|
5
|
+
var fs = require('node:fs');
|
|
6
|
+
var index = require('./index-Fkmyt0Rc.js');
|
|
7
|
+
var defaults = require('./defaults-QOAV8NSV.js');
|
|
8
|
+
var index$1 = require('./index-juOeq2Kt.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$1.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(index.pluginName, (compilation) => {
|
|
50
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(index.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: index.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-6YPFqoRJ.mjs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { b as pluginName } from './index-_74RBzwy.mjs';
|
|
5
|
+
import { g as getGroupedEntries, r as removeExt } from './defaults-TZpmwtzd.mjs';
|
|
6
|
+
import { c as createDebug } from './index-06BoOZig.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,10 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var defaults = require('./defaults-QOAV8NSV.js');
|
|
8
|
-
var index = require('./index-z25r_Htj.js');
|
|
5
|
+
var index = require('./index-KpA8Y68V.js');
|
|
6
|
+
require('./options-N9g3FpWO.js');
|
|
9
7
|
require('magic-string');
|
|
10
8
|
require('./replace.js');
|
|
11
9
|
require('@weapp-core/escape');
|
|
@@ -15,9 +13,15 @@ require('@weapp-core/regex');
|
|
|
15
13
|
require('@babel/generator');
|
|
16
14
|
require('@babel/parser');
|
|
17
15
|
require('@babel/traverse');
|
|
16
|
+
require('./defaults-QOAV8NSV.js');
|
|
17
|
+
require('./defu-KWuJnZLV.js');
|
|
18
18
|
require('@babel/types');
|
|
19
19
|
require('htmlparser2');
|
|
20
20
|
require('postcss');
|
|
21
|
+
require('./index-Fkmyt0Rc.js');
|
|
22
|
+
require('@csstools/postcss-is-pseudo-class');
|
|
23
|
+
require('postcss-rem-to-responsive-pixel');
|
|
24
|
+
require('postcss-selector-parser');
|
|
21
25
|
require('node:path');
|
|
22
26
|
require('node:fs');
|
|
23
27
|
require('semver');
|
|
@@ -25,144 +29,9 @@ require('tailwindcss-patch');
|
|
|
25
29
|
require('@tailwindcss-mangle/shared');
|
|
26
30
|
require('lru-cache');
|
|
27
31
|
require('md5');
|
|
28
|
-
require('
|
|
29
|
-
require('postcss-rem-to-responsive-pixel');
|
|
30
|
-
require('postcss-selector-parser');
|
|
31
|
-
require('./defu-KWuJnZLV.js');
|
|
32
|
+
require('./index-juOeq2Kt.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;
|