weapp-tailwindcss 3.7.0 → 3.8.0-alpha.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.
Files changed (149) hide show
  1. package/README.md +1 -23
  2. package/dist/chunk-35CYTBPM.js +26 -0
  3. package/dist/chunk-6FNC3XMI.js +45 -0
  4. package/dist/chunk-6Z776ZWK.js +43 -0
  5. package/dist/chunk-75EWCRQW.mjs +13 -0
  6. package/dist/chunk-7J6ZENMS.js +216 -0
  7. package/dist/chunk-A2EDVNQK.mjs +173 -0
  8. package/dist/chunk-AB467PG7.mjs +43 -0
  9. package/dist/chunk-AXBFBHS2.mjs +45 -0
  10. package/dist/chunk-C7DFN4K3.js +152 -0
  11. package/dist/chunk-FYOOMUKL.js +115 -0
  12. package/dist/chunk-HBQASQKY.js +13 -0
  13. package/dist/chunk-JVPRWRPJ.mjs +115 -0
  14. package/dist/chunk-K7CL4YBQ.mjs +216 -0
  15. package/dist/chunk-KE7J6XFD.mjs +537 -0
  16. package/dist/chunk-LQN2VTMU.js +537 -0
  17. package/dist/chunk-MUJ65IQ3.mjs +26 -0
  18. package/dist/chunk-QJPVKPQS.js +1003 -0
  19. package/dist/chunk-RFNUATFD.js +24 -0
  20. package/dist/chunk-T4A3DCFN.mjs +152 -0
  21. package/dist/chunk-U7O2XXYR.mjs +24 -0
  22. package/dist/chunk-VFCTLSC3.mjs +1003 -0
  23. package/dist/chunk-VKSQ6BRD.mjs +27 -0
  24. package/dist/chunk-WMQLIT4T.js +173 -0
  25. package/dist/chunk-XSZXPWWL.js +27 -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 +26 -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/webpack.d.ts CHANGED
@@ -1 +1,26 @@
1
- export * from './bundlers/webpack/index';
1
+ import { Compiler } from 'webpack';
2
+ import { o as IBaseWebpackPlugin, m as InternalUserDefinedOptions, A as AppType, U as UserDefinedOptions } from './index-g4epDIUu.js';
3
+ import '@babel/generator';
4
+ import '@babel/parser';
5
+ import 'magic-string';
6
+ import 'postcss';
7
+ import 'tailwindcss-patch';
8
+ import 'node:buffer';
9
+ import 'lru-cache';
10
+ import '@tailwindcss-mangle/shared';
11
+ import 'postcss-load-config';
12
+ import 'postcss-rem-to-responsive-pixel';
13
+
14
+ /**
15
+ * @name UnifiedWebpackPluginV5
16
+ * @description webpack5 核心转义插件
17
+ * @link https://tw.icebreaker.top/docs/intro
18
+ */
19
+ declare class UnifiedWebpackPluginV5 implements IBaseWebpackPlugin {
20
+ options: InternalUserDefinedOptions;
21
+ appType?: AppType;
22
+ constructor(options?: UserDefinedOptions);
23
+ apply(compiler: Compiler): void;
24
+ }
25
+
26
+ export { UnifiedWebpackPluginV5 };
package/dist/webpack.js CHANGED
@@ -1,38 +1,14 @@
1
- 'use strict';
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var _chunk7J6ZENMSjs = require('./chunk-7J6ZENMS.js');
4
+ require('./chunk-HBQASQKY.js');
5
+ require('./chunk-QJPVKPQS.js');
6
+ require('./chunk-FYOOMUKL.js');
7
+ require('./chunk-35CYTBPM.js');
8
+ require('./chunk-LQN2VTMU.js');
9
+ require('./chunk-RFNUATFD.js');
10
+ require('./chunk-XSZXPWWL.js');
11
+ require('./chunk-6FNC3XMI.js');
4
12
 
