weapp-tailwindcss 5.0.0-next.17 → 5.0.0-next.19

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 (57) hide show
  1. package/README.md +2 -2
  2. package/dist/{bundle-state-DDgxuERW.js → bundle-state-C9G1XBp0.js} +83 -2
  3. package/dist/{bundle-state-YW-zLcsc.mjs → bundle-state-u4DFiZEj.mjs} +47 -3
  4. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  5. package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
  6. package/dist/bundlers/vite/generate-bundle.d.ts +4 -0
  7. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  8. package/dist/bundlers/vite/rewrite-css-imports.d.ts +3 -0
  9. package/dist/bundlers/vite/source-candidates.d.ts +1 -0
  10. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -0
  11. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +5 -0
  12. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  13. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -8
  14. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  15. package/dist/cli.js +63 -61
  16. package/dist/cli.mjs +63 -61
  17. package/dist/core.js +1 -1
  18. package/dist/core.mjs +1 -1
  19. package/dist/{generator-BIEhxFdv.js → generator-CQ8A3YVm.js} +1 -1
  20. package/dist/{generator-Ber8UVgv.mjs → generator-CbjnpVed.mjs} +1 -1
  21. package/dist/generator.js +2 -2
  22. package/dist/generator.mjs +2 -2
  23. package/dist/gulp.js +5 -5
  24. package/dist/gulp.mjs +5 -5
  25. package/dist/{incremental-runtime-class-set-CfznDtJ0.js → incremental-runtime-class-set-BMo8s7do.js} +54 -21
  26. package/dist/{incremental-runtime-class-set-DC0RsBbK.mjs → incremental-runtime-class-set-Cwq1Wbo2.mjs} +52 -19
  27. package/dist/index.js +4 -4
  28. package/dist/index.mjs +4 -4
  29. package/dist/{postcss-DW08tZXt.mjs → postcss-CLQ3yVXP.mjs} +3 -20
  30. package/dist/{postcss-DCOUtuwI.js → postcss-CXJLLWRe.js} +3 -20
  31. package/dist/postcss.js +1 -1
  32. package/dist/postcss.mjs +1 -1
  33. package/dist/{precheck-CX-5VqM1.mjs → precheck-Bbcmh24Z.mjs} +2 -2
  34. package/dist/{precheck-CZfnh4T6.js → precheck-CTRQCNuH.js} +2 -2
  35. package/dist/presets.js +2 -2
  36. package/dist/presets.mjs +2 -2
  37. package/dist/{postcss-CZE8k8oP.js → runtime-registry-D5qnaSpo.js} +33 -0
  38. package/dist/{source-candidates-DGlDzkvf.mjs → source-candidates-B3NL91dO.mjs} +23 -73
  39. package/dist/{source-candidates-BDyoPviV.js → source-candidates-CVp7TQFL.js} +23 -75
  40. package/dist/tailwindcss/source-scan.d.ts +10 -0
  41. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  42. package/dist/tailwindcss/v4-engine/types.d.ts +3 -0
  43. package/dist/{tailwindcss-BVoa7vx-.js → tailwindcss-DO30H8ux.js} +1 -1
  44. package/dist/{tailwindcss-D74Wk4ys.mjs → tailwindcss-P0OQvEif.mjs} +1 -1
  45. package/dist/{v3-engine-CCxDqZ8e.mjs → v3-engine-DHsPM4ye.mjs} +176 -149
  46. package/dist/{v3-engine-BRInt2DS.js → v3-engine-DpaX1FqH.js} +209 -146
  47. package/dist/{vite-bmU2kkO6.mjs → vite-BfR3PR2w.mjs} +311 -118
  48. package/dist/{vite-DnHdmHHD.js → vite-D82lLEfX.js} +318 -123
  49. package/dist/vite.js +1 -1
  50. package/dist/vite.mjs +1 -1
  51. package/dist/weapp-tw-css-import-rewrite-loader.js +5018 -86
  52. package/dist/weapp-tw-runtime-classset-loader.js +7 -20
  53. package/dist/{webpack-BkBoEn4k.mjs → webpack-BY-mkkMS.mjs} +67 -16
  54. package/dist/{webpack-SxEdWHlL.js → webpack-cMf0bWIS.js} +67 -16
  55. package/dist/webpack.js +1 -1
  56. package/dist/webpack.mjs +1 -1
  57. package/package.json +6 -6
