weapp-tailwindcss 4.0.11 → 4.1.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.
@@ -3,7 +3,7 @@
3
3
  var _chunkLSSLYD6Bjs = require('./chunk-LSSLYD6B.js');
4
4
 
5
5
 
6
- var _chunkT7PCCJBLjs = require('./chunk-T7PCCJBL.js');
6
+ var _chunkWO4ZUVOCjs = require('./chunk-WO4ZUVOC.js');
7
7
 
8
8
  // src/bundlers/gulp/index.ts
9
9
  var _buffer = require('buffer');
@@ -11,7 +11,7 @@ var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
11
11
  var debug = _chunkLSSLYD6Bjs.createDebug.call(void 0, );
12
12
  var Transform = _stream2.default.Transform;
13
13
  function createPlugins(options = {}) {
14
- const opts = _chunkT7PCCJBLjs.getCompilerContext.call(void 0, options);
14
+ const opts = _chunkWO4ZUVOCjs.getCompilerContext.call(void 0, options);
15
15
  const { templateHandler, styleHandler, jsHandler, setMangleRuntimeSet, cache, twPatcher } = opts;
16
16
  let runtimeSet = /* @__PURE__ */ new Set();
17
17
  twPatcher.patch();
@@ -1,6 +1,6 @@
1
1
  // src/constants.ts
2
2
  var pluginName = "weapp-tailwindcss-webpack-plugin";
3
- var vitePluginName = "vite-plugin-uni-app-weapp-tailwindcss-adaptor";
3
+ var vitePluginName = "weapp-tailwindcss:adaptor";
4
4
  var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
5
5
 
6
6
  export {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-3AUX4FGE.mjs";
4
4
  import {
5
5
  getCompilerContext
6
- } from "./chunk-OL4UJCXZ.mjs";
6
+ } from "./chunk-QVF2EZHN.mjs";
7
7
 
8
8
  // src/bundlers/gulp/index.ts
9
9
  import { Buffer } from "node:buffer";
@@ -3,10 +3,10 @@
3
3
  var _chunkLSSLYD6Bjs = require('./chunk-LSSLYD6B.js');
4
4
 
5
5
 
6
- var _chunkEHEK77ROjs = require('./chunk-EHEK77RO.js');
6
+ var _chunkOGROHM4Ljs = require('./chunk-OGROHM4L.js');
7
7
 
8
8
 
9
- var _chunkT7PCCJBLjs = require('./chunk-T7PCCJBL.js');
9
+ var _chunkWO4ZUVOCjs = require('./chunk-WO4ZUVOC.js');
10
10
 
11
11
 
12
12
 
@@ -18,7 +18,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
18
18
  var debug = _chunkLSSLYD6Bjs.createDebug.call(void 0, );
19
19
  var UnifiedWebpackPluginV5 = class {
20
20
  constructor(options = {}) {
21
- this.options = _chunkT7PCCJBLjs.getCompilerContext.call(void 0, options);
21
+ this.options = _chunkWO4ZUVOCjs.getCompilerContext.call(void 0, options);
22
22
  this.appType = this.options.appType;
23
23
  }
24
24
  apply(compiler) {
@@ -59,8 +59,8 @@ var UnifiedWebpackPluginV5 = class {
59
59
  ident: null,
60
60
  type: null
61
61
  };
62
- compiler.hooks.compilation.tap(_chunkEHEK77ROjs.pluginName, (compilation) => {
63
- NormalModule.getCompilationHooks(compilation).loader.tap(_chunkEHEK77ROjs.pluginName, (_loaderContext, module) => {
62
+ compiler.hooks.compilation.tap(_chunkOGROHM4Ljs.pluginName, (compilation) => {
63
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkOGROHM4Ljs.pluginName, (_loaderContext, module) => {
64
64
  if (isExisted) {
65
65
  const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
66
66
  if (idx > -1) {
@@ -70,7 +70,7 @@ var UnifiedWebpackPluginV5 = class {
70
70
  });
71
71
  compilation.hooks.processAssets.tapPromise(
72
72
  {
73
- name: _chunkEHEK77ROjs.pluginName,
73
+ name: _chunkOGROHM4Ljs.pluginName,
74
74
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
75
75
  },
76
76
  async (assets) => {
@@ -86,6 +86,7 @@ var UnifiedWebpackPluginV5 = class {
86
86
  const runtimeSet = await twPatcher.getClassSet();
87
87
  setMangleRuntimeSet(runtimeSet);
88
88
  debug("get runtimeSet, class count: %d", runtimeSet.size);
89
+ const promises = [];
89
90
  if (Array.isArray(groupedEntries.html)) {
90
91
  let noCachedCount = 0;
91
92
  for (const element of groupedEntries.html) {
@@ -94,31 +95,33 @@ var UnifiedWebpackPluginV5 = class {
94
95
  const hash = cache.computeHash(rawSource);
95
96
  const cacheKey = file;
96
97
  cache.calcHashValueChanged(cacheKey, hash);
97
- await cache.process(
98
- cacheKey,
99
- () => {
100
- const source = cache.get(cacheKey);
101
- if (source) {
98
+ promises.push(
99
+ cache.process(
100
+ cacheKey,
101
+ () => {
102
+ const source = cache.get(cacheKey);
103
+ if (source) {
104
+ compilation.updateAsset(file, source);
105
+ debug("html cache hit: %s", file);
106
+ } else {
107
+ return false;
108
+ }
109
+ },
110
+ async () => {
111
+ const wxml = await templateHandler(rawSource, {
112
+ runtimeSet
113
+ });
114
+ const source = new ConcatSource(wxml);
102
115
  compilation.updateAsset(file, source);
103
- debug("html cache hit: %s", file);
104
- } else {
105
- return false;
116
+ onUpdate(file, rawSource, wxml);
117
+ debug("html handle: %s", file);
118
+ noCachedCount++;
119
+ return {
120
+ key: cacheKey,
121
+ source
122
+ };
106
123
  }
107
- },
108
- async () => {
109
- const wxml = await templateHandler(rawSource, {
110
- runtimeSet
111
- });
112
- const source = new 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
- }
124
+ )
122
125
  );
123
126
  }
124
127
  debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
@@ -128,38 +131,40 @@ var UnifiedWebpackPluginV5 = class {
128
131
  for (const element of groupedEntries.js) {
129
132
  const [file, originalSource] = element;
130
133
  const cacheKey = _chunkO335YLYHjs.removeExt.call(void 0, file);
131
- await cache.process(
132
- cacheKey,
133
- () => {
134
- const source = cache.get(cacheKey);
135
- if (source) {
134
+ promises.push(
135
+ cache.process(
136
+ cacheKey,
137
+ () => {
138
+ const source = cache.get(cacheKey);
139
+ if (source) {
140
+ compilation.updateAsset(file, source);
141
+ debug("js cache hit: %s", file);
142
+ } else {
143
+ return false;
144
+ }
145
+ },
146
+ async () => {
147
+ const rawSource = originalSource.source().toString();
148
+ const mapFilename = `${file}.map`;
149
+ const hasMap = Boolean(assets[mapFilename]);
150
+ const { code, map } = await jsHandler(rawSource, runtimeSet, {
151
+ generateMap: hasMap
152
+ });
153
+ const source = new ConcatSource(code);
136
154
  compilation.updateAsset(file, source);
137
- debug("js cache hit: %s", file);
138
- } else {
139
- return false;
155
+ onUpdate(file, rawSource, code);
156
+ debug("js handle: %s", file);
157
+ noCachedCount++;
158
+ if (hasMap && map) {
159
+ const source2 = new RawSource(map.toString());
160
+ compilation.updateAsset(mapFilename, source2);
161
+ }
162
+ return {
163
+ key: cacheKey,
164
+ source
165
+ };
140
166
  }
141
- },
142
- async () => {
143
- const rawSource = originalSource.source().toString();
144
- const mapFilename = `${file}.map`;
145
- const hasMap = Boolean(assets[mapFilename]);
146
- const { code, map } = await jsHandler(rawSource, runtimeSet, {
147
- generateMap: hasMap
148
- });
149
- const source = new ConcatSource(code);
150
- compilation.updateAsset(file, source);
151
- onUpdate(file, rawSource, code);
152
- debug("js handle: %s", file);
153
- noCachedCount++;
154
- if (hasMap && map) {
155
- const source2 = new RawSource(map.toString());
156
- compilation.updateAsset(mapFilename, source2);
157
- }
158
- return {
159
- key: cacheKey,
160
- source
161
- };
162
- }
167
+ )
163
168
  );
164
169
  }
165
170
  debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
@@ -172,35 +177,43 @@ var UnifiedWebpackPluginV5 = class {
172
177
  const hash = cache.computeHash(rawSource);
173
178
  const cacheKey = file;
174
179
  cache.calcHashValueChanged(cacheKey, hash);
175
- await cache.process(
176
- cacheKey,
177
- () => {
178
- const source = cache.get(cacheKey);
179
- if (source) {
180
+ promises.push(
181
+ cache.process(
182
+ cacheKey,
183
+ () => {
184
+ const source = cache.get(cacheKey);
185
+ if (source) {
186
+ compilation.updateAsset(file, source);
187
+ debug("css cache hit: %s", file);
188
+ } else {
189
+ return false;
190
+ }
191
+ },
192
+ async () => {
193
+ const { css } = await styleHandler(rawSource, {
194
+ isMainChunk: mainCssChunkMatcher(file, this.appType),
195
+ postcssOptions: {
196
+ options: {
197
+ from: file
198
+ }
199
+ }
200
+ });
201
+ const source = new ConcatSource(css);
180
202
  compilation.updateAsset(file, source);
181
- debug("css cache hit: %s", file);
182
- } else {
183
- return false;
203
+ onUpdate(file, rawSource, css);
204
+ debug("css handle: %s", file);
205
+ noCachedCount++;
206
+ return {
207
+ key: cacheKey,
208
+ source
209
+ };
184
210
  }
185
- },
186
- async () => {
187
- const { css } = await styleHandler(rawSource, {
188
- isMainChunk: mainCssChunkMatcher(file, this.appType)
189
- });
190
- const source = new ConcatSource(css);
191
- compilation.updateAsset(file, source);
192
- onUpdate(file, rawSource, css);
193
- debug("css handle: %s", file);
194
- noCachedCount++;
195
- return {
196
- key: cacheKey,
197
- source
198
- };
199
- }
211
+ )
200
212
  );
201
213
  }
202
214
  debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
203
215
  }
216
+ await Promise.all(promises);
204
217
  debug("end");
205
218
  onEnd();
206
219
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/constants.ts
2
2
  var pluginName = "weapp-tailwindcss-webpack-plugin";
3
- var vitePluginName = "vite-plugin-uni-app-weapp-tailwindcss-adaptor";
3
+ var vitePluginName = "weapp-tailwindcss:adaptor";
4
4
  var WEAPP_TW_REQUIRED_NODE_VERSION = "18.17.0";
5
5
 
6
6
 
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-3AUX4FGE.mjs";
4
4
  import {
5
5
  pluginName
6
- } from "./chunk-L7PW3J3N.mjs";
6
+ } from "./chunk-CMUA5KCO.mjs";
7
7
  import {
8
8
  getCompilerContext
9
- } from "./chunk-OL4UJCXZ.mjs";
9
+ } from "./chunk-QVF2EZHN.mjs";
10
10
  import {
11
11
  getGroupedEntries,
12
12
  removeExt
@@ -89,6 +89,7 @@ var UnifiedWebpackPluginV5 = class {
89
89
  const runtimeSet = await twPatcher.getClassSet();
90
90
  setMangleRuntimeSet(runtimeSet);
91
91
  debug("get runtimeSet, class count: %d", runtimeSet.size);
92
+ const promises = [];
92
93
  if (Array.isArray(groupedEntries.html)) {
93
94
  let noCachedCount = 0;
94
95
  for (const element of groupedEntries.html) {
@@ -97,31 +98,33 @@ var UnifiedWebpackPluginV5 = class {
97
98
  const hash = cache.computeHash(rawSource);
98
99
  const cacheKey = file;
99
100
  cache.calcHashValueChanged(cacheKey, hash);
100
- await cache.process(
101
- cacheKey,
102
- () => {
103
- const source = cache.get(cacheKey);
104
- if (source) {
101
+ promises.push(
102
+ cache.process(
103
+ cacheKey,
104
+ () => {
105
+ const source = cache.get(cacheKey);
106
+ if (source) {
107
+ compilation.updateAsset(file, source);
108
+ debug("html cache hit: %s", file);
109
+ } else {
110
+ return false;
111
+ }
112
+ },
113
+ async () => {
114
+ const wxml = await templateHandler(rawSource, {
115
+ runtimeSet
116
+ });
117
+ const source = new ConcatSource(wxml);
105
118
  compilation.updateAsset(file, source);
106
- debug("html cache hit: %s", file);
107
- } else {
108
- return false;
119
+ onUpdate(file, rawSource, wxml);
120
+ debug("html handle: %s", file);
121
+ noCachedCount++;
122
+ return {
123
+ key: cacheKey,
124
+ source
125
+ };
109
126
  }
110
- },
111
- async () => {
112
- const wxml = await templateHandler(rawSource, {
113
- runtimeSet
114
- });
115
- const source = new ConcatSource(wxml);
116
- compilation.updateAsset(file, source);
117
- onUpdate(file, rawSource, wxml);
118
- debug("html handle: %s", file);
119
- noCachedCount++;
120
- return {
121
- key: cacheKey,
122
- source
123
- };
124
- }
127
+ )
125
128
  );
126
129
  }
127
130
  debug("html handle finish, total: %d, no-cached: %d", groupedEntries.html.length, noCachedCount);
@@ -131,38 +134,40 @@ var UnifiedWebpackPluginV5 = class {
131
134
  for (const element of groupedEntries.js) {
132
135
  const [file, originalSource] = element;
133
136
  const cacheKey = removeExt(file);
134
- await cache.process(
135
- cacheKey,
136
- () => {
137
- const source = cache.get(cacheKey);
138
- if (source) {
137
+ promises.push(
138
+ cache.process(
139
+ cacheKey,
140
+ () => {
141
+ const source = cache.get(cacheKey);
142
+ if (source) {
143
+ compilation.updateAsset(file, source);
144
+ debug("js cache hit: %s", file);
145
+ } else {
146
+ return false;
147
+ }
148
+ },
149
+ async () => {
150
+ const rawSource = originalSource.source().toString();
151
+ const mapFilename = `${file}.map`;
152
+ const hasMap = Boolean(assets[mapFilename]);
153
+ const { code, map } = await jsHandler(rawSource, runtimeSet, {
154
+ generateMap: hasMap
155
+ });
156
+ const source = new ConcatSource(code);
139
157
  compilation.updateAsset(file, source);
140
- debug("js cache hit: %s", file);
141
- } else {
142
- return false;
158
+ onUpdate(file, rawSource, code);
159
+ debug("js handle: %s", file);
160
+ noCachedCount++;
161
+ if (hasMap && map) {
162
+ const source2 = new RawSource(map.toString());
163
+ compilation.updateAsset(mapFilename, source2);
164
+ }
165
+ return {
166
+ key: cacheKey,
167
+ source
168
+ };
143
169
  }
144
- },
145
- async () => {
146
- const rawSource = originalSource.source().toString();
147
- const mapFilename = `${file}.map`;
148
- const hasMap = Boolean(assets[mapFilename]);
149
- const { code, map } = await jsHandler(rawSource, runtimeSet, {
150
- generateMap: hasMap
151
- });
152
- const source = new 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 RawSource(map.toString());
159
- compilation.updateAsset(mapFilename, source2);
160
- }
161
- return {
162
- key: cacheKey,
163
- source
164
- };
165
- }
170
+ )
166
171
  );
167
172
  }
168
173
  debug("js handle finish, total: %d, no-cached: %d", groupedEntries.js.length, noCachedCount);
@@ -175,35 +180,43 @@ var UnifiedWebpackPluginV5 = class {
175
180
  const hash = cache.computeHash(rawSource);
176
181
  const cacheKey = file;
177
182
  cache.calcHashValueChanged(cacheKey, hash);
178
- await cache.process(
179
- cacheKey,
180
- () => {
181
- const source = cache.get(cacheKey);
182
- if (source) {
183
+ promises.push(
184
+ cache.process(
185
+ cacheKey,
186
+ () => {
187
+ const source = cache.get(cacheKey);
188
+ if (source) {
189
+ compilation.updateAsset(file, source);
190
+ debug("css cache hit: %s", file);
191
+ } else {
192
+ return false;
193
+ }
194
+ },
195
+ async () => {
196
+ const { css } = await styleHandler(rawSource, {
197
+ isMainChunk: mainCssChunkMatcher(file, this.appType),
198
+ postcssOptions: {
199
+ options: {
200
+ from: file
201
+ }
202
+ }
203
+ });
204
+ const source = new ConcatSource(css);
183
205
  compilation.updateAsset(file, source);
184
- debug("css cache hit: %s", file);
185
- } else {
186
- return false;
206
+ onUpdate(file, rawSource, css);
207
+ debug("css handle: %s", file);
208
+ noCachedCount++;
209
+ return {
210
+ key: cacheKey,
211
+ source
212
+ };
187
213
  }
188
- },
189
- async () => {
190
- const { css } = await styleHandler(rawSource, {
191
- isMainChunk: mainCssChunkMatcher(file, this.appType)
192
- });
193
- const source = new ConcatSource(css);
194
- compilation.updateAsset(file, source);
195
- onUpdate(file, rawSource, css);
196
- debug("css handle: %s", file);
197
- noCachedCount++;
198
- return {
199
- key: cacheKey,
200
- source
201
- };
202
- }
214
+ )
203
215
  );
204
216
  }
205
217
  debug("css handle finish, total: %d, no-cached: %d", groupedEntries.css.length, noCachedCount);
206
218
  }
219
+ await Promise.all(promises);
207
220
  debug("end");
208
221
  onEnd();
209
222
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-Q67IXIAH.mjs";
4
4
  import {
5
5
  getDefaultOptions
6
- } from "./chunk-RGDWO3OF.mjs";
6
+ } from "./chunk-WS4AAHOX.mjs";
7
7
  import {
8
8
  defuOverrideArray,
9
9
  isMap,
@@ -93,10 +93,6 @@ function initializeCache(cacheConfig) {
93
93
  return cacheConfig;
94
94
  }
95
95
 
96
- // src/js/babel.ts
97
- import { jsStringEscape as jsStringEscape2 } from "@ast-core/escape";
98
- import MagicString from "magic-string";
99
-
100
96
  // src/babel/index.ts
101
97
  import _babelTraverse from "@babel/traverse";
102
98
  import { parse, parseExpression } from "@babel/parser";
@@ -105,6 +101,11 @@ function _interopDefaultCompat(e) {
105
101
  }
106
102
  var traverse = _interopDefaultCompat(_babelTraverse);
107
103
 
104
+ // src/js/babel.ts
105
+ import { jsStringEscape as jsStringEscape2 } from "@ast-core/escape";
106
+ import { LRUCache as LRUCache2 } from "lru-cache";
107
+ import MagicString from "magic-string";
108
+
108
109
  // src/js/handlers.ts
109
110
  import { jsStringEscape } from "@ast-core/escape";
110
111
  import { escapeStringRegexp } from "@weapp-core/regex";
@@ -337,25 +338,47 @@ var NodePathWalker = class {
337
338
  };
338
339
 
339
340
  // src/js/babel.ts
341
+ var parseCache = new LRUCache2(
342
+ {
343
+ max: 512
344
+ }
345
+ );
346
+ function babelParse(code, { cache, ...options } = {}) {
347
+ let result;
348
+ if (cache) {
349
+ result = parseCache.get(code);
350
+ }
351
+ if (!result) {
352
+ result = parse(code, options);
353
+ if (cache) {
354
+ parseCache.set(code, result);
355
+ }
356
+ }
357
+ return result;
358
+ }
340
359
  function isEvalPath(p) {
341
360
  if (p.isCallExpression()) {
342
361
  const calleePath = p.get("callee");
343
- return calleePath.isIdentifier() && calleePath.node.name === "eval";
362
+ return calleePath.isIdentifier(
363
+ {
364
+ name: "eval"
365
+ }
366
+ );
344
367
  }
345
368
  return false;
346
369
  }
347
370
  var ignoreFlagMap = /* @__PURE__ */ new WeakMap();
348
371
  function jsHandler(rawSource, options) {
349
- const ms = new MagicString(rawSource);
350
372
  let ast;
351
373
  try {
352
- ast = parse(rawSource, options.babelParserOptions);
374
+ ast = babelParse(rawSource, options.babelParserOptions);
353
375
  } catch (error) {
354
376
  return {
355
377
  code: rawSource,
356
378
  error
357
379
  };
358
380
  }
381
+ const ms = new MagicString(rawSource);
359
382
  const jsTokenUpdater = new JsTokenUpdater();
360
383
  const walker = new NodePathWalker(
361
384
  {