weapp-tailwindcss 4.7.9 → 4.8.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 (41) hide show
  1. package/dist/{chunk-JBZ63WDH.mjs → chunk-3RXY3OXF.mjs} +1 -1
  2. package/dist/{chunk-WSMHVHT4.mjs → chunk-5RHSVID3.mjs} +42 -2
  3. package/dist/{chunk-W7BVY5S5.js → chunk-A5VN7CO5.js} +16 -2
  4. package/dist/{chunk-PYXTMD6B.mjs → chunk-DKPIYG24.mjs} +1 -0
  5. package/dist/{chunk-DTBKYR3J.js → chunk-FQ5MKRKX.js} +57 -17
  6. package/dist/{chunk-RIMKL2AV.js → chunk-GI2M6KFD.js} +26 -18
  7. package/dist/{chunk-BLSNFAO7.mjs → chunk-QK5QBH6X.mjs} +11 -3
  8. package/dist/{chunk-SMEWY6FJ.js → chunk-QNGB574L.js} +6 -6
  9. package/dist/chunk-R3CUQGRM.js +59 -0
  10. package/dist/{chunk-TPBIR7NL.mjs → chunk-TTCMOWCO.mjs} +182 -8
  11. package/dist/{chunk-KZUIVLPP.mjs → chunk-TTIRN5LZ.mjs} +17 -7
  12. package/dist/chunk-UKAU6OXS.mjs +59 -0
  13. package/dist/{chunk-HPVYHFXX.js → chunk-X7QD7NUX.js} +213 -39
  14. package/dist/{chunk-SMYOFNHJ.js → chunk-ZSTF2AEN.js} +1 -0
  15. package/dist/cli.js +173 -10
  16. package/dist/cli.mjs +172 -9
  17. package/dist/core.js +8 -8
  18. package/dist/core.mjs +2 -2
  19. package/dist/defaults.js +2 -2
  20. package/dist/defaults.mjs +1 -1
  21. package/dist/gulp.js +4 -4
  22. package/dist/gulp.mjs +3 -3
  23. package/dist/index.d.mts +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +10 -8
  26. package/dist/index.mjs +11 -9
  27. package/dist/types.d.mts +9 -0
  28. package/dist/types.d.ts +9 -0
  29. package/dist/vite.js +5 -5
  30. package/dist/vite.mjs +4 -4
  31. package/dist/webpack.d.mts +2 -1
  32. package/dist/webpack.d.ts +2 -1
  33. package/dist/webpack.js +8 -6
  34. package/dist/webpack.mjs +9 -7
  35. package/dist/webpack4.d.mts +2 -1
  36. package/dist/webpack4.d.ts +2 -1
  37. package/dist/webpack4.js +27 -19
  38. package/dist/webpack4.mjs +13 -5
  39. package/package.json +3 -3
  40. package/dist/chunk-2F7HOQQY.mjs +0 -8
  41. package/dist/chunk-6GP37C26.js +0 -8
@@ -7,7 +7,7 @@ import {
7
7
  createTailwindPatchPromise,
8
8
  getCompilerContext,
9
9
  refreshTailwindRuntimeState
10
- } from "./chunk-TPBIR7NL.mjs";
10
+ } from "./chunk-TTCMOWCO.mjs";
11
11
 
12
12
  // src/bundlers/gulp/index.ts
13
13
  import { Buffer } from "buffer";
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  pushConcurrentTaskFactories,
3
3
  resolveOutputSpecifier,
4
+ resolvePackageDir,
4
5
  toAbsoluteOutputPath
5
- } from "./chunk-KZUIVLPP.mjs";
6
+ } from "./chunk-TTIRN5LZ.mjs";
6
7
  import {
7
8
  processCachedTask
8
9
  } from "./chunk-RRHPTTCP.mjs";
