weapp-tailwindcss 4.8.13 → 4.8.14
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/dist/{chunk-B7643BFR.js → chunk-2AWOAQD3.js} +34 -32
- package/dist/{chunk-4E2U7YIQ.mjs → chunk-2HIXWVX2.mjs} +50 -47
- package/dist/{chunk-HXYNNE6Q.mjs → chunk-3SKEY32E.mjs} +18 -119
- package/dist/{chunk-3S6VRBOM.js → chunk-477TX4LM.js} +3 -3
- package/dist/{chunk-BLTNVVBH.js → chunk-63LJ4WHF.js} +1 -1
- package/dist/chunk-6VSFN3NA.js +251 -0
- package/dist/{chunk-7MREZHFO.mjs → chunk-7UAU27KZ.mjs} +1 -1
- package/dist/{chunk-JSV4IYLL.mjs → chunk-EKF3ABRO.mjs} +2 -2
- package/dist/chunk-FSI2IWUY.mjs +251 -0
- package/dist/{chunk-CSDB62E5.mjs → chunk-HJWY5Y6L.mjs} +14 -12
- package/dist/{chunk-G4UFQ3CK.js → chunk-L3AOBWDW.js} +7 -7
- package/dist/{chunk-U6O2TOS7.js → chunk-ML4F4ZPY.js} +66 -63
- package/dist/{chunk-Z6E242OH.js → chunk-ORSWL3MI.js} +18 -119
- package/dist/{chunk-WHELJMZL.mjs → chunk-ZC5JYOAR.mjs} +1 -1
- package/dist/cli.js +9 -9
- package/dist/cli.mjs +1 -1
- package/dist/core.js +8 -8
- package/dist/core.mjs +2 -2
- package/dist/gulp.js +4 -4
- package/dist/gulp.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.mjs +7 -7
- package/dist/types.d.mts +24 -2
- package/dist/types.d.ts +24 -2
- package/dist/vite.js +5 -5
- package/dist/vite.mjs +4 -4
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -18
- package/dist/weapp-tw-runtime-classset-loader.js +1 -3
- package/dist/webpack.js +6 -6
- package/dist/webpack.mjs +5 -5
- package/dist/webpack4.js +35 -33
- package/dist/webpack4.mjs +14 -12
- package/package.json +3 -3
- package/dist/chunk-BYXBJQAS.js +0 -1
- package/dist/chunk-OPA2EYQV.mjs +0 -136
- package/dist/chunk-XX7SUSE7.js +0 -136
|
@@ -4,31 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var _chunkXX7SUSE7js = require('./chunk-XX7SUSE7.js');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
|
|
12
|
+
var _chunk6VSFN3NAjs = require('./chunk-6VSFN3NA.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
var _chunkORSWL3MIjs = require('./chunk-ORSWL3MI.js');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
var _chunkLTJQUORKjs = require('./chunk-LTJQUORK.js');
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
var
|
|
25
|
+
var _chunk477TX4LMjs = require('./chunk-477TX4LM.js');
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
var
|
|
32
|
+
var _chunk63LJ4WHFjs = require('./chunk-63LJ4WHF.js');
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
@@ -37,11 +38,11 @@ var _chunkUW3WHSZ5js = require('./chunk-UW3WHSZ5.js');
|
|
|
37
38
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
38
39
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
39
40
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
40
|
-
var debug =
|
|
41
|
-
var weappTailwindcssPackageDir =
|
|
41
|
+
var debug = _chunk63LJ4WHFjs.createDebug.call(void 0, );
|
|
42
|
+
var weappTailwindcssPackageDir = _chunkORSWL3MIjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
42
43
|
var UnifiedWebpackPluginV5 = class {
|
|
43
44
|
constructor(options = {}) {
|
|
44
|
-
this.options =
|
|
45
|
+
this.options = _chunk63LJ4WHFjs.getCompilerContext.call(void 0, options);
|
|
45
46
|
this.appType = this.options.appType;
|
|
46
47
|
}
|
|
47
48
|
apply(compiler) {
|
|
@@ -62,21 +63,22 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
62
63
|
twPatcher: initialTwPatcher,
|
|
63
64
|
refreshTailwindcssPatcher
|
|
64
65
|
} = this.options;
|
|
65
|
-
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
66
|
+
const disabledOptions = _chunkORSWL3MIjs.resolveDisabledOptions.call(void 0, disabled);
|
|
68
67
|
const isTailwindcssV4 = (_nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0))) >= 4;
|
|
69
|
-
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false;
|
|
70
|
-
const isMpxApp =
|
|
68
|
+
const shouldRewriteCssImports = isTailwindcssV4 && this.options.rewriteCssImports !== false && !disabledOptions.rewriteCssImports;
|
|
69
|
+
const isMpxApp = _chunk6VSFN3NAjs.isMpx.call(void 0, this.appType);
|
|
71
70
|
if (shouldRewriteCssImports) {
|
|
72
|
-
|
|
71
|
+
_chunk6VSFN3NAjs.applyTailwindcssCssImportRewrite.call(void 0, compiler, {
|
|
73
72
|
pkgDir: weappTailwindcssPackageDir,
|
|
74
73
|
enabled: true,
|
|
75
74
|
appType: this.appType
|
|
76
75
|
});
|
|
77
|
-
|
|
76
|
+
_chunk6VSFN3NAjs.setupMpxTailwindcssRedirect.call(void 0, weappTailwindcssPackageDir, isMpxApp);
|
|
77
|
+
}
|
|
78
|
+
if (disabledOptions.plugin) {
|
|
79
|
+
return;
|
|
78
80
|
}
|
|
79
|
-
const patchRecorderState =
|
|
81
|
+
const patchRecorderState = _chunk477TX4LMjs.setupPatchRecorder.call(void 0, initialTwPatcher, this.options.tailwindcssBasedir, {
|
|
80
82
|
source: "runtime",
|
|
81
83
|
cwd: _nullishCoalesce(this.options.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
82
84
|
});
|
|
@@ -87,14 +89,14 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
87
89
|
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
88
90
|
};
|
|
89
91
|
const refreshRuntimeState = async (force) => {
|
|
90
|
-
await
|
|
92
|
+
await _chunk63LJ4WHFjs.refreshTailwindRuntimeState.call(void 0, runtimeState, force);
|
|
91
93
|
};
|
|
92
94
|
const { Compilation, sources, NormalModule } = compiler.webpack;
|
|
93
95
|
const { ConcatSource } = sources;
|
|
94
96
|
async function getClassSetInLoader() {
|
|
95
97
|
await refreshRuntimeState(true);
|
|
96
98
|
await runtimeState.patchPromise;
|
|
97
|
-
await
|
|
99
|
+
await _chunk63LJ4WHFjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
98
100
|
}
|
|
99
101
|
const runtimeClassSetLoader = _nullishCoalesce(runtimeLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-runtime-classset-loader.js")));
|
|
100
102
|
const runtimeCssImportRewriteLoader = shouldRewriteCssImports ? _nullishCoalesce(runtimeCssImportRewriteLoaderPath, () => ( _path2.default.resolve(__dirname, "./weapp-tw-css-import-rewrite-loader.js"))) : void 0;
|
|
@@ -107,16 +109,16 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
107
109
|
const classSetLoaderOptions = {
|
|
108
110
|
getClassSet: getClassSetInLoader
|
|
109
111
|
};
|
|
110
|
-
const { findRewriteAnchor, findClassSetAnchor } =
|
|
112
|
+
const { findRewriteAnchor, findClassSetAnchor } = _chunk6VSFN3NAjs.createLoaderAnchorFinders.call(void 0, this.appType);
|
|
111
113
|
const cssImportRewriteLoaderOptions = runtimeLoaderRewriteOptions ? {
|
|
112
114
|
rewriteCssImports: runtimeLoaderRewriteOptions
|
|
113
115
|
} : void 0;
|
|
114
116
|
onLoad();
|
|
115
117
|
if (shouldRewriteCssImports && isMpxApp) {
|
|
116
|
-
|
|
118
|
+
_chunk6VSFN3NAjs.ensureMpxTailwindcssAliases.call(void 0, compiler, weappTailwindcssPackageDir);
|
|
117
119
|
}
|
|
118
120
|
if (runtimeCssImportRewriteLoader && shouldRewriteCssImports && cssImportRewriteLoaderOptions && isMpxApp) {
|
|
119
|
-
|
|
121
|
+
_chunk6VSFN3NAjs.injectMpxCssRewritePreRules.call(void 0, compiler, runtimeCssImportRewriteLoader, cssImportRewriteLoaderOptions);
|
|
120
122
|
}
|
|
121
123
|
const createRuntimeClassSetLoaderEntry = () => ({
|
|
122
124
|
loader: runtimeClassSetLoader,
|
|
@@ -135,17 +137,17 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
135
137
|
type: null
|
|
136
138
|
};
|
|
137
139
|
};
|
|
138
|
-
compiler.hooks.compilation.tap(
|
|
139
|
-
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
140
|
+
compiler.hooks.compilation.tap(_chunk63LJ4WHFjs.pluginName, (compilation) => {
|
|
141
|
+
NormalModule.getCompilationHooks(compilation).loader.tap(_chunk63LJ4WHFjs.pluginName, (_loaderContext, module) => {
|
|
140
142
|
const hasRuntimeLoader = runtimeClassSetLoaderExists || runtimeCssImportRewriteLoaderExists;
|
|
141
143
|
if (!hasRuntimeLoader) {
|
|
142
144
|
return;
|
|
143
145
|
}
|
|
144
|
-
|
|
146
|
+
_chunk6VSFN3NAjs.patchMpxLoaderResolve.call(void 0, _loaderContext, weappTailwindcssPackageDir, shouldRewriteCssImports && isMpxApp);
|
|
145
147
|
const loaderEntries = module.loaders || [];
|
|
146
148
|
let rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
147
149
|
const classSetAnchorIdx = findClassSetAnchor(loaderEntries);
|
|
148
|
-
const isCssModule =
|
|
150
|
+
const isCssModule = _chunk6VSFN3NAjs.isCssLikeModuleResource.call(void 0, module.resource, this.options.cssMatcher, this.appType);
|
|
149
151
|
if (_process2.default.env.WEAPP_TW_LOADER_DEBUG && isCssModule) {
|
|
150
152
|
debug("loader hook css module: %s loaders=%o anchors=%o", module.resource, loaderEntries.map((x) => x.loader), { rewriteAnchorIdx, classSetAnchorIdx });
|
|
151
153
|
}
|
|
@@ -177,7 +179,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
177
179
|
rewriteAnchorIdx = findRewriteAnchor(loaderEntries);
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
|
-
if (runtimeClassSetLoaderExists && !
|
|
182
|
+
if (runtimeClassSetLoaderExists && !_chunk6VSFN3NAjs.hasLoaderEntry.call(void 0, loaderEntries, runtimeClassSetLoader)) {
|
|
181
183
|
const classSetLoaderEntry = createRuntimeClassSetLoaderEntry();
|
|
182
184
|
const anchorIndex = findClassSetAnchor(loaderEntries);
|
|
183
185
|
if (anchorIndex === -1) {
|
|
@@ -190,7 +192,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
190
192
|
});
|
|
191
193
|
compilation.hooks.processAssets.tapPromise(
|
|
192
194
|
{
|
|
193
|
-
name:
|
|
195
|
+
name: _chunk63LJ4WHFjs.pluginName,
|
|
194
196
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
195
197
|
},
|
|
196
198
|
async (assets) => {
|
|
@@ -208,13 +210,13 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
208
210
|
const jsAssets = /* @__PURE__ */ new Map();
|
|
209
211
|
for (const [file] of entries) {
|
|
210
212
|
if (this.options.jsMatcher(file) || this.options.wxsMatcher(file)) {
|
|
211
|
-
const absolute =
|
|
213
|
+
const absolute = _chunkORSWL3MIjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
212
214
|
jsAssets.set(absolute, file);
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
const moduleGraphOptions = {
|
|
216
218
|
resolve(specifier, importer) {
|
|
217
|
-
return
|
|
219
|
+
return _chunkORSWL3MIjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => jsAssets.has(candidate));
|
|
218
220
|
},
|
|
219
221
|
load: (id) => {
|
|
220
222
|
const assetName = jsAssets.get(id);
|
|
@@ -259,7 +261,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
259
261
|
const groupedEntries = _chunkUW3WHSZ5js.getGroupedEntries.call(void 0, entries, this.options);
|
|
260
262
|
await refreshRuntimeState(true);
|
|
261
263
|
await runtimeState.patchPromise;
|
|
262
|
-
const runtimeSet = await
|
|
264
|
+
const runtimeSet = await _chunk63LJ4WHFjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, { force: true, skipRefresh: true });
|
|
263
265
|
debug("get runtimeSet, class count: %d", runtimeSet.size);
|
|
264
266
|
const tasks = [];
|
|
265
267
|
if (Array.isArray(groupedEntries.html)) {
|
|
@@ -296,12 +298,12 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
296
298
|
const jsTaskFactories = [];
|
|
297
299
|
if (Array.isArray(groupedEntries.js)) {
|
|
298
300
|
for (const [file] of groupedEntries.js) {
|
|
299
|
-
const cacheKey =
|
|
301
|
+
const cacheKey = _chunk6VSFN3NAjs.getCacheKey.call(void 0, file);
|
|
300
302
|
const asset = compilation.getAsset(file);
|
|
301
303
|
if (!asset) {
|
|
302
304
|
continue;
|
|
303
305
|
}
|
|
304
|
-
const absoluteFile =
|
|
306
|
+
const absoluteFile = _chunkORSWL3MIjs.toAbsoluteOutputPath.call(void 0, file, outputDir);
|
|
305
307
|
const initialSource = asset.source.source();
|
|
306
308
|
const initialRawSource = typeof initialSource === "string" ? initialSource : initialSource.toString();
|
|
307
309
|
jsTaskFactories.push(async () => {
|
|
@@ -376,7 +378,7 @@ var UnifiedWebpackPluginV5 = class {
|
|
|
376
378
|
);
|
|
377
379
|
}
|
|
378
380
|
}
|
|
379
|
-
|
|
381
|
+
_chunkORSWL3MIjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
380
382
|
await Promise.all(tasks);
|
|
381
383
|
debug("end");
|
|
382
384
|
onEnd();
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pushConcurrentTaskFactories,
|
|
3
|
+
resolveDisabledOptions,
|
|
3
4
|
resolveOutputSpecifier,
|
|
4
5
|
resolvePackageDir,
|
|
5
6
|
resolveTailwindcssImport,
|
|
6
7
|
rewriteTailwindcssImportsInCode,
|
|
7
8
|
toAbsoluteOutputPath
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3SKEY32E.mjs";
|
|
9
10
|
import {
|
|
10
11
|
processCachedTask
|
|
11
12
|
} from "./chunk-RRHPTTCP.mjs";
|
|
12
13
|
import {
|
|
13
14
|
setupPatchRecorder
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7UAU27KZ.mjs";
|
|
15
16
|
import {
|
|
16
17
|
collectRuntimeClassSet,
|
|
17
18
|
createAttributeMatcher,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
replaceWxml,
|
|
23
24
|
toCustomAttributesEntities,
|
|
24
25
|
vitePluginName
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ZC5JYOAR.mjs";
|
|
26
27
|
import {
|
|
27
28
|
getGroupedEntries
|
|
28
29
|
} from "./chunk-ZNKIYZRQ.mjs";
|
|
@@ -463,8 +464,52 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
463
464
|
uniAppX,
|
|
464
465
|
disabledDefaultTemplateHandler
|
|
465
466
|
} = opts;
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
const disabledOptions = resolveDisabledOptions(disabled);
|
|
468
|
+
const tailwindcssMajorVersion = initialTwPatcher.majorVersion ?? 0;
|
|
469
|
+
const shouldRewriteCssImports = opts.rewriteCssImports !== false && !disabledOptions.rewriteCssImports && (rewriteCssImportsSpecified || tailwindcssMajorVersion >= 4);
|
|
470
|
+
const rewritePlugins = !shouldRewriteCssImports ? [] : [
|
|
471
|
+
{
|
|
472
|
+
name: `${vitePluginName}:rewrite-css-imports`,
|
|
473
|
+
enforce: "pre",
|
|
474
|
+
resolveId: {
|
|
475
|
+
order: "pre",
|
|
476
|
+
handler(id, importer) {
|
|
477
|
+
const replacement = resolveTailwindcssImport(id, weappTailwindcssDirPosix, {
|
|
478
|
+
join: joinPosixPath,
|
|
479
|
+
appType
|
|
480
|
+
});
|
|
481
|
+
if (!replacement) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
if (importer && !isCssLikeImporter(importer)) {
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
return replacement;
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
transform: {
|
|
491
|
+
order: "pre",
|
|
492
|
+
handler(code, id) {
|
|
493
|
+
if (!isCSSRequest(id)) {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, {
|
|
497
|
+
join: joinPosixPath,
|
|
498
|
+
appType
|
|
499
|
+
});
|
|
500
|
+
if (!rewritten) {
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
code: rewritten,
|
|
505
|
+
map: null
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
];
|
|
511
|
+
if (disabledOptions.plugin) {
|
|
512
|
+
return rewritePlugins.length ? rewritePlugins : void 0;
|
|
468
513
|
}
|
|
469
514
|
const customAttributesEntities = toCustomAttributesEntities(customAttributes);
|
|
470
515
|
const patchRecorderState = setupPatchRecorder(initialTwPatcher, opts.tailwindcssBasedir, {
|
|
@@ -511,48 +556,6 @@ function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
|
511
556
|
}
|
|
512
557
|
}
|
|
513
558
|
onLoad();
|
|
514
|
-
const shouldRewriteCssImports = opts.rewriteCssImports !== false && (rewriteCssImportsSpecified || (runtimeState.twPatcher.majorVersion ?? 0) >= 4);
|
|
515
|
-
const rewritePlugins = !shouldRewriteCssImports ? [] : [
|
|
516
|
-
{
|
|
517
|
-
name: `${vitePluginName}:rewrite-css-imports`,
|
|
518
|
-
enforce: "pre",
|
|
519
|
-
resolveId: {
|
|
520
|
-
order: "pre",
|
|
521
|
-
handler(id, importer) {
|
|
522
|
-
const replacement = resolveTailwindcssImport(id, weappTailwindcssDirPosix, {
|
|
523
|
-
join: joinPosixPath,
|
|
524
|
-
appType
|
|
525
|
-
});
|
|
526
|
-
if (!replacement) {
|
|
527
|
-
return null;
|
|
528
|
-
}
|
|
529
|
-
if (importer && !isCssLikeImporter(importer)) {
|
|
530
|
-
return null;
|
|
531
|
-
}
|
|
532
|
-
return replacement;
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
transform: {
|
|
536
|
-
order: "pre",
|
|
537
|
-
handler(code, id) {
|
|
538
|
-
if (!isCSSRequest(id)) {
|
|
539
|
-
return null;
|
|
540
|
-
}
|
|
541
|
-
const rewritten = rewriteTailwindcssImportsInCode(code, weappTailwindcssDirPosix, {
|
|
542
|
-
join: joinPosixPath,
|
|
543
|
-
appType
|
|
544
|
-
});
|
|
545
|
-
if (!rewritten) {
|
|
546
|
-
return null;
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
code: rewritten,
|
|
550
|
-
map: null
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
];
|
|
556
559
|
const getResolvedConfig = () => resolvedConfig;
|
|
557
560
|
const uniAppXPlugins = uniAppX ? createUniAppXPlugins({
|
|
558
561
|
appType,
|
|
@@ -53,6 +53,20 @@ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
|
53
53
|
return matchWithExtensions(candidate, hasOutput);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// src/utils/disabled.ts
|
|
57
|
+
function resolveDisabledOptions(disabled) {
|
|
58
|
+
if (disabled === true) {
|
|
59
|
+
return { plugin: true, rewriteCssImports: false };
|
|
60
|
+
}
|
|
61
|
+
if (disabled === false || disabled == null) {
|
|
62
|
+
return { plugin: false, rewriteCssImports: false };
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
plugin: disabled.plugin ?? false,
|
|
66
|
+
rewriteCssImports: disabled.rewriteCssImports ?? false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
// src/utils/resolve-package.ts
|
|
57
71
|
import { createRequire } from "module";
|
|
58
72
|
import path2 from "path";
|
|
@@ -62,119 +76,8 @@ function resolvePackageDir(name) {
|
|
|
62
76
|
return path2.dirname(pkgPath);
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
// src/shared/mpx.ts
|
|
66
|
-
import path4 from "path";
|
|
67
|
-
|
|
68
|
-
// src/shared/tailwindcss-css-redirect.ts
|
|
69
|
-
import Module from "module";
|
|
70
|
-
import path3 from "path";
|
|
71
|
-
var moduleWithMutableResolve = Module;
|
|
72
|
-
var patched = /* @__PURE__ */ new WeakSet();
|
|
73
|
-
function installTailwindcssCssRedirect(pkgDir) {
|
|
74
|
-
const target = path3.join(pkgDir, "index.css");
|
|
75
|
-
const original = moduleWithMutableResolve._resolveFilename;
|
|
76
|
-
if (patched.has(original)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const replacements = /* @__PURE__ */ new Set(["tailwindcss", "tailwindcss$"]);
|
|
80
|
-
const resolveTailwindcssCss = (request, parent, isMain, options) => {
|
|
81
|
-
if (replacements.has(request)) {
|
|
82
|
-
return target;
|
|
83
|
-
}
|
|
84
|
-
if (request.startsWith("tailwindcss/")) {
|
|
85
|
-
return path3.join(pkgDir, request.slice("tailwindcss/".length));
|
|
86
|
-
}
|
|
87
|
-
return original(request, parent, isMain, options);
|
|
88
|
-
};
|
|
89
|
-
moduleWithMutableResolve._resolveFilename = resolveTailwindcssCss;
|
|
90
|
-
patched.add(moduleWithMutableResolve._resolveFilename);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// src/shared/mpx.ts
|
|
94
|
-
var MPX_STYLE_RESOURCE_QUERY_RE = /(?:^|[?&])type=styles(?:&|$)/;
|
|
95
|
-
function isMpxStyleResourceQuery(query) {
|
|
96
|
-
if (typeof query !== "string") {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return MPX_STYLE_RESOURCE_QUERY_RE.test(query);
|
|
100
|
-
}
|
|
101
|
-
function isMpx(appType) {
|
|
102
|
-
return appType === "mpx";
|
|
103
|
-
}
|
|
104
|
-
function getTailwindcssCssEntry(pkgDir) {
|
|
105
|
-
return path4.join(pkgDir, "index.css");
|
|
106
|
-
}
|
|
107
|
-
function ensureMpxTailwindcssAliases(compiler, pkgDir) {
|
|
108
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
109
|
-
compiler.options = compiler.options || {};
|
|
110
|
-
compiler.options.resolve = compiler.options.resolve || {};
|
|
111
|
-
const alias = compiler.options.resolve.alias ?? {};
|
|
112
|
-
if (Array.isArray(alias)) {
|
|
113
|
-
alias.push(
|
|
114
|
-
{ name: "tailwindcss", alias: tailwindcssCssEntry },
|
|
115
|
-
{ name: "tailwindcss$", alias: tailwindcssCssEntry }
|
|
116
|
-
);
|
|
117
|
-
} else {
|
|
118
|
-
compiler.options.resolve.alias = alias;
|
|
119
|
-
alias.tailwindcss = tailwindcssCssEntry;
|
|
120
|
-
alias.tailwindcss$ = tailwindcssCssEntry;
|
|
121
|
-
}
|
|
122
|
-
return tailwindcssCssEntry;
|
|
123
|
-
}
|
|
124
|
-
function patchMpxLoaderResolve(loaderContext, pkgDir, enabled) {
|
|
125
|
-
if (!enabled || typeof loaderContext.resolve !== "function") {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const originalResolve = loaderContext.resolve;
|
|
129
|
-
if (originalResolve.__weappTwPatched) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const tailwindcssCssEntry = getTailwindcssCssEntry(pkgDir);
|
|
133
|
-
const wrappedResolve = function(context, request, callback) {
|
|
134
|
-
if (request === "tailwindcss" || request === "tailwindcss$") {
|
|
135
|
-
return callback(null, tailwindcssCssEntry);
|
|
136
|
-
}
|
|
137
|
-
if (request?.startsWith("tailwindcss/")) {
|
|
138
|
-
return callback(null, path4.join(pkgDir, request.slice("tailwindcss/".length)));
|
|
139
|
-
}
|
|
140
|
-
return originalResolve.call(this, context, request, callback);
|
|
141
|
-
};
|
|
142
|
-
wrappedResolve.__weappTwPatched = true;
|
|
143
|
-
loaderContext.resolve = wrappedResolve;
|
|
144
|
-
}
|
|
145
|
-
function setupMpxTailwindcssRedirect(pkgDir, enabled) {
|
|
146
|
-
if (enabled) {
|
|
147
|
-
installTailwindcssCssRedirect(pkgDir);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function injectMpxCssRewritePreRules(compiler, loader, loaderOptions) {
|
|
151
|
-
var _a;
|
|
152
|
-
if (!loader) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const moduleOptions = (_a = compiler.options).module ?? (_a.module = { rules: [] });
|
|
156
|
-
moduleOptions.rules = moduleOptions.rules || [];
|
|
157
|
-
const createRule = (match) => ({
|
|
158
|
-
...match,
|
|
159
|
-
enforce: "pre",
|
|
160
|
-
use: [
|
|
161
|
-
{
|
|
162
|
-
loader,
|
|
163
|
-
options: loaderOptions
|
|
164
|
-
}
|
|
165
|
-
]
|
|
166
|
-
});
|
|
167
|
-
moduleOptions.rules.unshift(
|
|
168
|
-
createRule({ resourceQuery: (query) => isMpxStyleResourceQuery(query) }),
|
|
169
|
-
createRule({
|
|
170
|
-
test: /\.css$/i,
|
|
171
|
-
resourceQuery: (query) => !isMpxStyleResourceQuery(query)
|
|
172
|
-
})
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
79
|
// src/bundlers/shared/css-imports.ts
|
|
177
|
-
import
|
|
80
|
+
import path3 from "path";
|
|
178
81
|
var tailwindcssImportRE = /^tailwindcss(?:\/.*)?$/;
|
|
179
82
|
var tailwindcssCssImportStatementRE = /(@import\s+(?:url\(\s*)?)(["'])(tailwindcss(?:\/[^"']*)?\$?)(\2\s*\)?)/gi;
|
|
180
83
|
function normalizeTailwindcssSpecifier(specifier) {
|
|
@@ -194,10 +97,10 @@ function resolveTailwindcssImport(specifier, pkgDir, options) {
|
|
|
194
97
|
if (!tailwindcssImportRE.test(normalized)) {
|
|
195
98
|
return null;
|
|
196
99
|
}
|
|
197
|
-
if (
|
|
100
|
+
if (normalized === "tailwindcss") {
|
|
198
101
|
return "weapp-tailwindcss/index.css";
|
|
199
102
|
}
|
|
200
|
-
const join = options?.join ??
|
|
103
|
+
const join = options?.join ?? path3.join;
|
|
201
104
|
const subpath = getTailwindcssSubpath(normalized);
|
|
202
105
|
return join(pkgDir, subpath);
|
|
203
106
|
}
|
|
@@ -260,12 +163,8 @@ function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
|
260
163
|
export {
|
|
261
164
|
toAbsoluteOutputPath,
|
|
262
165
|
resolveOutputSpecifier,
|
|
166
|
+
resolveDisabledOptions,
|
|
263
167
|
resolvePackageDir,
|
|
264
|
-
isMpx,
|
|
265
|
-
ensureMpxTailwindcssAliases,
|
|
266
|
-
patchMpxLoaderResolve,
|
|
267
|
-
setupMpxTailwindcssRedirect,
|
|
268
|
-
injectMpxCssRewritePreRules,
|
|
269
168
|
resolveTailwindcssImport,
|
|
270
169
|
rewriteTailwindcssImportsInCode,
|
|
271
170
|
pushConcurrentTaskFactories
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk63LJ4WHFjs = require('./chunk-63LJ4WHF.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
var _chunkJ4MI4EJOjs = require('./chunk-J4MI4EJO.js');
|
|
8
8
|
|
|
9
9
|
// src/tailwindcss/recorder.ts
|
|
10
10
|
function setupPatchRecorder(patcher, baseDir, options) {
|
|
11
|
-
const recorder =
|
|
11
|
+
const recorder = _chunk63LJ4WHFjs.createPatchTargetRecorder.call(void 0, baseDir, patcher, options);
|
|
12
12
|
if (_optionalChain([recorder, 'optionalAccess', _ => _.message]) && _optionalChain([options, 'optionalAccess', _2 => _2.logMessage]) !== false) {
|
|
13
13
|
const prefix = _optionalChain([options, 'optionalAccess', _3 => _3.messagePrefix]) ? `${options.messagePrefix} ` : "";
|
|
14
14
|
_chunkJ4MI4EJOjs.logger.info("%s%s", prefix, recorder.message);
|
|
@@ -16,7 +16,7 @@ function setupPatchRecorder(patcher, baseDir, options) {
|
|
|
16
16
|
const onPatchCompleted = _optionalChain([recorder, 'optionalAccess', _4 => _4.onPatched]) ? async () => {
|
|
17
17
|
await recorder.onPatched();
|
|
18
18
|
} : void 0;
|
|
19
|
-
const patchPromise = patcher ?
|
|
19
|
+
const patchPromise = patcher ? _chunk63LJ4WHFjs.createTailwindPatchPromise.call(void 0, patcher, onPatchCompleted) : Promise.resolve();
|
|
20
20
|
return {
|
|
21
21
|
recorder,
|
|
22
22
|
patchPromise,
|
|
@@ -187,7 +187,7 @@ async function collectRuntimeClassSet(twPatcher, options = {}) {
|
|
|
187
187
|
// package.json
|
|
188
188
|
var package_default = {
|
|
189
189
|
name: "weapp-tailwindcss",
|
|
190
|
-
version: "4.8.
|
|
190
|
+
version: "4.8.14",
|
|
191
191
|
description: "\u628A tailwindcss \u539F\u5B50\u5316\u6837\u5F0F\u601D\u60F3\uFF0C\u5E26\u7ED9\u5C0F\u7A0B\u5E8F\u5F00\u53D1\u8005\u4EEC! bring tailwindcss to miniprogram developers!",
|
|
192
192
|
author: "ice breaker <1324318532@qq.com>",
|
|
193
193
|
license: "MIT",
|