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/vite.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { g as getGroupedEntries } from './defaults-TZpmwtzd.mjs';
|
|
4
|
-
import { c as createDebug } from './index-06BoOZig.mjs';
|
|
1
|
+
export { U as UnifiedViteWeappTailwindcssPlugin } from './index-O8jpXUxP.mjs';
|
|
2
|
+
import './options-6YPFqoRJ.mjs';
|
|
5
3
|
import 'magic-string';
|
|
6
4
|
import './replace.mjs';
|
|
7
5
|
import '@weapp-core/escape';
|
|
@@ -11,9 +9,15 @@ import '@weapp-core/regex';
|
|
|
11
9
|
import '@babel/generator';
|
|
12
10
|
import '@babel/parser';
|
|
13
11
|
import '@babel/traverse';
|
|
12
|
+
import './defaults-TZpmwtzd.mjs';
|
|
13
|
+
import './defu-ms_ZBCiB.mjs';
|
|
14
14
|
import '@babel/types';
|
|
15
15
|
import 'htmlparser2';
|
|
16
16
|
import 'postcss';
|
|
17
|
+
import './index-_74RBzwy.mjs';
|
|
18
|
+
import '@csstools/postcss-is-pseudo-class';
|
|
19
|
+
import 'postcss-rem-to-responsive-pixel';
|
|
20
|
+
import 'postcss-selector-parser';
|
|
17
21
|
import 'node:path';
|
|
18
22
|
import 'node:fs';
|
|
19
23
|
import 'semver';
|
|
@@ -21,144 +25,5 @@ import 'tailwindcss-patch';
|
|
|
21
25
|
import '@tailwindcss-mangle/shared';
|
|
22
26
|
import 'lru-cache';
|
|
23
27
|
import 'md5';
|
|
24
|
-
import '
|
|
25
|
-
import 'postcss-rem-to-responsive-pixel';
|
|
26
|
-
import 'postcss-selector-parser';
|
|
27
|
-
import './defu-ms_ZBCiB.mjs';
|
|
28
|
+
import './index-06BoOZig.mjs';
|
|
28
29
|
import 'debug';
|
|
29
|
-
|
|
30
|
-
const debug = createDebug('generateBundle: ');
|
|
31
|
-
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
32
|
-
if (options.customReplaceDictionary === undefined) {
|
|
33
|
-
options.customReplaceDictionary = 'simple';
|
|
34
|
-
}
|
|
35
|
-
const opts = getOptions(options);
|
|
36
|
-
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
|
|
37
|
-
if (disabled) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
patch === null || patch === void 0 ? void 0 : patch();
|
|
41
|
-
const twPatcher = createTailwindcssPatcher();
|
|
42
|
-
onLoad();
|
|
43
|
-
return {
|
|
44
|
-
name: vitePluginName,
|
|
45
|
-
enforce: 'post',
|
|
46
|
-
generateBundle(opt, bundle) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
debug('start');
|
|
49
|
-
onStart();
|
|
50
|
-
const entries = Object.entries(bundle);
|
|
51
|
-
const groupedEntries = getGroupedEntries(entries, opts);
|
|
52
|
-
const runtimeSet = twPatcher.getClassSet({
|
|
53
|
-
basedir: tailwindcssBasedir
|
|
54
|
-
});
|
|
55
|
-
setMangleRuntimeSet(runtimeSet);
|
|
56
|
-
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
57
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
58
|
-
let noCachedCount = 0;
|
|
59
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
60
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
61
|
-
const oldVal = originalSource.source.toString();
|
|
62
|
-
const hash = cache.computeHash(oldVal);
|
|
63
|
-
cache.calcHashValueChanged(file, hash);
|
|
64
|
-
yield cache.process(file, () => {
|
|
65
|
-
const source = cache.get(file);
|
|
66
|
-
if (source) {
|
|
67
|
-
originalSource.source = source;
|
|
68
|
-
debug('html cache hit: %s', file);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
}, () => {
|
|
74
|
-
originalSource.source = templateHandler(oldVal, {
|
|
75
|
-
runtimeSet
|
|
76
|
-
});
|
|
77
|
-
onUpdate(file, oldVal, originalSource.source);
|
|
78
|
-
debug('html handle: %s', file);
|
|
79
|
-
noCachedCount++;
|
|
80
|
-
return {
|
|
81
|
-
key: file,
|
|
82
|
-
source: originalSource.source
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
87
|
-
}
|
|
88
|
-
if (Array.isArray(groupedEntries.js)) {
|
|
89
|
-
let noCachedCount = 0;
|
|
90
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
91
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
92
|
-
const rawSource = originalSource.code;
|
|
93
|
-
const hash = cache.computeHash(rawSource);
|
|
94
|
-
cache.calcHashValueChanged(file, hash);
|
|
95
|
-
yield cache.process(file, () => {
|
|
96
|
-
const source = cache.get(file);
|
|
97
|
-
if (source) {
|
|
98
|
-
originalSource.code = source;
|
|
99
|
-
debug('js cache hit: %s', file);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
}, () => {
|
|
105
|
-
const mapFilename = file + '.map';
|
|
106
|
-
const hasMap = Boolean(bundle[mapFilename]);
|
|
107
|
-
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
108
|
-
generateMap: hasMap
|
|
109
|
-
});
|
|
110
|
-
originalSource.code = code;
|
|
111
|
-
onUpdate(file, rawSource, code);
|
|
112
|
-
debug('js handle: %s', file);
|
|
113
|
-
noCachedCount++;
|
|
114
|
-
if (hasMap && map) {
|
|
115
|
-
bundle[mapFilename].source = map.toString();
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
key: file,
|
|
119
|
-
source: code
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
124
|
-
}
|
|
125
|
-
if (Array.isArray(groupedEntries.css)) {
|
|
126
|
-
let noCachedCount = 0;
|
|
127
|
-
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
128
|
-
const [file, originalSource] = groupedEntries.css[i];
|
|
129
|
-
const rawSource = originalSource.source.toString();
|
|
130
|
-
const hash = cache.computeHash(rawSource);
|
|
131
|
-
cache.calcHashValueChanged(file, hash);
|
|
132
|
-
yield cache.process(file, () => {
|
|
133
|
-
const source = cache.get(file);
|
|
134
|
-
if (source) {
|
|
135
|
-
originalSource.source = source;
|
|
136
|
-
debug('css cache hit: %s', file);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
const css = yield styleHandler(rawSource, {
|
|
143
|
-
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
144
|
-
});
|
|
145
|
-
originalSource.source = css;
|
|
146
|
-
onUpdate(file, rawSource, css);
|
|
147
|
-
debug('css handle: %s', file);
|
|
148
|
-
noCachedCount++;
|
|
149
|
-
return {
|
|
150
|
-
key: file,
|
|
151
|
-
source: css
|
|
152
|
-
};
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
|
-
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
156
|
-
}
|
|
157
|
-
onEnd();
|
|
158
|
-
debug('end');
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export { UnifiedViteWeappTailwindcssPlugin };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var loaderUtils = require('loader-utils');
|
|
4
4
|
|
|
5
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : {
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
6
6
|
|
|
7
7
|
var loaderUtils__default = /*#__PURE__*/_interopDefaultCompat(loaderUtils);
|
|
8
8
|
|
package/dist/webpack.js
CHANGED
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var fs = require('node:fs');
|
|
8
|
-
var postcss = require('./postcss-zkCNv4BC.js');
|
|
9
|
-
var defaults = require('./defaults-QOAV8NSV.js');
|
|
10
|
-
var index = require('./index-z25r_Htj.js');
|
|
5
|
+
var v5 = require('./v5-RkdOexPP.js');
|
|
6
|
+
require('./options-N9g3FpWO.js');
|
|
11
7
|
require('magic-string');
|
|
12
8
|
require('./replace.js');
|
|
13
9
|
require('@weapp-core/escape');
|
|
@@ -17,195 +13,25 @@ require('@weapp-core/regex');
|
|
|
17
13
|
require('@babel/generator');
|
|
18
14
|
require('@babel/parser');
|
|
19
15
|
require('@babel/traverse');
|
|
16
|
+
require('./defaults-QOAV8NSV.js');
|
|
17
|
+
require('./defu-KWuJnZLV.js');
|
|
20
18
|
require('@babel/types');
|
|
21
19
|
require('htmlparser2');
|
|
22
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');
|
|
25
|
+
require('node:path');
|
|
26
|
+
require('node:fs');
|
|
23
27
|
require('semver');
|
|
24
28
|
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
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
35
|
-
|
|
36
|
-
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
37
|
-
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
38
35
|
|
|
39
|
-
const debug = index.createDebug('processAssets: ');
|
|
40
|
-
class UnifiedWebpackPluginV5 {
|
|
41
|
-
constructor(options$1 = {}) {
|
|
42
|
-
if (options$1.customReplaceDictionary === undefined) {
|
|
43
|
-
options$1.customReplaceDictionary = 'simple';
|
|
44
|
-
}
|
|
45
|
-
this.options = options.getOptions(options$1);
|
|
46
|
-
this.appType = this.options.appType;
|
|
47
|
-
}
|
|
48
|
-
apply(compiler) {
|
|
49
|
-
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, tailwindcssBasedir } = this.options;
|
|
50
|
-
if (disabled) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
patch === null || patch === void 0 ? void 0 : patch();
|
|
54
|
-
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
55
|
-
const { ConcatSource, RawSource } = sources;
|
|
56
|
-
const twPatcher = options.createTailwindcssPatcher();
|
|
57
|
-
function getClassSet() {
|
|
58
|
-
return twPatcher.getClassSet({
|
|
59
|
-
basedir: tailwindcssBasedir
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
onLoad();
|
|
63
|
-
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path__default["default"].resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
64
|
-
const isExisted = fs__default["default"].existsSync(loader);
|
|
65
|
-
const WeappTwRuntimeAopLoader = {
|
|
66
|
-
loader,
|
|
67
|
-
options: {
|
|
68
|
-
getClassSet
|
|
69
|
-
},
|
|
70
|
-
ident: null,
|
|
71
|
-
type: null
|
|
72
|
-
};
|
|
73
|
-
compiler.hooks.compilation.tap(postcss.pluginName, (compilation) => {
|
|
74
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(postcss.pluginName, (loaderContext, module) => {
|
|
75
|
-
if (isExisted) {
|
|
76
|
-
const idx = module.loaders.findIndex((x) => x.loader.includes('postcss-loader'));
|
|
77
|
-
if (idx > -1) {
|
|
78
|
-
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
compilation.hooks.processAssets.tapPromise({
|
|
83
|
-
name: postcss.pluginName,
|
|
84
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
85
|
-
}, (assets) => options.__awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
onStart();
|
|
87
|
-
debug('start');
|
|
88
|
-
for (const chunk of compilation.chunks) {
|
|
89
|
-
if (chunk.id && chunk.hash) {
|
|
90
|
-
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const entries = Object.entries(assets);
|
|
94
|
-
const groupedEntries = defaults.getGroupedEntries(entries, this.options);
|
|
95
|
-
const runtimeSet = getClassSet();
|
|
96
|
-
setMangleRuntimeSet(runtimeSet);
|
|
97
|
-
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
98
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
99
|
-
let noCachedCount = 0;
|
|
100
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
101
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
102
|
-
const rawSource = originalSource.source().toString();
|
|
103
|
-
const hash = cache.computeHash(rawSource);
|
|
104
|
-
const cacheKey = file;
|
|
105
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
106
|
-
yield cache.process(cacheKey, () => {
|
|
107
|
-
const source = cache.get(cacheKey);
|
|
108
|
-
if (source) {
|
|
109
|
-
compilation.updateAsset(file, source);
|
|
110
|
-
debug('html cache hit: %s', file);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}, () => {
|
|
116
|
-
const wxml = templateHandler(rawSource, {
|
|
117
|
-
runtimeSet
|
|
118
|
-
});
|
|
119
|
-
const source = new ConcatSource(wxml);
|
|
120
|
-
compilation.updateAsset(file, source);
|
|
121
|
-
onUpdate(file, rawSource, wxml);
|
|
122
|
-
debug('html handle: %s', file);
|
|
123
|
-
noCachedCount++;
|
|
124
|
-
return {
|
|
125
|
-
key: cacheKey,
|
|
126
|
-
source
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
131
|
-
}
|
|
132
|
-
if (Array.isArray(groupedEntries.js)) {
|
|
133
|
-
let noCachedCount = 0;
|
|
134
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
135
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
136
|
-
const cacheKey = defaults.removeExt(file);
|
|
137
|
-
yield cache.process(cacheKey, () => {
|
|
138
|
-
const source = cache.get(cacheKey);
|
|
139
|
-
if (source) {
|
|
140
|
-
compilation.updateAsset(file, source);
|
|
141
|
-
debug('js cache hit: %s', file);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
}, () => {
|
|
147
|
-
const rawSource = originalSource.source().toString();
|
|
148
|
-
const mapFilename = file + '.map';
|
|
149
|
-
const hasMap = Boolean(assets[mapFilename]);
|
|
150
|
-
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
151
|
-
generateMap: hasMap
|
|
152
|
-
});
|
|
153
|
-
const source = new ConcatSource(code);
|
|
154
|
-
compilation.updateAsset(file, source);
|
|
155
|
-
onUpdate(file, rawSource, code);
|
|
156
|
-
debug('js handle: %s', file);
|
|
157
|
-
noCachedCount++;
|
|
158
|
-
if (hasMap && map) {
|
|
159
|
-
const source = new RawSource(map.toString());
|
|
160
|
-
compilation.updateAsset(mapFilename, source);
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
key: cacheKey,
|
|
164
|
-
source
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
169
|
-
}
|
|
170
|
-
if (Array.isArray(groupedEntries.css)) {
|
|
171
|
-
let noCachedCount = 0;
|
|
172
|
-
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
173
|
-
const [file, originalSource] = groupedEntries.css[i];
|
|
174
|
-
const rawSource = originalSource.source().toString();
|
|
175
|
-
const hash = cache.computeHash(rawSource);
|
|
176
|
-
const cacheKey = file;
|
|
177
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
178
|
-
yield cache.process(cacheKey, () => {
|
|
179
|
-
const source = cache.get(cacheKey);
|
|
180
|
-
if (source) {
|
|
181
|
-
compilation.updateAsset(file, source);
|
|
182
|
-
debug('css cache hit: %s', file);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
}, () => options.__awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
const css = yield styleHandler(rawSource, {
|
|
189
|
-
isMainChunk: mainCssChunkMatcher(file, this.appType)
|
|
190
|
-
});
|
|
191
|
-
const source = new ConcatSource(css);
|
|
192
|
-
compilation.updateAsset(file, source);
|
|
193
|
-
onUpdate(file, rawSource, css);
|
|
194
|
-
debug('css handle: %s', file);
|
|
195
|
-
noCachedCount++;
|
|
196
|
-
return {
|
|
197
|
-
key: cacheKey,
|
|
198
|
-
source
|
|
199
|
-
};
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
203
|
-
}
|
|
204
|
-
debug('end');
|
|
205
|
-
onEnd();
|
|
206
|
-
}));
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
36
|
|
|
211
|
-
exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;
|
|
37
|
+
exports.UnifiedWebpackPluginV5 = v5.UnifiedWebpackPluginV5;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import { p as pluginName } from './postcss-irzTcRfl.mjs';
|
|
5
|
-
import { g as getGroupedEntries, r as removeExt } from './defaults-TZpmwtzd.mjs';
|
|
6
|
-
import { c as createDebug } from './index-06BoOZig.mjs';
|
|
1
|
+
export { U as UnifiedWebpackPluginV5 } from './v5-UTJ5AaEA.mjs';
|
|
2
|
+
import './options-6YPFqoRJ.mjs';
|
|
7
3
|
import 'magic-string';
|
|
8
4
|
import './replace.mjs';
|
|
9
5
|
import '@weapp-core/escape';
|
|
@@ -13,190 +9,21 @@ import '@weapp-core/regex';
|
|
|
13
9
|
import '@babel/generator';
|
|
14
10
|
import '@babel/parser';
|
|
15
11
|
import '@babel/traverse';
|
|
12
|
+
import './defaults-TZpmwtzd.mjs';
|
|
13
|
+
import './defu-ms_ZBCiB.mjs';
|
|
16
14
|
import '@babel/types';
|
|
17
15
|
import 'htmlparser2';
|
|
18
16
|
import 'postcss';
|
|
17
|
+
import './index-_74RBzwy.mjs';
|
|
18
|
+
import '@csstools/postcss-is-pseudo-class';
|
|
19
|
+
import 'postcss-rem-to-responsive-pixel';
|
|
20
|
+
import 'postcss-selector-parser';
|
|
21
|
+
import 'node:path';
|
|
22
|
+
import 'node:fs';
|
|
19
23
|
import 'semver';
|
|
20
24
|
import 'tailwindcss-patch';
|
|
21
25
|
import '@tailwindcss-mangle/shared';
|
|
22
26
|
import 'lru-cache';
|
|
23
27
|
import 'md5';
|
|
24
|
-
import '
|
|
25
|
-
import 'postcss-rem-to-responsive-pixel';
|
|
26
|
-
import 'postcss-selector-parser';
|
|
27
|
-
import './defu-ms_ZBCiB.mjs';
|
|
28
|
+
import './index-06BoOZig.mjs';
|
|
28
29
|
import 'debug';
|
|
29
|
-
|
|
30
|
-
const debug = createDebug('processAssets: ');
|
|
31
|
-
class UnifiedWebpackPluginV5 {
|
|
32
|
-
constructor(options = {}) {
|
|
33
|
-
if (options.customReplaceDictionary === undefined) {
|
|
34
|
-
options.customReplaceDictionary = 'simple';
|
|
35
|
-
}
|
|
36
|
-
this.options = getOptions(options);
|
|
37
|
-
this.appType = this.options.appType;
|
|
38
|
-
}
|
|
39
|
-
apply(compiler) {
|
|
40
|
-
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, tailwindcssBasedir } = this.options;
|
|
41
|
-
if (disabled) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
patch === null || patch === void 0 ? void 0 : patch();
|
|
45
|
-
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
46
|
-
const { ConcatSource, RawSource } = sources;
|
|
47
|
-
const twPatcher = createTailwindcssPatcher();
|
|
48
|
-
function getClassSet() {
|
|
49
|
-
return twPatcher.getClassSet({
|
|
50
|
-
basedir: tailwindcssBasedir
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
onLoad();
|
|
54
|
-
const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? 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
|
-
name: pluginName,
|
|
75
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
76
|
-
}, (assets) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
onStart();
|
|
78
|
-
debug('start');
|
|
79
|
-
for (const chunk of compilation.chunks) {
|
|
80
|
-
if (chunk.id && chunk.hash) {
|
|
81
|
-
cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const entries = Object.entries(assets);
|
|
85
|
-
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
86
|
-
const runtimeSet = getClassSet();
|
|
87
|
-
setMangleRuntimeSet(runtimeSet);
|
|
88
|
-
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
89
|
-
if (Array.isArray(groupedEntries.html)) {
|
|
90
|
-
let noCachedCount = 0;
|
|
91
|
-
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
92
|
-
const [file, originalSource] = groupedEntries.html[i];
|
|
93
|
-
const rawSource = originalSource.source().toString();
|
|
94
|
-
const hash = cache.computeHash(rawSource);
|
|
95
|
-
const cacheKey = file;
|
|
96
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
97
|
-
yield cache.process(cacheKey, () => {
|
|
98
|
-
const source = cache.get(cacheKey);
|
|
99
|
-
if (source) {
|
|
100
|
-
compilation.updateAsset(file, source);
|
|
101
|
-
debug('html cache hit: %s', file);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}, () => {
|
|
107
|
-
const wxml = templateHandler(rawSource, {
|
|
108
|
-
runtimeSet
|
|
109
|
-
});
|
|
110
|
-
const source = new ConcatSource(wxml);
|
|
111
|
-
compilation.updateAsset(file, source);
|
|
112
|
-
onUpdate(file, rawSource, wxml);
|
|
113
|
-
debug('html handle: %s', file);
|
|
114
|
-
noCachedCount++;
|
|
115
|
-
return {
|
|
116
|
-
key: cacheKey,
|
|
117
|
-
source
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
122
|
-
}
|
|
123
|
-
if (Array.isArray(groupedEntries.js)) {
|
|
124
|
-
let noCachedCount = 0;
|
|
125
|
-
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
126
|
-
const [file, originalSource] = groupedEntries.js[i];
|
|
127
|
-
const cacheKey = removeExt(file);
|
|
128
|
-
yield cache.process(cacheKey, () => {
|
|
129
|
-
const source = cache.get(cacheKey);
|
|
130
|
-
if (source) {
|
|
131
|
-
compilation.updateAsset(file, source);
|
|
132
|
-
debug('js cache hit: %s', file);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
}, () => {
|
|
138
|
-
const rawSource = originalSource.source().toString();
|
|
139
|
-
const mapFilename = file + '.map';
|
|
140
|
-
const hasMap = Boolean(assets[mapFilename]);
|
|
141
|
-
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
142
|
-
generateMap: hasMap
|
|
143
|
-
});
|
|
144
|
-
const source = new ConcatSource(code);
|
|
145
|
-
compilation.updateAsset(file, source);
|
|
146
|
-
onUpdate(file, rawSource, code);
|
|
147
|
-
debug('js handle: %s', file);
|
|
148
|
-
noCachedCount++;
|
|
149
|
-
if (hasMap && map) {
|
|
150
|
-
const source = new RawSource(map.toString());
|
|
151
|
-
compilation.updateAsset(mapFilename, source);
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
key: cacheKey,
|
|
155
|
-
source
|
|
156
|
-
};
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
160
|
-
}
|
|
161
|
-
if (Array.isArray(groupedEntries.css)) {
|
|
162
|
-
let noCachedCount = 0;
|
|
163
|
-
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
164
|
-
const [file, originalSource] = groupedEntries.css[i];
|
|
165
|
-
const rawSource = originalSource.source().toString();
|
|
166
|
-
const hash = cache.computeHash(rawSource);
|
|
167
|
-
const cacheKey = file;
|
|
168
|
-
cache.calcHashValueChanged(cacheKey, hash);
|
|
169
|
-
yield cache.process(cacheKey, () => {
|
|
170
|
-
const source = cache.get(cacheKey);
|
|
171
|
-
if (source) {
|
|
172
|
-
compilation.updateAsset(file, source);
|
|
173
|
-
debug('css cache hit: %s', file);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
const css = yield styleHandler(rawSource, {
|
|
180
|
-
isMainChunk: mainCssChunkMatcher(file, this.appType)
|
|
181
|
-
});
|
|
182
|
-
const source = new ConcatSource(css);
|
|
183
|
-
compilation.updateAsset(file, source);
|
|
184
|
-
onUpdate(file, rawSource, css);
|
|
185
|
-
debug('css handle: %s', file);
|
|
186
|
-
noCachedCount++;
|
|
187
|
-
return {
|
|
188
|
-
key: cacheKey,
|
|
189
|
-
source
|
|
190
|
-
};
|
|
191
|
-
}));
|
|
192
|
-
}
|
|
193
|
-
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
194
|
-
}
|
|
195
|
-
debug('end');
|
|
196
|
-
onEnd();
|
|
197
|
-
}));
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export { UnifiedWebpackPluginV5 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bundlers/webpack/BaseUnifiedPlugin/v4';
|