weapp-tailwindcss 2.4.3 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -3
- package/dist/cli.mjs +3 -3
- package/dist/constants.d.ts +1 -1
- package/dist/gulp.js +10 -8
- package/dist/gulp.mjs +10 -8
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/dist/{options-a2ba3653.mjs → options-1e3a224a.mjs} +51 -37
- package/dist/{options-2e71e6b3.js → options-ad127e0c.js} +51 -37
- package/dist/postcss/plugin.d.ts +1 -1
- package/dist/postcss/shared.d.ts +1 -1
- package/dist/{postcss-15e2ef2d.mjs → postcss-9a63df9d.mjs} +11 -4
- package/dist/{postcss-b8952a11.js → postcss-fbdc673b.js} +10 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/reg.d.ts +1 -1
- package/dist/replace.js +1 -1
- package/dist/replace.mjs +2 -2
- package/dist/{shared-fc50603a.mjs → shared-7c88fb94.mjs} +19 -2
- package/dist/{shared-cdb5ee55.js → shared-ae7dd073.js} +19 -2
- package/dist/types.d.ts +8 -3
- package/dist/vite.js +9 -7
- package/dist/vite.mjs +9 -7
- package/dist/weapp-tw-runtime-loader.js +16 -0
- package/dist/weapp-tw-runtime-loader.mjs +10 -0
- package/dist/webpack/BaseUnifiedPlugin/v5.d.ts +0 -1
- package/dist/webpack/loaders/weapp-tw-runtime-loader.d.ts +5 -0
- package/dist/webpack.js +37 -20
- package/dist/webpack.mjs +32 -20
- package/dist/wxml/index.d.ts +1 -1
- package/dist/wxml/utils.d.ts +2 -2
- package/package.json +22 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var selectorParser = require('postcss-selector-parser');
|
|
4
|
-
var shared = require('./shared-
|
|
4
|
+
var shared = require('./shared-ae7dd073.js');
|
|
5
5
|
var postcss = require('postcss');
|
|
6
6
|
require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
|
|
@@ -63,7 +63,15 @@ function testIfVariablesScope(node, count = 1) {
|
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
65
|
function commonChunkPreflight(node, options) {
|
|
66
|
-
|
|
66
|
+
let childCombinatorReplaceValue = 'view + view';
|
|
67
|
+
if (Array.isArray(options.cssChildCombinatorReplaceValue)) {
|
|
68
|
+
const part = options.cssChildCombinatorReplaceValue.join(',');
|
|
69
|
+
childCombinatorReplaceValue = [part, ' + ', part].join('');
|
|
70
|
+
}
|
|
71
|
+
else if (typeof options.cssChildCombinatorReplaceValue === 'string') {
|
|
72
|
+
childCombinatorReplaceValue = options.cssChildCombinatorReplaceValue;
|
|
73
|
+
}
|
|
74
|
+
node.selector = node.selector.replaceAll(BROAD_MATCH_GLOBAL_REGEXP, childCombinatorReplaceValue);
|
|
67
75
|
if (testIfVariablesScope(node)) {
|
|
68
76
|
const selectorParts = node.selector.split(',');
|
|
69
77
|
if (!selectorParts.includes('view')) {
|
|
@@ -88,7 +96,6 @@ function commonChunkPreflight(node, options) {
|
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
const NS = 'jsx-rename-loader';
|
|
92
99
|
const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin';
|
|
93
100
|
const pluginName = 'weapp-tailwindcss-webpack-plugin';
|
|
94
101
|
const vitePluginName = 'vite-plugin-uni-app-weapp-tailwindcss-adaptor';
|
|
@@ -111,7 +118,6 @@ const postcssWeappTailwindcss = (options = {
|
|
|
111
118
|
};
|
|
112
119
|
postcssWeappTailwindcss.postcss = true;
|
|
113
120
|
|
|
114
|
-
exports.NS = NS;
|
|
115
121
|
exports.pluginName = pluginName;
|
|
116
122
|
exports.postcssWeappTailwindcss = postcssWeappTailwindcss;
|
|
117
123
|
exports.vitePluginName = vitePluginName;
|
package/dist/postcss.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var postcss = require('./postcss-
|
|
5
|
+
var postcss = require('./postcss-fbdc673b.js');
|
|
6
6
|
var postcssIsPseudoClass = require('@csstools/postcss-is-pseudo-class');
|
|
7
7
|
require('postcss-selector-parser');
|
|
8
|
-
require('./shared-
|
|
8
|
+
require('./shared-ae7dd073.js');
|
|
9
9
|
require('postcss');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
package/dist/postcss.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { p as postcssWeappTailwindcss } from './postcss-
|
|
1
|
+
export { p as postcssWeappTailwindcss } from './postcss-9a63df9d.mjs';
|
|
2
2
|
export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
|
|
3
3
|
import 'postcss-selector-parser';
|
|
4
|
-
import './shared-
|
|
4
|
+
import './shared-7c88fb94.mjs';
|
|
5
5
|
import 'postcss';
|
package/dist/reg.d.ts
CHANGED
|
@@ -12,13 +12,13 @@ export declare function createTempleteHandlerMatchRegexp(tag: string | RegExp, a
|
|
|
12
12
|
export declare function createTemplateClassRegexp(attrs: ItemOrItemArray<string | RegExp>, options?: ICreateRegexpOptions): RegExp;
|
|
13
13
|
export declare function makeCustomAttributes(entries?: [string | RegExp, ItemOrItemArray<string | RegExp>][]): ICustomRegexp[] | undefined;
|
|
14
14
|
export declare const variableRegExp: RegExp;
|
|
15
|
-
export declare function variableMatch(original: string): RegExpExecArray | null;
|
|
16
15
|
export declare const classRegexp: RegExp;
|
|
17
16
|
export declare const vueTemplateClassRegexp: RegExp;
|
|
18
17
|
export declare const tagRegexp: RegExp;
|
|
19
18
|
export declare const tagWithClassRegexp: RegExp;
|
|
20
19
|
export declare function classStringReplace(str: string, replacement: (substring: string, ...args: any[]) => string): string;
|
|
21
20
|
export declare function tagStringReplace(str: string, replacement: (substring: string, ...args: any[]) => string): string;
|
|
21
|
+
export declare const wxsTagRegexp: RegExp;
|
|
22
22
|
export declare const wxmlAllowClassCharsRegExp: RegExp;
|
|
23
23
|
export declare function createWxmlAllowClassCharsRegExp(): RegExp;
|
|
24
24
|
export declare const doubleQuoteRegexp: RegExp;
|
package/dist/replace.js
CHANGED
package/dist/replace.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as escape, S as SimpleMappingChars2String } from './shared-
|
|
2
|
-
export { M as MappingChars2String, b as MappingChars2StringEntries, a as SYMBOL_TABLE, c as SimpleMappingChars2StringEntries, i as replaceCss } from './shared-
|
|
1
|
+
import { e as escape, S as SimpleMappingChars2String } from './shared-7c88fb94.mjs';
|
|
2
|
+
export { M as MappingChars2String, b as MappingChars2StringEntries, a as SYMBOL_TABLE, c as SimpleMappingChars2StringEntries, i as replaceCss } from './shared-7c88fb94.mjs';
|
|
3
3
|
|
|
4
4
|
function replaceWxml(original, options = {
|
|
5
5
|
keepEOL: false,
|
|
@@ -103,6 +103,9 @@ const SimpleMappingChars2String = {
|
|
|
103
103
|
const SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
|
|
104
104
|
|
|
105
105
|
const MAX_ASCII_CHAR_CODE = 127;
|
|
106
|
+
function isAsciiNumber(code) {
|
|
107
|
+
return code >= 48 && code <= 57;
|
|
108
|
+
}
|
|
106
109
|
function escape(selectors, options = {
|
|
107
110
|
map: SimpleMappingChars2String
|
|
108
111
|
}) {
|
|
@@ -120,8 +123,22 @@ function escape(selectors, options = {
|
|
|
120
123
|
else if (hit) {
|
|
121
124
|
sb[i] = hit;
|
|
122
125
|
}
|
|
123
|
-
else if (i === 0
|
|
124
|
-
|
|
126
|
+
else if (i === 0) {
|
|
127
|
+
if (isAsciiNumber(code)) {
|
|
128
|
+
sb[i] = '_' + char;
|
|
129
|
+
}
|
|
130
|
+
else if (char === '-') {
|
|
131
|
+
const nextChar = sb[i + 1];
|
|
132
|
+
if (nextChar) {
|
|
133
|
+
const nextCharCode = nextChar.codePointAt(0);
|
|
134
|
+
if (nextCharCode && isAsciiNumber(nextCharCode)) {
|
|
135
|
+
sb[i] = '_' + char;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (nextChar === undefined) {
|
|
139
|
+
sb[i] = '_' + char;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
125
142
|
}
|
|
126
143
|
}
|
|
127
144
|
}
|
|
@@ -105,6 +105,9 @@ const SimpleMappingChars2String = {
|
|
|
105
105
|
const SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
|
|
106
106
|
|
|
107
107
|
const MAX_ASCII_CHAR_CODE = 127;
|
|
108
|
+
function isAsciiNumber(code) {
|
|
109
|
+
return code >= 48 && code <= 57;
|
|
110
|
+
}
|
|
108
111
|
function escape(selectors, options = {
|
|
109
112
|
map: SimpleMappingChars2String
|
|
110
113
|
}) {
|
|
@@ -122,8 +125,22 @@ function escape(selectors, options = {
|
|
|
122
125
|
else if (hit) {
|
|
123
126
|
sb[i] = hit;
|
|
124
127
|
}
|
|
125
|
-
else if (i === 0
|
|
126
|
-
|
|
128
|
+
else if (i === 0) {
|
|
129
|
+
if (isAsciiNumber(code)) {
|
|
130
|
+
sb[i] = '_' + char;
|
|
131
|
+
}
|
|
132
|
+
else if (char === '-') {
|
|
133
|
+
const nextChar = sb[i + 1];
|
|
134
|
+
if (nextChar) {
|
|
135
|
+
const nextCharCode = nextChar.codePointAt(0);
|
|
136
|
+
if (nextCharCode && isAsciiNumber(nextCharCode)) {
|
|
137
|
+
sb[i] = '_' + char;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (nextChar === undefined) {
|
|
141
|
+
sb[i] = '_' + char;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
127
144
|
}
|
|
128
145
|
}
|
|
129
146
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type RequiredStyleHandlerOptions = {
|
|
|
16
16
|
isMainChunk: boolean;
|
|
17
17
|
cssInjectPreflight?: InjectPreflight;
|
|
18
18
|
cssPreflightRange?: 'view' | 'all';
|
|
19
|
+
cssChildCombinatorReplaceValue?: string | string[];
|
|
19
20
|
replaceUniversalSelectorWith?: string | false;
|
|
20
21
|
escapeMap?: Record<string, string>;
|
|
21
22
|
};
|
|
@@ -42,8 +43,6 @@ export interface RawSource {
|
|
|
42
43
|
end: number;
|
|
43
44
|
raw: string;
|
|
44
45
|
source?: string;
|
|
45
|
-
prevConcatenated: boolean;
|
|
46
|
-
nextConcatenated: boolean;
|
|
47
46
|
}
|
|
48
47
|
export interface ILengthUnitsPatchDangerousOptions {
|
|
49
48
|
packageName?: string;
|
|
@@ -87,6 +86,9 @@ export interface UserDefinedOptions {
|
|
|
87
86
|
minifiedJs?: boolean;
|
|
88
87
|
mangle?: boolean | IMangleOptions;
|
|
89
88
|
arbitraryValues?: IArbitraryValues;
|
|
89
|
+
cssChildCombinatorReplaceValue?: string | string[];
|
|
90
|
+
wxsMatcher?: ((name: string) => boolean) | string | string[];
|
|
91
|
+
inlineWxs?: boolean;
|
|
90
92
|
}
|
|
91
93
|
export interface IMangleScopeContext {
|
|
92
94
|
rawOptions: UserDefinedOptions['mangle'];
|
|
@@ -111,8 +113,11 @@ export interface ITempleteHandlerOptions extends ICommonReplaceOptions {
|
|
|
111
113
|
customAttributesEntities?: ICustomAttributesEntities;
|
|
112
114
|
escapeMap?: Record<string, string>;
|
|
113
115
|
mangleContext?: IMangleScopeContext;
|
|
116
|
+
inlineWxs?: boolean;
|
|
117
|
+
jsHandler?: (rawSource: string, set: Set<string>) => GeneratorResult;
|
|
118
|
+
runtimeSet?: Set<string>;
|
|
114
119
|
}
|
|
115
|
-
export type GlobOrFunctionMatchers = 'htmlMatcher' | 'cssMatcher' | 'jsMatcher' | 'mainCssChunkMatcher';
|
|
120
|
+
export type GlobOrFunctionMatchers = 'htmlMatcher' | 'cssMatcher' | 'jsMatcher' | 'mainCssChunkMatcher' | 'wxsMatcher';
|
|
116
121
|
export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, GlobOrFunctionMatchers | 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary'> & {
|
|
117
122
|
[K in GlobOrFunctionMatchers]: K extends 'mainCssChunkMatcher' ? (name: string, appType?: AppType) => boolean : (name: string) => boolean;
|
|
118
123
|
} & {
|
package/dist/vite.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var options = require('./options-
|
|
6
|
-
var postcss = require('./postcss-
|
|
5
|
+
var options = require('./options-ad127e0c.js');
|
|
6
|
+
var postcss = require('./postcss-fbdc673b.js');
|
|
7
7
|
require('micromatch');
|
|
8
8
|
require('@babel/types');
|
|
9
9
|
require('@babel/generator');
|
|
10
10
|
require('@babel/parser');
|
|
11
11
|
require('@babel/traverse');
|
|
12
12
|
require('./replace.js');
|
|
13
|
-
require('./shared-
|
|
13
|
+
require('./shared-ae7dd073.js');
|
|
14
14
|
require('postcss');
|
|
15
15
|
require('@csstools/postcss-is-pseudo-class');
|
|
16
16
|
require('node:path');
|
|
@@ -41,13 +41,15 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
|
41
41
|
generateBundle(opt, bundle, isWrite) {
|
|
42
42
|
const entries = Object.entries(bundle);
|
|
43
43
|
const groupedEntries = options.getGroupedEntries(entries, opts);
|
|
44
|
-
const
|
|
45
|
-
setMangleRuntimeSet(
|
|
44
|
+
const runtimeSet = twPatcher.getClassSet();
|
|
45
|
+
setMangleRuntimeSet(runtimeSet);
|
|
46
46
|
if (Array.isArray(groupedEntries.html)) {
|
|
47
47
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
48
48
|
const [file, originalSource] = groupedEntries.html[i];
|
|
49
49
|
const oldVal = originalSource.source.toString();
|
|
50
|
-
originalSource.source = templeteHandler(oldVal
|
|
50
|
+
originalSource.source = templeteHandler(oldVal, {
|
|
51
|
+
runtimeSet
|
|
52
|
+
});
|
|
51
53
|
onUpdate(file, oldVal, originalSource.source);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
@@ -66,7 +68,7 @@ function UnifiedViteWeappTailwindcssPlugin(options$1 = {}) {
|
|
|
66
68
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
67
69
|
const [file, originalSource] = groupedEntries.js[i];
|
|
68
70
|
const rawSource = originalSource.code;
|
|
69
|
-
const { code } = jsHandler(rawSource,
|
|
71
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
70
72
|
originalSource.code = code;
|
|
71
73
|
onUpdate(file, rawSource, code);
|
|
72
74
|
}
|
package/dist/vite.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-
|
|
2
|
-
import { v as vitePluginName } from './postcss-
|
|
1
|
+
import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-1e3a224a.mjs';
|
|
2
|
+
import { v as vitePluginName } from './postcss-9a63df9d.mjs';
|
|
3
3
|
import 'micromatch';
|
|
4
4
|
import '@babel/types';
|
|
5
5
|
import '@babel/generator';
|
|
6
6
|
import '@babel/parser';
|
|
7
7
|
import '@babel/traverse';
|
|
8
8
|
import './replace.mjs';
|
|
9
|
-
import './shared-
|
|
9
|
+
import './shared-7c88fb94.mjs';
|
|
10
10
|
import 'postcss';
|
|
11
11
|
import '@csstools/postcss-is-pseudo-class';
|
|
12
12
|
import 'node:path';
|
|
@@ -37,13 +37,15 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
37
37
|
generateBundle(opt, bundle, isWrite) {
|
|
38
38
|
const entries = Object.entries(bundle);
|
|
39
39
|
const groupedEntries = getGroupedEntries(entries, opts);
|
|
40
|
-
const
|
|
41
|
-
setMangleRuntimeSet(
|
|
40
|
+
const runtimeSet = twPatcher.getClassSet();
|
|
41
|
+
setMangleRuntimeSet(runtimeSet);
|
|
42
42
|
if (Array.isArray(groupedEntries.html)) {
|
|
43
43
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
44
44
|
const [file, originalSource] = groupedEntries.html[i];
|
|
45
45
|
const oldVal = originalSource.source.toString();
|
|
46
|
-
originalSource.source = templeteHandler(oldVal
|
|
46
|
+
originalSource.source = templeteHandler(oldVal, {
|
|
47
|
+
runtimeSet
|
|
48
|
+
});
|
|
47
49
|
onUpdate(file, oldVal, originalSource.source);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -62,7 +64,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
62
64
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
63
65
|
const [file, originalSource] = groupedEntries.js[i];
|
|
64
66
|
const rawSource = originalSource.code;
|
|
65
|
-
const { code } = jsHandler(rawSource,
|
|
67
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
66
68
|
originalSource.code = code;
|
|
67
69
|
onUpdate(file, rawSource, code);
|
|
68
70
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var loaderUtils = require('loader-utils');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
var loaderUtils__default = /*#__PURE__*/_interopDefaultCompat(loaderUtils);
|
|
8
|
+
|
|
9
|
+
const WeappTwRuntimeAopLoader = function (source) {
|
|
10
|
+
var _a;
|
|
11
|
+
const opt = loaderUtils__default["default"].getOptions(this);
|
|
12
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.getClassSet) === null || _a === void 0 ? void 0 : _a.call(opt);
|
|
13
|
+
return source;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = WeappTwRuntimeAopLoader;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import loaderUtils from 'loader-utils';
|
|
2
|
+
|
|
3
|
+
const WeappTwRuntimeAopLoader = function (source) {
|
|
4
|
+
var _a;
|
|
5
|
+
const opt = loaderUtils.getOptions(this);
|
|
6
|
+
(_a = opt === null || opt === void 0 ? void 0 : opt.getClassSet) === null || _a === void 0 ? void 0 : _a.call(opt);
|
|
7
|
+
return source;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { WeappTwRuntimeAopLoader as default };
|
|
@@ -3,7 +3,6 @@ import type { AppType, UserDefinedOptions, InternalUserDefinedOptions, IBaseWebp
|
|
|
3
3
|
export declare class UnifiedWebpackPluginV5 implements IBaseWebpackPlugin {
|
|
4
4
|
options: InternalUserDefinedOptions;
|
|
5
5
|
appType?: AppType;
|
|
6
|
-
static NS: string;
|
|
7
6
|
constructor(options?: UserDefinedOptions);
|
|
8
7
|
apply(compiler: Compiler): void;
|
|
9
8
|
}
|
package/dist/webpack.js
CHANGED
|
@@ -2,24 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var path = require('node:path');
|
|
6
|
+
var fs = require('node:fs');
|
|
7
|
+
var options = require('./options-ad127e0c.js');
|
|
8
|
+
var postcss = require('./postcss-fbdc673b.js');
|
|
7
9
|
require('micromatch');
|
|
8
10
|
require('@babel/types');
|
|
9
11
|
require('@babel/generator');
|
|
10
12
|
require('@babel/parser');
|
|
11
13
|
require('@babel/traverse');
|
|
12
14
|
require('./replace.js');
|
|
13
|
-
require('./shared-
|
|
15
|
+
require('./shared-ae7dd073.js');
|
|
14
16
|
require('postcss');
|
|
15
17
|
require('@csstools/postcss-is-pseudo-class');
|
|
16
|
-
require('node:path');
|
|
17
|
-
require('node:fs');
|
|
18
18
|
require('semver');
|
|
19
19
|
require('tailwindcss-patch');
|
|
20
20
|
require('tailwindcss-mangle-shared');
|
|
21
21
|
require('postcss-selector-parser');
|
|
22
22
|
|
|
23
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
26
|
+
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
27
|
+
|
|
23
28
|
class UnifiedWebpackPluginV5 {
|
|
24
29
|
constructor(options$1 = {}) {
|
|
25
30
|
if (options$1.customReplaceDictionary === undefined) {
|
|
@@ -34,21 +39,32 @@ class UnifiedWebpackPluginV5 {
|
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
36
41
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
37
|
-
const Compilation = compiler.webpack
|
|
38
|
-
const { ConcatSource } =
|
|
42
|
+
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
43
|
+
const { ConcatSource } = sources;
|
|
39
44
|
const twPatcher = options.createTailwindcssPatcher();
|
|
40
45
|
function getClassSet() {
|
|
41
|
-
|
|
42
|
-
if (set.size === 0) {
|
|
43
|
-
const cacheSet = twPatcher.getCache();
|
|
44
|
-
if (cacheSet && cacheSet.size > 0) {
|
|
45
|
-
set = cacheSet;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return set;
|
|
46
|
+
return twPatcher.getClassSet();
|
|
49
47
|
}
|
|
50
48
|
onLoad();
|
|
49
|
+
const loader = path__default["default"].resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
50
|
+
const isExisted = fs__default["default"].existsSync(loader);
|
|
51
|
+
const WeappTwRuntimeAopLoader = {
|
|
52
|
+
loader,
|
|
53
|
+
options: {
|
|
54
|
+
getClassSet
|
|
55
|
+
},
|
|
56
|
+
ident: null,
|
|
57
|
+
type: null
|
|
58
|
+
};
|
|
51
59
|
compiler.hooks.compilation.tap(postcss.pluginName, (compilation) => {
|
|
60
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(postcss.pluginName, (loaderContext, module) => {
|
|
61
|
+
if (isExisted) {
|
|
62
|
+
const idx = module.loaders.findIndex((x) => x.loader.includes('postcss-loader'));
|
|
63
|
+
if (idx > -1) {
|
|
64
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
52
68
|
compilation.hooks.processAssets.tap({
|
|
53
69
|
name: postcss.pluginName,
|
|
54
70
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
@@ -56,13 +72,15 @@ class UnifiedWebpackPluginV5 {
|
|
|
56
72
|
onStart();
|
|
57
73
|
const entries = Object.entries(assets);
|
|
58
74
|
const groupedEntries = options.getGroupedEntries(entries, this.options);
|
|
59
|
-
const
|
|
60
|
-
setMangleRuntimeSet(
|
|
75
|
+
const runtimeSet = getClassSet();
|
|
76
|
+
setMangleRuntimeSet(runtimeSet);
|
|
61
77
|
if (Array.isArray(groupedEntries.html)) {
|
|
62
78
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
63
79
|
const [file, originalSource] = groupedEntries.html[i];
|
|
64
80
|
const rawSource = originalSource.source().toString();
|
|
65
|
-
const wxml = templeteHandler(rawSource
|
|
81
|
+
const wxml = templeteHandler(rawSource, {
|
|
82
|
+
runtimeSet
|
|
83
|
+
});
|
|
66
84
|
const source = new ConcatSource(wxml);
|
|
67
85
|
compilation.updateAsset(file, source);
|
|
68
86
|
onUpdate(file, rawSource, wxml);
|
|
@@ -72,7 +90,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
72
90
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
73
91
|
const [file, originalSource] = groupedEntries.js[i];
|
|
74
92
|
const rawSource = originalSource.source().toString();
|
|
75
|
-
const { code } = jsHandler(rawSource,
|
|
93
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
76
94
|
const source = new ConcatSource(code);
|
|
77
95
|
compilation.updateAsset(file, source);
|
|
78
96
|
onUpdate(file, rawSource, code);
|
|
@@ -95,6 +113,5 @@ class UnifiedWebpackPluginV5 {
|
|
|
95
113
|
});
|
|
96
114
|
}
|
|
97
115
|
}
|
|
98
|
-
UnifiedWebpackPluginV5.NS = postcss.NS;
|
|
99
116
|
|
|
100
117
|
exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { g as getOptions, a as createTailwindcssPatcher, b as getGroupedEntries } from './options-1e3a224a.mjs';
|
|
4
|
+
import { a as pluginName } from './postcss-9a63df9d.mjs';
|
|
3
5
|
import 'micromatch';
|
|
4
6
|
import '@babel/types';
|
|
5
7
|
import '@babel/generator';
|
|
6
8
|
import '@babel/parser';
|
|
7
9
|
import '@babel/traverse';
|
|
8
10
|
import './replace.mjs';
|
|
9
|
-
import './shared-
|
|
11
|
+
import './shared-7c88fb94.mjs';
|
|
10
12
|
import 'postcss';
|
|
11
13
|
import '@csstools/postcss-is-pseudo-class';
|
|
12
|
-
import 'node:path';
|
|
13
|
-
import 'node:fs';
|
|
14
14
|
import 'semver';
|
|
15
15
|
import 'tailwindcss-patch';
|
|
16
16
|
import 'tailwindcss-mangle-shared';
|
|
@@ -30,21 +30,32 @@ class UnifiedWebpackPluginV5 {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
patch === null || patch === void 0 ? void 0 : patch();
|
|
33
|
-
const Compilation = compiler.webpack
|
|
34
|
-
const { ConcatSource } =
|
|
33
|
+
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
34
|
+
const { ConcatSource } = sources;
|
|
35
35
|
const twPatcher = createTailwindcssPatcher();
|
|
36
36
|
function getClassSet() {
|
|
37
|
-
|
|
38
|
-
if (set.size === 0) {
|
|
39
|
-
const cacheSet = twPatcher.getCache();
|
|
40
|
-
if (cacheSet && cacheSet.size > 0) {
|
|
41
|
-
set = cacheSet;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return set;
|
|
37
|
+
return twPatcher.getClassSet();
|
|
45
38
|
}
|
|
46
39
|
onLoad();
|
|
40
|
+
const loader = path.resolve(__dirname, './weapp-tw-runtime-loader.js');
|
|
41
|
+
const isExisted = fs.existsSync(loader);
|
|
42
|
+
const WeappTwRuntimeAopLoader = {
|
|
43
|
+
loader,
|
|
44
|
+
options: {
|
|
45
|
+
getClassSet
|
|
46
|
+
},
|
|
47
|
+
ident: null,
|
|
48
|
+
type: null
|
|
49
|
+
};
|
|
47
50
|
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
51
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (loaderContext, module) => {
|
|
52
|
+
if (isExisted) {
|
|
53
|
+
const idx = module.loaders.findIndex((x) => x.loader.includes('postcss-loader'));
|
|
54
|
+
if (idx > -1) {
|
|
55
|
+
module.loaders.unshift(WeappTwRuntimeAopLoader);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
48
59
|
compilation.hooks.processAssets.tap({
|
|
49
60
|
name: pluginName,
|
|
50
61
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
@@ -52,13 +63,15 @@ class UnifiedWebpackPluginV5 {
|
|
|
52
63
|
onStart();
|
|
53
64
|
const entries = Object.entries(assets);
|
|
54
65
|
const groupedEntries = getGroupedEntries(entries, this.options);
|
|
55
|
-
const
|
|
56
|
-
setMangleRuntimeSet(
|
|
66
|
+
const runtimeSet = getClassSet();
|
|
67
|
+
setMangleRuntimeSet(runtimeSet);
|
|
57
68
|
if (Array.isArray(groupedEntries.html)) {
|
|
58
69
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
59
70
|
const [file, originalSource] = groupedEntries.html[i];
|
|
60
71
|
const rawSource = originalSource.source().toString();
|
|
61
|
-
const wxml = templeteHandler(rawSource
|
|
72
|
+
const wxml = templeteHandler(rawSource, {
|
|
73
|
+
runtimeSet
|
|
74
|
+
});
|
|
62
75
|
const source = new ConcatSource(wxml);
|
|
63
76
|
compilation.updateAsset(file, source);
|
|
64
77
|
onUpdate(file, rawSource, wxml);
|
|
@@ -68,7 +81,7 @@ class UnifiedWebpackPluginV5 {
|
|
|
68
81
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
69
82
|
const [file, originalSource] = groupedEntries.js[i];
|
|
70
83
|
const rawSource = originalSource.source().toString();
|
|
71
|
-
const { code } = jsHandler(rawSource,
|
|
84
|
+
const { code } = jsHandler(rawSource, runtimeSet);
|
|
72
85
|
const source = new ConcatSource(code);
|
|
73
86
|
compilation.updateAsset(file, source);
|
|
74
87
|
onUpdate(file, rawSource, code);
|
|
@@ -91,6 +104,5 @@ class UnifiedWebpackPluginV5 {
|
|
|
91
104
|
});
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
|
-
UnifiedWebpackPluginV5.NS = NS;
|
|
95
107
|
|
|
96
108
|
export { UnifiedWebpackPluginV5 };
|
package/dist/wxml/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { replaceWxml } from './shared';
|
|
2
|
-
export { generateCode, templeteHandler, templeteReplacer } from './utils';
|
|
2
|
+
export { generateCode, templeteHandler, templeteReplacer, customTempleteHandler, createTempleteHandler, extractSource } from './utils';
|
package/dist/wxml/utils.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare function generateCode(match: string, options?: ITempleteHandlerOp
|
|
|
3
3
|
export declare function extractSource(original: string): RawSource[];
|
|
4
4
|
export declare function templeteReplacer(original: string, options?: ITempleteHandlerOptions): string;
|
|
5
5
|
export declare function templeteHandler(rawSource: string, options?: ITempleteHandlerOptions): string;
|
|
6
|
-
export declare function customTempleteHandler(rawSource: string, options
|
|
7
|
-
export declare function createTempleteHandler(options?: ITempleteHandlerOptions): (rawSource: string, opt?: ITempleteHandlerOptions) => string;
|
|
6
|
+
export declare function customTempleteHandler(rawSource: string, options: Required<ITempleteHandlerOptions>): string;
|
|
7
|
+
export declare function createTempleteHandler(options?: Omit<ITempleteHandlerOptions, 'runtimeSet'>): (rawSource: string, opt?: Pick<ITempleteHandlerOptions, 'runtimeSet'>) => string;
|