weapp-tailwindcss 4.9.2-alpha.2 → 4.9.3

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 (54) hide show
  1. package/dist/{chunk-W4XFWZB5.js → chunk-3UOPODB3.js} +44 -44
  2. package/dist/{chunk-JOLM54PI.mjs → chunk-4HESZS5A.mjs} +2 -2
  3. package/dist/{chunk-5O6237HX.js → chunk-4RUFPPI6.js} +400 -377
  4. package/dist/{chunk-ZE7JKKFT.mjs → chunk-7D27E7TU.mjs} +438 -415
  5. package/dist/{chunk-KA2JONAP.js → chunk-A2BRI46M.js} +5 -5
  6. package/dist/{chunk-3SKEY32E.mjs → chunk-F2CKKG6Q.mjs} +67 -67
  7. package/dist/{chunk-YBTRKOE2.js → chunk-I3IRT5VH.js} +7 -7
  8. package/dist/chunk-IMOEZLDR.js +441 -0
  9. package/dist/{chunk-OU2OBBPZ.mjs → chunk-IW3B6ZJD.mjs} +646 -565
  10. package/dist/{chunk-NGRAUBWU.js → chunk-KXZ4MP4L.js} +277 -236
  11. package/dist/chunk-PU5CC4ZI.mjs +444 -0
  12. package/dist/{chunk-FFGR5V3H.mjs → chunk-SPH6SCTM.mjs} +1 -1
  13. package/dist/{chunk-J7KULRTR.js → chunk-VOD2WUH6.js} +635 -554
  14. package/dist/{chunk-2WPTDMN3.js → chunk-VPHA77FH.js} +61 -61
  15. package/dist/{chunk-QA5NZSGN.mjs → chunk-WH65CIYG.mjs} +41 -41
  16. package/dist/{chunk-UAEME5HT.js → chunk-Y6F6NBA7.js} +1 -1
  17. package/dist/{chunk-6HBFEXOW.mjs → chunk-Z2D5NSG5.mjs} +265 -224
  18. package/dist/{chunk-XWGIWOHV.mjs → chunk-ZL22KEHH.mjs} +2 -2
  19. package/dist/cli.js +182 -136
  20. package/dist/cli.mjs +194 -148
  21. package/dist/core.js +10 -10
  22. package/dist/core.mjs +4 -4
  23. package/dist/css-macro/postcss.js +1 -1
  24. package/dist/css-macro/postcss.mjs +1 -1
  25. package/dist/css-macro.js +1 -1
  26. package/dist/css-macro.mjs +1 -1
  27. package/dist/defaults.js +1 -1
  28. package/dist/defaults.mjs +1 -1
  29. package/dist/gulp.js +6 -6
  30. package/dist/gulp.mjs +5 -5
  31. package/dist/index.js +10 -10
  32. package/dist/index.mjs +9 -9
  33. package/dist/postcss-html-transform.js +1 -1
  34. package/dist/postcss-html-transform.mjs +1 -1
  35. package/dist/presets.js +5 -5
  36. package/dist/presets.mjs +2 -2
  37. package/dist/reset.d.mts +2 -1
  38. package/dist/reset.d.ts +2 -1
  39. package/dist/reset.js +25 -21
  40. package/dist/reset.mjs +25 -21
  41. package/dist/types.d.mts +503 -474
  42. package/dist/types.d.ts +503 -474
  43. package/dist/types.js +1 -1
  44. package/dist/types.mjs +1 -1
  45. package/dist/vite.js +7 -7
  46. package/dist/vite.mjs +6 -6
  47. package/dist/weapp-tw-css-import-rewrite-loader.js +2 -4
  48. package/dist/webpack.js +8 -8
  49. package/dist/webpack.mjs +7 -7
  50. package/dist/webpack4.js +351 -307
  51. package/dist/webpack4.mjs +341 -297
  52. package/package.json +11 -11
  53. package/dist/chunk-CF7VDUIE.mjs +0 -397
  54. package/dist/chunk-OGG7WXHZ.js +0 -394
