weapp-tailwindcss 3.0.3 → 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-bdPbDgs7.js → index-Fkmyt0Rc.js} +3 -1
- package/dist/index-KpA8Y68V.js +142 -0
- package/dist/index-O8jpXUxP.mjs +140 -0
- package/dist/{postcss-MxkGjr8g.mjs → index-_74RBzwy.mjs} +2 -1
- 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-9bBYg22L.mjs → options-6YPFqoRJ.mjs} +2 -2
- package/dist/{options-MDCr-9Qn.js → options-N9g3FpWO.js} +3 -3
- 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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-6YPFqoRJ.mjs';
|
|
2
|
+
import { v as vitePluginName } from './index-_74RBzwy.mjs';
|
|
3
|
+
import { g as getGroupedEntries } from './defaults-TZpmwtzd.mjs';
|
|
4
|
+
import { c as createDebug } from './index-06BoOZig.mjs';
|
|
5
|
+
|
|
6
|
+
const debug = createDebug('generateBundle: ');
|
|
7
|
+
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
8
|
+
if (options.customReplaceDictionary === undefined) {
|
|
9
|
+
options.customReplaceDictionary = 'simple';
|
|
10
|
+
}
|
|
11
|
+
const opts = getOptions(options);
|
|
12
|
+
const { disabled, onEnd, onLoad, onStart, onUpdate, templateHandler, styleHandler, patch, jsHandler, mainCssChunkMatcher, appType, setMangleRuntimeSet, cache, tailwindcssBasedir } = opts;
|
|
13
|
+
if (disabled) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
17
|
+
const twPatcher = createTailwindcssPatcher();
|
|
18
|
+
onLoad();
|
|
19
|
+
return {
|
|
20
|
+
name: vitePluginName,
|
|
21
|
+
enforce: 'post',
|
|
22
|
+
generateBundle(opt, bundle) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
debug('start');
|
|
25
|
+
onStart();
|
|
26
|
+
const entries = Object.entries(bundle);
|
|
27
|
+
const groupedEntries = getGroupedEntries(entries, opts);
|
|
28
|
+
const runtimeSet = twPatcher.getClassSet({
|
|
29
|
+
basedir: tailwindcssBasedir
|
|
30
|
+
});
|
|
31
|
+
setMangleRuntimeSet(runtimeSet);
|
|
32
|
+
debug('get runtimeSet, class count: %d', runtimeSet.size);
|
|
33
|
+
if (Array.isArray(groupedEntries.html)) {
|
|
34
|
+
let noCachedCount = 0;
|
|
35
|
+
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
36
|
+
const [file, originalSource] = groupedEntries.html[i];
|
|
37
|
+
const oldVal = originalSource.source.toString();
|
|
38
|
+
const hash = cache.computeHash(oldVal);
|
|
39
|
+
cache.calcHashValueChanged(file, hash);
|
|
40
|
+
yield cache.process(file, () => {
|
|
41
|
+
const source = cache.get(file);
|
|
42
|
+
if (source) {
|
|
43
|
+
originalSource.source = source;
|
|
44
|
+
debug('html cache hit: %s', file);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}, () => {
|
|
50
|
+
originalSource.source = templateHandler(oldVal, {
|
|
51
|
+
runtimeSet
|
|
52
|
+
});
|
|
53
|
+
onUpdate(file, oldVal, originalSource.source);
|
|
54
|
+
debug('html handle: %s', file);
|
|
55
|
+
noCachedCount++;
|
|
56
|
+
return {
|
|
57
|
+
key: file,
|
|
58
|
+
source: originalSource.source
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(groupedEntries.js)) {
|
|
65
|
+
let noCachedCount = 0;
|
|
66
|
+
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
67
|
+
const [file, originalSource] = groupedEntries.js[i];
|
|
68
|
+
const rawSource = originalSource.code;
|
|
69
|
+
const hash = cache.computeHash(rawSource);
|
|
70
|
+
cache.calcHashValueChanged(file, hash);
|
|
71
|
+
yield cache.process(file, () => {
|
|
72
|
+
const source = cache.get(file);
|
|
73
|
+
if (source) {
|
|
74
|
+
originalSource.code = source;
|
|
75
|
+
debug('js cache hit: %s', file);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}, () => {
|
|
81
|
+
const mapFilename = file + '.map';
|
|
82
|
+
const hasMap = Boolean(bundle[mapFilename]);
|
|
83
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
84
|
+
generateMap: hasMap
|
|
85
|
+
});
|
|
86
|
+
originalSource.code = code;
|
|
87
|
+
onUpdate(file, rawSource, code);
|
|
88
|
+
debug('js handle: %s', file);
|
|
89
|
+
noCachedCount++;
|
|
90
|
+
if (hasMap && map) {
|
|
91
|
+
bundle[mapFilename].source = map.toString();
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
key: file,
|
|
95
|
+
source: code
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(groupedEntries.css)) {
|
|
102
|
+
let noCachedCount = 0;
|
|
103
|
+
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
104
|
+
const [file, originalSource] = groupedEntries.css[i];
|
|
105
|
+
const rawSource = originalSource.source.toString();
|
|
106
|
+
const hash = cache.computeHash(rawSource);
|
|
107
|
+
cache.calcHashValueChanged(file, hash);
|
|
108
|
+
yield cache.process(file, () => {
|
|
109
|
+
const source = cache.get(file);
|
|
110
|
+
if (source) {
|
|
111
|
+
originalSource.source = source;
|
|
112
|
+
debug('css cache hit: %s', file);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const css = yield styleHandler(rawSource, {
|
|
119
|
+
isMainChunk: mainCssChunkMatcher(originalSource.fileName, appType)
|
|
120
|
+
});
|
|
121
|
+
originalSource.source = css;
|
|
122
|
+
onUpdate(file, rawSource, css);
|
|
123
|
+
debug('css handle: %s', file);
|
|
124
|
+
noCachedCount++;
|
|
125
|
+
return {
|
|
126
|
+
key: file,
|
|
127
|
+
source: css
|
|
128
|
+
};
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
|
|
132
|
+
}
|
|
133
|
+
onEnd();
|
|
134
|
+
debug('end');
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export { UnifiedViteWeappTailwindcssPlugin as U };
|
|
@@ -372,6 +372,7 @@ function commonChunkPreflight(node, options) {
|
|
|
372
372
|
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
373
373
|
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
374
374
|
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
375
|
+
const WEAPP_TW_REQUIRED_NODE_VERSION = '16.6.0';
|
|
375
376
|
|
|
376
377
|
function isAtMediaHover(atRule) {
|
|
377
378
|
return /media\(\s*hover\s*:\s*hover\s*\)/.test(atRule.name) || (atRule.name === 'media' && /\(\s*hover\s*:\s*hover\s*\)/.test(atRule.params));
|
|
@@ -478,4 +479,4 @@ function getPlugins(options) {
|
|
|
478
479
|
return plugins;
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
export {
|
|
482
|
+
export { WEAPP_TW_REQUIRED_NODE_VERSION as W, postcssWeappTailwindcssPrePlugin as a, pluginName as b, getPlugins as g, postcssWeappTailwindcssPostPlugin as p, vitePluginName as v };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _createDebug = require('debug');
|
|
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 _createDebug__default = /*#__PURE__*/_interopDefaultCompat(_createDebug);
|
|
8
8
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { g as getOptions, c as createTailwindcssPatcher, _ as __awaiter } from './options-6YPFqoRJ.mjs';
|
|
2
|
+
import stream from 'node:stream';
|
|
3
|
+
|
|
4
|
+
const Transform = stream.Transform;
|
|
5
|
+
function createPlugins(options = {}) {
|
|
6
|
+
const opts = getOptions(options);
|
|
7
|
+
const { templateHandler, styleHandler, patch, jsHandler, setMangleRuntimeSet, tailwindcssBasedir } = opts;
|
|
8
|
+
let runtimeSet = new Set();
|
|
9
|
+
patch === null || patch === void 0 ? void 0 : patch();
|
|
10
|
+
const twPatcher = createTailwindcssPatcher();
|
|
11
|
+
function transformWxss() {
|
|
12
|
+
const transformStream = new Transform({ objectMode: true });
|
|
13
|
+
transformStream._transform = function (file, encoding, callback) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
runtimeSet = twPatcher.getClassSet({
|
|
16
|
+
basedir: tailwindcssBasedir
|
|
17
|
+
});
|
|
18
|
+
setMangleRuntimeSet(runtimeSet);
|
|
19
|
+
const error = null;
|
|
20
|
+
if (file.contents) {
|
|
21
|
+
const code = yield styleHandler(file.contents.toString(), {
|
|
22
|
+
isMainChunk: true
|
|
23
|
+
});
|
|
24
|
+
file.contents = Buffer.from(code);
|
|
25
|
+
}
|
|
26
|
+
callback(error, file);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return transformStream;
|
|
30
|
+
}
|
|
31
|
+
function transformJs() {
|
|
32
|
+
const transformStream = new Transform({ objectMode: true });
|
|
33
|
+
transformStream._transform = function (file, encoding, callback) {
|
|
34
|
+
const error = null;
|
|
35
|
+
if (file.contents) {
|
|
36
|
+
const { code } = jsHandler(file.contents.toString(), runtimeSet);
|
|
37
|
+
file.contents = Buffer.from(code);
|
|
38
|
+
}
|
|
39
|
+
callback(error, file);
|
|
40
|
+
};
|
|
41
|
+
return transformStream;
|
|
42
|
+
}
|
|
43
|
+
function transformWxml() {
|
|
44
|
+
const transformStream = new Transform({ objectMode: true });
|
|
45
|
+
transformStream._transform = function (file, encoding, callback) {
|
|
46
|
+
const error = null;
|
|
47
|
+
if (file.contents) {
|
|
48
|
+
const code = templateHandler(file.contents.toString(), {
|
|
49
|
+
runtimeSet
|
|
50
|
+
});
|
|
51
|
+
file.contents = Buffer.from(code);
|
|
52
|
+
}
|
|
53
|
+
callback(error, file);
|
|
54
|
+
};
|
|
55
|
+
return transformStream;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
transformWxss,
|
|
59
|
+
transformWxml,
|
|
60
|
+
transformJs
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { createPlugins as c };
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
require('./options-
|
|
5
|
+
var v5 = require('./v5-RkdOexPP.js');
|
|
6
|
+
var index = require('./index-KpA8Y68V.js');
|
|
7
|
+
var index$1 = require('./index-8OJKpYld.js');
|
|
8
|
+
require('./options-N9g3FpWO.js');
|
|
9
9
|
require('magic-string');
|
|
10
10
|
require('./replace.js');
|
|
11
11
|
require('@weapp-core/escape');
|
|
@@ -20,7 +20,7 @@ require('./defu-KWuJnZLV.js');
|
|
|
20
20
|
require('@babel/types');
|
|
21
21
|
require('htmlparser2');
|
|
22
22
|
require('postcss');
|
|
23
|
-
require('./
|
|
23
|
+
require('./index-Fkmyt0Rc.js');
|
|
24
24
|
require('@csstools/postcss-is-pseudo-class');
|
|
25
25
|
require('postcss-rem-to-responsive-pixel');
|
|
26
26
|
require('postcss-selector-parser');
|
|
@@ -31,12 +31,12 @@ require('tailwindcss-patch');
|
|
|
31
31
|
require('@tailwindcss-mangle/shared');
|
|
32
32
|
require('lru-cache');
|
|
33
33
|
require('md5');
|
|
34
|
-
require('./index-
|
|
34
|
+
require('./index-juOeq2Kt.js');
|
|
35
35
|
require('debug');
|
|
36
36
|
require('node:stream');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
exports.UnifiedWebpackPluginV5 =
|
|
41
|
-
exports.UnifiedViteWeappTailwindcssPlugin =
|
|
42
|
-
exports.createPlugins =
|
|
40
|
+
exports.UnifiedWebpackPluginV5 = v5.UnifiedWebpackPluginV5;
|
|
41
|
+
exports.UnifiedViteWeappTailwindcssPlugin = index.UnifiedViteWeappTailwindcssPlugin;
|
|
42
|
+
exports.createPlugins = index$1.createPlugins;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { UnifiedWebpackPluginV5 } from './
|
|
2
|
-
export { UnifiedViteWeappTailwindcssPlugin } from './
|
|
3
|
-
export { createPlugins } from './
|
|
4
|
-
import './options-
|
|
1
|
+
export { U as UnifiedWebpackPluginV5 } from './v5-UTJ5AaEA.mjs';
|
|
2
|
+
export { U as UnifiedViteWeappTailwindcssPlugin } from './index-O8jpXUxP.mjs';
|
|
3
|
+
export { c as createPlugins } from './index-u-U9HdG6.mjs';
|
|
4
|
+
import './options-6YPFqoRJ.mjs';
|
|
5
5
|
import 'magic-string';
|
|
6
6
|
import './replace.mjs';
|
|
7
7
|
import '@weapp-core/escape';
|
|
@@ -16,7 +16,7 @@ import './defu-ms_ZBCiB.mjs';
|
|
|
16
16
|
import '@babel/types';
|
|
17
17
|
import 'htmlparser2';
|
|
18
18
|
import 'postcss';
|
|
19
|
-
import './
|
|
19
|
+
import './index-_74RBzwy.mjs';
|
|
20
20
|
import '@csstools/postcss-is-pseudo-class';
|
|
21
21
|
import 'postcss-rem-to-responsive-pixel';
|
|
22
22
|
import 'postcss-selector-parser';
|
|
@@ -10,7 +10,7 @@ import { d as defuOverrideArray, n as noop, a as defaultOptions, i as isMap } fr
|
|
|
10
10
|
import * as t from '@babel/types';
|
|
11
11
|
import { Parser } from 'htmlparser2';
|
|
12
12
|
import postcss from 'postcss';
|
|
13
|
-
import { g as getPlugins } from './
|
|
13
|
+
import { g as getPlugins } from './index-_74RBzwy.mjs';
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
import fs from 'node:fs';
|
|
16
16
|
import { gte } from 'semver';
|
|
@@ -687,4 +687,4 @@ function getOptions(options = {}) {
|
|
|
687
687
|
return result;
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
-
export { __awaiter as _,
|
|
690
|
+
export { __awaiter as _, createPatch as a, createTailwindcssPatcher as c, getOptions as g };
|
|
@@ -12,7 +12,7 @@ var defaults = require('./defaults-QOAV8NSV.js');
|
|
|
12
12
|
var t = require('@babel/types');
|
|
13
13
|
var htmlparser2 = require('htmlparser2');
|
|
14
14
|
var postcss = require('postcss');
|
|
15
|
-
var
|
|
15
|
+
var index = require('./index-Fkmyt0Rc.js');
|
|
16
16
|
var path = require('node:path');
|
|
17
17
|
var fs = require('node:fs');
|
|
18
18
|
var semver = require('semver');
|
|
@@ -21,7 +21,7 @@ var shared = require('@tailwindcss-mangle/shared');
|
|
|
21
21
|
var lruCache = require('lru-cache');
|
|
22
22
|
var md5 = require('md5');
|
|
23
23
|
|
|
24
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : {
|
|
24
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
25
25
|
|
|
26
26
|
function _interopNamespaceCompat(e) {
|
|
27
27
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -394,7 +394,7 @@ function createTemplateHandler(options = {}) {
|
|
|
394
394
|
|
|
395
395
|
function styleHandler(rawSource, options) {
|
|
396
396
|
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
-
return (yield postcss__default["default"](
|
|
397
|
+
return (yield postcss__default["default"](index.getPlugins(options)).process(rawSource).async()).css;
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
400
|
function createStyleHandler(options) {
|
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;
|