5
- var v5 = require('./v5-DwFXG7m_.js');
6
- require('./options-Bv-1GQJY.js');
7
- require('lru-cache');
8
- require('md5');
9
- require('./defaults-CdqzSWsR.js');
10
- require('@ast-core/escape');
11
- require('@weapp-core/escape');
12
- require('./defu-Cdz2PomB.js');
13
- require('magic-string');
14
- require('@babel/generator');
15
- require('@babel/traverse');
16
- require('@babel/parser');
17
- require('consola');
18
- require('@weapp-core/regex');
19
- require('./replace.js');
20
- require('./shared-r_GpWheO.js');
21
- require('@tailwindcss-mangle/shared');
22
- require('postcss');
23
- require('./index-h2-ZMO3S.js');
24
- require('@csstools/postcss-is-pseudo-class');
25
- require('postcss-rem-to-responsive-pixel');
26
- require('postcss-selector-parser');
27
- require('node:path');
28
- require('node:process');
29
- require('tailwindcss-patch');
30
- require('@babel/types');
31
- require('htmlparser2');
32
- require('node:fs');
33
- require('./index-HC-Qkn0i.js');
34
- require('debug');
35
13
 
36
-
37
-
38
- exports.UnifiedWebpackPluginV5 = v5.UnifiedWebpackPluginV5;
14
+ exports.UnifiedWebpackPluginV5 = _chunk7J6ZENMSjs.UnifiedWebpackPluginV5;
package/dist/webpack.mjs CHANGED
@@ -1,30 +1,14 @@
1
- export { U as UnifiedWebpackPluginV5 } from './v5-N5BYJ5JY.mjs';
2
- import './options-yXyCFCtr.mjs';
3
- import 'lru-cache';
4
- import 'md5';
5
- import './defaults-5A8JI2hW.mjs';
6
- import '@ast-core/escape';
7
- import '@weapp-core/escape';
8
- import './defu-n46TJT6t.mjs';
9
- import 'magic-string';
10
- import '@babel/generator';
11
- import '@babel/traverse';
12
- import '@babel/parser';
13
- import 'consola';
14
- import '@weapp-core/regex';
15
- import './replace.mjs';
16
- import './shared-COWjpokr.mjs';
17
- import '@tailwindcss-mangle/shared';
18
- import 'postcss';
19
- import './index-BF8k8rHr.mjs';
20
- import '@csstools/postcss-is-pseudo-class';
21
- import 'postcss-rem-to-responsive-pixel';
22
- import 'postcss-selector-parser';
23
- import 'node:path';
24
- import 'node:process';
25
- import 'tailwindcss-patch';
26
- import '@babel/types';
27
- import 'htmlparser2';
28
- import 'node:fs';
29
- import './index-BEIjgKpF.mjs';
30
- import 'debug';
1
+ import {
2
+ UnifiedWebpackPluginV5
3
+ } from "./chunk-K7CL4YBQ.mjs";
4
+ import "./chunk-75EWCRQW.mjs";
5
+ import "./chunk-VFCTLSC3.mjs";
6
+ import "./chunk-JVPRWRPJ.mjs";
7
+ import "./chunk-MUJ65IQ3.mjs";
8
+ import "./chunk-KE7J6XFD.mjs";
9
+ import "./chunk-U7O2XXYR.mjs";
10
+ import "./chunk-VKSQ6BRD.mjs";
11
+ import "./chunk-AXBFBHS2.mjs";
12
+ export {
13
+ UnifiedWebpackPluginV5
14
+ };
@@ -0,0 +1,27 @@
1
+ import { Compiler } from 'webpack4';
2
+ import { o as IBaseWebpackPlugin, m as InternalUserDefinedOptions, A as AppType, U as UserDefinedOptions } from './index-g4epDIUu.mjs';
3
+ import '@babel/generator';
4
+ import '@babel/parser';
5
+ import 'magic-string';
6
+ import 'postcss';
7
+ import 'tailwindcss-patch';
8
+ import 'node:buffer';
9
+ import 'webpack';
10
+ import 'lru-cache';
11
+ import '@tailwindcss-mangle/shared';
12
+ import 'postcss-load-config';
13
+ import 'postcss-rem-to-responsive-pixel';
14
+
15
+ /**
16
+ * @name UnifiedWebpackPluginV4
17
+ * @description webpack4 核心转义插件
18
+ * @link https://tw.icebreaker.top/docs/intro
19
+ */
20
+ declare class UnifiedWebpackPluginV4 implements IBaseWebpackPlugin {
21
+ options: InternalUserDefinedOptions;
22
+ appType?: AppType;
23
+ constructor(options?: UserDefinedOptions);
24
+ apply(compiler: Compiler): void;
25
+ }
26
+
27
+ export { UnifiedWebpackPluginV4 };
@@ -1 +1,27 @@
1
- export * from './bundlers/webpack/BaseUnifiedPlugin/v4';
1
+ import { Compiler } from 'webpack4';
2
+ import { o as IBaseWebpackPlugin, m as InternalUserDefinedOptions, A as AppType, U as UserDefinedOptions } from './index-g4epDIUu.js';
3
+ import '@babel/generator';
4
+ import '@babel/parser';
5
+ import 'magic-string';
6
+ import 'postcss';
7
+ import 'tailwindcss-patch';
8
+ import 'node:buffer';
9
+ import 'webpack';
10
+ import 'lru-cache';
11
+ import '@tailwindcss-mangle/shared';
12
+ import 'postcss-load-config';
13
+ import 'postcss-rem-to-responsive-pixel';
14
+
15
+ /**
16
+ * @name UnifiedWebpackPluginV4
17
+ * @description webpack4 核心转义插件
18
+ * @link https://tw.icebreaker.top/docs/intro
19
+ */
20
+ declare class UnifiedWebpackPluginV4 implements IBaseWebpackPlugin {
21
+ options: InternalUserDefinedOptions;
22
+ appType?: AppType;
23
+ constructor(options?: UserDefinedOptions);
24
+ apply(compiler: Compiler): void;
25
+ }
26
+
27
+ export { UnifiedWebpackPluginV4 };
package/dist/webpack4.js CHANGED
@@ -1,203 +1,215 @@
1
- 'use strict';
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var _chunkHBQASQKYjs = require('./chunk-HBQASQKY.js');
4
4
 