package/README.md CHANGED
@@ -73,9 +73,9 @@
73
73
 
74
74
  ## [配置项参考](https://tw.icebreaker.top/docs/api/interfaces/UserDefinedOptions)
75
75
 
76
- ### Tailwind CSS v4 自动前缀
76
+ ### Tailwind CSS 自动前缀
77
77
 
78
- 在 Tailwind CSS v4 场景下,`weapp-tailwindcss` 会默认对生成后的小程序 CSS 执行内置 `autoprefixer` 后处理,用于补齐小程序 WebView 需要的兼容前缀。例如 `bg-clip-text` 会输出 `-webkit-background-clip: text`,从而支持渐变文字。
78
+ 在 Tailwind CSS v3 / v4 场景下,`weapp-tailwindcss` 会默认对生成后的小程序 CSS 执行内置 `autoprefixer` 后处理,用于补齐小程序 WebView 需要的兼容前缀。例如 `bg-clip-text` 会输出 `-webkit-background-clip: text`,从而支持渐变文字。
79
79
 
80
80
  通常不再需要在业务项目的 `postcss.config.js` 中手动配置 `autoprefixer`。如果项目已经显式配置了 `autoprefixer`,内置后处理会避免重复追加。需要关闭时可配置:
81
81
 
@@ -1,8 +1,11 @@
1
1
  const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_precheck = require("./precheck-CZfnh4T6.js");
2
+ const require_precheck = require("./precheck-CTRQCNuH.js");
3
3
  let node_module = require("node:module");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_chunk.__toESM(node_path);
6
+ let node_process = require("node:process");
7
+ node_process = require_chunk.__toESM(node_process);
8
+ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
6
9
  let node_buffer = require("node:buffer");
7
10
  let htmlparser2 = require("htmlparser2");
8
11
  //#region src/bundlers/shared/module-graph.ts
@@ -73,6 +76,35 @@ function isSourceStyleRequest(request) {
73
76
  return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
74
77
  }
75
78
  //#endregion
79
+ //#region src/bundlers/vite/utils.ts
80
+ function slash(p) {
81
+ return (0, _weapp_tailwindcss_shared.ensurePosix)(p);
82
+ }
83
+ const isWindows = node_process.default.platform === "win32";
84
+ const cssLangRE = new RegExp(`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`);
85
+ function isCSSRequest(request) {
86
+ return cssLangRE.test(request) || isSourceStyleRequest(request);
87
+ }
88
+ function normalizePath(id) {
89
+ return node_path.default.posix.normalize(isWindows ? (0, _weapp_tailwindcss_shared.ensurePosix)(id) : id);
90
+ }
91
+ async function formatPostcssSourceMap(rawMap, file) {
92
+ const inputFileDir = node_path.default.dirname(file);
93
+ const sources = rawMap.sources.map((source) => {
94
+ const cleanSource = (0, _weapp_tailwindcss_shared.cleanUrl)(decodeURIComponent(source));
95
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) return `\0${cleanSource}`;
96
+ return normalizePath(node_path.default.resolve(inputFileDir, cleanSource));
97
+ });
98
+ return {
99
+ file,
100
+ mappings: rawMap.mappings,
101
+ names: rawMap.names,
102
+ sources,
103
+ sourcesContent: rawMap.sourcesContent,
104
+ version: rawMap.version
105
+ };
106
+ }
107
+ //#endregion
76
108
  //#region src/utils/disabled.ts