@@ -1,394 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
- var _chunkW4XFWZB5js = require('./chunk-W4XFWZB5.js');
13
-
14
-
15
-
16
-
17
-
18
-
19
- var _chunk2WPTDMN3js = require('./chunk-2WPTDMN3.js');
20
-
21
-
22
- var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
23
-
24
-
25
- var _chunkKA2JONAPjs = require('./chunk-KA2JONAP.js');
26
-
27
-
28
-
29
-
30
-
31
-
32
- var _chunkJ7KULRTRjs = require('./chunk-J7KULRTR.js');
33
-
34
-
35
- var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
36
-
37
- // src/bundlers/webpack/BaseUnifiedPlugin/v5.ts
38
- var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
39
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
40
- var _process = require('process'); var _process2 = _interopRequireDefault(_process);
41
- var debug = _chunkJ7KULRTRjs.createDebug.call(void 0, );
42
- var weappTailwindcssPackageDir = _chunk2WPTDMN3js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
43
- var UnifiedWebpackPluginV5 = class {
44
- constructor(options = {}) {
45
- this.options = _chunkJ7KULRTRjs.getCompilerContext.call(void 0, options);
46
- this.appType = this.options.appType;
47
- }
48
- apply(compiler) {
49
- compiler.options = compiler.options || {};
50
- const {
51
- mainCssChunkMatcher,
52
- disabled,
53
- onLoad,
54
- onUpdate,
55
- onEnd,
56
- onStart,
57
- styleHandler,
58
- templateHandler,
59
- jsHandler,
60
- runtimeLoaderPath,
61
- runtimeCssImportRewriteLoaderPath,
62
- cache,
63
- twPatcher: initialTwPatcher,
64
- refreshTailwindcssPatcher
65
- } = this.options;
66
- const disabledOptions = _chunk2WPTDMN3js.resolveDisabledOptions.call(void 0, disabled);
67
- const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
68
- const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
69
- const isMpxApp = _chunkW4XFWZB5js.isMpx.call(void 0, this.appType);
70
- if (shouldRewriteCssImports) {
71
- _chunkW4XFWZB5js.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
72
- pkgDir: weappTailwindcssPackageDir,
73
- enabled: true,
74
- appType: this.appType
75
- });
76
- _chunkW4XFWZB5js.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
77
- }
78
- if (disabledOptions.plugin) {
79
- return;
80
- }
81
- const patchRecorderState = _chunkKA2JONAPjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
82
- source: "runtime",
83
- cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
84
- });
85
- const runtimeState = {
86
- twPatcher: initialTwPatcher,
87
- patchPromise: patchRecorderState.patchPromise,
88
- refreshTailwindcssPatcher,
89
- onPatchCompleted: patchRecorderState.onPatchCompleted
90
- };
91
- const refreshRuntimeState = async (force) => {
92
- await _chunkJ7KULRTRjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
93
- };
94
- const { Compilation, sources, NormalModule } = compiler.webpack;
95
- const { ConcatSource } = sources;
96
- async function getClassSetInLoader() {
97
- await refreshRuntimeState(true);
98
- await runtimeState.patchPromise;
99
- await _chunkJ7KULRTRjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
100
- }
101
- const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
102
- const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
103
- const runtimeClassSetLoaderExists = _fs2.default.existsSync(runtimeClassSetLoader);
104
- const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? _fs2.default.existsSync(runtimeCssImportRewriteLoader) : false;
105
- const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
106
- pkgDir: weappTailwindcssPackageDir,
107
- appType: this.appType
108
- } : void 0;
109
- const classSetLoaderOptions = {
110
- getClassSet: getClassSetInLoader
111
- };
112
- const { findRewriteAnchor, findClassSetAnchor } = _chunkW4XFWZB5js.createLoaderAnchorFinders.call(void 0, this.appType);
113
- const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
114
- rewriteCssImports: runtimeLoaderRewriteOptions
115
- } : void 0;
116
- onLoad();
117
- if (shouldRewriteCssImports && isMpxApp) {
118
- _chunkW4XFWZB5js.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir);
119
- }
120
- if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
121
- _chunkW4XFWZB5js.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
122
- }
123
- const createRuntimeClassSetLoaderEntry = () => ({
124
- loader: runtimeClassSetLoader,
125
- options: classSetLoaderOptions,
126
- ident: null,
127
- type: null
128
- });
129
- const createCssImportRewriteLoaderEntry = () => {
130
- if (!runtimeCssImportRewriteLoader) {
131
- return null;
132
- }
133
- return {
134
- loader: runtimeCssImportRewriteLoader,
135
- options: cssImportRewriteLoaderOptions,
136
- ident: null,
137
- type: null
138
- };
139
- };
140
- compiler.hooks.compilation.tap(_chunkJ7KULRTRjs.pluginName, (compilation) => {
141
- NormalModule.getCompilationHooks(compilation).loader.tap(_chunkJ7KULRTRjs.pluginName, (_loaderContext, module) => {
142
- const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
143
- if (!hasRuntimeLoader) {
144
- return;
145
- }
146
- _chunkW4XFWZB5js.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
147
- const loaderEntries = module.loaders || [];
148
- let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
149
- const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
150
- const isCssModule = _chunkW4XFWZB5js.isCssLikeModuleResource.call(void 0, module.resource, this.options.cssMatcher, this.appType);
151
- if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
152
- debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
153
- }
154
- if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) {
155
- debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
156
- } else if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) {
157
- debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
158
- }
159
- if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) {
160
- return;
161
- }
162
- const anchorlessInsert = (entry, position) => {
163
- if (position === "after") {
164
- loaderEntries.push(entry);
165
- } else {
166
- loaderEntries.unshift(entry);
167
- }
168
- };
169
- if (cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoaderExists && runtimeCssImportRewriteLoader) {
170
- const existingIndex = loaderEntries.findIndex((entry) => _optionalChain([entry, 'access', _ => _.loader, 'optionalAccess', _2 => _2.includes, 'optionalCall', _3 => _3(runtimeCssImportRewriteLoader)]));
171
- const rewriteLoaderEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
172
- if (rewriteLoaderEntry) {
173
- const anchorIndex = findRewriteAnchor(loaderEntries);
174
- if (anchorIndex === -1) {
175
- anchorlessInsert(rewriteLoaderEntry, "after");
176
- } else {
177
- loaderEntries.splice(anchorIndex + 1, 0, rewriteLoaderEntry);
178
- }
179
- rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
180
- }
181
- }
182
- if (runtimeClassSetLoaderExists && !_chunkW4XFWZB5js.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
183
- const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
184
- const anchorIndex = findClassSetAnchor(loaderEntries);
185
- if (anchorIndex === -1) {
186
- anchorlessInsert(classSetLoaderEntry, "before");
187
- } else {
188
- const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
189
- loaderEntries.splice(insertIndex, 0, classSetLoaderEntry);
190
- }
191
- }
192
- });
193
- compilation.hooks.processAssets.tapPromise(
194
- {
195
- name: _chunkJ7KULRTRjs.pluginName,
196
- stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
197
- },
198
- async (assets) => {
199
- onStart();
200
- debug("start");
201
- await runtimeState.patchPromise;
202
- for (const chunk of compilation.chunks) {
203
- if (chunk.id && chunk.hash) {
204
- cache.calcHashValueChanged(chunk.id, chunk.hash);
205
- }
206
- }
207
- const entries = Object.entries(assets);
208
- const compilerOutputPath = _nullishCoalesce(_optionalChain([compilation, 'access', _4 => _4.compiler, 'optionalAccess', _5 => _5.outputPath]), () => ( compiler.outputPath));
209
- const outputDir = compilerOutputPath ? _path2.default.resolve(compilerOutputPath) : _nullishCoalesce(_optionalChain([compilation, 'access', _6 => _6.outputOptions, 'optionalAccess', _7 => _7.path]), () => ( _process2.default.cwd()));
210
- const jsAssets = /* @__PURE__ */ new Map();
211
- for (const [file] of entries) {
212
- if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
213
- const absolute = _chunk2WPTDMN3js.toAbsoluteOutputPath.call(void 0, file, outputDir);
214
- jsAssets.set(absolute, file);
215
- }
216
- }
217
- const moduleGraphOptions = {
218
- resolve(specifier, importer) {
219
- return _chunk2WPTDMN3js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
220
- },
221
- load: (id) => {
222
- const assetName = jsAssets.get(id);
223
- if (!assetName) {
224
- return void 0;
225
- }
226
- const asset = compilation.getAsset(assetName);
227
- if (!asset) {
228
- return void 0;
229
- }
230
- const source = asset.source.source();
231
- return typeof source === "string" ? source : source.toString();
232
- },
233
- filter(id) {
234
- return jsAssets.has(id);
235
- }
236
- };
237
- const applyLinkedResults = (linked) => {
238
- if (!linked) {
239
- return;
240
- }
241
- for (const [id, { code }] of Object.entries(linked)) {
242
- const assetName = jsAssets.get(id);
243
- if (!assetName) {
244
- continue;
245
- }
246
- const asset = compilation.getAsset(assetName);
247
- if (!asset) {
248
- continue;
249
- }
250
- const previousSource = asset.source.source();
251
- const previous = typeof previousSource === "string" ? previousSource : previousSource.toString();
252
- if (previous === code) {
253
- continue;
254
- }
255
- const source = new ConcatSource(code);
256
- compilation.updateAsset(assetName, source);
257
- onUpdate(assetName, previous, code);
258
- debug("js linked handle: %s", assetName);
259
- }
260
- };
261
- const groupedEntries = _chunkDYLQ6UOIjs.getGroupedEntries.call(void 0, entries, this.options);
262
- await refreshRuntimeState(true);
263
- await runtimeState.patchPromise;
264
- const runtimeSet = await _chunkJ7KULRTRjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
265
- debug("get runtimeSet, class count: %d", runtimeSet.size);
266
- const tasks = [];
267
- if (Array.isArray(groupedEntries.html)) {
268
- for (const element of groupedEntries.html) {
269
- const [file, originalSource] = element;
270
- const rawSource = originalSource.source().toString();
271
- const cacheKey = file;
272
- tasks.push(
273
- _chunkLTJQUORKjs.processCachedTask.call(void 0, {
274
- cache,
275
- cacheKey,
276
- rawSource,
277
- applyResult(source) {
278
- compilation.updateAsset(file, source);
279
- },
280
- onCacheHit() {
281
- debug("html cache hit: %s", file);
282
- },
283
- transform: async () => {
284
- const wxml = await templateHandler(rawSource, {
285
- runtimeSet
286
- });
287
- const source = new ConcatSource(wxml);
288
- onUpdate(file, rawSource, wxml);
289
- debug("html handle: %s", file);
290
- return {
291
- result: source
292
- };
293
- }
294
- })
295
- );
296
- }
297
- }
298
- const jsTaskFactories = [];
299
- if (Array.isArray(groupedEntries.js)) {
300
- for (const [file] of groupedEntries.js) {
301
- const cacheKey = _chunkW4XFWZB5js.getCacheKey.call(void 0, file);
302
- const asset = compilation.getAsset(file);
303
- if (!asset) {
304
- continue;
305
- }
306
- const absoluteFile = _chunk2WPTDMN3js.toAbsoluteOutputPath.call(void 0, file, outputDir);
307
- const initialSource = asset.source.source();
308
- const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
309
- jsTaskFactories.push(async () => {
310
- await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
311
- cache,
312
- cacheKey,
313
- rawSource: initialRawSource,
314
- applyResult(source) {
315
- compilation.updateAsset(file, source);
316
- },
317
- onCacheHit() {
318
- debug("js cache hit: %s", file);
319
- },
320
- transform: async () => {
321
- const currentAsset = compilation.getAsset(file);
322
- const currentSourceValue = _optionalChain([currentAsset, 'optionalAccess', _8 => _8.source, 'access', _9 => _9.source, 'call', _10 => _10()]);
323
- const currentSource = typeof currentSourceValue === "string" ? currentSourceValue : _nullishCoalesce(_optionalChain([currentSourceValue, 'optionalAccess', _11 => _11.toString, 'call', _12 => _12()]), () => ( ""));
324
- const { code, linked } = await jsHandler(currentSource, runtimeSet, {
325
- filename: absoluteFile,
326
- moduleGraph: moduleGraphOptions,
327
- babelParserOptions: {
328
- sourceFilename: absoluteFile
329
- }
330
- });
331
- const source = new ConcatSource(code);
332
- onUpdate(file, currentSource, code);
333
- debug("js handle: %s", file);
334
- applyLinkedResults(linked);
335
- return {
336
- result: source
337
- };
338
- }
339
- });
340
- });
341
- }
342
- }
343
- if (Array.isArray(groupedEntries.css)) {
344
- for (const element of groupedEntries.css) {
345
- const [file, originalSource] = element;
346
- const rawSource = originalSource.source().toString();
347
- const cacheKey = file;
348
- tasks.push(
349
- _chunkLTJQUORKjs.processCachedTask.call(void 0, {
350
- cache,
351
- cacheKey,
352
- rawSource,
353
- applyResult(source) {
354
- compilation.updateAsset(file, source);
355
- },
356
- onCacheHit() {
357
- debug("css cache hit: %s", file);
358
- },
359
- transform: async () => {
360
- await runtimeState.patchPromise;
361
- const { css } = await styleHandler(rawSource, {
362
- isMainChunk: mainCssChunkMatcher(file, this.appType),
363
- postcssOptions: {
364
- options: {
365
- from: file
366
- }
367
- },
368
- majorVersion: runtimeState.twPatcher.majorVersion
369
- });
370
- const source = new ConcatSource(css);
371
- onUpdate(file, rawSource, css);
372
- debug("css handle: %s", file);
373
- return {
374
- result: source
375
- };
376
- }
377
- })
378
- );
379
- }
380
- }
381
- _chunk2WPTDMN3js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
382
- await Promise.all(tasks);
383
- debug("end");
384
- onEnd();
385
- }
386
- );
387
- });
388
- }
389
- };
390
-
391
-
392
-
393
-
394
- exports.weappTailwindcssPackageDir = weappTailwindcssPackageDir; exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;