weapp-tailwindcss 2.8.4 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache/index.d.ts +11 -0
- package/dist/cli.js +2 -1
- package/dist/cli.mjs +2 -1
- package/dist/debug/index.d.ts +2 -0
- package/dist/gulp.js +2 -1
- package/dist/gulp.mjs +2 -1
- package/dist/index.js +3 -1
- package/dist/index.mjs +3 -1
- package/dist/{options-904051d2.js → options-84d4eeb7.js} +15 -0
- package/dist/{options-c9c14817.mjs → options-d2268f8f.mjs} +15 -0
- package/dist/types.d.ts +2 -0
- package/dist/vite.js +2 -1
- package/dist/vite.mjs +2 -1
- package/dist/webpack.js +63 -14
- package/dist/webpack.mjs +62 -14
- package/package.json +22 -19
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LRUCache } from 'lru-cache';
|
|
2
|
+
import type { sources } from 'webpack';
|
|
3
|
+
export interface ICreateCacheReturnType {
|
|
4
|
+
hashMap: Map<string | number, {
|
|
5
|
+
hash: string;
|
|
6
|
+
changed: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
instance: LRUCache<string, sources.Source>;
|
|
9
|
+
}
|
|
10
|
+
declare function createCache(): ICreateCacheReturnType;
|
|
11
|
+
export { createCache };
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var options = require('./options-
|
|
3
|
+
var options = require('./options-84d4eeb7.js');
|
|
4
4
|
require('micromatch');
|
|
5
5
|
require('magic-string');
|
|
6
6
|
require('./replace.js');
|
|
@@ -23,6 +23,7 @@ require('node:fs');
|
|
|
23
23
|
require('semver');
|
|
24
24
|
require('tailwindcss-patch');
|
|
25
25
|
require('@tailwindcss-mangle/shared');
|
|
26
|
+
require('lru-cache');
|
|
26
27
|
|
|
27
28
|
const args = process.argv.slice(2);
|
|
28
29
|
if (args[0] === 'patch') {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getOptions, c as createPatch } from './options-
|
|
1
|
+
import { g as getOptions, c as createPatch } from './options-d2268f8f.mjs';
|
|
2
2
|
import 'micromatch';
|
|
3
3
|
import 'magic-string';
|
|
4
4
|
import './replace.mjs';
|
|
@@ -21,6 +21,7 @@ import 'node:fs';
|
|
|
21
21
|
import 'semver';
|
|
22
22
|
import 'tailwindcss-patch';
|
|
23
23
|
import '@tailwindcss-mangle/shared';
|
|
24
|
+
import 'lru-cache';
|
|
24
25
|
|
|
25
26
|
const args = process.argv.slice(2);
|
|
26
27
|
if (args[0] === 'patch') {
|
package/dist/gulp.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var stream = require('node:stream');
|
|
6
|
-
var options = require('./options-
|
|
6
|
+
var options = require('./options-84d4eeb7.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('magic-string');
|
|
9
9
|
require('./replace.js');
|
|
@@ -26,6 +26,7 @@ require('node:fs');
|
|
|
26
26
|
require('semver');
|
|
27
27
|
require('tailwindcss-patch');
|
|
28
28
|
require('@tailwindcss-mangle/shared');
|
|
29
|
+
require('lru-cache');
|
|
29
30
|
|
|
30
31
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
31
32
|
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import stream from 'node:stream';
|
|
2
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-
|
|
2
|
+
import { g as getOptions, a as createTailwindcssPatcher } from './options-d2268f8f.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import 'magic-string';
|
|
5
5
|
import './replace.mjs';
|
|
@@ -22,6 +22,7 @@ import 'node:fs';
|
|
|
22
22
|
import 'semver';
|
|
23
23
|
import 'tailwindcss-patch';
|
|
24
24
|
import '@tailwindcss-mangle/shared';
|
|
25
|
+
import 'lru-cache';
|
|
25
26
|
|
|
26
27
|
const Transform = stream.Transform;
|
|
27
28
|
function createPlugins(options = {}) {
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var vite = require('./vite.js');
|
|
|
7
7
|
var gulp = require('./gulp.js');
|
|
8
8
|
require('node:path');
|
|
9
9
|
require('node:fs');
|
|
10
|
-
require('./options-
|
|
10
|
+
require('./options-84d4eeb7.js');
|
|
11
11
|
require('micromatch');
|
|
12
12
|
require('magic-string');
|
|
13
13
|
require('./replace.js');
|
|
@@ -28,6 +28,8 @@ require('@csstools/postcss-is-pseudo-class');
|
|
|
28
28
|
require('semver');
|
|
29
29
|
require('tailwindcss-patch');
|
|
30
30
|
require('@tailwindcss-mangle/shared');
|
|
31
|
+
require('lru-cache');
|
|
32
|
+
require('debug');
|
|
31
33
|
require('node:stream');
|
|
32
34
|
|
|
33
35
|
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export { UnifiedViteWeappTailwindcssPlugin } from './vite.mjs';
|
|
|
3
3
|
export { createPlugins } from './gulp.mjs';
|
|
4
4
|
import 'node:path';
|
|
5
5
|
import 'node:fs';
|
|
6
|
-
import './options-
|
|
6
|
+
import './options-d2268f8f.mjs';
|
|
7
7
|
import 'micromatch';
|
|
8
8
|
import 'magic-string';
|
|
9
9
|
import './replace.mjs';
|
|
@@ -24,4 +24,6 @@ import '@csstools/postcss-is-pseudo-class';
|
|
|
24
24
|
import 'semver';
|
|
25
25
|
import 'tailwindcss-patch';
|
|
26
26
|
import '@tailwindcss-mangle/shared';
|
|
27
|
+
import 'lru-cache';
|
|
28
|
+
import 'debug';
|
|
27
29
|
import 'node:stream';
|
|
@@ -20,6 +20,7 @@ var fs = require('node:fs');
|
|
|
20
20
|
var semver = require('semver');
|
|
21
21
|
var tailwindcssPatch = require('tailwindcss-patch');
|
|
22
22
|
var shared = require('@tailwindcss-mangle/shared');
|
|
23
|
+
var lruCache = require('lru-cache');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
26
|
|
|
@@ -697,6 +698,19 @@ function useMangleStore() {
|
|
|
697
698
|
};
|
|
698
699
|
}
|
|
699
700
|
|
|
701
|
+
function createCache() {
|
|
702
|
+
const hashMap = new Map();
|
|
703
|
+
const instance = new lruCache.LRUCache({
|
|
704
|
+
max: 1024,
|
|
705
|
+
ttl: 0,
|
|
706
|
+
ttlAutopurge: false
|
|
707
|
+
});
|
|
708
|
+
return {
|
|
709
|
+
hashMap,
|
|
710
|
+
instance
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
700
714
|
function createGlobMatcher(pattern) {
|
|
701
715
|
return function (file) {
|
|
702
716
|
return micromatch.isMatch(file, pattern);
|
|
@@ -767,6 +781,7 @@ function getOptions(options = {}) {
|
|
|
767
781
|
result.templateHandler = templateHandler;
|
|
768
782
|
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
769
783
|
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
784
|
+
result.cache = createCache();
|
|
770
785
|
return result;
|
|
771
786
|
}
|
|
772
787
|
|
|
@@ -18,6 +18,7 @@ import fs from 'node:fs';
|
|
|
18
18
|
import { gte } from 'semver';
|
|
19
19
|
import { monkeyPatchForExposingContext, requireResolve, TailwindcssPatcher } from 'tailwindcss-patch';
|
|
20
20
|
import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/shared';
|
|
21
|
+
import { LRUCache } from 'lru-cache';
|
|
21
22
|
|
|
22
23
|
const validateFilterRE = /[\w%-?\u00A0-\uFFFF-]/;
|
|
23
24
|
function isValidSelector(selector = '') {
|
|
@@ -666,6 +667,19 @@ function useMangleStore() {
|
|
|
666
667
|
};
|
|
667
668
|
}
|
|
668
669
|
|
|
670
|
+
function createCache() {
|
|
671
|
+
const hashMap = new Map();
|
|
672
|
+
const instance = new LRUCache({
|
|
673
|
+
max: 1024,
|
|
674
|
+
ttl: 0,
|
|
675
|
+
ttlAutopurge: false
|
|
676
|
+
});
|
|
677
|
+
return {
|
|
678
|
+
hashMap,
|
|
679
|
+
instance
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
669
683
|
function createGlobMatcher(pattern) {
|
|
670
684
|
return function (file) {
|
|
671
685
|
return isMatch(file, pattern);
|
|
@@ -736,6 +750,7 @@ function getOptions(options = {}) {
|
|
|
736
750
|
result.templateHandler = templateHandler;
|
|
737
751
|
result.patch = createPatch(supportCustomLengthUnitsPatch);
|
|
738
752
|
result.setMangleRuntimeSet = setMangleRuntimeSet;
|
|
753
|
+
result.cache = createCache();
|
|
739
754
|
return result;
|
|
740
755
|
}
|
|
741
756
|
|
package/dist/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { IClassGeneratorOptions, ClassGenerator } from '@tailwindcss-mangle
|
|
|
3
3
|
import type { SourceMap } from 'magic-string';
|
|
4
4
|
import type { GeneratorResult } from '@babel/generator';
|
|
5
5
|
import type { InjectPreflight } from './postcss/preflight';
|
|
6
|
+
import type { ICreateCacheReturnType } from "./cache";
|
|
6
7
|
export type ItemOrItemArray<T> = T | T[];
|
|
7
8
|
export type AppType = 'uni-app' | 'uni-app-vite' | 'taro' | 'remax' | 'rax' | 'native' | 'kbone' | 'mpx';
|
|
8
9
|
export interface IPropValue {
|
|
@@ -141,6 +142,7 @@ export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobO
|
|
|
141
142
|
patch: () => void;
|
|
142
143
|
customReplaceDictionary: Record<string, string>;
|
|
143
144
|
setMangleRuntimeSet: (runtimeSet: Set<string>) => void;
|
|
145
|
+
cache: ICreateCacheReturnType;
|
|
144
146
|
}>;
|
|
145
147
|
export type InternalPostcssOptions = Pick<UserDefinedOptions, 'cssMatcher' | 'mainCssChunkMatcher' | 'cssPreflight' | 'replaceUniversalSelectorWith' | 'cssPreflightRange' | 'customRuleCallback' | 'disabled'>;
|
|
146
148
|
export interface IBaseWebpackPlugin {
|
package/dist/vite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var options = require('./options-
|
|
5
|
+
var options = require('./options-84d4eeb7.js');
|
|
6
6
|
var postcss = require('./postcss-8d7f67b4.js');
|
|
7
7
|
var defaults = require('./defaults-263271f9.js');
|
|
8
8
|
require('micromatch');
|
|
@@ -24,6 +24,7 @@ require('node:fs');
|
|
|
24
24
|
require('semver');
|
|
25
25
|
require('tailwindcss-patch');
|
|
26
26
|
require('@tailwindcss-mangle/shared');
|
|
27
|
+
require('lru-cache');
|
|
27
28
|
require('postcss-selector-parser');
|
|
28
29
|
|
|
29
30
|
function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-
|
|
1
|
+
import { g as getOptions, a as createTailwindcssPatcher } from './options-d2268f8f.mjs';
|
|
2
2
|
import { v as vitePluginName } from './postcss-55ed4d42.mjs';
|
|
3
3
|
import { g as getGroupedEntries } from './defaults-dc8a0e3d.mjs';
|
|
4
4
|
import 'micromatch';
|
|
@@ -20,6 +20,7 @@ import 'node:fs';
|
|
|
20
20
|
import 'semver';
|
|
21
21
|
import 'tailwindcss-patch';
|
|
22
22
|
import '@tailwindcss-mangle/shared';
|
|
23
|
+
import 'lru-cache';
|
|
23
24
|
import 'postcss-selector-parser';
|
|
24
25
|
|
|
25
26
|
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
package/dist/webpack.js
CHANGED
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var fs = require('node:fs');
|
|
7
|
-
var options = require('./options-
|
|
7
|
+
var options = require('./options-84d4eeb7.js');
|
|
8
8
|
var postcss = require('./postcss-8d7f67b4.js');
|
|
9
9
|
var defaults = require('./defaults-263271f9.js');
|
|
10
|
+
var createDebug = require('debug');
|
|
10
11
|
require('micromatch');
|
|
11
12
|
require('magic-string');
|
|
12
13
|
require('./replace.js');
|
|
@@ -24,12 +25,16 @@ require('@csstools/postcss-is-pseudo-class');
|
|
|
24
25
|
require('semver');
|
|
25
26
|
require('tailwindcss-patch');
|
|
26
27
|
require('@tailwindcss-mangle/shared');
|
|
28
|
+
require('lru-cache');
|
|
27
29
|
require('postcss-selector-parser');
|
|
28
30
|
|
|
29
31
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
30
32
|
|
|
31
33
|
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
32
34
|
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
35
|
+
var createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
|
|
36
|
+
|
|
37
|
+
const debug = createDebug__default["default"]('weapp-tw');
|
|
33
38
|
|
|
34
39
|
class UnifiedWebpackPluginV5 {
|
|
35
40
|
constructor(options$1 = {}) {
|
|
@@ -40,7 +45,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
40
45
|
this.appType = this.options.appType;
|
|
41
46
|
}
|
|
42
47
|
apply(compiler) {
|
|
43
|
-
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath } = this.options;
|
|
48
|
+
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache } = this.options;
|
|
44
49
|
if (disabled) {
|
|
45
50
|
return;
|
|
46
51
|
}
|
|
@@ -76,10 +81,39 @@ class UnifiedWebpackPluginV5 {
|
|
|
76
81
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
77
82
|
}, (assets) => {
|
|
78
83
|
onStart();
|
|
84
|
+
debug('processAssets: start');
|
|
85
|
+
for (const chunk of compilation.chunks) {
|
|
86
|
+
if (chunk.id && chunk.hash) {
|
|
87
|
+
if (cache.hashMap.has(chunk.id)) {
|
|
88
|
+
const value = cache.hashMap.get(chunk.id);
|
|
89
|
+
if (value) {
|
|
90
|
+
if (chunk.hash === value.hash) {
|
|
91
|
+
cache.hashMap.set(chunk.id, {
|
|
92
|
+
changed: false,
|
|
93
|
+
hash: chunk.hash
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
cache.hashMap.set(chunk.id, {
|
|
98
|
+
changed: true,
|
|
99
|
+
hash: chunk.hash
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
cache.hashMap.set(chunk.id, {
|
|
106
|
+
changed: true,
|
|
107
|
+
hash: chunk.hash
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
79
112
|
const entries = Object.entries(assets);
|
|
80
113
|
const groupedEntries = defaults.getGroupedEntries(entries, this.options);
|
|
81
114
|
const runtimeSet = getClassSet();
|
|
82
115
|
setMangleRuntimeSet(runtimeSet);
|
|
116
|
+
debug('processAssets: runtimeSet inited, class count: %d', runtimeSet.size);
|
|
83
117
|
if (Array.isArray(groupedEntries.html)) {
|
|
84
118
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
85
119
|
const [file, originalSource] = groupedEntries.html[i];
|
|
@@ -91,24 +125,37 @@ class UnifiedWebpackPluginV5 {
|
|
|
91
125
|
compilation.updateAsset(file, source);
|
|
92
126
|
onUpdate(file, rawSource, wxml);
|
|
93
127
|
}
|
|
128
|
+
debug('processAssets: html handle finish, count: %s', groupedEntries.html.length);
|
|
94
129
|
}
|
|
95
130
|
if (Array.isArray(groupedEntries.js)) {
|
|
96
131
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
97
132
|
const [file, originalSource] = groupedEntries.js[i];
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
133
|
+
const key = file.replace(/\.[^./]+$/, '');
|
|
134
|
+
const hit = cache.hashMap.get(key);
|
|
135
|
+
if (hit && !hit.changed) {
|
|
136
|
+
const source = cache.instance.get(key);
|
|
137
|
+
source && compilation.updateAsset(file, source);
|
|
138
|
+
debug('processAssets: js cache hited: %s', file);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const rawSource = originalSource.source().toString();
|
|
142
|
+
const mapFilename = file + '.map';
|
|
143
|
+
const hasMap = Boolean(assets[mapFilename]);
|
|
144
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
145
|
+
generateMap: hasMap
|
|
146
|
+
});
|
|
147
|
+
const source = new ConcatSource(code);
|
|
148
|
+
compilation.updateAsset(file, source);
|
|
149
|
+
onUpdate(file, rawSource, code);
|
|
150
|
+
debug('processAssets: js handle: %s', file);
|
|
151
|
+
cache.instance.set(key, source);
|
|
152
|
+
if (hasMap && map) {
|
|
153
|
+
const source = new RawSource(map.toString());
|
|
154
|
+
compilation.updateAsset(mapFilename, source);
|
|
155
|
+
}
|
|
110
156
|
}
|
|
111
157
|
}
|
|
158
|
+
debug('processAssets: js handler finish, count: %s', groupedEntries.js.length);
|
|
112
159
|
}
|
|
113
160
|
if (Array.isArray(groupedEntries.css)) {
|
|
114
161
|
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
@@ -121,7 +168,9 @@ class UnifiedWebpackPluginV5 {
|
|
|
121
168
|
compilation.updateAsset(file, source);
|
|
122
169
|
onUpdate(file, rawSource, css);
|
|
123
170
|
}
|
|
171
|
+
debug('processAssets: css handler finish, count: %s', groupedEntries.css.length);
|
|
124
172
|
}
|
|
173
|
+
debug('processAssets: end');
|
|
125
174
|
onEnd();
|
|
126
175
|
});
|
|
127
176
|
});
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
-
import { g as getOptions, a as createTailwindcssPatcher } from './options-
|
|
3
|
+
import { g as getOptions, a as createTailwindcssPatcher } from './options-d2268f8f.mjs';
|
|
4
4
|
import { a as pluginName } from './postcss-55ed4d42.mjs';
|
|
5
5
|
import { g as getGroupedEntries } from './defaults-dc8a0e3d.mjs';
|
|
6
|
+
import createDebug from 'debug';
|
|
6
7
|
import 'micromatch';
|
|
7
8
|
import 'magic-string';
|
|
8
9
|
import './replace.mjs';
|
|
@@ -20,8 +21,11 @@ import '@csstools/postcss-is-pseudo-class';
|
|
|
20
21
|
import 'semver';
|
|
21
22
|
import 'tailwindcss-patch';
|
|
22
23
|
import '@tailwindcss-mangle/shared';
|
|
24
|
+
import 'lru-cache';
|
|
23
25
|
import 'postcss-selector-parser';
|
|
24
26
|
|
|
27
|
+
const debug = createDebug('weapp-tw');
|
|
28
|
+
|
|
25
29
|
class UnifiedWebpackPluginV5 {
|
|
26
30
|
constructor(options = {}) {
|
|
27
31
|
if (options.customReplaceDictionary === undefined) {
|
|
@@ -31,7 +35,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
31
35
|
this.appType = this.options.appType;
|
|
32
36
|
}
|
|
33
37
|
apply(compiler) {
|
|
34
|
-
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath } = this.options;
|
|
38
|
+
const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache } = this.options;
|
|
35
39
|
if (disabled) {
|
|
36
40
|
return;
|
|
37
41
|
}
|
|
@@ -67,10 +71,39 @@ class UnifiedWebpackPluginV5 {
|
|
|
67
71
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
68
72
|
}, (assets) => {
|
|
69
73
|
onStart();
|
|
74
|
+
debug('processAssets: start');
|
|
75
|
+
for (const chunk of compilation.chunks) {
|
|
76
|
+
if (chunk.id && chunk.hash) {
|
|
77
|
+
if (cache.hashMap.has(chunk.id)) {
|
|
78
|
+
const value = cache.hashMap.get(chunk.id);
|
|
79
|
+
if (value) {
|
|
80
|
+
if (chunk.hash === value.hash) {
|
|
81
|
+
cache.hashMap.set(chunk.id, {
|
|
82
|
+
changed: false,
|
|
83
|
+
hash: chunk.hash
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
cache.hashMap.set(chunk.id, {
|
|
88
|
+
changed: true,
|
|
89
|
+
hash: chunk.hash
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
cache.hashMap.set(chunk.id, {
|
|
96
|
+
changed: true,
|
|
97
|
+
hash: chunk.hash
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
70
102
|
const entries = Object.entries(assets);
|
|
71
103
|
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
72
104
|
const runtimeSet = getClassSet();
|
|
73
105
|
setMangleRuntimeSet(runtimeSet);
|
|
106
|
+
debug('processAssets: runtimeSet inited, class count: %d', runtimeSet.size);
|
|
74
107
|
if (Array.isArray(groupedEntries.html)) {
|
|
75
108
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
76
109
|
const [file, originalSource] = groupedEntries.html[i];
|
|
@@ -82,24 +115,37 @@ class UnifiedWebpackPluginV5 {
|
|
|
82
115
|
compilation.updateAsset(file, source);
|
|
83
116
|
onUpdate(file, rawSource, wxml);
|
|
84
117
|
}
|
|
118
|
+
debug('processAssets: html handle finish, count: %s', groupedEntries.html.length);
|
|
85
119
|
}
|
|
86
120
|
if (Array.isArray(groupedEntries.js)) {
|
|
87
121
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
88
122
|
const [file, originalSource] = groupedEntries.js[i];
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
123
|
+
const key = file.replace(/\.[^./]+$/, '');
|
|
124
|
+
const hit = cache.hashMap.get(key);
|
|
125
|
+
if (hit && !hit.changed) {
|
|
126
|
+
const source = cache.instance.get(key);
|
|
127
|
+
source && compilation.updateAsset(file, source);
|
|
128
|
+
debug('processAssets: js cache hited: %s', file);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
const rawSource = originalSource.source().toString();
|
|
132
|
+
const mapFilename = file + '.map';
|
|
133
|
+
const hasMap = Boolean(assets[mapFilename]);
|
|
134
|
+
const { code, map } = jsHandler(rawSource, runtimeSet, {
|
|
135
|
+
generateMap: hasMap
|
|
136
|
+
});
|
|
137
|
+
const source = new ConcatSource(code);
|
|
138
|
+
compilation.updateAsset(file, source);
|
|
139
|
+
onUpdate(file, rawSource, code);
|
|
140
|
+
debug('processAssets: js handle: %s', file);
|
|
141
|
+
cache.instance.set(key, source);
|
|
142
|
+
if (hasMap && map) {
|
|
143
|
+
const source = new RawSource(map.toString());
|
|
144
|
+
compilation.updateAsset(mapFilename, source);
|
|
145
|
+
}
|
|
101
146
|
}
|
|
102
147
|
}
|
|
148
|
+
debug('processAssets: js handler finish, count: %s', groupedEntries.js.length);
|
|
103
149
|
}
|
|
104
150
|
if (Array.isArray(groupedEntries.css)) {
|
|
105
151
|
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
@@ -112,7 +158,9 @@ class UnifiedWebpackPluginV5 {
|
|
|
112
158
|
compilation.updateAsset(file, source);
|
|
113
159
|
onUpdate(file, rawSource, css);
|
|
114
160
|
}
|
|
161
|
+
debug('processAssets: css handler finish, count: %s', groupedEntries.css.length);
|
|
115
162
|
}
|
|
163
|
+
debug('processAssets: end');
|
|
116
164
|
onEnd();
|
|
117
165
|
});
|
|
118
166
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "把tailwindcss jit引擎,带给小程序开发者们! bring tailwindcss jit engine to miniprogram developers!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"homepage": "https://weapp-tw.icebreaker.top",
|
|
104
104
|
"devDependencies": {
|
|
105
|
-
"@babel/core": "^7.22.
|
|
105
|
+
"@babel/core": "^7.22.20",
|
|
106
106
|
"@icebreakers/cli": "0.1.1",
|
|
107
107
|
"@icebreakers/readme": "0.1.0",
|
|
108
108
|
"@rollup/plugin-alias": "^5.0.0",
|
|
@@ -111,21 +111,22 @@
|
|
|
111
111
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
112
112
|
"@rollup/plugin-terser": "^0.4.3",
|
|
113
113
|
"@rollup/plugin-typescript": "^11.1.3",
|
|
114
|
-
"@tsconfig/recommended": "^1.0.
|
|
115
|
-
"@types/babel__generator": "^7.6.
|
|
116
|
-
"@types/babel__traverse": "^7.20.
|
|
117
|
-
"@types/
|
|
118
|
-
"@types/
|
|
114
|
+
"@tsconfig/recommended": "^1.0.3",
|
|
115
|
+
"@types/babel__generator": "^7.6.5",
|
|
116
|
+
"@types/babel__traverse": "^7.20.2",
|
|
117
|
+
"@types/debug": "^4.1.8",
|
|
118
|
+
"@types/diff": "^5.0.4",
|
|
119
|
+
"@types/fs-extra": "^11.0.2",
|
|
119
120
|
"@types/gulp": "^4.0.13",
|
|
120
121
|
"@types/gulp-postcss": "^8.0.3",
|
|
121
|
-
"@types/jest": "^29.5.
|
|
122
|
-
"@types/js-beautify": "^1.14.
|
|
123
|
-
"@types/klaw": "^3.0.
|
|
122
|
+
"@types/jest": "^29.5.5",
|
|
123
|
+
"@types/js-beautify": "^1.14.1",
|
|
124
|
+
"@types/klaw": "^3.0.4",
|
|
124
125
|
"@types/loader-utils": "^2.0.4",
|
|
125
126
|
"@types/lodash": "^4.14.198",
|
|
126
127
|
"@types/micromatch": "^4.0.2",
|
|
127
|
-
"@types/node": "^20.6.
|
|
128
|
-
"@types/semver": "^7.5.
|
|
128
|
+
"@types/node": "^20.6.2",
|
|
129
|
+
"@types/semver": "^7.5.2",
|
|
129
130
|
"@types/vinyl": "^2.0.7",
|
|
130
131
|
"@types/webpack": "^5.28.2",
|
|
131
132
|
"@types/webpack-sources": "^3.2.0",
|
|
@@ -163,7 +164,7 @@
|
|
|
163
164
|
"postcss-rem-to-responsive-pixel": "^5.1.3",
|
|
164
165
|
"prettier": "^3.0.3",
|
|
165
166
|
"promisify-loader-runner": "^1.0.0",
|
|
166
|
-
"rollup": "^3.29.
|
|
167
|
+
"rollup": "^3.29.2",
|
|
167
168
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
168
169
|
"style-loader": "^3.3.3",
|
|
169
170
|
"tailwind-children": "^0.5.0",
|
|
@@ -186,22 +187,24 @@
|
|
|
186
187
|
"@ast-core/escape": "^1.0.1",
|
|
187
188
|
"@babel/generator": "^7.22.15",
|
|
188
189
|
"@babel/parser": "^7.22.16",
|
|
189
|
-
"@babel/traverse": "^7.22.
|
|
190
|
-
"@babel/types": "^7.22.
|
|
190
|
+
"@babel/traverse": "^7.22.20",
|
|
191
|
+
"@babel/types": "^7.22.19",
|
|
191
192
|
"@csstools/postcss-is-pseudo-class": "^4.0.1",
|
|
192
|
-
"@tailwindcss-mangle/shared": "^2.1
|
|
193
|
+
"@tailwindcss-mangle/shared": "^2.2.1",
|
|
193
194
|
"@weapp-core/escape": "^2.0.0",
|
|
194
195
|
"@weapp-core/regex": "^1.0.1",
|
|
196
|
+
"debug": "^4.3.4",
|
|
195
197
|
"htmlparser2": "^9.0.0",
|
|
196
198
|
"loader-utils": "^2.0.3",
|
|
199
|
+
"lru-cache": "^10.0.1",
|
|
197
200
|
"magic-string": "^0.30.3",
|
|
198
201
|
"micromatch": "^4.0.5",
|
|
199
202
|
"postcss": "8.4.29",
|
|
200
203
|
"postcss-selector-parser": "^6.0.13",
|
|
201
204
|
"semver": "^7.5.4",
|
|
202
|
-
"tailwindcss-patch": "^2.
|
|
205
|
+
"tailwindcss-patch": "^2.2.1"
|
|
203
206
|
},
|
|
204
|
-
"packageManager": "pnpm@8.
|
|
207
|
+
"packageManager": "pnpm@8.7.4",
|
|
205
208
|
"engines": {
|
|
206
209
|
"node": ">=16.6.0"
|
|
207
210
|
},
|
|
@@ -211,7 +214,7 @@
|
|
|
211
214
|
"build:demo": "yarn demo:del-dist && cross-env NODE_ENV=demo rollup -c rollup.config.ts --configPlugin typescript && yarn demo:sync-dist",
|
|
212
215
|
"build:tsc": "cross-env NODE_ENV=development tsc --build tsconfig.json",
|
|
213
216
|
"dts": "tsc --emitDeclarationOnly -p tsconfig.dts.json",
|
|
214
|
-
"test": "jest && vitest run",
|
|
217
|
+
"test": "cross-env DEBUG=weapp-tw jest && vitest run",
|
|
215
218
|
"jest-u": "jest -u",
|
|
216
219
|
"jest:u": "jest -u",
|
|
217
220
|
"test:dev": "vitest",
|