weapp-tailwindcss 5.0.0-next.2 → 5.0.0-next.20
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 +6 -7
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/bundle-state-BlXvU4jl.js +530 -0
- package/dist/bundle-state-PO6MysTJ.mjs +414 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +5 -0
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +7 -3
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +28 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +14 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +24 -0
- package/dist/bundlers/shared/generator-css.d.ts +16 -22
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +7 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +24 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +14 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/index.d.ts +1 -1
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +25 -0
- package/dist/bundlers/vite/source-candidates.d.ts +16 -1
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +6 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +9 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -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 -6
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cache/index.d.ts +6 -6
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +605 -611
- package/dist/cli.mjs +614 -620
- package/dist/constants.d.ts +1 -2
- package/dist/core.js +13 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/postcss.js +3 -2
- package/dist/css-macro/postcss.mjs +3 -2
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults-B1igPF_e.mjs +150 -0
- package/dist/defaults-IHhYxNeU.js +193 -0
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +6 -131
- package/dist/defaults.mjs +2 -129
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +9 -8
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-DIuglJub.mjs +32 -0
- package/dist/generator-N4jy1HCk.js +55 -0
- package/dist/generator.js +12 -11
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +185 -47
- package/dist/gulp.mjs +179 -41
- package/dist/incremental-runtime-class-set-CJ0Pnsw2.js +2348 -0
- package/dist/incremental-runtime-class-set-hF-uiw6W.mjs +2285 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/precheck.d.ts +2 -2
- package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
- package/dist/lightningcss/style-handler.d.ts +3 -3
- package/dist/logger-CZUxvJJD.mjs +2 -0
- package/dist/logger-EVNB9z7i.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-D4UdbBQ6.mjs +228 -0
- package/dist/postcss-DlY-YRvA.js +237 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -276
- package/dist/postcss.mjs +1 -269
- package/dist/{recorder-gYSNLfOP.js → precheck-BjEbVEpX.js} +218 -314
- package/dist/{recorder-zsgatmkB.mjs → precheck-tbk626YL.mjs} +186 -281
- package/dist/presets.js +13 -11
- package/dist/presets.mjs +11 -9
- package/dist/reset.d.ts +1 -0
- package/dist/runtime-registry-D5qnaSpo.js +5516 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-BrvneDDd.mjs +209 -0
- package/dist/source-candidates-gxijpPI3.js +222 -0
- package/dist/tailwindcss/miniprogram.d.ts +5 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -5
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-BhG7BtB-.js +651 -0
- package/dist/tailwindcss-c6ROlNNW.mjs +600 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +51 -48
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +23 -23
- package/dist/types/user-defined-options/important.d.ts +31 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
- package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
- package/dist/v3-engine-5LoZUH-4.js +3695 -0
- package/dist/v3-engine-DIXDEDmL.mjs +3406 -0
- package/dist/{vite-CrlzCNqz.mjs → vite-B5faZcbE.mjs} +1256 -1088
- package/dist/vite-MyXBNux0.js +2368 -0
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +5157 -16
- package/dist/weapp-tw-runtime-classset-loader.js +32 -7
- package/dist/webpack-BnVyDmsD.mjs +836 -0
- package/dist/webpack-Mz1V0A9p.js +846 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +27 -37
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-Y-Ikv4Fu.mjs +0 -1177
- package/dist/generator-css-B5ejWUMv.mjs +0 -1098
- package/dist/generator-css-D3OdPRiS.js +0 -1125
- package/dist/generator-mmhXzZnv.js +0 -1276
- package/dist/js/syntax.d.ts +0 -10
- package/dist/loader-anchors-CNkWT8hx.js +0 -273
- package/dist/loader-anchors-TrU7EUr7.mjs +0 -205
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/vite-BC9U7ahn.js +0 -2199
- package/dist/webpack-Bu6M-Hbw.mjs +0 -441
- package/dist/webpack-DD7A6V0u.js +0 -456
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
- /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
- /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
package/dist/webpack4.mjs
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
import { g as ensureRuntimeClassSet, n as shouldSkipJsTransform, p as pluginName, r as getCompilerContext, t as setupPatchRecorder, v as createDebug } from "./recorder-zsgatmkB.mjs";
|
|
2
|
-
import { r as getGroupedEntries } from "./utils-7DUGTFED.mjs";
|
|
3
|
-
import { d as getRuntimeClassSetSignature } from "./logger-BoVx1Dbt.mjs";
|
|
4
|
-
import { i as processCachedTask, t as generateCssByGenerator } from "./generator-css-B5ejWUMv.mjs";
|
|
5
|
-
import { a as resolveDisabledOptions, c as toAbsoluteOutputPath, i as resolvePackageDir, r as pushConcurrentTaskFactories, s as resolveOutputSpecifier } from "./css-imports-CSdPq_Sc.mjs";
|
|
6
|
-
import { a as hasLoaderEntry, c as applyTailwindcssCssImportRewrite, d as isMpx, f as patchMpxLoaderResolve, i as getCacheKey, l as ensureMpxTailwindcssAliases, n as __dirname, p as setupMpxTailwindcssRedirect, r as createAssetHashByChunkMap, s as isCssLikeModuleResource, t as createLoaderAnchorFinders, u as injectMpxCssRewritePreRules } from "./loader-anchors-TrU7EUr7.mjs";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import process from "node:process";
|
|
9
|
-
import fs from "node:fs";
|
|
10
|
-
import { ConcatSource } from "webpack-sources";
|
|
11
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v4-assets.ts
|
|
12
|
-
function resolveWebpackStaleClassNameFallback(option, _compiler) {
|
|
13
|
-
if (typeof option === "boolean") return option;
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
function toWebpackV4AssetCompilation(compilation) {
|
|
17
|
-
return compilation;
|
|
18
|
-
}
|
|
19
|
-
function readWebpackV4AssetSource(asset) {
|
|
20
|
-
const source = asset.source();
|
|
21
|
-
return typeof source === "string" ? source : source.toString();
|
|
22
|
-
}
|
|
23
|
-
function setupWebpackV4EmitHook(options) {
|
|
24
|
-
const { compiler, options: compilerOptions, appType, runtimeState, debug } = options;
|
|
25
|
-
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
26
|
-
const cssUserHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
27
|
-
compiler.hooks.emit.tapPromise(pluginName, async (compilation) => {
|
|
28
|
-
await runtimeState.patchPromise;
|
|
29
|
-
compilerOptions.onStart();
|
|
30
|
-
debug("start");
|
|
31
|
-
for (const chunk of compilation.chunks) if (chunk.id && chunk.hash) compilerOptions.cache.calcHashValueChanged(chunk.id, chunk.hash);
|
|
32
|
-
const assetCompilation = toWebpackV4AssetCompilation(compilation);
|
|
33
|
-
const assetHashByChunk = createAssetHashByChunkMap(compilation.chunks);
|
|
34
|
-
const assets = assetCompilation.assets;
|
|
35
|
-
const entries = Object.entries(assets);
|
|
36
|
-
const outputDir = compiler.options?.output?.path ? path.resolve(compiler.options.output.path) : process.cwd();
|
|
37
|
-
const jsAssets = /* @__PURE__ */ new Map();
|
|
38
|
-
for (const [file] of entries) if (compilerOptions.jsMatcher(file) || compilerOptions.wxsMatcher(file)) {
|
|
39
|
-
const absolute = toAbsoluteOutputPath(file, outputDir);
|
|
40
|
-
jsAssets.set(absolute, file);
|
|
41
|
-
}
|
|
42
|
-
const moduleGraphOptions = {
|
|
43
|
-
resolve(specifier, importer) {
|
|
44
|
-
return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
45
|
-
},
|
|
46
|
-
load: (id) => {
|
|
47
|
-
const assetName = jsAssets.get(id);
|
|
48
|
-
if (!assetName) return;
|
|
49
|
-
const assetSource = assetCompilation.assets[assetName];
|
|
50
|
-
if (!assetSource) return;
|
|
51
|
-
return readWebpackV4AssetSource(assetSource);
|
|
52
|
-
},
|
|
53
|
-
filter(id) {
|
|
54
|
-
return jsAssets.has(id);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const applyLinkedResults = (linked) => {
|
|
58
|
-
if (!linked) return;
|
|
59
|
-
for (const [id, { code }] of Object.entries(linked)) {
|
|
60
|
-
const assetName = jsAssets.get(id);
|
|
61
|
-
if (!assetName) continue;
|
|
62
|
-
const assetSource = assetCompilation.assets[assetName];
|
|
63
|
-
if (!assetSource) continue;
|
|
64
|
-
const previous = readWebpackV4AssetSource(assetSource);
|
|
65
|
-
if (previous === code) continue;
|
|
66
|
-
const source = new ConcatSource(code);
|
|
67
|
-
assetCompilation.updateAsset(assetName, source);
|
|
68
|
-
compilerOptions.onUpdate(assetName, previous, code);
|
|
69
|
-
debug("js linked handle: %s", assetName);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const groupedEntries = getGroupedEntries(entries, compilerOptions);
|
|
73
|
-
const getCssHandlerOptions = (file) => {
|
|
74
|
-
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
75
|
-
const isMainChunk = compilerOptions.mainCssChunkMatcher(file, appType);
|
|
76
|
-
const cacheKey = `${majorVersion ?? "unknown"}:${isMainChunk ? "1" : "0"}:${file}`;
|
|
77
|
-
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
78
|
-
if (cached) return cached;
|
|
79
|
-
const created = {
|
|
80
|
-
isMainChunk,
|
|
81
|
-
postcssOptions: { options: { from: file } },
|
|
82
|
-
majorVersion
|
|
83
|
-
};
|
|
84
|
-
cssHandlerOptionsCache.set(cacheKey, created);
|
|
85
|
-
return created;
|
|
86
|
-
};
|
|
87
|
-
const getCssUserHandlerOptions = (file) => {
|
|
88
|
-
const cacheKey = `${runtimeState.twPatcher.majorVersion ?? "unknown"}:${file}`;
|
|
89
|
-
const cached = cssUserHandlerOptionsCache.get(cacheKey);
|
|
90
|
-
if (cached) return cached;
|
|
91
|
-
const created = {
|
|
92
|
-
...getCssHandlerOptions(file),
|
|
93
|
-
isMainChunk: false
|
|
94
|
-
};
|
|
95
|
-
cssUserHandlerOptionsCache.set(cacheKey, created);
|
|
96
|
-
return created;
|
|
97
|
-
};
|
|
98
|
-
const staleClassNameFallback = resolveWebpackStaleClassNameFallback(compilerOptions.staleClassNameFallback, compiler);
|
|
99
|
-
const runtimeSet = await ensureRuntimeClassSet(runtimeState, {
|
|
100
|
-
forceCollect: true,
|
|
101
|
-
allowEmpty: false
|
|
102
|
-
});
|
|
103
|
-
const defaultTemplateHandlerOptions = { runtimeSet };
|
|
104
|
-
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
105
|
-
const tasks = [];
|
|
106
|
-
if (Array.isArray(groupedEntries.html)) for (const element of groupedEntries.html) {
|
|
107
|
-
const [file, originalSource] = element;
|
|
108
|
-
const rawSource = readWebpackV4AssetSource(originalSource);
|
|
109
|
-
const cacheKey = file;
|
|
110
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
111
|
-
tasks.push(processCachedTask({
|
|
112
|
-
cache: compilerOptions.cache,
|
|
113
|
-
cacheKey,
|
|
114
|
-
hashKey: `${file}:asset`,
|
|
115
|
-
rawSource,
|
|
116
|
-
hash: chunkHash,
|
|
117
|
-
applyResult(source) {
|
|
118
|
-
assetCompilation.updateAsset(file, source);
|
|
119
|
-
},
|
|
120
|
-
onCacheHit() {
|
|
121
|
-
debug("html cache hit: %s", file);
|
|
122
|
-
},
|
|
123
|
-
transform: async () => {
|
|
124
|
-
const wxml = await compilerOptions.templateHandler(rawSource, defaultTemplateHandlerOptions);
|
|
125
|
-
const source = new ConcatSource(wxml);
|
|
126
|
-
compilerOptions.onUpdate(file, rawSource, wxml);
|
|
127
|
-
debug("html handle: %s", file);
|
|
128
|
-
return { result: source };
|
|
129
|
-
}
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
const jsTaskFactories = [];
|
|
133
|
-
if (Array.isArray(groupedEntries.js)) for (const [file] of groupedEntries.js) {
|
|
134
|
-
const cacheKey = getCacheKey(file);
|
|
135
|
-
const assetSource = assetCompilation.assets[file];
|
|
136
|
-
if (!assetSource) continue;
|
|
137
|
-
const initialRawSource = readWebpackV4AssetSource(assetSource);
|
|
138
|
-
const absoluteFile = toAbsoluteOutputPath(file, outputDir);
|
|
139
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
140
|
-
const sourceAwareHash = chunkHash ? `${chunkHash}:${compilerOptions.cache.computeHash(initialRawSource)}` : void 0;
|
|
141
|
-
jsTaskFactories.push(async () => {
|
|
142
|
-
await processCachedTask({
|
|
143
|
-
cache: compilerOptions.cache,
|
|
144
|
-
cacheKey,
|
|
145
|
-
hashKey: `${file}:asset`,
|
|
146
|
-
rawSource: initialRawSource,
|
|
147
|
-
hash: sourceAwareHash,
|
|
148
|
-
applyResult(source) {
|
|
149
|
-
assetCompilation.updateAsset(file, source);
|
|
150
|
-
},
|
|
151
|
-
onCacheHit() {
|
|
152
|
-
debug("js cache hit: %s", file);
|
|
153
|
-
},
|
|
154
|
-
transform: async () => {
|
|
155
|
-
const currentAsset = assetCompilation.assets[file];
|
|
156
|
-
const currentSource = currentAsset ? readWebpackV4AssetSource(currentAsset) : "";
|
|
157
|
-
const handlerOptions = {
|
|
158
|
-
staleClassNameFallback,
|
|
159
|
-
tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
|
|
160
|
-
filename: absoluteFile,
|
|
161
|
-
moduleGraph: moduleGraphOptions,
|
|
162
|
-
babelParserOptions: { sourceFilename: absoluteFile }
|
|
163
|
-
};
|
|
164
|
-
if (shouldSkipJsTransform(currentSource, handlerOptions)) return { result: new ConcatSource(currentSource) };
|
|
165
|
-
const { code, linked } = await compilerOptions.jsHandler(currentSource, runtimeSet, handlerOptions);
|
|
166
|
-
const source = new ConcatSource(code);
|
|
167
|
-
compilerOptions.onUpdate(file, currentSource, code);
|
|
168
|
-
debug("js handle: %s", file);
|
|
169
|
-
applyLinkedResults(linked);
|
|
170
|
-
return { result: source };
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (Array.isArray(groupedEntries.css)) for (const element of groupedEntries.css) {
|
|
176
|
-
const [file, originalSource] = element;
|
|
177
|
-
const rawSource = readWebpackV4AssetSource(originalSource);
|
|
178
|
-
const cacheKey = file;
|
|
179
|
-
const chunkHash = assetHashByChunk.get(file);
|
|
180
|
-
tasks.push(processCachedTask({
|
|
181
|
-
cache: compilerOptions.cache,
|
|
182
|
-
cacheKey,
|
|
183
|
-
hashKey: `${file}:asset`,
|
|
184
|
-
rawSource,
|
|
185
|
-
hash: chunkHash,
|
|
186
|
-
applyResult(source) {
|
|
187
|
-
assetCompilation.updateAsset(file, source);
|
|
188
|
-
},
|
|
189
|
-
onCacheHit() {
|
|
190
|
-
debug("css cache hit: %s", file);
|
|
191
|
-
},
|
|
192
|
-
transform: async () => {
|
|
193
|
-
await runtimeState.patchPromise;
|
|
194
|
-
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
195
|
-
const generated = await generateCssByGenerator({
|
|
196
|
-
opts: compilerOptions,
|
|
197
|
-
runtimeState,
|
|
198
|
-
runtime: runtimeSet,
|
|
199
|
-
rawSource,
|
|
200
|
-
file,
|
|
201
|
-
cssHandlerOptions,
|
|
202
|
-
cssUserHandlerOptions: getCssUserHandlerOptions(file),
|
|
203
|
-
styleHandler: compilerOptions.styleHandler,
|
|
204
|
-
debug
|
|
205
|
-
});
|
|
206
|
-
const css = generated?.css ?? (await compilerOptions.styleHandler(rawSource, cssHandlerOptions)).css;
|
|
207
|
-
const source = new ConcatSource(css);
|
|
208
|
-
compilerOptions.onUpdate(file, rawSource, css);
|
|
209
|
-
if (generated) debug("css handle via tailwind v%s engine(%s): %s", runtimeState.twPatcher.majorVersion, generated.target, file);
|
|
210
|
-
else debug("css handle: %s", file);
|
|
211
|
-
return { result: source };
|
|
212
|
-
}
|
|
213
|
-
}));
|
|
214
|
-
}
|
|
215
|
-
pushConcurrentTaskFactories(tasks, jsTaskFactories);
|
|
216
|
-
await Promise.all(tasks);
|
|
217
|
-
debug("end");
|
|
218
|
-
compilerOptions.onEnd();
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.ts
|
|
223
|
-
function setupWebpackV4Loaders(options) {
|
|
224
|
-
const { compiler, options: compilerOptions, appType, weappTailwindcssPackageDir, shouldRewriteCssImports, runtimeLoaderPath, runtimeCssImportRewriteLoaderPath, getClassSetInLoader, debug } = options;
|
|
225
|
-
const isMpxApp = isMpx(appType);
|
|
226
|
-
if (shouldRewriteCssImports && isMpxApp) ensureMpxTailwindcssAliases(compiler, weappTailwindcssPackageDir);
|
|
227
|
-
const runtimeClassSetLoader = runtimeLoaderPath ?? path.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js");
|
|
228
|
-
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? runtimeCssImportRewriteLoaderPath ?? path.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js") : void 0;
|
|
229
|
-
const runtimeClassSetLoaderExists = fs.existsSync(runtimeClassSetLoader);
|
|
230
|
-
const runtimeCssImportRewriteLoaderExists = runtimeCssImportRewriteLoader ? fs.existsSync(runtimeCssImportRewriteLoader) : false;
|
|
231
|
-
const runtimeLoaderRewriteOptions = shouldRewriteCssImports ? {
|
|
232
|
-
pkgDir: weappTailwindcssPackageDir,
|
|
233
|
-
appType
|
|
234
|
-
} : void 0;
|
|
235
|
-
const classSetLoaderOptions = { getClassSet: getClassSetInLoader };
|
|
236
|
-
const { findRewriteAnchor, findClassSetAnchor } = createLoaderAnchorFinders(appType);
|
|
237
|
-
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? { rewriteCssImports: runtimeLoaderRewriteOptions } : void 0;
|
|
238
|
-
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) injectMpxCssRewritePreRules(compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
239
|
-
const createRuntimeClassSetLoaderEntry = () => ({
|
|
240
|
-
loader: runtimeClassSetLoader,
|
|
241
|
-
options: classSetLoaderOptions,
|
|
242
|
-
ident: null,
|
|
243
|
-
type: null
|
|
244
|
-
});
|
|
245
|
-
const createCssImportRewriteLoaderEntry = () => {
|
|
246
|
-
if (!runtimeCssImportRewriteLoader) return null;
|
|
247
|
-
return {
|
|
248
|
-
loader: runtimeCssImportRewriteLoader,
|
|
249
|
-
options: cssImportRewriteLoaderOptions,
|
|
250
|
-
ident: null,
|
|
251
|
-
type: null
|
|
252
|
-
};
|
|
253
|
-
};
|
|
254
|
-
compiler.hooks.compilation.tap(pluginName, (compilation) => {
|
|
255
|
-
compilation.hooks.normalModuleLoader.tap(pluginName, (_loaderContext, module) => {
|
|
256
|
-
if (!(runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists)) return;
|
|
257
|
-
if (shouldRewriteCssImports && isMpx(appType) && typeof _loaderContext.resolve === "function") patchMpxLoaderResolve(_loaderContext, weappTailwindcssPackageDir, true);
|
|
258
|
-
const loaderEntries = module.loaders || [];
|
|
259
|
-
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
260
|
-
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
261
|
-
const isCssModule = isCssLikeModuleResource(module.resource, compilerOptions.cssMatcher, appType);
|
|
262
|
-
if (process.env.WEAPP_TW_LOADER_DEBUG && isCssModule) debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
263
|
-
rewriteAnchorIdx,
|
|
264
|
-
classSetAnchorIdx
|
|
265
|
-
});
|
|
266
|
-
if (process.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.includes("app.css")) debug("app.css module loaders=%o anchors=%o", loaderEntries.map((x) => x.loader), {
|
|
267
|
-
rewriteAnchorIdx,
|
|
268
|
-
classSetAnchorIdx
|
|
269
|
-
});
|
|
270
|
-
else if (process.env.WEAPP_TW_LOADER_DEBUG && typeof module.resource === "string" && module.resource.endsWith(".css")) debug("css module seen: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), {
|
|
271
|
-
rewriteAnchorIdx,
|
|
272
|
-
classSetAnchorIdx
|
|
273
|
-
});
|
|
274
|
-
if (rewriteAnchorIdx === -1 && classSetAnchorIdx === -1 && !isCssModule) return;
|
|
275
|
-
const anchorlessInsert = (entry, position) => {
|
|
276
|
-
if (position === "after") loaderEntries.push(entry);
|
|
277
|
-
else loaderEntries.unshift(entry);
|
|
278
|
-
};
|
|
279
|
-
if (runtimeLoaderRewriteOptions && runtimeCssImportRewriteLoaderExists && cssImportRewriteLoaderOptions && runtimeCssImportRewriteLoader) {
|
|
280
|
-
const existingIndex = loaderEntries.findIndex((entry) => entry.loader?.includes?.(runtimeCssImportRewriteLoader));
|
|
281
|
-
const rewriteEntry = existingIndex !== -1 ? loaderEntries.splice(existingIndex, 1)[0] : createCssImportRewriteLoaderEntry();
|
|
282
|
-
if (rewriteEntry) {
|
|
283
|
-
const anchorIndex = findRewriteAnchor(loaderEntries);
|
|
284
|
-
if (anchorIndex === -1) anchorlessInsert(rewriteEntry, "after");
|
|
285
|
-
else loaderEntries.splice(anchorIndex + 1, 0, rewriteEntry);
|
|
286
|
-
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if (runtimeClassSetLoaderExists && !hasLoaderEntry(loaderEntries, runtimeClassSetLoader)) {
|
|
290
|
-
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
291
|
-
if (anchorIndex === -1) anchorlessInsert(createRuntimeClassSetLoaderEntry(), "before");
|
|
292
|
-
else {
|
|
293
|
-
const insertIndex = anchorIndex === -1 ? rewriteAnchorIdx : anchorIndex;
|
|
294
|
-
loaderEntries.splice(insertIndex, 0, createRuntimeClassSetLoaderEntry());
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
//#endregion
|
|
301
|
-
//#region src/bundlers/webpack/BaseUnifiedPlugin/v4.ts
|
|
302
|
-
const debug = createDebug();
|
|
303
|
-
const weappTailwindcssPackageDir = resolvePackageDir("weapp-tailwindcss");
|
|
304
|
-
/**
|
|
305
|
-
* @name UnifiedWebpackPluginV4
|
|
306
|
-
* @description webpack4 核心转义插件
|
|
307
|
-
* @link https://tw.icebreaker.top/docs/intro
|
|
308
|
-
*/
|
|
309
|
-
var UnifiedWebpackPluginV4 = class {
|
|
310
|
-
constructor(options = {}) {
|
|
311
|
-
this.options = getCompilerContext(options);
|
|
312
|
-
this.appType = this.options.appType;
|
|
313
|
-
}
|
|
314
|
-
apply(compiler) {
|
|
315
|
-
compiler.options = compiler.options || {};
|
|
316
|
-
const { disabled, onLoad, runtimeLoaderPath, runtimeCssImportRewriteLoaderPath, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = this.options;
|
|
317
|
-
const disabledOptions = resolveDisabledOptions(disabled);
|
|
318
|
-
const shouldRewriteCssImports = (initialTwPatcher.majorVersion ?? 0) >= 4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
|
|
319
|
-
const isMpxApp = isMpx(this.appType);
|
|
320
|
-
if (shouldRewriteCssImports) {
|
|
321
|
-
applyTailwindcssCssImportRewrite(compiler, {
|
|
322
|
-
pkgDir: weappTailwindcssPackageDir,
|
|
323
|
-
enabled: true,
|
|
324
|
-
appType: this.appType
|
|
325
|
-
});
|
|
326
|
-
setupMpxTailwindcssRedirect(weappTailwindcssPackageDir, isMpxApp);
|
|
327
|
-
}
|
|
328
|
-
if (disabledOptions.plugin) return;
|
|
329
|
-
const patchRecorderState = setupPatchRecorder(initialTwPatcher, this.options.tailwindcssBasedir, {
|
|
330
|
-
source: "runtime",
|
|
331
|
-
cwd: this.options.tailwindcssBasedir ?? process.cwd()
|
|
332
|
-
});
|
|
333
|
-
const runtimeState = {
|
|
334
|
-
twPatcher: initialTwPatcher,
|
|
335
|
-
patchPromise: patchRecorderState.patchPromise,
|
|
336
|
-
refreshTailwindcssPatcher,
|
|
337
|
-
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
338
|
-
};
|
|
339
|
-
let runtimeSetPrepared = false;
|
|
340
|
-
let runtimeSetSignature;
|
|
341
|
-
compiler.hooks.compilation.tap(pluginName, () => {
|
|
342
|
-
runtimeSetPrepared = false;
|
|
343
|
-
});
|
|
344
|
-
async function getClassSetInLoader() {
|
|
345
|
-
if (runtimeSetPrepared) return;
|
|
346
|
-
const signature = getRuntimeClassSetSignature(runtimeState.twPatcher);
|
|
347
|
-
const forceRefresh = signature !== runtimeSetSignature;
|
|
348
|
-
runtimeSetPrepared = true;
|
|
349
|
-
await ensureRuntimeClassSet(runtimeState, {
|
|
350
|
-
forceRefresh,
|
|
351
|
-
forceCollect: true,
|
|
352
|
-
clearCache: forceRefresh,
|
|
353
|
-
allowEmpty: true
|
|
354
|
-
});
|
|
355
|
-
runtimeSetSignature = signature;
|
|
356
|
-
}
|
|
357
|
-
onLoad();
|
|
358
|
-
setupWebpackV4Loaders({
|
|
359
|
-
compiler,
|
|
360
|
-
options: this.options,
|
|
361
|
-
appType: this.appType,
|
|
362
|
-
weappTailwindcssPackageDir,
|
|
363
|
-
shouldRewriteCssImports,
|
|
364
|
-
runtimeLoaderPath,
|
|
365
|
-
runtimeCssImportRewriteLoaderPath,
|
|
366
|
-
getClassSetInLoader,
|
|
367
|
-
debug
|
|
368
|
-
});
|
|
369
|
-
setupWebpackV4EmitHook({
|
|
370
|
-
compiler,
|
|
371
|
-
options: this.options,
|
|
372
|
-
appType: this.appType,
|
|
373
|
-
runtimeState,
|
|
374
|
-
debug
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
//#endregion
|
|
379
|
-
export { UnifiedWebpackPluginV4, UnifiedWebpackPluginV4 as WeappTailwindcss, UnifiedWebpackPluginV4 as weappTailwindcss, weappTailwindcssPackageDir };
|
package/scripts/postinstall.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process'
|
|
2
|
-
import process from 'node:process'
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
4
|
-
|
|
5
|
-
const cliPath = fileURLToPath(new URL('../bin/weapp-tailwindcss.js', import.meta.url))
|
|
6
|
-
const missingRuntimeModuleMessage = `${[
|
|
7
|
-
'[weapp-tailwindcss] postinstall patch skipped because a runtime module is missing.',
|
|
8
|
-
'Run `pnpm --filter weapp-tailwindcss build` before strict CLI validation.',
|
|
9
|
-
].join(' ')}\n`
|
|
10
|
-
|
|
11
|
-
export function isMissingRuntimeModuleOutput(output) {
|
|
12
|
-
return /MODULE_NOT_FOUND|Cannot find module/.test(output)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function resolvePostinstallPatchExitCode(result) {
|
|
16
|
-
if (result.error) {
|
|
17
|
-
return {
|
|
18
|
-
code: 0,
|
|
19
|
-
message: `[weapp-tailwindcss] postinstall patch skipped: ${result.error.message}\n`,
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (result.status && isMissingRuntimeModuleOutput(`${result.stderr ?? ''}\n${result.stdout ?? ''}`)) {
|
|
24
|
-
return {
|
|
25
|
-
code: 0,
|
|
26
|
-
message: missingRuntimeModuleMessage,
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
code: result.status ?? 0,
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function runPostinstallPatch() {
|
|
36
|
-
const result = spawnSync(process.execPath, [cliPath, 'patch'], {
|
|
37
|
-
encoding: 'utf8',
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
if (result.stdout) {
|
|
41
|
-
process.stdout.write(result.stdout)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (result.stderr) {
|
|
45
|
-
process.stderr.write(result.stderr)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const resolved = resolvePostinstallPatchExitCode(result)
|
|
49
|
-
if (resolved.message) {
|
|
50
|
-
process.stderr.write(resolved.message)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
process.exitCode = resolved.code
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const entryPoint = process.argv[1] ? pathToFileURL(process.argv[1]).href : undefined
|
|
57
|
-
if (import.meta.url === entryPoint) {
|
|
58
|
-
runPostinstallPatch()
|
|
59
|
-
}
|
|
File without changes
|
|
File without changes
|