@@ -17,7 +18,7 @@ import {
17
18
  replaceWxml,
18
19
  toCustomAttributesEntities,
19
20
  vitePluginName
20
- } from "./chunk-TPBIR7NL.mjs";
21
+ } from "./chunk-TTCMOWCO.mjs";
21
22
  import {
22
23
  getGroupedEntries
23
24
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -214,6 +215,28 @@ async function formatPostcssSourceMap(rawMap, file) {
214
215
 
215
216
  // src/bundlers/vite/index.ts
216
217
  var debug = createDebug();
218
+ var weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
219
+ var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
220
+ var tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
221
+ function resolveCssTailwindImport(id) {
222
+ if (!tailwindcssImportRE.test(id)) {
223
+ return null;
224
+ }
225
+ if (id === "tailwindcss" || id === "tailwindcss$") {
226
+ return `${weappTailwindcssDirPosix}/index.css`;
227
+ }
228
+ if (id.startsWith("tailwindcss/")) {
229
+ return `${weappTailwindcssDirPosix}/${id.slice("tailwindcss/".length)}`;
230
+ }
231
+ return null;
232
+ }
233
+ function isCssLikeImporter(importer) {
234
+ if (!importer) {
235
+ return false;
236
+ }
237
+ const normalized = cleanUrl(importer);
238
+ return isCSSRequest(normalized);
239
+ }
217
240
  function readOutputEntry(entry) {
218
241
  if (entry.output.type === "chunk") {
219
242
  return entry.output.code;
@@ -342,7 +365,24 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
342
365
  }
343
366
  }
344
367
  onLoad();
368
+ const rewritePlugins = opts.rewriteCssImports === false ? [] : [
369
+ {
370
+ name: `${vitePluginName}:rewrite-css-imports`,
371
+ enforce: "pre",
372
+ resolveId(id, importer) {
373
+ const replacement = resolveCssTailwindImport(id);
374
+ if (!replacement) {
375
+ return null;
376
+ }
377
+ if (importer && !isCssLikeImporter(importer)) {
378
+ return null;
379
+ }
380
+ return replacement;
381
+ }
382
+ }
383
+ ];
345
384
  const plugins = [
385
+ ...rewritePlugins,
346
386
  {
347
387
  name: `${vitePluginName}:post`,
348
388
  enforce: "post",
@@ -1,5 +1,18 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/bundlers/shared/module-graph.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+ var _chunkXGRBCPBIjs = require('./chunk-XGRBCPBI.js');
4
+
5
+ // src/utils/resolve-package.ts
6
+ var _module = require('module');
2
7
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
+ var require2 = _module.createRequire.call(void 0, _chunkXGRBCPBIjs.importMetaUrl);
9
+ function resolvePackageDir(name) {
10
+ const pkgPath = require2.resolve(`${name}/package.json`);
11
+ return _path2.default.dirname(pkgPath);
12
+ }
13
+
14
+ // src/bundlers/shared/module-graph.ts
15
+
3
16
  var QUERY_HASH_RE = /[?#].*$/u;
4
17
  var PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
5
18
  var VIRTUAL_PREFIX = "\0";
@@ -97,4 +110,5 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
97
110
 
98
111
 
99
112
 
100
- exports.toAbsoluteOutputPath = toAbsoluteOutputPath; exports.resolveOutputSpecifier = resolveOutputSpecifier; exports.pushConcurrentTaskFactories = pushConcurrentTaskFactories;
113
+
114
+ exports.resolvePackageDir = resolvePackageDir; exports.toAbsoluteOutputPath = toAbsoluteOutputPath; exports.resolveOutputSpecifier = resolveOutputSpecifier; exports.pushConcurrentTaskFactories = pushConcurrentTaskFactories;
@@ -80,6 +80,7 @@ function getDefaultOptions() {
80
80
  cssChildCombinatorReplaceValue: ["view", "text"],
81
81
  inlineWxs: false,
82
82
  injectAdditionalCssVarScope: false,
83
+ rewriteCssImports: true,
83
84
  jsPreserveClass: (keyword) => {
84
85
  if (keyword === "*") {
85
86
  return true;
@@ -2,7 +2,8 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkW7BVY5S5js = require('./chunk-W7BVY5S5.js');
5
+
6
+ var _chunkA5VN7CO5js = require('./chunk-A5VN7CO5.js');
6
7
 
7
8
 
8
9
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
@@ -17,7 +18,7 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
17
18
 
18
19
 
19
20
 
20
- var _chunkHPVYHFXXjs = require('./chunk-HPVYHFXX.js');
21
+ var _chunkX7QD7NUXjs = require('./chunk-X7QD7NUX.js');
21
22
 
22
23
 
23
24
  var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
@@ -49,7 +50,7 @@ function updateStaticAttribute(ms, prop) {
49
50
  const start = prop.value.loc.start.offset + 1;
50
51
  const end = prop.value.loc.end.offset - 1;
51
52
  if (start < end) {
52
- ms.update(start, end, _chunkHPVYHFXXjs.replaceWxml.call(void 0, prop.value.content));
53
+ ms.update(start, end, _chunkX7QD7NUXjs.replaceWxml.call(void 0, prop.value.content));
53
54
  }
54
55
  }
55
56
  function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
@@ -61,7 +62,7 @@ function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
61
62
  if (start >= end) {
62
63
  return;
63
64
  }
64
- const generated = _chunkHPVYHFXXjs.generateCode.call(void 0, prop.exp.content, {
65
+ const generated = _chunkX7QD7NUXjs.generateCode.call(void 0, prop.exp.content, {
65
66
  jsHandler,
66
67
  runtimeSet,
67
68
  wrapExpression: true
@@ -90,7 +91,7 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
90
91
  return;
91
92
  }
92
93
  const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
93
- const matchCustomAttribute = _chunkHPVYHFXXjs.createAttributeMatcher.call(void 0, customAttributesEntities);
94
+ const matchCustomAttribute = _chunkX7QD7NUXjs.createAttributeMatcher.call(void 0, customAttributesEntities);
94
95
  const ms = new (0, _magicstring2.default)(code);
95
96
  const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
96
97
  if (errors.length === 0) {
@@ -213,7 +214,29 @@ async function formatPostcssSourceMap(rawMap, file) {
213
214
  }
214
215
 
215
216
  // src/bundlers/vite/index.ts
216
- var debug = _chunkHPVYHFXXjs.createDebug.call(void 0, );
217
+ var debug = _chunkX7QD7NUXjs.createDebug.call(void 0, );
218
+ var weappTailwindcssPackageDir = _chunkA5VN7CO5js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
219
+ var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
220
+ var tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
221
+ function resolveCssTailwindImport(id) {
222
+ if (!tailwindcssImportRE.test(id)) {
223
+ return null;
224
+ }
225
+ if (id === "tailwindcss" || id === "tailwindcss$") {
226
+ return `${weappTailwindcssDirPosix}/index.css`;
227
+ }
228
+ if (id.startsWith("tailwindcss/")) {
229
+ return `${weappTailwindcssDirPosix}/${id.slice("tailwindcss/".length)}`;
230
+ }
231
+ return null;
232
+ }
233
+ function isCssLikeImporter(importer) {
234
+ if (!importer) {
235
+ return false;
236
+ }
237
+ const normalized = cleanUrl(importer);
238
+ return isCSSRequest(normalized);
239
+ }
217
240
  function readOutputEntry(entry) {
218
241
  if (entry.output.type === "chunk") {
219
242
  return entry.output.code;
@@ -243,7 +266,7 @@ function isJavaScriptEntry(entry) {
243
266
  function createBundleModuleGraphOptions(outputDir, entries) {
244
267
  return {
245
268
  resolve(specifier, importer) {
246
- return _chunkW7BVY5S5js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => entries.has(candidate));
269
+ return _chunkA5VN7CO5js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => entries.has(candidate));
247
270
  },
248
271
  load(id) {
249
272
  const entry = entries.get(id);
@@ -280,7 +303,7 @@ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
280
303
  }
281
304
  }
282
305
  function UnifiedViteWeappTailwindcssPlugin(options = {}) {
283
- const opts = _chunkHPVYHFXXjs.getCompilerContext.call(void 0, options);
306
+ const opts = _chunkX7QD7NUXjs.getCompilerContext.call(void 0, options);
284
307
  const {
285
308
  disabled,
286
309
  customAttributes,
@@ -302,17 +325,17 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
302
325
  if (disabled) {
303
326
  return;
304
327
  }
305
- const customAttributesEntities = _chunkHPVYHFXXjs.toCustomAttributesEntities.call(void 0, customAttributes);
328
+ const customAttributesEntities = _chunkX7QD7NUXjs.toCustomAttributesEntities.call(void 0, customAttributes);
306
329
  const runtimeState = {
307
330
  twPatcher: initialTwPatcher,
308
- patchPromise: _chunkHPVYHFXXjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
331
+ patchPromise: _chunkX7QD7NUXjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
309
332
  refreshTailwindcssPatcher
310
333
  };
311
334
  let runtimeSet;
312
335
  let runtimeSetPromise;
313
336
  let resolvedConfig;
314
337
  async function refreshRuntimeState(force) {
315
- const refreshed = await _chunkHPVYHFXXjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
338
+ const refreshed = await _chunkX7QD7NUXjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
316
339
  if (refreshed) {
317
340
  runtimeSet = void 0;
318
341
  runtimeSetPromise = void 0;
@@ -325,7 +348,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
325
348
  return runtimeSet;
326
349
  }
327
350
  if (force || !runtimeSetPromise) {
328
- const task2 = _chunkHPVYHFXXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
351
+ const task2 = _chunkX7QD7NUXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
329
352
  force: force || !runtimeSet,
330
353
  skipRefresh: force
331
354
  });
@@ -342,9 +365,26 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
342
365
  }
343
366
  }
344
367
  onLoad();
368
+ const rewritePlugins = opts.rewriteCssImports === false ? [] : [
369
+ {
370
+ name: `${_chunkX7QD7NUXjs.vitePluginName}:rewrite-css-imports`,
371
+ enforce: "pre",
372
+ resolveId(id, importer) {
373
+ const replacement = resolveCssTailwindImport(id);
374
+ if (!replacement) {
375
+ return null;
376
+ }
377
+ if (importer && !isCssLikeImporter(importer)) {
378
+ return null;
379
+ }
380
+ return replacement;
381
+ }
382
+ }
383
+ ];
345
384
  const plugins = [
385
+ ...rewritePlugins,
346
386
  {
347
- name: `${_chunkHPVYHFXXjs.vitePluginName}:post`,
387
+ name: `${_chunkX7QD7NUXjs.vitePluginName}:post`,
348
388
  enforce: "post",
349
389
  configResolved(config) {
350
390
  resolvedConfig = config;
@@ -370,7 +410,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
370
410
  for (const [fileName, output] of entries) {
371
411
  const entry = { fileName, output };
372
412
  if (isJavaScriptEntry(entry)) {
373
- const absolute = _chunkW7BVY5S5js.toAbsoluteOutputPath.call(void 0, fileName, outDir);
413
+ const absolute = _chunkA5VN7CO5js.toAbsoluteOutputPath.call(void 0, fileName, outDir);
374
414
  jsEntries.set(absolute, entry);
375
415
  }
376
416
  }
@@ -434,7 +474,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
434
474
  if (Array.isArray(groupedEntries.js)) {
435
475
  for (const [file, originalSource] of groupedEntries.js) {
436
476
  if (originalSource.type === "chunk") {
437
- const absoluteFile = _chunkW7BVY5S5js.toAbsoluteOutputPath.call(void 0, file, outDir);
477
+ const absoluteFile = _chunkA5VN7CO5js.toAbsoluteOutputPath.call(void 0, file, outDir);
438
478
  const initialRawSource = originalSource.code;
439
479
  jsTaskFactories.push(async () => {
440
480
  await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
@@ -460,7 +500,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
460
500
  });
461
501
  });
462
502
  } else if (uniAppX && originalSource.type === "asset") {
463
- const absoluteFile = _chunkW7BVY5S5js.toAbsoluteOutputPath.call(void 0, file, outDir);
503
+ const absoluteFile = _chunkA5VN7CO5js.toAbsoluteOutputPath.call(void 0, file, outDir);
464
504
  const rawSource = originalSource.source.toString();
465
505
  jsTaskFactories.push(async () => {
466
506
  await _chunkLTJQUORKjs.processCachedTask.call(void 0, {
@@ -531,7 +571,7 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
531
571
  );
532
572
  }
533
573
  }
534
- _chunkW7BVY5S5js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
574
+ _chunkA5VN7CO5js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
535
575
  await Promise.all(tasks);
536
576
  for (const apply of pendingLinkedUpdates) {
537
577
  apply();
@@ -1,11 +1,13 @@
1
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
2
 
3
- var _chunk6GP37C26js = require('./chunk-6GP37C26.js');
4
3
 
4
+ var _chunkR3CUQGRMjs = require('./chunk-R3CUQGRM.js');
5
5
 
6
6
 
7
7
 
8
- var _chunkW7BVY5S5js = require('./chunk-W7BVY5S5.js');
8
+
9
+
10
+ var _chunkA5VN7CO5js = require('./chunk-A5VN7CO5.js');
9
11
 
10
12
 
11
13
  var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
@@ -16,7 +18,7 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
16
18
 
17
19
 
18
20
 
19
- var _chunkHPVYHFXXjs = require('./chunk-HPVYHFXX.js');
21
+ var _chunkX7QD7NUXjs = require('./chunk-X7QD7NUX.js');
20
22
 
21
23
 
22
24
  var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
@@ -25,10 +27,11 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
25
27
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
26
28
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
27
29
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
28
- var debug = _chunkHPVYHFXXjs.createDebug.call(void 0, );
30
+ var debug = _chunkX7QD7NUXjs.createDebug.call(void 0, );
31
+ var weappTailwindcssPackageDir = _chunkA5VN7CO5js.resolvePackageDir.call(void 0, "weapp-tailwindcss");
29
32
  var UnifiedWebpackPluginV5 = class {
30
33
  constructor(options = {}) {
31
- this.options = _chunkHPVYHFXXjs.getCompilerContext.call(void 0, options);
34
+ this.options = _chunkX7QD7NUXjs.getCompilerContext.call(void 0, options);
32
35
  this.appType = this.options.appType;
33
36
  }
34
37
  apply(compiler) {
@@ -50,20 +53,24 @@ var UnifiedWebpackPluginV5 = class {
50
53
  if (disabled) {
51
54
  return;
52
55
  }
56
+ _chunkR3CUQGRMjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
57
+ pkgDir: weappTailwindcssPackageDir,
58
+ enabled: this.options.rewriteCssImports !== false
59
+ });
53
60
  const runtimeState = {
54
61
  twPatcher: initialTwPatcher,
55
- patchPromise: _chunkHPVYHFXXjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
62
+ patchPromise: _chunkX7QD7NUXjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
56
63
  refreshTailwindcssPatcher
57
64
  };
58
65
  const refreshRuntimeState = async (force) => {
59
- await _chunkHPVYHFXXjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
66
+ await _chunkX7QD7NUXjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
60
67
  };
61
68
  const { Compilation, sources, NormalModule } = compiler.webpack;
62
69
  const { ConcatSource } = sources;
63
70
  async function getClassSetInLoader() {
64
71
  await refreshRuntimeState(true);
65
72
  await runtimeState.patchPromise;
66
- await _chunkHPVYHFXXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
73
+ await _chunkX7QD7NUXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
67
74
  }
68
75
  onLoad();
69
76
  const loader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-loader.js")));
@@ -76,8 +83,8 @@ var UnifiedWebpackPluginV5 = class {
76
83
  ident: null,
77
84
  type: null
78
85
  };
79
- compiler.hooks.compilation.tap(_chunkHPVYHFXXjs.pluginName, (compilation) => {
80
- NormalModule.getCompilationHooks(compilation).loader.tap(_chunkHPVYHFXXjs.pluginName, (_loaderContext, module) => {
86
+ compiler.hooks.compilation.tap(_chunkX7QD7NUXjs.pluginName, (compilation) => {
87
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkX7QD7NUXjs.pluginName, (_loaderContext, module) => {
81
88
  if (isExisted) {
82
89
  const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
83
90
  if (idx > -1) {
@@ -87,7 +94,7 @@ var UnifiedWebpackPluginV5 = class {
87
94
  });
88
95
  compilation.hooks.processAssets.tapPromise(
89
96
  {
90
- name: _chunkHPVYHFXXjs.pluginName,
97
+ name: _chunkX7QD7NUXjs.pluginName,
91
98
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
92
99
  },
93
100
  async (assets) => {
@@ -105,13 +112,13 @@ var UnifiedWebpackPluginV5 = class {
105
112
  const jsAssets = /* @__PURE__ */ new Map();
106
113
  for (const [file] of entries) {
107
114
  if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
108
- const absolute = _chunkW7BVY5S5js.toAbsoluteOutputPath.call(void 0, file, outputDir);
115
+ const absolute = _chunkA5VN7CO5js.toAbsoluteOutputPath.call(void 0, file, outputDir);
109
116
  jsAssets.set(absolute, file);
110
117
  }
111
118
  }
112
119
  const moduleGraphOptions = {
113
120
  resolve(specifier, importer) {
114
- return _chunkW7BVY5S5js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
121
+ return _chunkA5VN7CO5js.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
115
122
  },
116
123
  load: (id) => {
117
124
  const assetName = jsAssets.get(id);
@@ -156,7 +163,7 @@ var UnifiedWebpackPluginV5 = class {
156
163
  const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
157
164
  await refreshRuntimeState(true);
158
165
  await runtimeState.patchPromise;
159
- const runtimeSet = await _chunkHPVYHFXXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
166
+ const runtimeSet = await _chunkX7QD7NUXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
160
167
  debug("get runtimeSet, class count: %d", runtimeSet.size);
161
168
  const tasks = [];
162
169
  if (Array.isArray(groupedEntries.html)) {
@@ -193,12 +200,12 @@ var UnifiedWebpackPluginV5 = class {
193
200
  const jsTaskFactories = [];
194
201
  if (Array.isArray(groupedEntries.js)) {
195
202
  for (const [file] of groupedEntries.js) {
196
- const cacheKey = _chunk6GP37C26js.getCacheKey.call(void 0, file);
203
+ const cacheKey = _chunkR3CUQGRMjs.getCacheKey.call(void 0, file);
197
204
  const asset = compilation.getAsset(file);
198
205
  if (!asset) {
199
206
  continue;
200
207
  }
201
- const absoluteFile = _chunkW7BVY5S5js.toAbsoluteOutputPath.call(void 0, file, outputDir);
208
+ const absoluteFile = _chunkA5VN7CO5js.toAbsoluteOutputPath.call(void 0, file, outputDir);
202
209
  const initialSource = asset.source.source();
203
210
  const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
204
211
  jsTaskFactories.push(async () => {
@@ -273,7 +280,7 @@ var UnifiedWebpackPluginV5 = class {
273
280
  );
274
281
  }
275
282
  }
276
- _chunkW7BVY5S5js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
283
+ _chunkA5VN7CO5js.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
277
284
  await Promise.all(tasks);
278
285
  debug("end");
279
286
  onEnd();
@@ -285,4 +292,5 @@ var UnifiedWebpackPluginV5 = class {
285
292
 
286
293
 
287
294
 
288
- exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;
295
+
296
+ exports.weappTailwindcssPackageDir = weappTailwindcssPackageDir; exports.UnifiedWebpackPluginV5 = UnifiedWebpackPluginV5;
@@ -1,11 +1,13 @@
1
1
  import {
2
+ applyTailwindcssCssImportRewrite,
2
3
  getCacheKey
3
- } from "./chunk-2F7HOQQY.mjs";
4
+ } from "./chunk-UKAU6OXS.mjs";
4
5
  import {
5
6
  pushConcurrentTaskFactories,
6
7
  resolveOutputSpecifier,
8
+ resolvePackageDir,
7
9
  toAbsoluteOutputPath
8
- } from "./chunk-KZUIVLPP.mjs";
10
+ } from "./chunk-TTIRN5LZ.mjs";
9
11
  import {
10
12
  processCachedTask
11
13
  } from "./chunk-RRHPTTCP.mjs";
@@ -16,7 +18,7 @@ import {
16
18
  getCompilerContext,
17
19
  pluginName,
18
20
  refreshTailwindRuntimeState
19
- } from "./chunk-TPBIR7NL.mjs";
21
+ } from "./chunk-TTCMOWCO.mjs";
20
22
  import {
21
23
  getGroupedEntries
22
24
  } from "./chunk-ZNKIYZRQ.mjs";
@@ -29,6 +31,7 @@ import fs from "fs";
29
31
  import path from "path";
30
32
  import process from "process";
31
33
  var debug = createDebug();
34
+ var weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
32
35
  var UnifiedWebpackPluginV5 = class {
33
36
  constructor(options = {}) {
34
37
  this.options = getCompilerContext(options);
@@ -53,6 +56,10 @@ var UnifiedWebpackPluginV5 = class {
53
56
  if (disabled) {
54
57
  return;
55
58
  }
59
+ applyTailwindcssCssImportRewrite(compiler, {
60
+ pkgDir: weappTailwindcssPackageDir,
61
+ enabled: this.options.rewriteCssImports !== false
62
+ });
56
63
  const runtimeState = {
57
64
  twPatcher: initialTwPatcher,
58
65
  patchPromise: createTailwindPatchPromise(initialTwPatcher),
@@ -287,5 +294,6 @@ var UnifiedWebpackPluginV5 = class {
287
294
  };
288
295
 
289
296
  export {
297
+ weappTailwindcssPackageDir,
290
298
  UnifiedWebpackPluginV5
291
299
  };
@@ -7,7 +7,7 @@ var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
7
7
 
8
8
 
9
9
 
10
- var _chunkHPVYHFXXjs = require('./chunk-HPVYHFXX.js');
10
+ var _chunkX7QD7NUXjs = require('./chunk-X7QD7NUX.js');
11
11
 
12
12
  // src/bundlers/gulp/index.ts
13
13
  var _buffer = require('buffer');
@@ -15,21 +15,21 @@ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
15
15
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
16
16
  var _process = require('process'); var _process2 = _interopRequireDefault(_process);
17
17
  var _stream = require('stream'); var _stream2 = _interopRequireDefault(_stream);
18
- var debug = _chunkHPVYHFXXjs.createDebug.call(void 0, );
18
+ var debug = _chunkX7QD7NUXjs.createDebug.call(void 0, );
19
19
  var Transform = _stream2.default.Transform;
20
20
  function createPlugins(options = {}) {
21
- const opts = _chunkHPVYHFXXjs.getCompilerContext.call(void 0, options);
21
+ const opts = _chunkX7QD7NUXjs.getCompilerContext.call(void 0, options);
22
22
  const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
23
23
  let runtimeSet = /* @__PURE__ */ new Set();
24
24
  const runtimeState = {
25
25
  twPatcher: initialTwPatcher,
26
- patchPromise: _chunkHPVYHFXXjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
26
+ patchPromise: _chunkX7QD7NUXjs.createTailwindPatchPromise.call(void 0, initialTwPatcher),
27
27
  refreshTailwindcssPatcher
28
28
  };
29
29
  const MODULE_EXTENSIONS = [".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx"];
30
30
  let runtimeSetInitialized = false;
31
31
  async function refreshRuntimeState(force) {
32
- await _chunkHPVYHFXXjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
32
+ await _chunkX7QD7NUXjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
33
33
  }
34
34
  async function refreshRuntimeSet(force = false) {
35
35
  await refreshRuntimeState(force);
@@ -37,7 +37,7 @@ function createPlugins(options = {}) {
37
37
  if (!force && runtimeSetInitialized && runtimeSet.size > 0) {
38
38
  return runtimeSet;
39
39
  }
40
- runtimeSet = await _chunkHPVYHFXXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force, skipRefresh: force });
40
+ runtimeSet = await _chunkX7QD7NUXjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force, skipRefresh: force });
41
41
  runtimeSetInitialized = true;
42
42
  return runtimeSet;
43
43
  }
@@ -0,0 +1,59 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
+ var _chunkX7QD7NUXjs = require('./chunk-X7QD7NUX.js');
4
+
5
+ // src/bundlers/webpack/shared/css-imports.ts
6
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
7
+ var CSS_EXT_RE = /\.(?:css|scss|sass|less|styl|pcss)$/i;
8
+ function stripResourceQuery(file) {
9
+ let idx = file.indexOf("?");
10
+ if (idx === -1) {
11
+ idx = file.indexOf("&");
12
+ }
13
+ return idx === -1 ? file : file.slice(0, idx);
14
+ }
15
+ function rewriteTailwindcssRequestForCss(data, pkgDir) {
16
+ if (!data) {
17
+ return;
18
+ }
19
+ let request = data.request;
20
+ if (!request) {
21
+ return;
22
+ }
23
+ if (request !== "tailwindcss" && request !== "tailwindcss$" && !request.startsWith("tailwindcss/")) {
24
+ return;
25
+ }
26
+ const issuer = _optionalChain([data, 'access', _ => _.contextInfo, 'optionalAccess', _2 => _2.issuer]);
27
+ if (!issuer) {
28
+ return;
29
+ }
30
+ const normalizedIssuer = stripResourceQuery(issuer);
31
+ if (!CSS_EXT_RE.test(normalizedIssuer)) {
32
+ return;
33
+ }
34
+ if (request === "tailwindcss$") {
35
+ request = "tailwindcss";
36
+ }
37
+ const subpath = request === "tailwindcss" ? "index.css" : request.slice("tailwindcss/".length);
38
+ data.request = _path2.default.join(pkgDir, subpath);
39
+ }
40
+ function applyTailwindcssCssImportRewrite(compiler, options) {
41
+ if (!options.enabled) {
42
+ return;
43
+ }
44
+ compiler.hooks.normalModuleFactory.tap(_chunkX7QD7NUXjs.pluginName, (factory) => {
45
+ factory.hooks.beforeResolve.tap(_chunkX7QD7NUXjs.pluginName, (data) => {
46
+ rewriteTailwindcssRequestForCss(data, options.pkgDir);
47
+ });
48
+ });
49
+ }
50
+
51
+ // src/bundlers/webpack/BaseUnifiedPlugin/shared.ts
52
+ function getCacheKey(filename) {
53
+ return filename;
54
+ }
55
+
56
+
57
+
58
+
59
+ exports.applyTailwindcssCssImportRewrite = applyTailwindcssCssImportRewrite; exports.getCacheKey = getCacheKey;