weapp-tailwindcss 3.7.0 → 3.8.0-alpha.1

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.
Files changed (149) hide show
  1. package/README.md +1 -23
  2. package/dist/chunk-2STNBSVB.js +216 -0
  3. package/dist/chunk-35CYTBPM.js +26 -0
  4. package/dist/chunk-6FNC3XMI.js +45 -0
  5. package/dist/chunk-6Z776ZWK.js +43 -0
  6. package/dist/chunk-75EWCRQW.mjs +13 -0
  7. package/dist/chunk-AB467PG7.mjs +43 -0
  8. package/dist/chunk-AXBFBHS2.mjs +45 -0
  9. package/dist/chunk-EODGLB63.mjs +173 -0
  10. package/dist/chunk-FG63RW47.mjs +7106 -0
  11. package/dist/chunk-HBQASQKY.js +13 -0
  12. package/dist/chunk-IETFIAKJ.js +152 -0
  13. package/dist/chunk-KE7J6XFD.mjs +537 -0
  14. package/dist/chunk-LQN2VTMU.js +537 -0
  15. package/dist/chunk-LWRZXI5T.js +1003 -0
  16. package/dist/chunk-MUJ65IQ3.mjs +26 -0
  17. package/dist/chunk-MWTUP5KG.mjs +1003 -0
  18. package/dist/chunk-NLFQ7XRK.mjs +152 -0
  19. package/dist/chunk-QEEWOML6.mjs +216 -0
  20. package/dist/chunk-RFNUATFD.js +24 -0
  21. package/dist/chunk-U7O2XXYR.mjs +24 -0
  22. package/dist/chunk-VKSQ6BRD.mjs +27 -0
  23. package/dist/chunk-XSZXPWWL.js +27 -0
  24. package/dist/chunk-YSEHQ3FF.js +173 -0
  25. package/dist/chunk-YYT4NLHK.js +7109 -0
  26. package/dist/cli.d.mts +2 -0
  27. package/dist/cli.d.ts +2 -1
  28. package/dist/cli.js +23 -3400
  29. package/dist/cli.mjs +28 -3392
  30. package/dist/core.d.mts +27 -0
  31. package/dist/core.d.ts +23 -4
  32. package/dist/core.js +34 -56
  33. package/dist/core.mjs +36 -54
  34. package/dist/css-macro/postcss.d.mts +7 -0
  35. package/dist/css-macro/postcss.d.ts +5 -3
  36. package/dist/css-macro/postcss.js +54 -45
  37. package/dist/css-macro/postcss.mjs +54 -45
  38. package/dist/css-macro.d.mts +18 -0
  39. package/dist/css-macro.d.ts +18 -0
  40. package/dist/css-macro.js +40 -0
  41. package/dist/css-macro.mjs +38 -0
  42. package/dist/defaults.d.mts +16 -0
  43. package/dist/defaults.d.ts +16 -2
  44. package/dist/defaults.js +5 -9
  45. package/dist/defaults.mjs +8 -4
  46. package/dist/escape.d.mts +19 -0
  47. package/dist/escape.d.ts +19 -4
  48. package/dist/escape.js +11 -0
  49. package/dist/escape.mjs +11 -0
  50. package/dist/gulp.d.mts +26 -0
  51. package/dist/gulp.d.ts +26 -1
  52. package/dist/gulp.js +11 -36
  53. package/dist/gulp.mjs +14 -31
  54. package/dist/index-g4epDIUu.d.mts +534 -0
  55. package/dist/index-g4epDIUu.d.ts +534 -0
  56. package/dist/index.d.mts +17 -0
  57. package/dist/index.d.ts +17 -4
  58. package/dist/index.js +22 -44
  59. package/dist/index.mjs +22 -34
  60. package/dist/postcss.d.mts +28 -0
  61. package/dist/postcss.d.ts +28 -1
  62. package/dist/postcss.js +9 -24
  63. package/dist/postcss.mjs +16 -8
  64. package/dist/replace.d.mts +22 -0
  65. package/dist/replace.d.ts +22 -3
  66. package/dist/replace.js +33 -50
  67. package/dist/replace.mjs +32 -25
  68. package/dist/shared-5ArEo9kL.d.mts +5 -0
  69. package/dist/shared-DI2Qz1ou.d.ts +5 -0
  70. package/dist/vite.d.mts +22 -0
  71. package/dist/vite.d.ts +22 -1
  72. package/dist/vite.js +11 -34
  73. package/dist/vite.mjs +14 -29
  74. package/dist/weapp-tw-runtime-loader.d.mts +7 -0
  75. package/dist/{bundlers/webpack/loaders/weapp-tw-runtime-loader.d.ts → weapp-tw-runtime-loader.d.ts} +4 -2
  76. package/dist/weapp-tw-runtime-loader.js +12 -12
  77. package/dist/weapp-tw-runtime-loader.mjs +12 -8
  78. package/dist/webpack.d.mts +26 -0
  79. package/dist/webpack.d.ts +26 -1
  80. package/dist/webpack.js +11 -35
  81. package/dist/webpack.mjs +14 -30
  82. package/dist/webpack4.d.mts +27 -0
  83. package/dist/webpack4.d.ts +27 -1
  84. package/dist/webpack4.js +204 -192
  85. package/dist/webpack4.mjs +210 -189
  86. package/package.json +29 -19
  87. package/dist/babel/index.d.ts +0 -5
  88. package/dist/bundlers/gulp/index.d.ts +0 -7
  89. package/dist/bundlers/vite/index.d.ts +0 -3
  90. package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -8
  91. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +0 -8
  92. package/dist/bundlers/webpack/index.d.ts +0 -1
  93. package/dist/cache/index.d.ts +0 -31
  94. package/dist/constants-CFM1J-h1.js +0 -42
  95. package/dist/constants-Dy2Dd3Fz.mjs +0 -36
  96. package/dist/constants.d.ts +0 -7
  97. package/dist/css-macro/constants.d.ts +0 -14
  98. package/dist/css-macro/index.d.ts +0 -15
  99. package/dist/css-macro/index.js +0 -36
  100. package/dist/css-macro/index.mjs +0 -30
  101. package/dist/debug/index.d.ts +0 -2
  102. package/dist/defaults-5A8JI2hW.mjs +0 -139
  103. package/dist/defaults-CdqzSWsR.js +0 -145
  104. package/dist/defu-Cdz2PomB.js +0 -60
  105. package/dist/defu-n46TJT6t.mjs +0 -57
  106. package/dist/env.d.ts +0 -2
  107. package/dist/extractors/split.d.ts +0 -3
  108. package/dist/index-BEIjgKpF.mjs +0 -11
  109. package/dist/index-BF8k8rHr.mjs +0 -517
  110. package/dist/index-BTXkyxen.js +0 -136
  111. package/dist/index-C0QsyqD6.mjs +0 -134
  112. package/dist/index-ClSBbhnm.js +0 -130
  113. package/dist/index-DoMb0-xW.mjs +0 -124
  114. package/dist/index-HC-Qkn0i.js +0 -17
  115. package/dist/index-h2-ZMO3S.js +0 -530
  116. package/dist/init.d.ts +0 -34
  117. package/dist/js/ast-grep.d.ts +0 -1
  118. package/dist/js/babel.d.ts +0 -3
  119. package/dist/js/handlers.d.ts +0 -11
  120. package/dist/js/index.d.ts +0 -7
  121. package/dist/logger.d.ts +0 -1
  122. package/dist/mangle/index.d.ts +0 -8
  123. package/dist/npm.d.ts +0 -22
  124. package/dist/options-Bv-1GQJY.js +0 -891
  125. package/dist/options-yXyCFCtr.mjs +0 -858
  126. package/dist/options.d.ts +0 -2
  127. package/dist/postcss/cssVars.d.ts +0 -5
  128. package/dist/postcss/index.d.ts +0 -4
  129. package/dist/postcss/mp.d.ts +0 -8
  130. package/dist/postcss/plugins/ctx.d.ts +0 -6
  131. package/dist/postcss/plugins/index.d.ts +0 -7
  132. package/dist/postcss/plugins/post.d.ts +0 -5
  133. package/dist/postcss/plugins/pre.d.ts +0 -5
  134. package/dist/postcss/preflight.d.ts +0 -3
  135. package/dist/postcss/selectorParser.d.ts +0 -6
  136. package/dist/postcss/shared.d.ts +0 -3
  137. package/dist/postcss/symbols.d.ts +0 -1
  138. package/dist/reg.d.ts +0 -1
  139. package/dist/shared-COWjpokr.mjs +0 -25
  140. package/dist/shared-r_GpWheO.js +0 -28
  141. package/dist/tailwindcss/patcher.d.ts +0 -3
  142. package/dist/types.d.ts +0 -165
  143. package/dist/utils.d.ts +0 -18
  144. package/dist/v5-DwFXG7m_.js +0 -181
  145. package/dist/v5-N5BYJ5JY.mjs +0 -174
  146. package/dist/wxml/Tokenizer.d.ts +0 -31
  147. package/dist/wxml/index.d.ts +0 -2
  148. package/dist/wxml/shared.d.ts +0 -2
  149. package/dist/wxml/utils.d.ts +0 -10