5
- var options = require('./options-Bv-1GQJY.js');
6
- var fs = require('node:fs');
7
- var path = require('node:path');
8
- var webpackSources = require('webpack-sources');
9
- var index = require('./index-h2-ZMO3S.js');
10
- var index$1 = require('./index-HC-Qkn0i.js');
11
- var defaults = require('./defaults-CdqzSWsR.js');
12
- require('lru-cache');
13
- require('md5');
14
- require('magic-string');
15
- require('@babel/generator');
16
- require('@babel/traverse');
17
- require('@babel/parser');
18
- require('@ast-core/escape');
19
- require('@weapp-core/escape');
20
- require('consola');
21
- require('@weapp-core/regex');
22
- require('./replace.js');
23
- require('./shared-r_GpWheO.js');
24
- require('@tailwindcss-mangle/shared');
25
- require('postcss');
26
- require('node:process');
27
- require('tailwindcss-patch');
28
- require('@babel/types');
29
- require('htmlparser2');
30
- require('@csstools/postcss-is-pseudo-class');
31
- require('postcss-rem-to-responsive-pixel');
32
- require('postcss-selector-parser');
33
- require('debug');
34
- require('./defu-Cdz2PomB.js');
35
5
 
36
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+ var _chunkQJPVKPQSjs = require('./chunk-QJPVKPQS.js');
7
+ require('./chunk-FYOOMUKL.js');
37
8
 
38
- var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
39
- var path__default = /*#__PURE__*/_interopDefaultCompat(path);
40
9
 