77
109
  function resolvePluginDisabledState(disabled) {
78
110
  if (disabled === true) return { plugin: true };
@@ -87,6 +119,19 @@ function resolvePackageDir(name) {
87
119
  return node_path.default.dirname(pkgPath);
88
120
  }
89
121
  //#endregion
122
+ //#region src/bundlers/shared/generated-css-marker.ts
123
+ const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/i;
124
+ const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/gi;
125
+ function createBundlerGeneratedCssMarker(bundler, file) {
126
+ return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
127
+ }
128
+ function hasBundlerGeneratedCssMarker(source) {
129
+ return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
130
+ }
131
+ function stripBundlerGeneratedCssMarkers(source) {
132
+ return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "");
133
+ }
134
+ //#endregion
90
135
  //#region src/bundlers/shared/run-tasks.ts
91
136
  async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
92
137
  if (factories.length === 0) return [];
@@ -267,7 +312,7 @@ function readEntrySource(output) {
267
312
  return output.source.toString();
268
313
  }
269
314
  function classifyBundleEntry(file, opts) {
270
- if (opts.cssMatcher(file)) return "css";
315
+ if (opts.cssMatcher(file) || isCSSRequest(file)) return "css";
271
316
  if (opts.htmlMatcher(file)) return "html";
272
317
  if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
273
318
  return "other";
@@ -393,6 +438,30 @@ Object.defineProperty(exports, "createBundleModuleGraphOptions", {
393
438
  return createBundleModuleGraphOptions;
394
439
  }
395
440
  });