package/dist/options.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { InternalUserDefinedOptions, UserDefinedOptions } from './types';
2
- export declare function getOptions(opts?: UserDefinedOptions): InternalUserDefinedOptions;
@@ -1,5 +0,0 @@
1
- declare const _default: {
2
- prop: string;
3
- value: string;
4
- }[];
5
- export default _default;
@@ -1,4 +0,0 @@
1
- import type { IStyleHandlerOptions } from '../types';
2
- import postcss from 'postcss';
3
- export declare function styleHandler(rawSource: string, options: IStyleHandlerOptions): Promise<postcss.Result<postcss.Document | postcss.Root>>;
4
- export declare function createStyleHandler(options: Partial<IStyleHandlerOptions>): (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => Promise<postcss.Result<postcss.Document | postcss.Root>>;
@@ -1,8 +0,0 @@
1
- import type { IStyleHandlerOptions } from '../types';
2
- import { Rule } from 'postcss';
3
- export declare function testIfVariablesScope(node: Rule, count?: number): boolean;
4
- export declare function testIfTwBackdrop(node: Rule, count?: number): boolean;
5
- export declare function makePseudoVarRule(): Rule;
6
- export declare function remakeCssVarSelector(selectors: string[], options: IStyleHandlerOptions): string[];
7
- export declare function remakeCombinatorSelector(selector: string, cssChildCombinatorReplaceValue: IStyleHandlerOptions['cssChildCombinatorReplaceValue']): string;
8
- export declare function commonChunkPreflight(node: Rule, options: IStyleHandlerOptions): void;
@@ -1,6 +0,0 @@
1
- export declare function createContext(): {
2
- variablesScopeWeakMap: WeakMap<object, any>;
3
- isVariablesScope: (rule: WeakKey) => boolean;
4
- markVariablesScope: (rule: WeakKey) => void;
5
- };
6
- export type IContext = ReturnType<typeof createContext>;
@@ -1,7 +0,0 @@
1
- import type { AcceptedPlugin } from 'postcss';
2
- import type { IStyleHandlerOptions } from '../../types';
3
- export declare function getPlugins(options: IStyleHandlerOptions): AcceptedPlugin[];
4
- export { postcssWeappTailwindcssPostPlugin } from './post';
5
- export { postcssWeappTailwindcssPrePlugin } from './pre';
6
- export { default as postcssIsPseudoClass } from '@csstools/postcss-is-pseudo-class';
7
- export { default as postcssRem2rpx } from 'postcss-rem-to-responsive-pixel';
@@ -1,5 +0,0 @@
1
- import type { PluginCreator } from 'postcss';
2
- import type { IStyleHandlerOptions } from '../../types';
3
- export type PostcssWeappTailwindcssRenamePlugin = PluginCreator<IStyleHandlerOptions>;
4
- declare const postcssWeappTailwindcssPostPlugin: PostcssWeappTailwindcssRenamePlugin;
5
- export { postcssWeappTailwindcssPostPlugin };
@@ -1,5 +0,0 @@
1
- import type { PluginCreator } from 'postcss';
2
- import type { IStyleHandlerOptions } from '../../types';
3
- export type PostcssWeappTailwindcssRenamePlugin = PluginCreator<IStyleHandlerOptions>;
4
- declare const postcssWeappTailwindcssPrePlugin: PostcssWeappTailwindcssRenamePlugin;
5
- export { postcssWeappTailwindcssPrePlugin };
@@ -1,3 +0,0 @@
1
- import type { CssPreflightOptions, IPropValue } from '../types';
2
- export type InjectPreflight = () => IPropValue[];
3
- export declare function createInjectPreflight(options?: CssPreflightOptions): InjectPreflight;
@@ -1,6 +0,0 @@
1
- import type { Rule } from 'postcss';
2
- import type { IStyleHandlerOptions } from '../types';
3
- import selectorParser from 'postcss-selector-parser';
4
- export declare function ruleTransformSync(rule: Rule, options: IStyleHandlerOptions): void;
5
- export declare function isOnlyBeforeAndAfterPseudoElement(node: Rule): boolean;
6
- export declare const fallbackRemove: selectorParser.Processor<void, selectorParser.Selectors>;
@@ -1,3 +0,0 @@
1
- import type { InternalCssSelectorReplacerOptions } from '../types';
2
- export declare function internalCssSelectorReplacer(selectors: string, options?: InternalCssSelectorReplacerOptions): string;
3
- export declare function composeIsPseudo(strs: string | string[]): string;
@@ -1 +0,0 @@
1
- export declare const VariablesScopeSymbol: unique symbol;
package/dist/reg.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '@weapp-core/regex';
@@ -1,25 +0,0 @@
1
- import '@ast-core/escape';
2
- import { escape, SimpleMappingChars2String } from '@weapp-core/escape';
3
-
4
- function internalCssSelectorReplacer(selectors, options = {
5
- escapeMap: SimpleMappingChars2String,
6
- }) {
7
- const { mangleContext, escapeMap } = options;
8
- if (mangleContext) {
9
- selectors = mangleContext.cssHandler(selectors);
10
- }
11
- return escape(selectors, {
12
- map: escapeMap,
13
- });
14
- }
15
- function composeIsPseudo(strs) {
16
- if (typeof strs === 'string') {
17
- return strs;
18
- }
19
- if (strs.length > 1) {
20
- return `:is(${strs.join(',')})`;
21
- }
22
- return strs.join('');
23
- }
24
-
25
- export { composeIsPseudo as c, internalCssSelectorReplacer as i };
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- require('@ast-core/escape');
4
- var escape = require('@weapp-core/escape');
5
-
6
- function internalCssSelectorReplacer(selectors, options = {
7
- escapeMap: escape.SimpleMappingChars2String,
8
- }) {
9
- const { mangleContext, escapeMap } = options;
10
- if (mangleContext) {
11
- selectors = mangleContext.cssHandler(selectors);
12
- }
13
- return escape.escape(selectors, {
14
- map: escapeMap,
15
- });
16
- }
17
- function composeIsPseudo(strs) {
18
- if (typeof strs === 'string') {
19
- return strs;
20
- }
21
- if (strs.length > 1) {
22
- return `:is(${strs.join(',')})`;
23
- }
24
- return strs.join('');
25
- }
26
-
27
- exports.composeIsPseudo = composeIsPseudo;
28
- exports.internalCssSelectorReplacer = internalCssSelectorReplacer;
@@ -1,3 +0,0 @@
1
- import type { ILengthUnitsPatchOptions } from 'tailwindcss-patch';
2
- import { TailwindcssPatcher } from 'tailwindcss-patch';
3
- export declare function createTailwindcssPatcher(basedir?: string, cacheDir?: string, supportCustomLengthUnitsPatch?: boolean | ILengthUnitsPatchOptions): TailwindcssPatcher;
package/dist/types.d.ts DELETED
@@ -1,165 +0,0 @@
1
- import type { GeneratorResult } from '@babel/generator';
2
- import type { ParseError, ParserOptions } from '@babel/parser';
3
- import type { ClassGenerator, IClassGeneratorOptions } from '@tailwindcss-mangle/shared';
4
- import type { SourceMap } from 'magic-string';
5
- import type { Document, Result as PostcssResult, Root, Rule } from 'postcss';
6
- import type { Result } from 'postcss-load-config';
7
- import type { UserDefinedOptions as rem2rpxOptions } from 'postcss-rem-to-responsive-pixel';
8
- import type { ILengthUnitsPatchOptions, TailwindcssPatcher } from 'tailwindcss-patch';
9
- import type { ICreateCacheReturnType } from './cache';
10
- import type { IContext as PostcssContext } from './postcss/plugins/ctx';
11
- import type { InjectPreflight } from './postcss/preflight';
12
- type PostcssOptions = Partial<Omit<Result, 'file'>>;
13
- export type ItemOrItemArray<T> = T | T[];
14
- export type AppType = 'uni-app' | 'uni-app-vite' | 'taro' | 'remax' | 'rax' | 'native' | 'kbone' | 'mpx' | 'weapp-vite';
15
- export interface IPropValue {
16
- prop: string;
17
- value: string;
18
- }
19
- export type CssPresetProps = string;
20
- export type CssPreflightOptions = {
21
- [key: CssPresetProps]: string | number | boolean;
22
- } | false;
23
- export type RequiredStyleHandlerOptions = {
24
- isMainChunk?: boolean;
25
- cssInjectPreflight?: InjectPreflight;
26
- escapeMap?: Record<string, string>;
27
- } & Pick<UserDefinedOptions, 'cssPreflightRange' | 'cssChildCombinatorReplaceValue' | 'injectAdditionalCssVarScope' | 'cssSelectorReplacement' | 'rem2rpx'>;
28
- export type CustomRuleCallback = (node: Rule, options: Readonly<RequiredStyleHandlerOptions>) => void;
29
- export interface InternalCssSelectorReplacerOptions {
30
- mangleContext?: IMangleScopeContext;
31
- escapeMap?: Record<string, string>;
32
- }
33
- export type IStyleHandlerOptions = {
34
- customRuleCallback?: CustomRuleCallback;
35
- mangleContext?: IMangleScopeContext;
36
- ctx?: PostcssContext;
37
- postcssOptions?: PostcssOptions;
38
- cssRemoveHoverPseudoClass?: boolean;
39
- } & RequiredStyleHandlerOptions;
40
- export interface JsHandlerReplaceResult {
41
- code: string;
42
- map?: SourceMap;
43
- }
44
- export type JsHandlerResult = (JsHandlerReplaceResult | GeneratorResult) & {
45
- error?: ParseError;
46
- };
47
- export type ICustomAttributes = Record<string, ItemOrItemArray<string | RegExp>> | Map<string | RegExp, ItemOrItemArray<string | RegExp>>;
48
- export type ICustomAttributesEntities = [string | RegExp, ItemOrItemArray<string | RegExp>][];
49
- export interface IJsHandlerOptions {
50
- escapeMap?: Record<string, string>;
51
- classNameSet?: Set<string>;
52
- arbitraryValues?: IArbitraryValues;
53
- mangleContext?: IMangleScopeContext;
54
- jsPreserveClass?: (keyword: string) => boolean | undefined;
55
- needEscaped?: boolean;
56
- generateMap?: boolean;
57
- always?: boolean;
58
- jsAstTool?: 'babel' | 'ast-grep';
59
- unescapeUnicode?: boolean;
60
- babelParserOptions?: ParserOptions;
61
- }
62
- export interface RawSource {
63
- start: number;
64
- end: number;
65
- raw: string;
66
- source?: string;
67
- }
68
- export interface IMangleOptions {
69
- classGenerator?: IClassGeneratorOptions;
70
- mangleClassFilter?: (className: string) => boolean;
71
- }
72
- export interface IArbitraryValues {
73
- allowDoubleQuotes?: boolean;
74
- }
75
- export interface UserDefinedOptions {
76
- htmlMatcher?: (name: string) => boolean;
77
- cssMatcher?: (name: string) => boolean;
78
- jsMatcher?: (name: string) => boolean;
79
- mainCssChunkMatcher?: (name: string, appType?: AppType) => boolean;
80
- cssPreflight?: CssPreflightOptions;
81
- cssPreflightRange?: 'all';
82
- disabled?: boolean;
83
- customRuleCallback?: CustomRuleCallback;
84
- onLoad?: () => void;
85
- onStart?: () => void;
86
- onUpdate?: (filename: string, oldVal: string, newVal: string) => void;
87
- onEnd?: () => void;
88
- customAttributes?: ICustomAttributes;
89
- customReplaceDictionary?: Record<string, string>;
90
- supportCustomLengthUnitsPatch?: ILengthUnitsPatchOptions | boolean;
91
- appType?: AppType;
92
- mangle?: boolean | IMangleOptions;
93
- arbitraryValues?: IArbitraryValues;
94
- cssChildCombinatorReplaceValue?: string | string[];
95
- wxsMatcher?: (name: string) => boolean;
96
- inlineWxs?: boolean;
97
- injectAdditionalCssVarScope?: boolean;
98
- jsPreserveClass?: (keyword: string) => boolean | undefined;
99
- disabledDefaultTemplateHandler?: boolean;
100
- runtimeLoaderPath?: string;
101
- cssSelectorReplacement?: {
102
- root?: string | string[] | false;
103
- universal?: string | string[] | false;
104
- };
105
- tailwindcssBasedir?: string;
106
- rem2rpx?: boolean | rem2rpxOptions;
107
- cache?: boolean | ICreateCacheReturnType;
108
- jsAstTool?: 'babel' | 'ast-grep';
109
- babelParserOptions?: ParserOptions;
110
- postcssOptions?: PostcssOptions;
111
- cssRemoveHoverPseudoClass?: boolean;
112
- }
113
- export interface JsHandler {
114
- (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions): JsHandlerResult | Promise<JsHandlerResult>;
115
- sync: (rawSource: string, set: Set<string>, options?: CreateJsHandlerOptions) => JsHandlerResult;
116
- }
117
- export interface IMangleScopeContext {
118
- rawOptions: UserDefinedOptions['mangle'];
119
- runtimeSet: Set<string>;
120
- classGenerator: ClassGenerator;
121
- filter: (className: string) => boolean;
122
- cssHandler: (rawSource: string) => string;
123
- jsHandler: (rawSource: string) => string;
124
- wxmlHandler: (rawSource: string) => string;
125
- }
126
- export interface ICommonReplaceOptions {
127
- keepEOL?: boolean;
128
- escapeMap?: Record<string, string>;
129
- }
130
- export interface ITemplateHandlerOptions extends ICommonReplaceOptions {
131
- customAttributesEntities?: ICustomAttributesEntities;
132
- escapeMap?: Record<string, string>;
133
- mangleContext?: IMangleScopeContext;
134
- inlineWxs?: boolean;
135
- jsHandler?: JsHandler;
136
- runtimeSet?: Set<string>;
137
- disabledDefaultTemplateHandler?: boolean;
138
- quote?: string | null;
139
- ignoreHead?: boolean;
140
- }
141
- export type InternalUserDefinedOptions = Required<Omit<UserDefinedOptions, 'supportCustomLengthUnitsPatch' | 'customReplaceDictionary' | 'cache'> & {
142
- supportCustomLengthUnitsPatch: ILengthUnitsPatchOptions | boolean;
143
- templateHandler: (rawSource: string, options?: ITemplateHandlerOptions) => Promise<string>;
144
- styleHandler: (rawSource: string, options?: IStyleHandlerOptions) => Promise<PostcssResult<Root | Document>>;
145
- jsHandler: JsHandler;
146
- escapeMap: Record<string, string>;
147
- patch: () => void;
148
- customReplaceDictionary: Record<string, string>;
149
- setMangleRuntimeSet: (runtimeSet: Set<string>) => void;
150
- cache: ICreateCacheReturnType;
151
- twPatcher: TailwindcssPatcher;
152
- }>;
153
- export type InternalPostcssOptions = Pick<UserDefinedOptions, 'cssMatcher' | 'mainCssChunkMatcher' | 'cssPreflight' | 'cssPreflightRange' | 'customRuleCallback' | 'disabled'>;
154
- export interface IBaseWebpackPlugin {
155
- options: InternalUserDefinedOptions;
156
- appType?: AppType;
157
- apply: (compiler: any) => void;
158
- }
159
- export interface InternalPatchResult {
160
- dataTypes?: string;
161
- processTailwindFeatures?: string;
162
- plugin?: string;
163
- }
164
- export type CreateJsHandlerOptions = Omit<IJsHandlerOptions, 'classNameSet'>;
165
- export {};
package/dist/utils.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { InternalUserDefinedOptions } from './types';
2
- export declare function isRegexp(value: unknown): boolean;
3
- export declare function isMap(value: unknown): boolean;
4
- export declare function regExpTest(arr: (string | RegExp)[] | undefined, str: string): boolean;
5
- export declare function noop(): void;
6
- export declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
7
- export declare function getGroupedEntries<T>(entries: [string, T][], options: InternalUserDefinedOptions): Record<"css" | "html" | "js" | "other", [string, T][]>;
8
- export declare function removeExt(file: string): string;
9
- export { default as defu } from 'defu';
10
- export declare const defuOverrideArray: <Source extends {
11
- [x: string]: any;
12
- [x: number]: any;
13
- [x: symbol]: any;
14
- }, Defaults extends Array<{
15
- [x: string]: any;
16
- [x: number]: any;
17
- [x: symbol]: any;
18
- } | (number | boolean | any[] | Record<never, any> | null | undefined)>>(source: Source, ...defaults: Defaults) => import("defu").Defu<Source, Defaults>;
@@ -1,181 +0,0 @@
1
- 'use strict';
2
-
3
- var options = require('./options-Bv-1GQJY.js');
4
- var fs = require('node:fs');
5
- var path = require('node:path');
6
- var index = require('./index-h2-ZMO3S.js');
7
- var index$1 = require('./index-HC-Qkn0i.js');
8
- var defaults = require('./defaults-CdqzSWsR.js');
9
-
10
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
-
12
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
13
- var path__default = /*#__PURE__*/_interopDefaultCompat(path);
14
-
15
- const debug = index$1.createDebug();
16
- class UnifiedWebpackPluginV5 {
17
- constructor(options$1 = {}) {
18
- this.options = options.getOptions(options$1);
19
- this.appType = this.options.appType;
20
- }
21
- apply(compiler) {
22
- const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, twPatcher, } = this.options;
23
- if (disabled) {
24
- return;
25
- }
26
- patch === null || patch === void 0 ? void 0 : patch();
27
- const { Compilation, sources, NormalModule } = compiler.webpack;
28
- const { ConcatSource, RawSource } = sources;
29
- function getClassSet() {
30
- return twPatcher.getClassSet();
31
- }
32
- onLoad();
33
- const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path__default["default"].resolve(__dirname, './weapp-tw-runtime-loader.js');
34
- const isExisted = fs__default["default"].existsSync(loader);
35
- const WeappTwRuntimeAopLoader = {
36
- loader,
37
- options: {
38
- getClassSet,
39
- },
40
- ident: null,
41
- type: null,
42
- };
43
- compiler.hooks.compilation.tap(index.pluginName, (compilation) => {
44
- NormalModule.getCompilationHooks(compilation).loader.tap(index.pluginName, (_loaderContext, module) => {
45
- if (isExisted) {
46
- const idx = module.loaders.findIndex(x => x.loader.includes('postcss-loader'));
47
- if (idx > -1) {
48
- module.loaders.unshift(WeappTwRuntimeAopLoader);
49
- }
50
- }
51
- });
52
- compilation.hooks.processAssets.tapPromise({
53
- name: index.pluginName,
54
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
55
- }, (assets) => options.__awaiter(this, void 0, void 0, function* () {
56
- onStart();
57
- debug('start');
58
- for (const chunk of compilation.chunks) {
59
- if (chunk.id && chunk.hash) {
60
- cache.calcHashValueChanged(chunk.id, chunk.hash);
61
- }
62
- }
63
- const entries = Object.entries(assets);
64
- const groupedEntries = defaults.getGroupedEntries(entries, this.options);
65
- const runtimeSet = getClassSet();
66
- setMangleRuntimeSet(runtimeSet);
67
- debug('get runtimeSet, class count: %d', runtimeSet.size);
68
- if (Array.isArray(groupedEntries.html)) {
69
- let noCachedCount = 0;
70
- for (let i = 0; i < groupedEntries.html.length; i++) {
71
- const [file, originalSource] = groupedEntries.html[i];
72
- const rawSource = originalSource.source().toString();
73
- const hash = cache.computeHash(rawSource);
74
- const cacheKey = file;
75
- cache.calcHashValueChanged(cacheKey, hash);
76
- yield cache.process(cacheKey, () => {
77
- const source = cache.get(cacheKey);
78
- if (source) {
79
- compilation.updateAsset(file, source);
80
- debug('html cache hit: %s', file);
81
- }
82
- else {
83
- return false;
84
- }
85
- }, () => options.__awaiter(this, void 0, void 0, function* () {
86
- const wxml = yield templateHandler(rawSource, {
87
- runtimeSet,
88
- });
89
- const source = new ConcatSource(wxml);
90
- compilation.updateAsset(file, source);
91
- onUpdate(file, rawSource, wxml);
92
- debug('html handle: %s', file);
93
- noCachedCount++;
94
- return {
95
- key: cacheKey,
96
- source,
97
- };
98
- }));
99
- }
100
- debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
101
- }
102
- if (Array.isArray(groupedEntries.js)) {
103
- let noCachedCount = 0;
104
- for (let i = 0; i < groupedEntries.js.length; i++) {
105
- const [file, originalSource] = groupedEntries.js[i];
106
- const cacheKey = defaults.removeExt(file);
107
- yield cache.process(cacheKey, () => {
108
- const source = cache.get(cacheKey);
109
- if (source) {
110
- compilation.updateAsset(file, source);
111
- debug('js cache hit: %s', file);
112
- }
113
- else {
114
- return false;
115
- }
116
- }, () => options.__awaiter(this, void 0, void 0, function* () {
117
- const rawSource = originalSource.source().toString();
118
- const mapFilename = `${file}.map`;
119
- const hasMap = Boolean(assets[mapFilename]);
120
- const { code, map } = yield jsHandler(rawSource, runtimeSet, {
121
- generateMap: hasMap,
122
- });
123
- const source = new ConcatSource(code);
124
- compilation.updateAsset(file, source);
125
- onUpdate(file, rawSource, code);
126
- debug('js handle: %s', file);
127
- noCachedCount++;
128
- if (hasMap && map) {
129
- const source = new RawSource(map.toString());
130
- compilation.updateAsset(mapFilename, source);
131
- }
132
- return {
133
- key: cacheKey,
134
- source,
135
- };
136
- }));
137
- }
138
- debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
139
- }
140
- if (Array.isArray(groupedEntries.css)) {
141
- let noCachedCount = 0;
142
- for (let i = 0; i < groupedEntries.css.length; i++) {
143
- const [file, originalSource] = groupedEntries.css[i];
144
- const rawSource = originalSource.source().toString();
145
- const hash = cache.computeHash(rawSource);
146
- const cacheKey = file;
147
- cache.calcHashValueChanged(cacheKey, hash);
148
- yield cache.process(cacheKey, () => {
149
- const source = cache.get(cacheKey);
150
- if (source) {
151
- compilation.updateAsset(file, source);
152
- debug('css cache hit: %s', file);
153
- }
154
- else {
155
- return false;
156
- }
157
- }, () => options.__awaiter(this, void 0, void 0, function* () {
158
- const { css } = yield styleHandler(rawSource, {
159
- isMainChunk: mainCssChunkMatcher(file, this.appType),
160
- });
161
- const source = new ConcatSource(css);
162
- compilation.updateAsset(file, source);
163
- onUpdate(file, rawSource, css);
164
- debug('css handle: %s', file);
165
- noCachedCount++;
166
- return {
167
- key: cacheKey,
168
- source,
169
- };
170
- }));
171
- }
172
- debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
173
- }
174
- debug('end');
175
- onEnd();
176
- }));
177
- });
178
- }
179
- }
180
-
181
- exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;