41
- const debug = index$1.createDebug();
42
- class UnifiedWebpackPluginV4 {
43
- constructor(options$1 = {}) {
44
- this.options = options.getOptions(options$1);
45
- this.appType = this.options.appType;
10
+
11
+ var _chunk35CYTBPMjs = require('./chunk-35CYTBPM.js');
12
+
13
+
14
+ var _chunkLQN2VTMUjs = require('./chunk-LQN2VTMU.js');
15
+ require('./chunk-RFNUATFD.js');
16
+ require('./chunk-XSZXPWWL.js');
17
+
18
+
19
+ var _chunk6FNC3XMIjs = require('./chunk-6FNC3XMI.js');
20
+
21
+ // src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
22
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
23
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
24
+ var _webpacksources = require('webpack-sources');
25
+ var debug = _chunkHBQASQKYjs.createDebug.call(void 0, );
26
+ var UnifiedWebpackPluginV4 = class {
27
+ constructor(options = {}) {
28
+ this.options = _chunkQJPVKPQSjs.getOptions.call(void 0, options);
29
+ this.appType = this.options.appType;
30
+ }
31
+ apply(compiler) {
32
+ const {
33
+ mainCssChunkMatcher,
34
+ disabled,
35
+ onLoad,
36
+ onUpdate,
37
+ onEnd,
38
+ onStart,
39
+ styleHandler,
40
+ patch,
41
+ templateHandler,
42
+ jsHandler,
43
+ setMangleRuntimeSet,
44
+ runtimeLoaderPath,
45
+ cache,
46
+ twPatcher
47
+ } = this.options;
48
+ if (disabled) {
49
+ return;
50
+ }
51
+ patch == null ? void 0 : patch();
52
+ function getClassSet() {
53
+ return twPatcher.getClassSet();
46
54
  }
47
- apply(compiler) {
48
- const { mainCssChunkMatcher, disabled, onLoad, onUpdate, onEnd, onStart, styleHandler, patch, templateHandler, jsHandler, setMangleRuntimeSet, runtimeLoaderPath, cache, twPatcher, } = this.options;
49
- if (disabled) {
50
- return;
55
+ onLoad();
56
+ const loader = runtimeLoaderPath != null ? runtimeLoaderPath : _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js");
57
+ const isExisted = _fs2.default.existsSync(loader);
58
+ const WeappTwRuntimeAopLoader = {
59
+ loader,
60
+ options: {
61
+ getClassSet
62
+ },
63
+ ident: null,
64
+ type: null
65
+ };
66
+ compiler.hooks.compilation.tap(_chunkLQN2VTMUjs.pluginName, (compilation) => {
67
+ compilation.hooks.normalModuleLoader.tap(_chunkLQN2VTMUjs.pluginName, (_loaderContext, module) => {
68
+ if (isExisted) {
69
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
70
+ if (idx > -1) {
71
+ module.loaders.unshift(WeappTwRuntimeAopLoader);
72
+ }
51
73
  }
52
- patch === null || patch === void 0 ? void 0 : patch();
53
- function getClassSet() {
54
- return twPatcher.getClassSet();
74
+ });
75
+ });
76
+ compiler.hooks.emit.tapPromise(_chunkLQN2VTMUjs.pluginName, (compilation) => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
77
+ onStart();
78
+ debug("start");
79
+ for (const chunk of compilation.chunks) {
80
+ if (chunk.id && chunk.hash) {
81
+ cache.calcHashValueChanged(chunk.id, chunk.hash);
55
82
  }
56
- onLoad();
57
- const loader = runtimeLoaderPath !== null && runtimeLoaderPath !== void 0 ? runtimeLoaderPath : path__default["default"].resolve(__dirname, './weapp-tw-runtime-loader.js');
58
- const isExisted = fs__default["default"].existsSync(loader);
59
- const WeappTwRuntimeAopLoader = {
60
- loader,
61
- options: {
62
- getClassSet,
83
+ }
84
+ const assets = compilation.assets;
85
+ const entries = Object.entries(assets);
86
+ const groupedEntries = _chunk35CYTBPMjs.getGroupedEntries.call(void 0, entries, this.options);
87
+ const runtimeSet = getClassSet();
88
+ setMangleRuntimeSet(runtimeSet);
89
+ debug("get runtimeSet, class count: %d", runtimeSet.size);
90
+ if (Array.isArray(groupedEntries.html)) {
91
+ let noCachedCount = 0;
92
+ for (let i = 0; i < groupedEntries.html.length; i++) {
93
+ const [file, originalSource] = groupedEntries.html[i];
94
+ const rawSource = originalSource.source().toString();
95
+ const hash = cache.computeHash(rawSource);
96
+ const cacheKey = file;
97
+ cache.calcHashValueChanged(cacheKey, hash);
98
+ yield cache.process(
99
+ cacheKey,
100
+ () => {
101
+ const source = cache.get(cacheKey);
102
+ if (source) {
103
+ compilation.updateAsset(file, source);
104
+ debug("html cache hit: %s", file);
105
+ } else {
106
+ return false;
107
+ }
63
108
  },
64
- ident: null,
65
- type: null,
66
- };
67
- compiler.hooks.compilation.tap(index.pluginName, (compilation) => {
68
- compilation.hooks.normalModuleLoader.tap(index.pluginName, (_loaderContext, module) => {
69
- if (isExisted) {
70
- const idx = module.loaders.findIndex(x => x.loader.includes('postcss-loader'));
71
- if (idx > -1) {
72
- module.loaders.unshift(WeappTwRuntimeAopLoader);
73
- }
74
- }
75
- });
76
- });
77
- compiler.hooks.emit.tapPromise(index.pluginName, (compilation) => options.__awaiter(this, void 0, void 0, function* () {
78
- onStart();
79
- debug('start');
80
- for (const chunk of compilation.chunks) {
81
- if (chunk.id && chunk.hash) {
82
- cache.calcHashValueChanged(chunk.id, chunk.hash);
83
- }
84
- }
85
- const assets = compilation.assets;
86
- const entries = Object.entries(assets);
87
- const groupedEntries = defaults.getGroupedEntries(entries, this.options);
88
- const runtimeSet = getClassSet();
89
- setMangleRuntimeSet(runtimeSet);
90
- debug('get runtimeSet, class count: %d', runtimeSet.size);
91
- if (Array.isArray(groupedEntries.html)) {
92
- let noCachedCount = 0;
93
- for (let i = 0; i < groupedEntries.html.length; i++) {
94
- const [file, originalSource] = groupedEntries.html[i];
95
- const rawSource = originalSource.source().toString();
96
- const hash = cache.computeHash(rawSource);
97
- const cacheKey = file;
98
- cache.calcHashValueChanged(cacheKey, hash);
99
- yield cache.process(cacheKey, () => {
100
- const source = cache.get(cacheKey);
101
- if (source) {
102
- compilation.updateAsset(file, source);
103
- debug('html cache hit: %s', file);
104
- }
105
- else {
106
- return false;
107
- }
108
- }, () => options.__awaiter(this, void 0, void 0, function* () {
109
- const wxml = yield templateHandler(rawSource, {
110
- runtimeSet,
111
- });
112
- const source = new webpackSources.ConcatSource(wxml);
113
- compilation.updateAsset(file, source);
114
- onUpdate(file, rawSource, wxml);
115
- debug('html handle: %s', file);
116
- noCachedCount++;
117
- return {
118
- key: cacheKey,
119
- source,
120
- };
121
- }));
122
- }
123
- debug('html handle finish, total: %d, no-cached: %d', groupedEntries.html.length, noCachedCount);
124
- }
125
- if (Array.isArray(groupedEntries.js)) {
126
- let noCachedCount = 0;
127
- for (let i = 0; i < groupedEntries.js.length; i++) {
128
- const [file, originalSource] = groupedEntries.js[i];
129
- const cacheKey = defaults.removeExt(file);
130
- yield cache.process(cacheKey, () => {
131
- const source = cache.get(cacheKey);
132
- if (source) {
133
- compilation.updateAsset(file, source);
134
- debug('js cache hit: %s', file);
135
- }
136
- else {
137
- return false;
138
- }
139
- }, () => options.__awaiter(this, void 0, void 0, function* () {
140
- const rawSource = originalSource.source().toString();
141
- const mapFilename = `${file}.map`;
142
- const hasMap = Boolean(assets[mapFilename]);
143
- const { code, map } = yield jsHandler(rawSource, runtimeSet, {
144
- generateMap: hasMap,
145
- });
146
- const source = new webpackSources.ConcatSource(code);
147
- compilation.updateAsset(file, source);
148
- onUpdate(file, rawSource, code);
149
- debug('js handle: %s', file);
150
- noCachedCount++;
151
- if (hasMap && map) {
152
- const source = new webpackSources.RawSource(map.toString());
153
- compilation.updateAsset(mapFilename, source);
154
- }
155
- return {
156
- key: cacheKey,
157
- source,
158
- };
159
- }));
160
- }
161
- debug('js handle finish, total: %d, no-cached: %d', groupedEntries.js.length, noCachedCount);
162
- }
163
- if (Array.isArray(groupedEntries.css)) {
164
- let noCachedCount = 0;
165
- for (let i = 0; i < groupedEntries.css.length; i++) {
166
- const [file, originalSource] = groupedEntries.css[i];
167
- const rawSource = originalSource.source().toString();
168
- const hash = cache.computeHash(rawSource);
169
- const cacheKey = file;
170
- cache.calcHashValueChanged(cacheKey, hash);
171
- yield cache.process(cacheKey, () => {
172
- const source = cache.get(cacheKey);
173
- if (source) {
174
- compilation.updateAsset(file, source);
175
- debug('css cache hit: %s', file);
176
- }
177
- else {
178
- return false;
179
- }
180
- }, () => options.__awaiter(this, void 0, void 0, function* () {
181
- const { css } = yield styleHandler(rawSource, {
182
- isMainChunk: mainCssChunkMatcher(file, this.appType),
183
- });
184
- const source = new webpackSources.ConcatSource(css);
185
- compilation.updateAsset(file, source);
186
- onUpdate(file, rawSource, css);
187
- debug('css handle: %s', file);
188
- noCachedCount++;
189
- return {
190
- key: cacheKey,
191
- source,
192
- };
193
- }));
194
- }
195
- debug('css handle finish, total: %d, no-cached: %d', groupedEntries.css.length, noCachedCount);
196
- }
197
- debug('end');
198
- onEnd();
199
- }));
200
- }
201
- }
109
+ // @ts-ignore
110
+ () => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
111
+ const wxml = yield templateHandler(rawSource, {
112
+ runtimeSet
113
+ });
114
+ const source = new (0, _webpacksources.ConcatSource)(wxml);
115
+ compilation.updateAsset(file, source);
116
+ onUpdate(file, rawSource, wxml);
117
+ debug("html handle: %s", file);
118
+ noCachedCount++;
119
+ return {
120
+ key: cacheKey,
121
+ source
122
+ };
123
+ })
124
+ );
125
+ }
126
+ debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
127
+ }
128
+ if (Array.isArray(groupedEntries.js)) {
129
+ let noCachedCount = 0;
130
+ for (let i = 0; i < groupedEntries.js.length; i++) {
131
+ const [file, originalSource] = groupedEntries.js[i];
132
+ const cacheKey = _chunk35CYTBPMjs.removeExt.call(void 0, file);
133
+ yield cache.process(
134
+ cacheKey,
135
+ () => {
136
+ const source = cache.get(cacheKey);
137
+ if (source) {
138
+ compilation.updateAsset(file, source);
139
+ debug("js cache hit: %s", file);
140
+ } else {
141
+ return false;
142
+ }
143
+ },
144
+ // @ts-ignore
145
+ () => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
146
+ const rawSource = originalSource.source().toString();
147
+ const mapFilename = `${file}.map`;
148
+ const hasMap = Boolean(assets[mapFilename]);
149
+ const { code, map } = yield jsHandler(rawSource, runtimeSet, {
150
+ generateMap: hasMap
151
+ });
152
+ const source = new (0, _webpacksources.ConcatSource)(code);
153
+ compilation.updateAsset(file, source);
154
+ onUpdate(file, rawSource, code);
155
+ debug("js handle: %s", file);
156
+ noCachedCount++;
157
+ if (hasMap && map) {
158
+ const source2 = new (0, _webpacksources.RawSource)(map.toString());
159
+ compilation.updateAsset(mapFilename, source2);
160
+ }
161
+ return {
162
+ key: cacheKey,
163
+ source
164
+ };
165
+ })
166
+ );
167
+ }
168
+ debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
169
+ }
170
+ if (Array.isArray(groupedEntries.css)) {
171
+ let noCachedCount = 0;
172
+ for (let i = 0; i < groupedEntries.css.length; i++) {
173
+ const [file, originalSource] = groupedEntries.css[i];
174
+ const rawSource = originalSource.source().toString();
175
+ const hash = cache.computeHash(rawSource);
176
+ const cacheKey = file;
177
+ cache.calcHashValueChanged(cacheKey, hash);
178
+ yield cache.process(
179
+ cacheKey,
180
+ () => {
181
+ const source = cache.get(cacheKey);
182
+ if (source) {
183
+ compilation.updateAsset(file, source);
184
+ debug("css cache hit: %s", file);
185
+ } else {
186
+ return false;
187
+ }
188
+ },
189
+ // @ts-ignore
190
+ () => _chunk6FNC3XMIjs.__async.call(void 0, this, null, function* () {
191
+ const { css } = yield styleHandler(rawSource, {
192
+ isMainChunk: mainCssChunkMatcher(file, this.appType)
193
+ });
194
+ const source = new (0, _webpacksources.ConcatSource)(css);
195
+ compilation.updateAsset(file, source);
196
+ onUpdate(file, rawSource, css);
197
+ debug("css handle: %s", file);
198
+ noCachedCount++;
199
+ return {
200
+ key: cacheKey,
201
+ source
202
+ };
203
+ })
204
+ );
205
+ }
206
+ debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
207
+ }
208
+ debug("end");
209
+ onEnd();
210
+ }));
211
+ }
212
+ };
213
+
202
214
 
203
215
  exports.UnifiedWebpackPluginV4 = UnifiedWebpackPluginV4;