441
+ Object.defineProperty(exports, "createBundlerGeneratedCssMarker", {
442
+ enumerable: true,
443
+ get: function() {
444
+ return createBundlerGeneratedCssMarker;
445
+ }
446
+ });
447
+ Object.defineProperty(exports, "formatPostcssSourceMap", {
448
+ enumerable: true,
449
+ get: function() {
450
+ return formatPostcssSourceMap;
451
+ }
452
+ });
453
+ Object.defineProperty(exports, "hasBundlerGeneratedCssMarker", {
454
+ enumerable: true,
455
+ get: function() {
456
+ return hasBundlerGeneratedCssMarker;
457
+ }
458
+ });
459
+ Object.defineProperty(exports, "isCSSRequest", {
460
+ enumerable: true,
461
+ get: function() {
462
+ return isCSSRequest;
463
+ }
464
+ });
396
465
  Object.defineProperty(exports, "isSourceStyleRequest", {
397
466
  enumerable: true,
398
467
  get: function() {
@@ -429,6 +498,18 @@ Object.defineProperty(exports, "resolvePluginDisabledState", {
429
498
  return resolvePluginDisabledState;
430
499
  }
431
500
  });
501
+ Object.defineProperty(exports, "slash", {
502
+ enumerable: true,
503
+ get: function() {
504
+ return slash;
505
+ }
506
+ });
507
+ Object.defineProperty(exports, "stripBundlerGeneratedCssMarkers", {
508
+ enumerable: true,
509
+ get: function() {
510
+ return stripBundlerGeneratedCssMarkers;
511
+ }
512
+ });
432
513
  Object.defineProperty(exports, "stripRequestQuery", {
433
514
  enumerable: true,
434
515
  get: function() {
@@ -1,6 +1,8 @@
1
- import { d as traverse, u as babelParse } from "./precheck-CX-5VqM1.mjs";
1
+ import { d as traverse, u as babelParse } from "./precheck-Bbcmh24Z.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
+ import process from "node:process";
5
+ import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
4
6
  import { Buffer } from "node:buffer";
5
7
  import { Parser } from "htmlparser2";
6
8
  //#region src/bundlers/shared/module-graph.ts
@@ -71,6 +73,35 @@ function isSourceStyleRequest(request) {
71
73
  return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
72
74
  }
73
75
  //#endregion
76
+ //#region src/bundlers/vite/utils.ts
77
+ function slash(p) {
78
+ return ensurePosix(p);
79
+ }
80
+ const isWindows = process.platform === "win32";
81
+ const cssLangRE = new RegExp(`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`);
82
+ function isCSSRequest(request) {
83
+ return cssLangRE.test(request) || isSourceStyleRequest(request);
84
+ }
85
+ function normalizePath(id) {
86
+ return path.posix.normalize(isWindows ? ensurePosix(id) : id);
87
+ }
88
+ async function formatPostcssSourceMap(rawMap, file) {
89
+ const inputFileDir = path.dirname(file);
90
+ const sources = rawMap.sources.map((source) => {
91
+ const cleanSource = cleanUrl(decodeURIComponent(source));
92
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) return `\0${cleanSource}`;
93
+ return normalizePath(path.resolve(inputFileDir, cleanSource));
94
+ });
95
+ return {
96
+ file,
97
+ mappings: rawMap.mappings,
98
+ names: rawMap.names,
99
+ sources,
100
+ sourcesContent: rawMap.sourcesContent,
101
+ version: rawMap.version
102
+ };
103
+ }
104
+ //#endregion
74
105
  //#region src/utils/disabled.ts
75
106
  function resolvePluginDisabledState(disabled) {
76
107
  if (disabled === true) return { plugin: true };
@@ -85,6 +116,19 @@ function resolvePackageDir(name) {
85
116
  return path.dirname(pkgPath);
86
117
  }
87
118
  //#endregion
119
+ //#region src/bundlers/shared/generated-css-marker.ts
120
+ const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/i;
121
+ const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/gi;
122
+ function createBundlerGeneratedCssMarker(bundler, file) {
123
+ return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
124
+ }
125
+ function hasBundlerGeneratedCssMarker(source) {
126
+ return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
127
+ }
128
+ function stripBundlerGeneratedCssMarkers(source) {
129
+ return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "");
130
+ }
131
+ //#endregion
88
132
  //#region src/bundlers/shared/run-tasks.ts
89
133
  async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
90
134
  if (factories.length === 0) return [];
@@ -265,7 +309,7 @@ function readEntrySource(output) {
265
309
  return output.source.toString();
266
310
  }
267
311
  function classifyBundleEntry(file, opts) {
268
- if (opts.cssMatcher(file)) return "css";
312
+ if (opts.cssMatcher(file) || isCSSRequest(file)) return "css";
269
313
  if (opts.htmlMatcher(file)) return "html";
270
314
  if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
271
315
  return "other";
@@ -367,4 +411,4 @@ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
367
411
  state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
368
412
  }
369
413
  //#endregion
370
- export { createBundleModuleGraphOptions as a, resolvePluginDisabledState as c, normalizeOutputPathKey as d, resolveOutputSpecifier as f, applyLinkedResults as i, isSourceStyleRequest as l, createBundleBuildState as n, pushConcurrentTaskFactories as o, toAbsoluteOutputPath as p, updateBundleBuildState as r, resolvePackageDir as s, buildBundleSnapshot as t, stripRequestQuery as u };
414
+ export { stripRequestQuery as _, createBundleModuleGraphOptions as a, toAbsoluteOutputPath as b, hasBundlerGeneratedCssMarker as c, resolvePluginDisabledState as d, cleanUrl as f, isSourceStyleRequest as g, slash as h, applyLinkedResults as i, stripBundlerGeneratedCssMarkers as l, isCSSRequest as m, createBundleBuildState as n, pushConcurrentTaskFactories as o, formatPostcssSourceMap as p, updateBundleBuildState as r, createBundlerGeneratedCssMarker as s, buildBundleSnapshot as t, resolvePackageDir as u, normalizeOutputPathKey as v, resolveOutputSpecifier as y };
@@ -0,0 +1,3 @@
1
+ export declare function createBundlerGeneratedCssMarker(bundler: 'vite' | 'webpack', file: string): string;
2
+ export declare function hasBundlerGeneratedCssMarker(source: unknown): boolean;
3
+ export declare function stripBundlerGeneratedCssMarkers(source: string): string;
@@ -14,12 +14,15 @@ interface CssFinalizerContext {
14
14
  debug: (format: string, ...args: unknown[]) => void;
15
15
  getResolvedConfig: () => ResolvedConfig | undefined;
16
16
  recordCssAssetResult?: (file: string, css: string) => void;
17
+ recordViteProcessedCssAssetResult?: (file: string, css: string) => void;
18
+ getViteProcessedCssAssetResults?: () => Iterable<[string, string]>;
17
19
  getRecordedGeneratorCandidates?: () => Set<string> | undefined;
18
20
  getSourceCandidates?: () => Set<string>;
19
21
  getSourceCandidatesForEntries?: ((entries: TailwindSourceEntry[] | undefined) => Set<string>) | undefined;
20
22
  waitForSourceCandidateSyncs?: () => Promise<void>;
21
23
  rememberMainCssSource?: (file: string, rawSource: string) => void;
22
24
  getRememberedMainCssSource?: (file: string) => string | undefined;
25
+ isViteProcessedCssAsset?: (asset: OutputAsset, file?: string) => boolean;
23
26
  }
24
27
  export declare function createViteCssFinalizerOutputPlugin(context: CssFinalizerContext): Plugin;
25
28
  export {};
@@ -18,7 +18,10 @@ interface GenerateBundleContext {
18
18
  debug: (format: string, ...args: unknown[]) => void;
19
19
  getResolvedConfig: () => ResolvedConfig | undefined;
20
20
  markCssAssetProcessed?: (asset: OutputAsset, file?: string) => void;
21
+ isViteProcessedCssAsset?: (asset: OutputAsset, file?: string) => boolean;
21
22
  recordCssAssetResult?: (file: string, css: string) => void;
23
+ recordViteProcessedCssAssetResult?: (file: string, css: string) => void;
24
+ getViteProcessedCssAssetResults?: () => Iterable<[string, string]>;
22
25
  getSourceCandidates?: () => Set<string>;
23
26
  getSourceCandidatesForEntries?: ((entries: TailwindSourceEntry[] | undefined) => Set<string>) | undefined;
24
27
  waitForSourceCandidateSyncs?: () => Promise<void>;
@@ -37,5 +40,6 @@ interface GenerateBundleThis {
37
40
  source: string;
38
41
  }) => string;
39
42
  }
43
+ export declare function resolveReplayCssOutputFile(rootDir: string, file: string): string;
40
44
  export declare function createGenerateBundleHook(context: GenerateBundleContext): (this: GenerateBundleThis, _opt: unknown, bundle: Record<string, OutputAsset | OutputChunk>) => Promise<void>;
41
45
  export {};
@@ -0,0 +1,32 @@
1
+ import type { OutputAsset, OutputBundle } from 'rollup';
2
+ import type { InternalUserDefinedOptions } from '../../types';
3
+ interface CssAssetMarkerMatcher {
4
+ (asset: OutputAsset, file?: string): boolean;
5
+ }
6
+ interface CssAssetProcessedMarker {
7
+ (asset: OutputAsset, file?: string): void;
8
+ }
9
+ interface CssAssetResultRecorder {
10
+ (file: string, css: string): void;
11
+ }
12
+ interface CssAssetResultsGetter {
13
+ (): Iterable<[string, string]>;
14
+ }
15
+ interface CollectViteProcessedCssAssetOptions {
16
+ isViteProcessedCssAsset?: CssAssetMarkerMatcher | undefined;
17
+ markCssAssetProcessed?: CssAssetProcessedMarker | undefined;
18
+ recordCssAssetResult?: CssAssetResultRecorder | undefined;
19
+ recordViteProcessedCssAssetResult?: CssAssetResultRecorder | undefined;
20
+ debug?: ((format: string, ...args: unknown[]) => void) | undefined;
21
+ }
22
+ interface InjectViteProcessedCssAssetOptions {
23
+ opts: InternalUserDefinedOptions;
24
+ getViteProcessedCssAssetResults?: CssAssetResultsGetter | undefined;
25
+ markCssAssetProcessed?: CssAssetProcessedMarker | undefined;
26
+ recordCssAssetResult?: CssAssetResultRecorder | undefined;
27
+ debug?: ((format: string, ...args: unknown[]) => void) | undefined;
28
+ onUpdate?: ((file: string, original: string, generated: string) => void) | undefined;
29
+ }
30
+ export declare function collectViteProcessedCssAssetResults(bundle: OutputBundle, options: CollectViteProcessedCssAssetOptions): number;
31
+ export declare function injectViteProcessedCssIntoMainCssAssets(bundle: OutputBundle, options: InjectViteProcessedCssAssetOptions): number;
32
+ export {};
@@ -3,6 +3,9 @@ import type { AppType } from '../../types';
3
3
  interface RewriteCssImportsOptions {
4
4
  appType?: AppType | undefined;
5
5
  getAppType?: (() => AppType | undefined) | undefined;
6
+ generateTailwindCss?: ((id: string, code: string, hookContext?: {
7
+ addWatchFile?: (id: string) => void;
8
+ }) => Promise<string | undefined> | string | undefined) | undefined;
6
9
  shouldOwnTailwindGeneration?: boolean | undefined;
7
10
  shouldRewrite: boolean;
8
11
  rootImport?: string | undefined;
@@ -3,6 +3,7 @@ export interface SourceCandidateCollector {
3
3
  sync: (id: string, source: string) => Promise<void>;
4
4
  merge: (id: string, source: string) => Promise<void>;
5
5
  syncFile: (id: string) => Promise<void>;
6
+ syncCurrentFile: (id: string) => Promise<void>;
6
7
  scanRoot: (options: ScanSourceCandidateRootOptions) => Promise<void>;
7
8
  syncInline: (inlineCandidates: TailwindInlineSourceCandidates | undefined) => void;
8
9
  remove: (id: string) => void;
@@ -11,6 +11,7 @@ interface SetupWebpackV5ProcessAssetsHookOptions {
11
11
  };
12
12
  getRuntimeRefreshRequirement: () => boolean;
13
13
  refreshRuntimeMetadata: (force: boolean) => Promise<void>;
14
+ isWebpackProcessedCssAsset?: ((file: string, rawSource: string) => boolean) | undefined;
14
15
  consumeRuntimeRefreshRequirement: () => void;
15
16
  isWatchMode?: (() => boolean) | undefined;
16
17
  runtimeClassSetManager?: BundleRuntimeClassSetManager | undefined;
@@ -1,5 +1,6 @@
1
1
  import type { TailwindV4CssSource } from 'tailwindcss-patch';
2
2
  import type { Compiler } from 'webpack';
3
+ import type { TailwindRuntimeState } from '../../../tailwindcss/runtime';
3
4
  import type { AppType, InternalUserDefinedOptions } from '../../../types';
4
5
  interface SetupWebpackV5LoadersOptions {
5
6
  compiler: Compiler;
@@ -9,11 +10,15 @@ interface SetupWebpackV5LoadersOptions {
9
10
  shouldRewriteCssImports: boolean;
10
11
  runtimeLoaderPath?: string | undefined;
11
12
  registerAutoCssSource?: ((source: TailwindV4CssSource) => Promise<void> | void) | undefined;
13
+ runtimeState: TailwindRuntimeState;
12
14
  getClassSetInLoader: () => Promise<void>;
15
+ getRuntimeSetInLoader: () => Promise<Set<string>>;
16
+ markWebpackProcessedCssSource?: ((file: string) => void) | undefined;
13
17
  getRuntimeWatchDependencies: () => {
14
18
  files: ReadonlySet<string>;
15
19
  contexts: ReadonlySet<string>;
16
20
  };
21
+ runtimeRegistryKey?: string | undefined;
17
22
  debug: (format: string, ...args: unknown[]) => void;
18
23
  }
19
24
  export declare function setupWebpackV5Loaders(options: SetupWebpackV5LoadersOptions): void;
@@ -0,0 +1,31 @@
1
+ import type { TailwindV4CssSource } from 'tailwindcss-patch';
2
+ import type { TailwindRuntimeState } from '../../../tailwindcss/runtime';
3
+ import type { AppType, InternalUserDefinedOptions } from '../../../types';
4
+ export interface WebpackRuntimeClassSetLoaderOptions {
5
+ getClassSet?: () => void | Promise<void>;
6
+ getWatchDependencies?: () => RuntimeLoaderWatchDependencies | Promise<RuntimeLoaderWatchDependencies | void> | void;
7
+ }
8
+ export interface RuntimeLoaderWatchDependencies {
9
+ files?: Iterable<string>;
10
+ contexts?: Iterable<string>;
11
+ }
12
+ export interface WebpackCssImportRewriteRuntimeOptions {
13
+ pkgDir: string;
14
+ appType?: AppType;
15
+ compilerOptions?: InternalUserDefinedOptions;
16
+ runtimeState?: TailwindRuntimeState;
17
+ registerCssSource?: (source: TailwindV4CssSource) => Promise<void> | void;
18
+ getRuntimeSet?: () => Promise<Set<string>> | Set<string>;
19
+ markGeneratedCssSource?: (file: string) => void;
20
+ }
21
+ export interface WebpackCssImportRewriteLoaderOptions {
22
+ tailwindcssImportRewrite?: WebpackCssImportRewriteRuntimeOptions;
23
+ tailwindcssImportRewriteRuntimeKey?: string;
24
+ }
25
+ export interface WebpackLoaderRuntimeEntry {
26
+ classSet?: WebpackRuntimeClassSetLoaderOptions;
27
+ cssImportRewrite?: WebpackCssImportRewriteRuntimeOptions;
28
+ }
29
+ export declare function setWebpackLoaderRuntime(key: string, entry: WebpackLoaderRuntimeEntry): void;
30
+ export declare function deleteWebpackLoaderRuntime(key: string): void;
31
+ export declare function getWebpackLoaderRuntime(key?: string): any;
@@ -1,13 +1,7 @@
1
- import type { TailwindV4CssSource } from 'tailwindcss-patch';
2
1
  import type webpack from 'webpack';
3
- import type { AppType } from '../../../types';
2
+ import type { WebpackCssImportRewriteLoaderOptions } from './runtime-registry';
4
3
  import { Buffer } from 'node:buffer';
5
- interface CssImportRewriteLoaderOptions {
6
- tailwindcssImportRewrite?: {
7
- pkgDir: string;
8
- appType?: AppType;
9
- registerCssSource?: (source: TailwindV4CssSource) => Promise<void> | void;
10
- };
4
+ interface CssImportRewriteLoaderOptions extends WebpackCssImportRewriteLoaderOptions {
11
5
  }
12
6
  export declare function transformCssImportRewriteSource(source: string | Buffer, options: CssImportRewriteLoaderOptions | undefined): string | Buffer<ArrayBufferLike>;
13
7
  declare const WeappTwCssImportRewriteLoader: webpack.LoaderDefinitionFunction<CssImportRewriteLoaderOptions>;
@@ -1,11 +1,7 @@
1
1
  import type webpack from 'webpack';
2
- interface RuntimeClassSetLoaderOptions {
3
- getClassSet?: () => void | Promise<void>;
4
- getWatchDependencies?: () => RuntimeLoaderWatchDependencies | Promise<RuntimeLoaderWatchDependencies | void> | void;
5
- }
6
- interface RuntimeLoaderWatchDependencies {
7
- files?: Iterable<string>;
8
- contexts?: Iterable<string>;
2
+ import type { WebpackRuntimeClassSetLoaderOptions } from './runtime-registry';
3
+ interface RuntimeClassSetLoaderOptions extends WebpackRuntimeClassSetLoaderOptions {
4
+ weappTailwindcssRuntimeKey?: string;
9
5
  }
10
6
  declare const WeappTwRuntimeClassSetLoader: webpack.LoaderDefinitionFunction<RuntimeClassSetLoaderOptions>;
11
7
  export default WeappTwRuntimeClassSetLoader;
package/dist/cli.js CHANGED
@@ -38,10 +38,10 @@ debug = __toESM(debug);
38
38
  let node_fs = require("node:fs");
39
39
  node_fs = __toESM(node_fs);
40
40
  require("postcss");
41
+ require("micromatch");
41
42
  let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
42
43
  let node_module = require("node:module");
43
44
  require("fast-glob");
44
- require("micromatch");
45
45
  require("tailwindcss-config");
46
46
  let _babel_traverse = require("@babel/traverse");
47
47
  _babel_traverse = __toESM(_babel_traverse);
@@ -73,6 +73,68 @@ function createDebug(prefix) {
73
73
  return debug$4;
74
74
  }
75
75
  //#endregion
76
+ //#region src/tailwindcss/source-scan.ts
77
+ const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
78
+ "html",
79
+ "wxml",
80
+ "axml",
81
+ "jxml",
82
+ "ksml",
83
+ "ttml",
84
+ "qml",
85
+ "tyml",
86
+ "xhsml",
87
+ "swan",
88
+ "vue",
89
+ "mpx",
90
+ "js",
91
+ "jsx",
92
+ "ts",
93
+ "tsx"
94
+ ];
95
+ const FULL_SOURCE_SCAN_EXTENSIONS = [
96
+ "js",
97
+ "jsx",
98
+ "mjs",
99
+ "cjs",
100
+ "ts",
101
+ "tsx",
102
+ "mts",
103
+ "cts",
104
+ "vue",
105
+ "uvue",
106
+ "nvue",
107
+ "svelte",
108
+ "mpx",
109
+ "html",
110
+ "wxml",
111
+ "axml",
112
+ "jxml",
113
+ "ksml",
114
+ "ttml",
115
+ "qml",
116
+ "tyml",
117
+ "xhsml",
118
+ "swan",
119
+ "css",
120
+ "wxss",
121
+ "acss",
122
+ "jxss",
123
+ "ttss",
124
+ "qss",
125
+ "tyss",
126
+ "scss",
127
+ "sass",
128
+ "less",
129
+ "styl",
130
+ "stylus"
131
+ ];
132
+ function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
133
+ return `**/*.{${extensions.join(",")}}`;
134
+ }
135
+ createSourceScanPattern(FULL_SOURCE_SCAN_EXTENSIONS);
136
+ new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})$`);
137
+ //#endregion
76
138
  //#region src/utils/object.ts
77
139
  function definedEntries(value) {
78
140
  return Object.entries(value).filter(([, item]) => item !== void 0);
@@ -448,29 +510,6 @@ function createTailwindV3DefaultColorThemeCss() {
448
510
  " margin: auto;",
449
511
  "}"
450
512
  ].join("\n");
451
- //#endregion
452
- //#region src/tailwindcss/source-scan.ts
453
- const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
454
- "html",
455
- "wxml",
456
- "axml",
457
- "jxml",
458
- "ksml",
459
- "ttml",
460
- "qml",
461
- "tyml",
462
- "xhsml",
463
- "swan",
464
- "vue",
465
- "mpx",
466
- "js",
467
- "jsx",
468
- "ts",
469
- "tsx"
470
- ];
471
- function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
472
- return `**/*.{${extensions.join(",")}}`;
473
- }
474
513
  (0, _weapp_tailwindcss_postcss.createStyleHandler)({
475
514
  cssChildCombinatorReplaceValue: ["view", "text"],
476
515
  cssRemoveHoverPseudoClass: true,
@@ -482,43 +521,6 @@ function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
482
521
  "@tailwind components;",
483
522
  "@tailwind utilities;"
484
523
  ].join("\n");
485
- createSourceScanPattern([
486
- "js",
487
- "jsx",
488
- "mjs",
489
- "cjs",
490
- "ts",
491
- "tsx",
492
- "mts",
493
- "cts",
494
- "vue",
495
- "uvue",
496
- "nvue",
497
- "svelte",
498
- "mpx",
499
- "html",
500
- "wxml",
501
- "axml",
502
- "jxml",
503
- "ksml",
504
- "ttml",
505
- "qml",
506
- "tyml",
507
- "xhsml",
508
- "swan",
509
- "css",
510
- "wxss",
511
- "acss",
512
- "jxss",
513
- "ttss",
514
- "qss",
515
- "tyss",
516
- "scss",
517
- "sass",
518
- "less",
519
- "styl",
520
- "stylus"
521
- ]);
522
524
  createDebug("[tailwindcss:runtime-patch] ");
523
525
  (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
524
526
  createDebug("[tailwindcss:runtime] ");