weapp-tailwindcss 5.0.0-next.18 → 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.
- package/README.md +2 -2
- package/dist/{bundle-state-Cmi0kFpJ.js → bundle-state-C9G1XBp0.js} +82 -1
- package/dist/{bundle-state-DsgThPdW.mjs → bundle-state-u4DFiZEj.mjs} +46 -2
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +4 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +3 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +5 -0
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -8
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{postcss-CZE8k8oP.js → runtime-registry-D5qnaSpo.js} +33 -0
- package/dist/{vite-oKeO_p82.mjs → vite-BfR3PR2w.mjs} +303 -110
- package/dist/{vite-DglfodCp.js → vite-D82lLEfX.js} +310 -115
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5018 -86
- package/dist/weapp-tw-runtime-classset-loader.js +7 -20
- package/dist/{webpack-BaqqyfEd.mjs → webpack-BY-mkkMS.mjs} +63 -12
- package/dist/{webpack-De6UzFP9.js → webpack-cMf0bWIS.js} +63 -12
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +5 -5
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
|
|
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
|
|
|
@@ -3,6 +3,9 @@ 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
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,
|
|
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 };
|
|
@@ -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;
|
|
@@ -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 {
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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/index.js
CHANGED
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_generator = require("./generator-CQ8A3YVm.js");
|
|
3
3
|
const require_gulp = require("./gulp.js");
|
|
4
4
|
const require_postcss = require("./postcss-CXJLLWRe.js");
|
|
5
|
-
const require_vite = require("./vite-
|
|
6
|
-
const require_webpack = require("./webpack-
|
|
5
|
+
const require_vite = require("./vite-D82lLEfX.js");
|
|
6
|
+
const require_webpack = require("./webpack-cMf0bWIS.js");
|
|
7
7
|
exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
|
|
8
8
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
9
9
|
exports.createPlugins = require_gulp.createPlugins;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as createWeappTailwindcssGenerator } from "./generator-CbjnpVed.mjs";
|
|
2
2
|
import { WeappTailwindcss as createPlugins } from "./gulp.mjs";
|
|
3
3
|
import { t as weappTailwindcssPostcssPlugin } from "./postcss-CLQ3yVXP.mjs";
|
|
4
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
5
|
-
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-
|
|
4
|
+
import { t as WeappTailwindcss } from "./vite-BfR3PR2w.mjs";
|
|
5
|
+
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-BY-mkkMS.mjs";
|
|
6
6
|
export { UnifiedWebpackPluginV5, WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
|
|
@@ -5469,15 +5469,48 @@ import_postcss.default.Rule;
|
|
|
5469
5469
|
import_postcss.default.Root;
|
|
5470
5470
|
import_postcss.default.Node;
|
|
5471
5471
|
//#endregion
|
|
5472
|
+
//#region src/tailwindcss/remove-unsupported-css.ts
|
|
5473
|
+
/**
|
|
5474
|
+
* 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
|
|
5475
|
+
*/
|
|
5476
|
+
function removeUnsupportedCascadeLayers(root) {
|
|
5477
|
+
root.walkAtRules("layer", (atRule) => {
|
|
5478
|
+
if (!atRule.nodes || atRule.nodes.length === 0) {
|
|
5479
|
+
atRule.remove();
|
|
5480
|
+
return;
|
|
5481
|
+
}
|
|
5482
|
+
atRule.replaceWith(...atRule.nodes);
|
|
5483
|
+
});
|
|
5484
|
+
}
|
|
5485
|
+
//#endregion
|
|
5486
|
+
//#region src/bundlers/webpack/loaders/runtime-registry.ts
|
|
5487
|
+
const runtimeRegistryHolder = globalThis;
|
|
5488
|
+
const runtimeRegistry = runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ ?? (runtimeRegistryHolder.__WEAPP_TW_WEBPACK_LOADER_RUNTIME_REGISTRY__ = /* @__PURE__ */ new Map());
|
|
5489
|
+
function getWebpackLoaderRuntime(key) {
|
|
5490
|
+
return key ? runtimeRegistry.get(key) : void 0;
|
|
5491
|
+
}
|
|
5492
|
+
//#endregion
|
|
5472
5493
|
Object.defineProperty(exports, "__toESM", {
|
|
5473
5494
|
enumerable: true,
|
|
5474
5495
|
get: function() {
|
|
5475
5496
|
return __toESM;
|
|
5476
5497
|
}
|
|
5477
5498
|
});
|
|
5499
|
+
Object.defineProperty(exports, "getWebpackLoaderRuntime", {
|
|
5500
|
+
enumerable: true,
|
|
5501
|
+
get: function() {
|
|
5502
|
+
return getWebpackLoaderRuntime;
|
|
5503
|
+
}
|
|
5504
|
+
});
|
|
5478
5505
|
Object.defineProperty(exports, "postcss_default", {
|
|
5479
5506
|
enumerable: true,
|
|
5480
5507
|
get: function() {
|
|
5481
5508
|
return postcss_default;
|
|
5482
5509
|
}
|
|
5483
5510
|
});
|
|
5511
|
+
Object.defineProperty(exports, "removeUnsupportedCascadeLayers", {
|
|
5512
|
+
enumerable: true,
|
|
5513
|
+
get: function() {
|
|
5514
|
+
return removeUnsupportedCascadeLayers;
|
|
5515
|
+
}
|
|
5516
|
+
});
|