weapp-tailwindcss 4.12.0 → 5.0.0-next.1
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/babel/index.d.ts +3 -0
- package/dist/bundlers/gulp/index.d.ts +7 -0
- package/dist/bundlers/shared/cache.d.ts +16 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +4 -0
- package/dist/bundlers/shared/css-imports.d.ts +8 -0
- package/dist/bundlers/shared/generator-candidates.d.ts +5 -0
- package/dist/bundlers/shared/generator-css.d.ts +41 -0
- package/dist/bundlers/shared/module-graph.d.ts +5 -0
- package/dist/bundlers/shared/run-tasks.d.ts +2 -0
- package/dist/bundlers/vite/bundle-entries.d.ts +14 -0
- package/dist/bundlers/vite/bundle-state.d.ts +43 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +19 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +20 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +21 -0
- package/dist/bundlers/vite/index.d.ts +3 -0
- package/dist/bundlers/vite/js-precheck.d.ts +1 -0
- package/dist/bundlers/vite/query.d.ts +15 -0
- package/dist/bundlers/vite/resolve-app-type.d.ts +2 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +11 -0
- package/dist/bundlers/vite/runtime-affecting-signature.d.ts +2 -0
- package/dist/bundlers/vite/utils.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +20 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +14 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +15 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +9 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +17 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +19 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +9 -0
- package/dist/bundlers/webpack/index.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +12 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +11 -0
- package/dist/bundlers/webpack/shared/css-imports.d.ts +6 -0
- package/dist/bundlers/webpack/shared/loader-anchors.d.ts +8 -0
- package/dist/cache/index.d.ts +38 -0
- package/dist/cache/md5.d.ts +1 -0
- package/dist/chunk-8l464Juk.js +28 -0
- package/dist/cli/config.d.ts +5 -0
- package/dist/cli/context.d.ts +16 -0
- package/dist/cli/doctor/constants.d.ts +7 -0
- package/dist/cli/doctor/types.d.ts +31 -0
- package/dist/cli/doctor.d.ts +4 -0
- package/dist/cli/helpers/options/format.d.ts +2 -0
- package/dist/cli/helpers/options/parse.d.ts +3 -0
- package/dist/cli/helpers/options/resolve.d.ts +1 -0
- package/dist/cli/helpers/options.d.ts +3 -0
- package/dist/cli/helpers/patch-cwd.d.ts +1 -0
- package/dist/cli/helpers.d.ts +5 -0
- package/dist/cli/mount-options/patch-status.d.ts +2 -0
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/patch-options.d.ts +6 -0
- package/dist/cli/tokens.d.ts +4 -0
- package/dist/cli/types.d.ts +17 -0
- package/dist/cli/vscode-entry.d.ts +14 -0
- package/dist/cli/workspace/package-dirs.d.ts +3 -0
- package/dist/cli/workspace/patch-package.d.ts +3 -0
- package/dist/cli/workspace/patch-utils.d.ts +3 -0
- package/dist/cli/workspace/types.d.ts +11 -0
- package/dist/cli/workspace/workspace-globs.d.ts +2 -0
- package/dist/cli/workspace/workspace-io.d.ts +1 -0
- package/dist/cli/workspace/workspace-lock.d.ts +1 -0
- package/dist/cli/workspace.d.ts +2 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +2425 -3524
- package/dist/cli.mjs +2402 -3505
- package/dist/constants-B-_T5UnW.mjs +44 -0
- package/dist/constants-p1dyh1x1.js +73 -0
- package/dist/constants.d.ts +13 -0
- package/dist/context/compiler-context-cache.d.ts +3 -0
- package/dist/context/custom-attributes.d.ts +2 -0
- package/dist/context/handlers.d.ts +6 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/context/logger.d.ts +4 -0
- package/dist/context/tailwindcss/basedir.d.ts +1 -0
- package/dist/context/tailwindcss/rax.d.ts +2 -0
- package/dist/context/tailwindcss.d.ts +4 -0
- package/dist/context/workspace.d.ts +3 -0
- package/dist/core.d.ts +5 -21
- package/dist/core.js +138 -180
- package/dist/core.mjs +135 -180
- package/dist/css-imports-BbrbluP9.js +177 -0
- package/dist/css-imports-CSdPq_Sc.mjs +128 -0
- package/dist/css-macro/constants.d.ts +14 -0
- package/dist/css-macro/index.d.ts +15 -0
- package/dist/css-macro/postcss.d.ts +3 -7
- package/dist/css-macro/postcss.js +44 -58
- package/dist/css-macro/postcss.mjs +44 -56
- package/dist/css-macro.d.ts +1 -20
- package/dist/css-macro.js +37 -50
- package/dist/css-macro.mjs +33 -47
- package/dist/debug/index.d.ts +5 -0
- package/dist/defaults.d.ts +2 -11
- package/dist/defaults.js +132 -8
- package/dist/defaults.mjs +128 -7
- package/dist/escape.js +31 -54
- package/dist/escape.mjs +18 -25
- package/dist/experimental/index.d.ts +2 -0
- package/dist/experimental/oxc/ast-utils.d.ts +30 -0
- package/dist/experimental/oxc/index.d.ts +2 -0
- package/dist/experimental/oxc/module-specifiers.d.ts +2 -0
- package/dist/experimental/shared/cache.d.ts +3 -0
- package/dist/experimental/shared/transform.d.ts +3 -0
- package/dist/experimental/shared.d.ts +8 -0
- package/dist/experimental/swc/ast-utils.d.ts +30 -0
- package/dist/experimental/swc/index.d.ts +2 -0
- package/dist/experimental/swc/module-specifiers.d.ts +2 -0
- package/dist/generator/index.d.ts +11 -0
- package/dist/generator/options.d.ts +15 -0
- package/dist/generator/types.d.ts +19 -0
- package/dist/generator-CZ-JXw6T.js +492 -0
- package/dist/generator-Dwxgra97.mjs +399 -0
- package/dist/generator-css-CnYjiMrD.js +1084 -0
- package/dist/generator-css-DhPFjSzK.mjs +1057 -0
- package/dist/generator.d.ts +1 -0
- package/dist/generator.js +19 -0
- package/dist/generator.mjs +2 -0
- package/dist/gulp.d.ts +4 -24
- package/dist/gulp.js +271 -13
- package/dist/gulp.mjs +263 -13
- package/dist/index.d.ts +8 -15
- package/dist/index.js +12 -24
- package/dist/index.mjs +6 -24
- package/dist/js/JsTokenUpdater.d.ts +14 -0
- package/dist/js/ModuleGraph.d.ts +18 -0
- package/dist/js/NodePathWalker.d.ts +33 -0
- package/dist/js/babel/parse.d.ts +9 -0
- package/dist/js/babel/process.d.ts +4 -0
- package/dist/js/babel.d.ts +13 -0
- package/dist/js/class-context.d.ts +3 -0
- package/dist/js/evalTransforms.d.ts +7 -0
- package/dist/js/handlers.d.ts +5 -0
- package/dist/js/index.d.ts +4 -0
- package/dist/js/module-graph/ignored-exports.d.ts +18 -0
- package/dist/js/module-graph/types.d.ts +17 -0
- package/dist/js/node-path-walker/export-handlers.d.ts +12 -0
- package/dist/js/node-path-walker/import-tokens.d.ts +24 -0
- package/dist/js/precheck.d.ts +2 -0
- package/dist/js/sourceAnalysis.d.ts +17 -0
- package/dist/js/syntax.d.ts +10 -0
- package/dist/js/taggedTemplateIgnore.d.ts +13 -0
- package/dist/js/types.d.ts +11 -0
- package/dist/lightningcss/index.d.ts +8 -0
- package/dist/lightningcss/style-handler/options.d.ts +3 -0
- package/dist/lightningcss/style-handler/selector-transform.d.ts +10 -0
- package/dist/lightningcss/style-handler/selector-utils.d.ts +10 -0
- package/dist/lightningcss/style-handler.d.ts +17 -0
- package/dist/loader-anchors-DvwgIYdA.mjs +205 -0
- package/dist/loader-anchors-cprm4Klq.js +273 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger-BZ45DZJT.js +1003 -0
- package/dist/logger-BoVx1Dbt.mjs +935 -0
- package/dist/patcher-options-6gJN2EXy.js +115 -0
- package/dist/patcher-options-DQfR5xxT.mjs +92 -0
- package/dist/postcss-html-transform.d.ts +3 -3
- package/dist/postcss-html-transform.js +7 -10
- package/dist/postcss-html-transform.mjs +3 -6
- package/dist/postcss.d.ts +15 -0
- package/dist/postcss.js +278 -0
- package/dist/postcss.mjs +268 -0
- package/dist/presets/hbuilderx.d.ts +4 -0
- package/dist/presets/index.d.ts +3 -0
- package/dist/presets/shared.d.ts +10 -0
- package/dist/presets/taro.d.ts +4 -0
- package/dist/presets/uni-app-x.d.ts +16 -0
- package/dist/presets/uni-app.d.ts +4 -0
- package/dist/presets.d.ts +1 -76
- package/dist/presets.js +115 -163
- package/dist/presets.mjs +107 -163
- package/dist/recorder-B_XyZ576.mjs +2763 -0
- package/dist/recorder-rn_2v_nd.js +2878 -0
- package/dist/reset/index.d.ts +2 -0
- package/dist/reset.d.ts +1 -4
- package/dist/reset.js +19 -8
- package/dist/reset.mjs +2 -8
- package/dist/shared/classname-transform.d.ts +14 -0
- package/dist/shared/mpx.d.ts +7 -0
- package/dist/shared/tailwindcss-css-redirect.d.ts +1 -0
- package/dist/tailwindcss/index.d.ts +11 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -0
- package/dist/tailwindcss/patcher-options.d.ts +56 -0
- package/dist/tailwindcss/patcher-resolve.d.ts +4 -0
- package/dist/tailwindcss/patcher.d.ts +13 -0
- package/dist/tailwindcss/recorder.d.ts +13 -0
- package/dist/tailwindcss/remove-unsupported-css.d.ts +2 -0
- package/dist/tailwindcss/runtime/cache.d.ts +11 -0
- package/dist/tailwindcss/runtime-logs.d.ts +3 -0
- package/dist/tailwindcss/runtime.d.ts +29 -0
- package/dist/tailwindcss/targets/paths.d.ts +13 -0
- package/dist/tailwindcss/targets/record-io.d.ts +5 -0
- package/dist/tailwindcss/targets/recorder.d.ts +3 -0
- package/dist/tailwindcss/targets/types.d.ts +35 -0
- package/dist/tailwindcss/targets.d.ts +6 -0
- package/dist/tailwindcss/v3-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v3-engine/index.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +4 -0
- package/dist/tailwindcss/v3-engine/source.d.ts +5 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +55 -0
- package/dist/tailwindcss/v4/config.d.ts +5 -0
- package/dist/tailwindcss/v4/css-entries.d.ts +7 -0
- package/dist/tailwindcss/v4/index.d.ts +2 -0
- package/dist/tailwindcss/v4/multi-patcher.d.ts +2 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +24 -0
- package/dist/tailwindcss/v4/patcher.d.ts +14 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/generator.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/index.d.ts +5 -0
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +4 -0
- package/dist/tailwindcss/v4-engine/source.d.ts +7 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -0
- package/dist/typedoc.export.d.ts +5 -0
- package/dist/types/base.d.ts +1 -0
- package/dist/types/disabled-options.d.ts +4 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/shared.d.ts +7 -0
- package/dist/types/user-defined-options/general.d.ts +31 -0
- package/dist/types/user-defined-options/important.d.ts +37 -0
- package/dist/types/user-defined-options/index.d.ts +11 -0
- package/dist/types/user-defined-options/lifecycle.d.ts +6 -0
- package/dist/types/user-defined-options/matcher.d.ts +9 -0
- package/dist/types.d.ts +1 -150
- package/dist/types.js +0 -1
- package/dist/types.mjs +1 -1
- package/dist/uni-app-x/component-local-style.d.ts +19 -0
- package/dist/uni-app-x/index.d.ts +2 -0
- package/dist/uni-app-x/options.d.ts +12 -0
- package/dist/uni-app-x/style-isolation.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +9 -0
- package/dist/uni-app-x/vite.d.ts +36 -0
- package/dist/utils/decode.d.ts +2 -0
- package/dist/utils/disabled.d.ts +6 -0
- package/dist/utils/hbuilderx.d.ts +5 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/nameMatcher.d.ts +4 -0
- package/dist/utils/resolve-package.d.ts +1 -0
- package/dist/utils/uni-platform.d.ts +11 -0
- package/dist/utils-7DUGTFED.mjs +48 -0
- package/dist/utils-DmC9_In3.js +61 -0
- package/dist/vite-BHpAqldo.js +1952 -0
- package/dist/vite-C8JlHiyR.mjs +1940 -0
- package/dist/vite.d.ts +4 -17
- package/dist/vite.js +5 -14
- package/dist/vite.mjs +2 -14
- package/dist/weapp-tw-css-import-rewrite-loader.js +59 -92
- package/dist/weapp-tw-runtime-classset-loader.js +31 -50
- package/dist/webpack-CABjKGGQ.mjs +441 -0
- package/dist/webpack-DNIJ0ysE.js +456 -0
- package/dist/webpack.d.ts +4 -25
- package/dist/webpack.js +6 -17
- package/dist/webpack.mjs +2 -17
- package/dist/webpack4.d.ts +4 -26
- package/dist/webpack4.js +375 -481
- package/dist/webpack4.mjs +366 -482
- package/dist/wxml/Tokenizer.d.ts +15 -0
- package/dist/wxml/custom-attributes.d.ts +4 -0
- package/dist/wxml/index.d.ts +2 -0
- package/dist/wxml/shared.d.ts +2 -0
- package/dist/wxml/tokenizer/types.d.ts +18 -0
- package/dist/wxml/utils/codegen/legacy-rewriter.d.ts +2 -0
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +8 -0
- package/dist/wxml/utils/codegen.d.ts +2 -0
- package/dist/wxml/utils/custom-template.d.ts +3 -0
- package/dist/wxml/utils/fragment-helpers.d.ts +6 -0
- package/dist/wxml/utils/fragment-updater.d.ts +4 -0
- package/dist/wxml/utils/template-fragments.d.ts +3 -0
- package/dist/wxml/utils.d.ts +8 -0
- package/dist/wxml/whitespace.d.ts +2 -0
- package/generator-placeholder.css +1 -0
- package/package.json +19 -5
- package/dist/chunk-24AGZQVR.js +0 -183
- package/dist/chunk-3VQKDHGP.mjs +0 -179
- package/dist/chunk-4AFQP74Z.js +0 -24
- package/dist/chunk-57SOQCAU.mjs +0 -582
- package/dist/chunk-5ZYHNDEK.mjs +0 -2439
- package/dist/chunk-76S2EME4.mjs +0 -34
- package/dist/chunk-A5PB4KZT.js +0 -138
- package/dist/chunk-DUHYLR2R.js +0 -276
- package/dist/chunk-DYLQ6UOI.js +0 -71
- package/dist/chunk-E7I5TW5K.js +0 -52
- package/dist/chunk-FS2NOOEB.js +0 -292
- package/dist/chunk-HVNGIKLS.js +0 -3930
- package/dist/chunk-JZQBZHN5.js +0 -579
- package/dist/chunk-KGTVD4EP.mjs +0 -3930
- package/dist/chunk-NNOQDMUP.mjs +0 -10
- package/dist/chunk-OF6MFURR.js +0 -34
- package/dist/chunk-OFB2KBRP.js +0 -2442
- package/dist/chunk-OOHJLO5M.mjs +0 -71
- package/dist/chunk-PCDYXXSK.mjs +0 -1515
- package/dist/chunk-RKISS72P.js +0 -7
- package/dist/chunk-RRQZL7FQ.mjs +0 -292
- package/dist/chunk-XAKAD2CR.mjs +0 -138
- package/dist/chunk-XZP3MREK.mjs +0 -276
- package/dist/chunk-ZAA5ZG3D.js +0 -1518
- package/dist/chunk-ZCH4YINE.mjs +0 -52
- package/dist/cli.d.mts +0 -2
- package/dist/core.d.mts +0 -26
- package/dist/css-macro/postcss.d.mts +0 -7
- package/dist/css-macro.d.mts +0 -18
- package/dist/defaults.d.mts +0 -11
- package/dist/gulp.d.mts +0 -24
- package/dist/index-BXrmQelt.d.mts +0 -672
- package/dist/index-BXrmQelt.d.ts +0 -672
- package/dist/index.d.mts +0 -15
- package/dist/postcss-html-transform.d.mts +0 -2
- package/dist/presets.d.mts +0 -76
- package/dist/reset.d.mts +0 -1
- package/dist/types.d.mts +0 -150
- package/dist/vite.d.mts +0 -17
- package/dist/webpack.d.mts +0 -25
- package/dist/webpack4.d.mts +0 -26
package/dist/chunk-OFB2KBRP.js
DELETED
|
@@ -1,2442 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunk24AGZQVRjs = require('./chunk-24AGZQVR.js');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunkOF6MFURRjs = require('./chunk-OF6MFURR.js');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _chunkHVNGIKLSjs = require('./chunk-HVNGIKLS.js');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var _chunkZAA5ZG3Djs = require('./chunk-ZAA5ZG3D.js');
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var _chunkDYLQ6UOIjs = require('./chunk-DYLQ6UOI.js');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var _chunkRKISS72Pjs = require('./chunk-RKISS72P.js');
|
|
47
|
-
|
|
48
|
-
// src/bundlers/vite/index.ts
|
|
49
|
-
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
50
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
51
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
52
|
-
var _logger = require('@weapp-tailwindcss/logger');
|
|
53
|
-
var _htmltransform = require('@weapp-tailwindcss/postcss/html-transform'); var _htmltransform2 = _interopRequireDefault(_htmltransform);
|
|
54
|
-
|
|
55
|
-
// src/uni-app-x/transform.ts
|
|
56
|
-
var _compilerdom = require('@vue/compiler-dom');
|
|
57
|
-
var _compilersfc = require('@vue/compiler-sfc');
|
|
58
|
-
var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring);
|
|
59
|
-
|
|
60
|
-
// src/uni-app-x/component-local-style.ts
|
|
61
|
-
var _extractors = require('@weapp-tailwindcss/shared/extractors');
|
|
62
|
-
|
|
63
|
-
var EXPRESSION_WRAPPER_PREFIX = "(\n";
|
|
64
|
-
var EXPRESSION_WRAPPER_SUFFIX = "\n)";
|
|
65
|
-
var COMPONENT_RE = /(?:^|[/\\])components(?:[/\\].+)?\.(?:uvue|nvue)$/;
|
|
66
|
-
function createStableHash(input) {
|
|
67
|
-
let hash = 2166136261;
|
|
68
|
-
for (let i = 0; i < input.length; i++) {
|
|
69
|
-
hash ^= input.charCodeAt(i);
|
|
70
|
-
hash = Math.imul(hash, 16777619);
|
|
71
|
-
}
|
|
72
|
-
return (hash >>> 0).toString(36);
|
|
73
|
-
}
|
|
74
|
-
function extractLiteralValue(path7) {
|
|
75
|
-
const allowDoubleQuotes = path7.isTemplateElement();
|
|
76
|
-
if (path7.isStringLiteral()) {
|
|
77
|
-
return {
|
|
78
|
-
allowDoubleQuotes,
|
|
79
|
-
literal: path7.node.value,
|
|
80
|
-
offset: 1
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
allowDoubleQuotes,
|
|
85
|
-
literal: typeof path7.node.value === "string" ? path7.node.value : path7.node.value.raw,
|
|
86
|
-
offset: 0
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function createAlias(fileId, utility, index) {
|
|
90
|
-
return `wtu-${createStableHash(`${fileId}:${utility}`)}-${index.toString(36)}`;
|
|
91
|
-
}
|
|
92
|
-
function isRuntimeCandidate(candidate, runtimeSet) {
|
|
93
|
-
if (!runtimeSet || runtimeSet.size === 0) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
return runtimeSet.has(candidate) || runtimeSet.has(_chunkHVNGIKLSjs.replaceWxml.call(void 0, candidate));
|
|
97
|
-
}
|
|
98
|
-
function shouldEnableComponentLocalStyle(id) {
|
|
99
|
-
return COMPONENT_RE.test(id);
|
|
100
|
-
}
|
|
101
|
-
var UniAppXComponentLocalStyleCollector = class {
|
|
102
|
-
constructor(fileId, runtimeSet) {
|
|
103
|
-
this.fileId = fileId;
|
|
104
|
-
this.runtimeSet = runtimeSet;
|
|
105
|
-
this.aliasByUtility = /* @__PURE__ */ new Map();
|
|
106
|
-
this.aliasByLookup = /* @__PURE__ */ new Map();
|
|
107
|
-
}
|
|
108
|
-
ensureAlias(utility) {
|
|
109
|
-
const cached = this.aliasByUtility.get(utility);
|
|
110
|
-
if (cached) {
|
|
111
|
-
return cached;
|
|
112
|
-
}
|
|
113
|
-
const alias = createAlias(this.fileId, utility, this.aliasByUtility.size);
|
|
114
|
-
this.aliasByUtility.set(utility, alias);
|
|
115
|
-
this.aliasByLookup.set(utility, alias);
|
|
116
|
-
this.aliasByLookup.set(_chunkHVNGIKLSjs.replaceWxml.call(void 0, utility), alias);
|
|
117
|
-
return alias;
|
|
118
|
-
}
|
|
119
|
-
rewriteLiteral(literal, shouldInclude) {
|
|
120
|
-
const candidates = _extractors.splitCode.call(void 0, literal);
|
|
121
|
-
if (candidates.length === 0) {
|
|
122
|
-
return literal;
|
|
123
|
-
}
|
|
124
|
-
let rewritten = literal;
|
|
125
|
-
for (const candidate of candidates) {
|
|
126
|
-
if (!shouldInclude(candidate)) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
rewritten = rewritten.replace(candidate, this.ensureAlias(candidate));
|
|
130
|
-
}
|
|
131
|
-
return rewritten;
|
|
132
|
-
}
|
|
133
|
-
collectAndRewriteStaticClass(literal) {
|
|
134
|
-
return this.rewriteLiteral(literal, (candidate) => isRuntimeCandidate(candidate, this.runtimeSet));
|
|
135
|
-
}
|
|
136
|
-
collectRuntimeClasses(rawSource, options = {}) {
|
|
137
|
-
const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
|
|
138
|
-
try {
|
|
139
|
-
const ast = _chunkHVNGIKLSjs.babelParse.call(void 0, wrapped, {
|
|
140
|
-
plugins: ["typescript"],
|
|
141
|
-
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
142
|
-
});
|
|
143
|
-
const analysis = _chunkHVNGIKLSjs.analyzeSource.call(void 0, ast, {}, void 0, false);
|
|
144
|
-
for (const path7 of analysis.targetPaths) {
|
|
145
|
-
const { literal, allowDoubleQuotes } = extractLiteralValue(path7);
|
|
146
|
-
const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
|
|
147
|
-
const classContext = options.wrapExpression || _chunkHVNGIKLSjs.isClassContextLiteralPath.call(void 0, path7);
|
|
148
|
-
for (const candidate of candidates) {
|
|
149
|
-
if (!candidate || !classContext && !isRuntimeCandidate(candidate, this.runtimeSet)) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (isRuntimeCandidate(candidate, this.runtimeSet)) {
|
|
153
|
-
this.ensureAlias(candidate);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
} catch (e) {
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
rewriteTransformedCode(rawSource, options = {}) {
|
|
161
|
-
if (this.aliasByLookup.size === 0) {
|
|
162
|
-
return rawSource;
|
|
163
|
-
}
|
|
164
|
-
const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
|
|
165
|
-
try {
|
|
166
|
-
const ast = _chunkHVNGIKLSjs.babelParse.call(void 0, wrapped, {
|
|
167
|
-
plugins: ["typescript"],
|
|
168
|
-
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
169
|
-
});
|
|
170
|
-
const analysis = _chunkHVNGIKLSjs.analyzeSource.call(void 0, ast, {}, void 0, false);
|
|
171
|
-
if (analysis.targetPaths.length === 0) {
|
|
172
|
-
return rawSource;
|
|
173
|
-
}
|
|
174
|
-
const updater = new (0, _chunkHVNGIKLSjs.JsTokenUpdater)();
|
|
175
|
-
for (const path7 of analysis.targetPaths) {
|
|
176
|
-
const { literal, allowDoubleQuotes, offset } = extractLiteralValue(path7);
|
|
177
|
-
const candidates = _extractors.splitCode.call(void 0, literal, allowDoubleQuotes);
|
|
178
|
-
if (candidates.length === 0) {
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
let rewritten = literal;
|
|
182
|
-
let mutated = false;
|
|
183
|
-
for (const candidate of candidates) {
|
|
184
|
-
const alias = this.aliasByLookup.get(candidate);
|
|
185
|
-
if (!alias) {
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
const replaced = rewritten.replace(candidate, alias);
|
|
189
|
-
if (replaced !== rewritten) {
|
|
190
|
-
rewritten = replaced;
|
|
191
|
-
mutated = true;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (!mutated || typeof path7.node.start !== "number" || typeof path7.node.end !== "number") {
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
updater.addToken({
|
|
198
|
-
start: path7.node.start + offset,
|
|
199
|
-
end: path7.node.end - offset,
|
|
200
|
-
value: rewritten,
|
|
201
|
-
path: path7
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
if (updater.length === 0) {
|
|
205
|
-
return rawSource;
|
|
206
|
-
}
|
|
207
|
-
const ms = new (0, _magicstring2.default)(wrapped);
|
|
208
|
-
updater.updateMagicString(ms);
|
|
209
|
-
if (options.wrapExpression) {
|
|
210
|
-
ms.remove(0, EXPRESSION_WRAPPER_PREFIX.length);
|
|
211
|
-
ms.remove(wrapped.length - EXPRESSION_WRAPPER_SUFFIX.length, wrapped.length);
|
|
212
|
-
}
|
|
213
|
-
return ms.toString();
|
|
214
|
-
} catch (e2) {
|
|
215
|
-
return rawSource;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
hasStyles() {
|
|
219
|
-
return this.aliasByUtility.size > 0;
|
|
220
|
-
}
|
|
221
|
-
toStyleBlock() {
|
|
222
|
-
if (!this.hasStyles()) {
|
|
223
|
-
return "";
|
|
224
|
-
}
|
|
225
|
-
const lines = ["<style scoped>"];
|
|
226
|
-
for (const [utility, alias] of this.aliasByUtility) {
|
|
227
|
-
lines.push(`.${alias} {`);
|
|
228
|
-
lines.push(` @apply ${utility};`);
|
|
229
|
-
lines.push("}");
|
|
230
|
-
}
|
|
231
|
-
lines.push("</style>");
|
|
232
|
-
return `${lines.join("\n")}
|
|
233
|
-
`;
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
// src/uni-app-x/transform.ts
|
|
238
|
-
function traverse2(node, visitor) {
|
|
239
|
-
visitor(node);
|
|
240
|
-
if (Array.isArray(node.children)) {
|
|
241
|
-
for (const child of node.children) {
|
|
242
|
-
if (child && typeof child === "object" && "type" in child) {
|
|
243
|
-
traverse2(child, visitor);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
function updateStaticAttribute(ms, prop, content = _optionalChain([prop, 'access', _ => _.value, 'optionalAccess', _2 => _2.content])) {
|
|
249
|
-
if (!prop.value) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const start = prop.value.loc.start.offset + 1;
|
|
253
|
-
const end = prop.value.loc.end.offset - 1;
|
|
254
|
-
if (start < end) {
|
|
255
|
-
ms.update(start, end, _chunkHVNGIKLSjs.replaceWxml.call(void 0, _nullishCoalesce(content, () => ( ""))));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
function updateStaticAttributeWithLocalStyle(ms, prop, collector, content = _optionalChain([prop, 'access', _3 => _3.value, 'optionalAccess', _4 => _4.content])) {
|
|
259
|
-
if (!prop.value) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const start = prop.value.loc.start.offset + 1;
|
|
263
|
-
const end = prop.value.loc.end.offset - 1;
|
|
264
|
-
if (start < end) {
|
|
265
|
-
ms.update(start, end, collector.collectAndRewriteStaticClass(_nullishCoalesce(content, () => ( ""))));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
function updateDirectiveExpression(ms, prop, jsHandler, runtimeSet) {
|
|
269
|
-
if (_optionalChain([prop, 'access', _5 => _5.exp, 'optionalAccess', _6 => _6.type]) !== _compilerdom.NodeTypes.SIMPLE_EXPRESSION) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const expression = prop.exp.content;
|
|
273
|
-
const start = prop.exp.loc.start.offset;
|
|
274
|
-
const end = prop.exp.loc.end.offset;
|
|
275
|
-
if (start >= end) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
const generated = _chunkHVNGIKLSjs.generateCode.call(void 0, expression, {
|
|
279
|
-
jsHandler,
|
|
280
|
-
runtimeSet,
|
|
281
|
-
wrapExpression: true
|
|
282
|
-
});
|
|
283
|
-
ms.update(start, end, generated);
|
|
284
|
-
}
|
|
285
|
-
function updateDirectiveExpressionWithLocalStyle(ms, prop, jsHandler, collector, runtimeSet) {
|
|
286
|
-
if (_optionalChain([prop, 'access', _7 => _7.exp, 'optionalAccess', _8 => _8.type]) !== _compilerdom.NodeTypes.SIMPLE_EXPRESSION) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
const expression = prop.exp.content;
|
|
290
|
-
const start = prop.exp.loc.start.offset;
|
|
291
|
-
const end = prop.exp.loc.end.offset;
|
|
292
|
-
if (start >= end) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
collector.collectRuntimeClasses(expression, {
|
|
296
|
-
wrapExpression: true
|
|
297
|
-
});
|
|
298
|
-
const generated = _chunkHVNGIKLSjs.generateCode.call(void 0, expression, {
|
|
299
|
-
jsHandler,
|
|
300
|
-
runtimeSet,
|
|
301
|
-
wrapExpression: true
|
|
302
|
-
});
|
|
303
|
-
ms.update(start, end, collector.rewriteTransformedCode(generated, { wrapExpression: true }));
|
|
304
|
-
}
|
|
305
|
-
function shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute) {
|
|
306
|
-
const lowerName = attrName.toLowerCase();
|
|
307
|
-
const shouldHandleDefault = !disabledDefaultTemplateHandler && lowerName === "class";
|
|
308
|
-
const shouldHandleCustom = _nullishCoalesce(_optionalChain([matchCustomAttribute, 'optionalCall', _9 => _9(tag, attrName)]), () => ( false));
|
|
309
|
-
return {
|
|
310
|
-
shouldHandleDefault,
|
|
311
|
-
shouldHandleCustom,
|
|
312
|
-
shouldHandle: shouldHandleDefault || shouldHandleCustom
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
var defaultCreateJsHandlerOptions = {
|
|
316
|
-
babelParserOptions: {
|
|
317
|
-
plugins: [
|
|
318
|
-
"typescript"
|
|
319
|
-
]
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
var UVUE_NVUE_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
323
|
-
function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
324
|
-
if (!UVUE_NVUE_RE.test(id)) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
|
|
328
|
-
const matchCustomAttribute = _chunkHVNGIKLSjs.createAttributeMatcher.call(void 0, customAttributesEntities);
|
|
329
|
-
const ms = new (0, _magicstring2.default)(code);
|
|
330
|
-
const { descriptor, errors } = _compilersfc.parse.call(void 0, code);
|
|
331
|
-
const localStyleCollector = options.enableComponentLocalStyle && shouldEnableComponentLocalStyle(id) ? new UniAppXComponentLocalStyleCollector(id, runtimeSet) : void 0;
|
|
332
|
-
if (errors.length === 0) {
|
|
333
|
-
if (_optionalChain([descriptor, 'access', _10 => _10.template, 'optionalAccess', _11 => _11.ast])) {
|
|
334
|
-
traverse2(descriptor.template.ast, (node) => {
|
|
335
|
-
if (node.type !== _compilerdom.NodeTypes.ELEMENT) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const tag = node.tag;
|
|
339
|
-
for (const prop of node.props) {
|
|
340
|
-
if (prop.type === _compilerdom.NodeTypes.ATTRIBUTE) {
|
|
341
|
-
const { shouldHandle, shouldHandleDefault } = shouldHandleAttribute(
|
|
342
|
-
tag,
|
|
343
|
-
prop.name,
|
|
344
|
-
disabledDefaultTemplateHandler,
|
|
345
|
-
matchCustomAttribute
|
|
346
|
-
);
|
|
347
|
-
if (!shouldHandle) {
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
if (shouldHandleDefault && localStyleCollector) {
|
|
351
|
-
updateStaticAttributeWithLocalStyle(ms, prop, localStyleCollector);
|
|
352
|
-
} else {
|
|
353
|
-
updateStaticAttribute(ms, prop);
|
|
354
|
-
}
|
|
355
|
-
if (shouldHandleDefault) {
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
} else if (prop.type === _compilerdom.NodeTypes.DIRECTIVE && prop.name === "bind" && _optionalChain([prop, 'access', _12 => _12.arg, 'optionalAccess', _13 => _13.type]) === _compilerdom.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic) {
|
|
359
|
-
const attrName = prop.arg.content;
|
|
360
|
-
const { shouldHandle } = shouldHandleAttribute(
|
|
361
|
-
tag,
|
|
362
|
-
attrName,
|
|
363
|
-
disabledDefaultTemplateHandler,
|
|
364
|
-
matchCustomAttribute
|
|
365
|
-
);
|
|
366
|
-
if (!shouldHandle) {
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
if (attrName.toLowerCase() === "class" && localStyleCollector) {
|
|
370
|
-
updateDirectiveExpressionWithLocalStyle(
|
|
371
|
-
ms,
|
|
372
|
-
prop,
|
|
373
|
-
jsHandler,
|
|
374
|
-
localStyleCollector,
|
|
375
|
-
runtimeSet
|
|
376
|
-
);
|
|
377
|
-
} else {
|
|
378
|
-
updateDirectiveExpression(ms, prop, jsHandler, runtimeSet);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
if (descriptor.script) {
|
|
385
|
-
_optionalChain([localStyleCollector, 'optionalAccess', _14 => _14.collectRuntimeClasses, 'call', _15 => _15(descriptor.script.content)]);
|
|
386
|
-
const { code: code2 } = jsHandler(descriptor.script.content, _nullishCoalesce(runtimeSet, () => ( /* @__PURE__ */ new Set())), defaultCreateJsHandlerOptions);
|
|
387
|
-
ms.update(
|
|
388
|
-
descriptor.script.loc.start.offset,
|
|
389
|
-
descriptor.script.loc.end.offset,
|
|
390
|
-
localStyleCollector ? localStyleCollector.rewriteTransformedCode(code2) : code2
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
if (descriptor.scriptSetup) {
|
|
394
|
-
_optionalChain([localStyleCollector, 'optionalAccess', _16 => _16.collectRuntimeClasses, 'call', _17 => _17(descriptor.scriptSetup.content)]);
|
|
395
|
-
const { code: code2 } = jsHandler(descriptor.scriptSetup.content, _nullishCoalesce(runtimeSet, () => ( /* @__PURE__ */ new Set())), defaultCreateJsHandlerOptions);
|
|
396
|
-
ms.update(
|
|
397
|
-
descriptor.scriptSetup.loc.start.offset,
|
|
398
|
-
descriptor.scriptSetup.loc.end.offset,
|
|
399
|
-
localStyleCollector ? localStyleCollector.rewriteTransformedCode(code2) : code2
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
if (_optionalChain([localStyleCollector, 'optionalAccess', _18 => _18.hasStyles, 'call', _19 => _19()])) {
|
|
403
|
-
ms.append(`
|
|
404
|
-
${localStyleCollector.toStyleBlock()}`);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
const result = {
|
|
408
|
-
code: ms.toString(),
|
|
409
|
-
map: null
|
|
410
|
-
};
|
|
411
|
-
Object.defineProperty(result, "map", {
|
|
412
|
-
configurable: true,
|
|
413
|
-
enumerable: true,
|
|
414
|
-
get() {
|
|
415
|
-
return ms.generateMap();
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
return result;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// src/bundlers/vite/query.ts
|
|
422
|
-
function parseVueRequest(id) {
|
|
423
|
-
const [filename, rawQuery] = id.split(`?`, 2);
|
|
424
|
-
const searchParams = new URLSearchParams(rawQuery);
|
|
425
|
-
const query = Object.fromEntries(searchParams);
|
|
426
|
-
if (query.vue != null) {
|
|
427
|
-
query.vue = true;
|
|
428
|
-
}
|
|
429
|
-
if (query.index != null) {
|
|
430
|
-
query.index = Number(query.index);
|
|
431
|
-
}
|
|
432
|
-
if (query.raw != null) {
|
|
433
|
-
query.raw = true;
|
|
434
|
-
}
|
|
435
|
-
if (query.url != null) {
|
|
436
|
-
query.url = true;
|
|
437
|
-
}
|
|
438
|
-
if (query.scoped != null) {
|
|
439
|
-
query.scoped = true;
|
|
440
|
-
}
|
|
441
|
-
const langTypeMatch = [...searchParams.keys()].find((key) => key.startsWith("lang."));
|
|
442
|
-
const langType = query.lang || (langTypeMatch ? langTypeMatch.slice("lang.".length) : void 0);
|
|
443
|
-
if (langType) {
|
|
444
|
-
query.lang = langType;
|
|
445
|
-
}
|
|
446
|
-
return {
|
|
447
|
-
filename,
|
|
448
|
-
query
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// src/bundlers/vite/utils.ts
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
var _shared = require('@weapp-tailwindcss/shared');
|
|
456
|
-
function slash(p) {
|
|
457
|
-
return _shared.ensurePosix.call(void 0, p);
|
|
458
|
-
}
|
|
459
|
-
var isWindows = _process2.default.platform === "win32";
|
|
460
|
-
var cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
461
|
-
var cssLangRE = new RegExp(cssLangs);
|
|
462
|
-
function isCSSRequest(request) {
|
|
463
|
-
return cssLangRE.test(request);
|
|
464
|
-
}
|
|
465
|
-
function normalizePath(id) {
|
|
466
|
-
return _path2.default.posix.normalize(isWindows ? _shared.ensurePosix.call(void 0, id) : id);
|
|
467
|
-
}
|
|
468
|
-
async function formatPostcssSourceMap(rawMap, file) {
|
|
469
|
-
const inputFileDir = _path2.default.dirname(file);
|
|
470
|
-
const sources = rawMap.sources.map((source) => {
|
|
471
|
-
const cleanSource = _shared.cleanUrl.call(void 0, decodeURIComponent(source));
|
|
472
|
-
if (cleanSource[0] === "<" && cleanSource.endsWith(">")) {
|
|
473
|
-
return `\0${cleanSource}`;
|
|
474
|
-
}
|
|
475
|
-
return normalizePath(_path2.default.resolve(inputFileDir, cleanSource));
|
|
476
|
-
});
|
|
477
|
-
return {
|
|
478
|
-
file,
|
|
479
|
-
mappings: rawMap.mappings,
|
|
480
|
-
names: rawMap.names,
|
|
481
|
-
sources,
|
|
482
|
-
sourcesContent: rawMap.sourcesContent,
|
|
483
|
-
version: rawMap.version
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// src/uni-app-x/style-isolation.ts
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
var _commentjson = require('comment-json');
|
|
491
|
-
var manifestCache = /* @__PURE__ */ new Map();
|
|
492
|
-
function resolveUniAppXStyleIsolationEnabled(root) {
|
|
493
|
-
if (!root) {
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
const normalizedRoot = _path2.default.resolve(root);
|
|
497
|
-
const cached = manifestCache.get(normalizedRoot);
|
|
498
|
-
if (cached !== void 0) {
|
|
499
|
-
return cached;
|
|
500
|
-
}
|
|
501
|
-
const manifestPath = _path2.default.join(normalizedRoot, "manifest.json");
|
|
502
|
-
let enabled = false;
|
|
503
|
-
try {
|
|
504
|
-
const raw = _fs2.default.readFileSync(manifestPath, "utf8");
|
|
505
|
-
const manifest = _commentjson.parse.call(void 0, raw);
|
|
506
|
-
enabled = `${_nullishCoalesce(_optionalChain([manifest, 'access', _20 => _20["uni-app-x"], 'optionalAccess', _21 => _21.styleIsolationVersion]), () => ( ""))}` === "2";
|
|
507
|
-
} catch (e3) {
|
|
508
|
-
enabled = false;
|
|
509
|
-
}
|
|
510
|
-
manifestCache.set(normalizedRoot, enabled);
|
|
511
|
-
return enabled;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// src/uni-app-x/vite.ts
|
|
515
|
-
var preprocessorLangs = /* @__PURE__ */ new Set(["scss", "sass", "less", "styl", "stylus"]);
|
|
516
|
-
var INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
517
|
-
var PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
518
|
-
var UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
519
|
-
var UVUE_NVUE_RE2 = /\.(?:uvue|nvue)$/;
|
|
520
|
-
function isPreprocessorRequest(id, lang) {
|
|
521
|
-
const normalizedLang = _optionalChain([lang, 'optionalAccess', _22 => _22.toLowerCase, 'call', _23 => _23()]);
|
|
522
|
-
if (normalizedLang && preprocessorLangs.has(normalizedLang)) {
|
|
523
|
-
return true;
|
|
524
|
-
}
|
|
525
|
-
const inlineLangMatch = id.match(INLINE_LANG_RE);
|
|
526
|
-
if (inlineLangMatch && preprocessorLangs.has(inlineLangMatch[1].toLowerCase())) {
|
|
527
|
-
return true;
|
|
528
|
-
}
|
|
529
|
-
return PREPROCESSOR_EXT_RE.test(id);
|
|
530
|
-
}
|
|
531
|
-
function resolveUniAppXCssTarget(id) {
|
|
532
|
-
return UVUE_NVUE_RE2.test(_shared.cleanUrl.call(void 0, id)) ? "uvue" : void 0;
|
|
533
|
-
}
|
|
534
|
-
function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
535
|
-
return uniAppX === void 0 ? true : _chunkZAA5ZG3Djs.isUniAppXEnabled.call(void 0, uniAppX);
|
|
536
|
-
}
|
|
537
|
-
function createUniAppXPlugins(options) {
|
|
538
|
-
const {
|
|
539
|
-
appType,
|
|
540
|
-
customAttributesEntities,
|
|
541
|
-
disabledDefaultTemplateHandler,
|
|
542
|
-
isIosPlatform: providedIosPlatform,
|
|
543
|
-
mainCssChunkMatcher,
|
|
544
|
-
runtimeState,
|
|
545
|
-
styleHandler,
|
|
546
|
-
jsHandler,
|
|
547
|
-
ensureRuntimeClassSet,
|
|
548
|
-
getResolvedConfig,
|
|
549
|
-
uniAppX
|
|
550
|
-
} = options;
|
|
551
|
-
const resolvedUniAppXOptions = _chunkZAA5ZG3Djs.resolveUniAppXOptions.call(void 0, uniAppX);
|
|
552
|
-
const isIosPlatform = _nullishCoalesce(providedIosPlatform, () => ( _chunkDYLQ6UOIjs.resolveUniUtsPlatform.call(void 0, ).isAppIos));
|
|
553
|
-
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
554
|
-
let componentLocalStyleEnabled;
|
|
555
|
-
function shouldEnableComponentLocalStyle2() {
|
|
556
|
-
if (!resolvedUniAppXOptions.componentLocalStyles.enabled) {
|
|
557
|
-
componentLocalStyleEnabled = false;
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
560
|
-
if (!resolvedUniAppXOptions.componentLocalStyles.onlyWhenStyleIsolationVersion2) {
|
|
561
|
-
componentLocalStyleEnabled = true;
|
|
562
|
-
return true;
|
|
563
|
-
}
|
|
564
|
-
if (componentLocalStyleEnabled !== void 0) {
|
|
565
|
-
return componentLocalStyleEnabled;
|
|
566
|
-
}
|
|
567
|
-
const root = _optionalChain([getResolvedConfig, 'call', _24 => _24(), 'optionalAccess', _25 => _25.root]);
|
|
568
|
-
componentLocalStyleEnabled = resolveUniAppXStyleIsolationEnabled(root);
|
|
569
|
-
return componentLocalStyleEnabled;
|
|
570
|
-
}
|
|
571
|
-
async function transformStyle(code, id, query) {
|
|
572
|
-
const parsed = _nullishCoalesce(query, () => ( parseVueRequest(id).query));
|
|
573
|
-
if (isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
574
|
-
const cacheKey = `${mainCssChunkMatcher(id, appType) ? "1" : "0"}:${id}`;
|
|
575
|
-
let styleHandlerOptions = cssHandlerOptionsCache.get(cacheKey);
|
|
576
|
-
if (!styleHandlerOptions) {
|
|
577
|
-
styleHandlerOptions = {
|
|
578
|
-
isMainChunk: mainCssChunkMatcher(id, appType),
|
|
579
|
-
uniAppXCssTarget: resolveUniAppXCssTarget(id),
|
|
580
|
-
uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
|
|
581
|
-
postcssOptions: {
|
|
582
|
-
options: {
|
|
583
|
-
from: id,
|
|
584
|
-
map: {
|
|
585
|
-
inline: false,
|
|
586
|
-
annotation: false,
|
|
587
|
-
// PostCSS 可能返回虚拟文件,因此需要启用这一项以获取源内容
|
|
588
|
-
sourcesContent: true
|
|
589
|
-
// 若上游预处理器已经生成 source map,sources 中可能出现重复条目
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
cssHandlerOptionsCache.set(cacheKey, styleHandlerOptions);
|
|
595
|
-
}
|
|
596
|
-
const postcssResult = await styleHandler(code, styleHandlerOptions);
|
|
597
|
-
const warnings = typeof postcssResult.warnings === "function" ? postcssResult.warnings() : [];
|
|
598
|
-
for (const warning of warnings) {
|
|
599
|
-
_chunkZAA5ZG3Djs.logger.warn(warning.toString());
|
|
600
|
-
}
|
|
601
|
-
const rawPostcssMap = postcssResult.map.toJSON();
|
|
602
|
-
const postcssMap = await formatPostcssSourceMap(
|
|
603
|
-
rawPostcssMap,
|
|
604
|
-
_shared.cleanUrl.call(void 0, id)
|
|
605
|
-
);
|
|
606
|
-
return {
|
|
607
|
-
code: postcssResult.css,
|
|
608
|
-
map: postcssMap
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
const cssPrePlugin = {
|
|
613
|
-
name: "weapp-tailwindcss:uni-app-x:css:pre",
|
|
614
|
-
enforce: "pre",
|
|
615
|
-
async transform(code, id) {
|
|
616
|
-
await runtimeState.patchPromise;
|
|
617
|
-
const { query } = parseVueRequest(id);
|
|
618
|
-
const lang = query.lang;
|
|
619
|
-
if (isIosPlatform && isPreprocessorRequest(id, lang)) {
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
return transformStyle(code, id, query);
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
const cssPlugin = {
|
|
626
|
-
name: "weapp-tailwindcss:uni-app-x:css",
|
|
627
|
-
async transform(code, id) {
|
|
628
|
-
await runtimeState.patchPromise;
|
|
629
|
-
return transformStyle(code, id);
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
const cssPlugins = [cssPlugin, cssPrePlugin];
|
|
633
|
-
const nvuePlugin = {
|
|
634
|
-
name: "weapp-tailwindcss:uni-app-x:nvue",
|
|
635
|
-
enforce: "pre",
|
|
636
|
-
async buildStart() {
|
|
637
|
-
await ensureRuntimeClassSet(true);
|
|
638
|
-
},
|
|
639
|
-
async transform(code, id) {
|
|
640
|
-
if (!UVUE_NVUE_QUERY_RE.test(id)) {
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
const resolvedConfig = getResolvedConfig();
|
|
644
|
-
const isServeCommand = _optionalChain([resolvedConfig, 'optionalAccess', _26 => _26.command]) === "serve";
|
|
645
|
-
const isWatchBuild = _optionalChain([resolvedConfig, 'optionalAccess', _27 => _27.command]) === "build" && !!_optionalChain([resolvedConfig, 'access', _28 => _28.build, 'optionalAccess', _29 => _29.watch]);
|
|
646
|
-
const isNonWatchBuild = _optionalChain([resolvedConfig, 'optionalAccess', _30 => _30.command]) === "build" && !_optionalChain([resolvedConfig, 'access', _31 => _31.build, 'optionalAccess', _32 => _32.watch]);
|
|
647
|
-
const shouldForceRefresh = isServeCommand || isWatchBuild || isNonWatchBuild;
|
|
648
|
-
const currentRuntimeSet = shouldForceRefresh ? await ensureRuntimeClassSet(true) : await ensureRuntimeClassSet();
|
|
649
|
-
const extraOptions = customAttributesEntities.length > 0 || disabledDefaultTemplateHandler ? {
|
|
650
|
-
customAttributesEntities,
|
|
651
|
-
disabledDefaultTemplateHandler,
|
|
652
|
-
enableComponentLocalStyle: shouldEnableComponentLocalStyle2()
|
|
653
|
-
} : void 0;
|
|
654
|
-
if (extraOptions) {
|
|
655
|
-
return transformUVue(code, id, jsHandler, currentRuntimeSet, extraOptions);
|
|
656
|
-
}
|
|
657
|
-
if (shouldEnableComponentLocalStyle2()) {
|
|
658
|
-
return transformUVue(code, id, jsHandler, currentRuntimeSet, {
|
|
659
|
-
enableComponentLocalStyle: true
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
return transformUVue(code, id, jsHandler, currentRuntimeSet);
|
|
663
|
-
},
|
|
664
|
-
async handleHotUpdate(ctx) {
|
|
665
|
-
const resolvedConfig = getResolvedConfig();
|
|
666
|
-
if (_optionalChain([resolvedConfig, 'optionalAccess', _33 => _33.command]) !== "serve") {
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
if (!UVUE_NVUE_RE2.test(ctx.file)) {
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
await ensureRuntimeClassSet(true);
|
|
673
|
-
},
|
|
674
|
-
async watchChange(id) {
|
|
675
|
-
const resolvedConfig = getResolvedConfig();
|
|
676
|
-
if (_optionalChain([resolvedConfig, 'optionalAccess', _34 => _34.command]) !== "build" || !_optionalChain([resolvedConfig, 'access', _35 => _35.build, 'optionalAccess', _36 => _36.watch])) {
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
if (!UVUE_NVUE_QUERY_RE.test(id)) {
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
await ensureRuntimeClassSet(true);
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
return [
|
|
686
|
-
...cssPlugins,
|
|
687
|
-
nvuePlugin
|
|
688
|
-
];
|
|
689
|
-
}
|
|
690
|
-
function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
691
|
-
return async () => {
|
|
692
|
-
const {
|
|
693
|
-
cache,
|
|
694
|
-
hashKey,
|
|
695
|
-
createHandlerOptions,
|
|
696
|
-
debug: debug3,
|
|
697
|
-
jsHandler,
|
|
698
|
-
onUpdate,
|
|
699
|
-
runtimeSet,
|
|
700
|
-
applyLinkedResults: applyLinkedResults2
|
|
701
|
-
} = options;
|
|
702
|
-
const absoluteFile = _chunk24AGZQVRjs.toAbsoluteOutputPath.call(void 0, file, outDir);
|
|
703
|
-
const rawSource = originalSource.source.toString();
|
|
704
|
-
const rawHashSource = options.hashSalt ? `${rawSource}
|
|
705
|
-
/*${options.hashSalt}*/` : rawSource;
|
|
706
|
-
await _chunkOF6MFURRjs.processCachedTask.call(void 0, {
|
|
707
|
-
cache,
|
|
708
|
-
cacheKey: file,
|
|
709
|
-
hashKey,
|
|
710
|
-
rawSource: rawHashSource,
|
|
711
|
-
applyResult(source) {
|
|
712
|
-
originalSource.source = source;
|
|
713
|
-
},
|
|
714
|
-
onCacheHit() {
|
|
715
|
-
debug3("js cache hit: %s", file);
|
|
716
|
-
},
|
|
717
|
-
async transform() {
|
|
718
|
-
const currentSource = originalSource.source.toString();
|
|
719
|
-
const { code, linked } = await jsHandler(currentSource, runtimeSet, createHandlerOptions(absoluteFile, {
|
|
720
|
-
uniAppX: resolveUniAppXJsTransformEnabled(options.uniAppX),
|
|
721
|
-
babelParserOptions: {
|
|
722
|
-
plugins: [
|
|
723
|
-
"typescript"
|
|
724
|
-
],
|
|
725
|
-
sourceType: "unambiguous"
|
|
726
|
-
}
|
|
727
|
-
}));
|
|
728
|
-
onUpdate(file, currentSource, code);
|
|
729
|
-
debug3("js handle: %s", file);
|
|
730
|
-
applyLinkedResults2(linked);
|
|
731
|
-
return {
|
|
732
|
-
result: code
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
// src/bundlers/vite/generate-bundle.ts
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
// src/bundlers/vite/bundle-entries.ts
|
|
746
|
-
var _buffer = require('buffer');
|
|
747
|
-
function readOutputEntry(entry) {
|
|
748
|
-
if (entry.output.type === "chunk") {
|
|
749
|
-
return entry.output.code;
|
|
750
|
-
}
|
|
751
|
-
const source = entry.output.source;
|
|
752
|
-
if (typeof source === "string") {
|
|
753
|
-
return source;
|
|
754
|
-
}
|
|
755
|
-
if (source instanceof Uint8Array) {
|
|
756
|
-
return _buffer.Buffer.from(source).toString();
|
|
757
|
-
}
|
|
758
|
-
const fallbackSource = source;
|
|
759
|
-
if (fallbackSource == null) {
|
|
760
|
-
return void 0;
|
|
761
|
-
}
|
|
762
|
-
if (typeof fallbackSource.toString === "function") {
|
|
763
|
-
return fallbackSource.toString();
|
|
764
|
-
}
|
|
765
|
-
return void 0;
|
|
766
|
-
}
|
|
767
|
-
function isJavaScriptEntry(entry) {
|
|
768
|
-
if (entry.output.type === "chunk") {
|
|
769
|
-
return true;
|
|
770
|
-
}
|
|
771
|
-
return entry.fileName.endsWith(".js");
|
|
772
|
-
}
|
|
773
|
-
function createBundleModuleGraphOptions(outputDir, entries) {
|
|
774
|
-
const normalizedEntries = /* @__PURE__ */ new Map();
|
|
775
|
-
for (const [id, entry] of entries) {
|
|
776
|
-
normalizedEntries.set(_chunk24AGZQVRjs.normalizeOutputPathKey.call(void 0, id), entry);
|
|
777
|
-
}
|
|
778
|
-
const getEntry = (id) => _nullishCoalesce(entries.get(id), () => ( normalizedEntries.get(_chunk24AGZQVRjs.normalizeOutputPathKey.call(void 0, id))));
|
|
779
|
-
return {
|
|
780
|
-
resolve(specifier, importer) {
|
|
781
|
-
return _chunk24AGZQVRjs.resolveOutputSpecifier.call(void 0, specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
|
|
782
|
-
},
|
|
783
|
-
load(id) {
|
|
784
|
-
const entry = getEntry(id);
|
|
785
|
-
if (!entry) {
|
|
786
|
-
return void 0;
|
|
787
|
-
}
|
|
788
|
-
return readOutputEntry(entry);
|
|
789
|
-
},
|
|
790
|
-
filter(id) {
|
|
791
|
-
return Boolean(getEntry(id));
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
|
|
796
|
-
if (!linked) {
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
const normalizedEntries = /* @__PURE__ */ new Map();
|
|
800
|
-
for (const [entryId, entry] of entries) {
|
|
801
|
-
normalizedEntries.set(_chunk24AGZQVRjs.normalizeOutputPathKey.call(void 0, entryId), entry);
|
|
802
|
-
}
|
|
803
|
-
for (const [id, { code }] of Object.entries(linked)) {
|
|
804
|
-
const entry = _nullishCoalesce(entries.get(id), () => ( normalizedEntries.get(_chunk24AGZQVRjs.normalizeOutputPathKey.call(void 0, id))));
|
|
805
|
-
if (!entry) {
|
|
806
|
-
continue;
|
|
807
|
-
}
|
|
808
|
-
const previous = readOutputEntry(entry);
|
|
809
|
-
if (previous == null || previous === code) {
|
|
810
|
-
continue;
|
|
811
|
-
}
|
|
812
|
-
if (entry.output.type === "chunk") {
|
|
813
|
-
entry.output.code = code;
|
|
814
|
-
} else {
|
|
815
|
-
entry.output.source = code;
|
|
816
|
-
}
|
|
817
|
-
_optionalChain([onApplied, 'optionalCall', _37 => _37(entry, code)]);
|
|
818
|
-
onLinkedUpdate(entry.fileName, previous, code);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
// src/bundlers/vite/runtime-affecting-signature.ts
|
|
823
|
-
var _htmlparser2 = require('htmlparser2');
|
|
824
|
-
var CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
|
|
825
|
-
var CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
|
|
826
|
-
var CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
|
|
827
|
-
var CSS_WHITESPACE_RE = /\s+/g;
|
|
828
|
-
function createHtmlRuntimeAffectingSignature(source) {
|
|
829
|
-
try {
|
|
830
|
-
const parts = [];
|
|
831
|
-
const parser = new (0, _htmlparser2.Parser)(
|
|
832
|
-
{
|
|
833
|
-
onattribute(name, value) {
|
|
834
|
-
parts.push(`a:${name}=${value}`);
|
|
835
|
-
},
|
|
836
|
-
oncomment(data) {
|
|
837
|
-
parts.push(`c:${data}`);
|
|
838
|
-
},
|
|
839
|
-
ontext(data) {
|
|
840
|
-
const value = data.trim();
|
|
841
|
-
if (value.length > 0) {
|
|
842
|
-
parts.push(`t:${value}`);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
xmlMode: true
|
|
848
|
-
}
|
|
849
|
-
);
|
|
850
|
-
parser.write(source);
|
|
851
|
-
parser.end();
|
|
852
|
-
return parts.join("\n");
|
|
853
|
-
} catch (e4) {
|
|
854
|
-
return source;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
function createJsRuntimeAffectingSignature(source) {
|
|
858
|
-
try {
|
|
859
|
-
const ast = _chunkHVNGIKLSjs.babelParse.call(void 0, source, {
|
|
860
|
-
cache: true,
|
|
861
|
-
cacheKey: "vite-runtime-affecting:unambiguous",
|
|
862
|
-
plugins: ["jsx", "typescript"],
|
|
863
|
-
sourceType: "unambiguous"
|
|
864
|
-
});
|
|
865
|
-
const parts = [];
|
|
866
|
-
_chunkHVNGIKLSjs.traverse.call(void 0, ast, {
|
|
867
|
-
noScope: true,
|
|
868
|
-
StringLiteral(path7) {
|
|
869
|
-
parts.push(`s:${path7.node.value}`);
|
|
870
|
-
},
|
|
871
|
-
TemplateElement(path7) {
|
|
872
|
-
parts.push(`t:${path7.node.value.raw}`);
|
|
873
|
-
},
|
|
874
|
-
JSXText(path7) {
|
|
875
|
-
const value = path7.node.value.trim();
|
|
876
|
-
if (value.length > 0) {
|
|
877
|
-
parts.push(`x:${value}`);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
const comments = ast.comments;
|
|
882
|
-
if (Array.isArray(comments)) {
|
|
883
|
-
for (const comment of comments) {
|
|
884
|
-
if (typeof _optionalChain([comment, 'optionalAccess', _38 => _38.value]) === "string" && comment.value.length > 0) {
|
|
885
|
-
parts.push(`c:${comment.value}`);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
return parts.join("\n");
|
|
890
|
-
} catch (e5) {
|
|
891
|
-
return source;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
function createCssRuntimeAffectingSignature(source) {
|
|
895
|
-
return source.replace(CSS_BLOCK_COMMENT_RE, "").replace(CSS_AROUND_PUNCTUATION_RE, "$1").replace(CSS_TRAILING_DECLARATION_SEMICOLON_RE, "}").replace(CSS_WHITESPACE_RE, " ").trim();
|
|
896
|
-
}
|
|
897
|
-
function createRuntimeAffectingSourceSignature(source, type) {
|
|
898
|
-
if (type === "html") {
|
|
899
|
-
return createHtmlRuntimeAffectingSignature(source);
|
|
900
|
-
}
|
|
901
|
-
if (type === "js") {
|
|
902
|
-
return createJsRuntimeAffectingSignature(source);
|
|
903
|
-
}
|
|
904
|
-
if (type === "css") {
|
|
905
|
-
return createCssRuntimeAffectingSignature(source);
|
|
906
|
-
}
|
|
907
|
-
return source;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
// src/bundlers/vite/bundle-state.ts
|
|
911
|
-
function createBundleBuildState() {
|
|
912
|
-
return {
|
|
913
|
-
iteration: 0,
|
|
914
|
-
sourceHashByFile: /* @__PURE__ */ new Map(),
|
|
915
|
-
runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
|
|
916
|
-
runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
|
|
917
|
-
linkedByEntry: /* @__PURE__ */ new Map(),
|
|
918
|
-
dependentsByLinkedFile: /* @__PURE__ */ new Map()
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
function createChangedByType() {
|
|
922
|
-
return {
|
|
923
|
-
html: /* @__PURE__ */ new Set(),
|
|
924
|
-
js: /* @__PURE__ */ new Set(),
|
|
925
|
-
css: /* @__PURE__ */ new Set(),
|
|
926
|
-
other: /* @__PURE__ */ new Set()
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
function createProcessFiles() {
|
|
930
|
-
return {
|
|
931
|
-
html: /* @__PURE__ */ new Set(),
|
|
932
|
-
js: /* @__PURE__ */ new Set(),
|
|
933
|
-
css: /* @__PURE__ */ new Set()
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
function readEntrySource(output) {
|
|
937
|
-
if (output.type === "chunk") {
|
|
938
|
-
return output.code;
|
|
939
|
-
}
|
|
940
|
-
return output.source.toString();
|
|
941
|
-
}
|
|
942
|
-
function classifyBundleEntry(file, opts) {
|
|
943
|
-
if (opts.cssMatcher(file)) {
|
|
944
|
-
return "css";
|
|
945
|
-
}
|
|
946
|
-
if (opts.htmlMatcher(file)) {
|
|
947
|
-
return "html";
|
|
948
|
-
}
|
|
949
|
-
if (opts.jsMatcher(file) || opts.wxsMatcher(file)) {
|
|
950
|
-
return "js";
|
|
951
|
-
}
|
|
952
|
-
return "other";
|
|
953
|
-
}
|
|
954
|
-
function collectJsEntries(fileName, output, outDir, store) {
|
|
955
|
-
const entry = { fileName, output };
|
|
956
|
-
if (!isJavaScriptEntry(entry)) {
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
const absolute = _chunk24AGZQVRjs.toAbsoluteOutputPath.call(void 0, fileName, outDir);
|
|
960
|
-
store.set(absolute, entry);
|
|
961
|
-
}
|
|
962
|
-
function markProcessFile(type, file, processFiles) {
|
|
963
|
-
if (type === "html" || type === "js" || type === "css") {
|
|
964
|
-
processFiles[type].add(file);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
|
|
968
|
-
const sourceHashByFile = /* @__PURE__ */ new Map();
|
|
969
|
-
const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
|
|
970
|
-
const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
|
|
971
|
-
const changedByType = createChangedByType();
|
|
972
|
-
const runtimeAffectingChangedByType = createChangedByType();
|
|
973
|
-
const processFiles = createProcessFiles();
|
|
974
|
-
const linkedImpactsByEntry = /* @__PURE__ */ new Map();
|
|
975
|
-
const jsEntries = /* @__PURE__ */ new Map();
|
|
976
|
-
const entries = [];
|
|
977
|
-
const firstRun = state.linkedByEntry.size === 0;
|
|
978
|
-
for (const [file, output] of Object.entries(bundle)) {
|
|
979
|
-
const type = classifyBundleEntry(file, opts);
|
|
980
|
-
const source = readEntrySource(output);
|
|
981
|
-
const hash = opts.cache.computeHash(source);
|
|
982
|
-
sourceHashByFile.set(file, hash);
|
|
983
|
-
const previousHash = state.sourceHashByFile.get(file);
|
|
984
|
-
const changed = previousHash == null || previousHash !== hash;
|
|
985
|
-
const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
|
|
986
|
-
const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
|
|
987
|
-
const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
|
|
988
|
-
const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
|
|
989
|
-
const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
|
|
990
|
-
runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
|
|
991
|
-
runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
|
|
992
|
-
if (changed) {
|
|
993
|
-
changedByType[type].add(file);
|
|
994
|
-
}
|
|
995
|
-
const runtimeAffectingChanged = previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash;
|
|
996
|
-
if (runtimeAffectingChanged) {
|
|
997
|
-
runtimeAffectingChangedByType[type].add(file);
|
|
998
|
-
}
|
|
999
|
-
if (forceAll || firstRun) {
|
|
1000
|
-
markProcessFile(type, file, processFiles);
|
|
1001
|
-
} else if (type === "html") {
|
|
1002
|
-
processFiles.html.add(file);
|
|
1003
|
-
} else if (changed && (type === "js" || type === "css")) {
|
|
1004
|
-
processFiles[type].add(file);
|
|
1005
|
-
}
|
|
1006
|
-
collectJsEntries(file, output, outDir, jsEntries);
|
|
1007
|
-
entries.push({
|
|
1008
|
-
file,
|
|
1009
|
-
output,
|
|
1010
|
-
source,
|
|
1011
|
-
type
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
if (!forceAll && !firstRun) {
|
|
1015
|
-
for (const changedFile of changedByType.js) {
|
|
1016
|
-
const dependents = state.dependentsByLinkedFile.get(changedFile);
|
|
1017
|
-
if (!dependents) {
|
|
1018
|
-
continue;
|
|
1019
|
-
}
|
|
1020
|
-
for (const entryFile of dependents) {
|
|
1021
|
-
processFiles.js.add(entryFile);
|
|
1022
|
-
let impacts = linkedImpactsByEntry.get(entryFile);
|
|
1023
|
-
if (!impacts) {
|
|
1024
|
-
impacts = /* @__PURE__ */ new Set();
|
|
1025
|
-
linkedImpactsByEntry.set(entryFile, impacts);
|
|
1026
|
-
}
|
|
1027
|
-
impacts.add(changedFile);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
return {
|
|
1032
|
-
entries,
|
|
1033
|
-
jsEntries,
|
|
1034
|
-
sourceHashByFile,
|
|
1035
|
-
runtimeAffectingSignatureByFile,
|
|
1036
|
-
runtimeAffectingHashByFile,
|
|
1037
|
-
changedByType,
|
|
1038
|
-
runtimeAffectingChangedByType,
|
|
1039
|
-
processFiles,
|
|
1040
|
-
linkedImpactsByEntry
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
function invertLinkedByEntry(linkedByEntry) {
|
|
1044
|
-
const dependentsByLinkedFile = /* @__PURE__ */ new Map();
|
|
1045
|
-
for (const [entryFile, linkedFiles] of linkedByEntry.entries()) {
|
|
1046
|
-
for (const linkedFile of linkedFiles) {
|
|
1047
|
-
let dependents = dependentsByLinkedFile.get(linkedFile);
|
|
1048
|
-
if (!dependents) {
|
|
1049
|
-
dependents = /* @__PURE__ */ new Set();
|
|
1050
|
-
dependentsByLinkedFile.set(linkedFile, dependents);
|
|
1051
|
-
}
|
|
1052
|
-
dependents.add(entryFile);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
return dependentsByLinkedFile;
|
|
1056
|
-
}
|
|
1057
|
-
function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
|
|
1058
|
-
const incremental = options.incremental === true;
|
|
1059
|
-
state.iteration += 1;
|
|
1060
|
-
state.sourceHashByFile = incremental ? new Map([
|
|
1061
|
-
...state.sourceHashByFile,
|
|
1062
|
-
...snapshot.sourceHashByFile
|
|
1063
|
-
]) : snapshot.sourceHashByFile;
|
|
1064
|
-
state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
|
|
1065
|
-
state.runtimeAffectingHashByFile = incremental ? new Map([
|
|
1066
|
-
...state.runtimeAffectingHashByFile,
|
|
1067
|
-
...snapshot.runtimeAffectingHashByFile
|
|
1068
|
-
]) : snapshot.runtimeAffectingHashByFile;
|
|
1069
|
-
state.linkedByEntry = incremental ? new Map([
|
|
1070
|
-
...state.linkedByEntry,
|
|
1071
|
-
...linkedByEntry
|
|
1072
|
-
]) : linkedByEntry;
|
|
1073
|
-
state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
// src/bundlers/vite/generate-bundle.ts
|
|
1077
|
-
function formatDebugFileList(files, limit = 8) {
|
|
1078
|
-
if (files.size === 0) {
|
|
1079
|
-
return "-";
|
|
1080
|
-
}
|
|
1081
|
-
const sorted = [...files].sort();
|
|
1082
|
-
if (sorted.length <= limit) {
|
|
1083
|
-
return sorted.join(",");
|
|
1084
|
-
}
|
|
1085
|
-
return `${sorted.slice(0, limit).join(",")},...(+${sorted.length - limit})`;
|
|
1086
|
-
}
|
|
1087
|
-
function createEmptyMetric() {
|
|
1088
|
-
return {
|
|
1089
|
-
total: 0,
|
|
1090
|
-
transformed: 0,
|
|
1091
|
-
cacheHits: 0,
|
|
1092
|
-
elapsed: 0
|
|
1093
|
-
};
|
|
1094
|
-
}
|
|
1095
|
-
function createEmptyMetrics() {
|
|
1096
|
-
return {
|
|
1097
|
-
runtimeSet: 0,
|
|
1098
|
-
html: createEmptyMetric(),
|
|
1099
|
-
js: createEmptyMetric(),
|
|
1100
|
-
css: createEmptyMetric()
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
function measureElapsed(start) {
|
|
1104
|
-
return performance.now() - start;
|
|
1105
|
-
}
|
|
1106
|
-
function resolveUniAppXJsTransformEnabled2(uniAppX) {
|
|
1107
|
-
return uniAppX === void 0 ? true : _chunkZAA5ZG3Djs.isUniAppXEnabled.call(void 0, uniAppX);
|
|
1108
|
-
}
|
|
1109
|
-
function formatCacheHitRate(metric) {
|
|
1110
|
-
if (metric.total === 0) {
|
|
1111
|
-
return "0.00%";
|
|
1112
|
-
}
|
|
1113
|
-
return `${(metric.cacheHits / metric.total * 100).toFixed(2)}%`;
|
|
1114
|
-
}
|
|
1115
|
-
function formatMs(value) {
|
|
1116
|
-
return value.toFixed(2);
|
|
1117
|
-
}
|
|
1118
|
-
function summarizeStringDiff(previous, next) {
|
|
1119
|
-
if (previous === next) {
|
|
1120
|
-
return "same";
|
|
1121
|
-
}
|
|
1122
|
-
const previousLength = previous.length;
|
|
1123
|
-
const nextLength = next.length;
|
|
1124
|
-
const minLength = Math.min(previousLength, nextLength);
|
|
1125
|
-
let prefixLength = 0;
|
|
1126
|
-
while (prefixLength < minLength && previous.charCodeAt(prefixLength) === next.charCodeAt(prefixLength)) {
|
|
1127
|
-
prefixLength += 1;
|
|
1128
|
-
}
|
|
1129
|
-
let previousSuffixCursor = previousLength - 1;
|
|
1130
|
-
let nextSuffixCursor = nextLength - 1;
|
|
1131
|
-
while (previousSuffixCursor >= prefixLength && nextSuffixCursor >= prefixLength && previous.charCodeAt(previousSuffixCursor) === next.charCodeAt(nextSuffixCursor)) {
|
|
1132
|
-
previousSuffixCursor -= 1;
|
|
1133
|
-
nextSuffixCursor -= 1;
|
|
1134
|
-
}
|
|
1135
|
-
const previousChangedLength = previousSuffixCursor >= prefixLength ? previousSuffixCursor - prefixLength + 1 : 0;
|
|
1136
|
-
const nextChangedLength = nextSuffixCursor >= prefixLength ? nextSuffixCursor - prefixLength + 1 : 0;
|
|
1137
|
-
return `changed@${prefixLength} old=${previousChangedLength} new=${nextChangedLength} len=${previousLength}->${nextLength}`;
|
|
1138
|
-
}
|
|
1139
|
-
function createLinkedImpactSignature(entry, linkedImpactsByEntry, sourceHashByFile) {
|
|
1140
|
-
const changedLinkedFiles = linkedImpactsByEntry.get(entry);
|
|
1141
|
-
if (!changedLinkedFiles || changedLinkedFiles.size === 0) {
|
|
1142
|
-
return void 0;
|
|
1143
|
-
}
|
|
1144
|
-
const parts = [...changedLinkedFiles].sort().map((file) => {
|
|
1145
|
-
const hash = _nullishCoalesce(sourceHashByFile.get(file), () => ( "missing"));
|
|
1146
|
-
return `${file}:${hash}`;
|
|
1147
|
-
});
|
|
1148
|
-
return parts.join(",");
|
|
1149
|
-
}
|
|
1150
|
-
function createJsHashSalt(runtimeSignature, linkedImpactSignature) {
|
|
1151
|
-
if (!linkedImpactSignature) {
|
|
1152
|
-
return runtimeSignature;
|
|
1153
|
-
}
|
|
1154
|
-
return `${runtimeSignature}:linked:${linkedImpactSignature}`;
|
|
1155
|
-
}
|
|
1156
|
-
function getSnapshotHash(snapshotMap, file, fallback) {
|
|
1157
|
-
return _nullishCoalesce(snapshotMap.get(file), () => ( fallback));
|
|
1158
|
-
}
|
|
1159
|
-
function hasRuntimeAffectingSourceChanges(changedByType) {
|
|
1160
|
-
return changedByType.html.size > 0 || changedByType.js.size > 0;
|
|
1161
|
-
}
|
|
1162
|
-
var CSS_URL_FUNCTION_RE = /url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/gi;
|
|
1163
|
-
var CSS_PATH_INDEPENDENT_URL_RE = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/|#)/i;
|
|
1164
|
-
var CSS_IMPORT_RE = /@import\b/i;
|
|
1165
|
-
function isPathIndependentCssUrl(value) {
|
|
1166
|
-
const normalized = value.trim();
|
|
1167
|
-
return normalized.length > 0 && CSS_PATH_INDEPENDENT_URL_RE.test(normalized);
|
|
1168
|
-
}
|
|
1169
|
-
function hasPathDependentCssUrl(rawSource) {
|
|
1170
|
-
CSS_URL_FUNCTION_RE.lastIndex = 0;
|
|
1171
|
-
let match = CSS_URL_FUNCTION_RE.exec(rawSource);
|
|
1172
|
-
while (match !== null) {
|
|
1173
|
-
const value = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(match[1], () => ( match[2])), () => ( match[3])), () => ( ""));
|
|
1174
|
-
if (!isPathIndependentCssUrl(value)) {
|
|
1175
|
-
return true;
|
|
1176
|
-
}
|
|
1177
|
-
match = CSS_URL_FUNCTION_RE.exec(rawSource);
|
|
1178
|
-
}
|
|
1179
|
-
return false;
|
|
1180
|
-
}
|
|
1181
|
-
function createCssTransformShareScope(file, rawSource) {
|
|
1182
|
-
if (CSS_IMPORT_RE.test(rawSource) || hasPathDependentCssUrl(rawSource)) {
|
|
1183
|
-
return `dir:${_chunk24AGZQVRjs.normalizeOutputPathKey.call(void 0, _path2.default.dirname(file))}`;
|
|
1184
|
-
}
|
|
1185
|
-
return "global";
|
|
1186
|
-
}
|
|
1187
|
-
function hasOmittedKnownBundleFiles(currentBundleFiles, previousBundleFiles) {
|
|
1188
|
-
const currentFileSet = new Set(currentBundleFiles);
|
|
1189
|
-
for (const file of previousBundleFiles) {
|
|
1190
|
-
if (!currentFileSet.has(file)) {
|
|
1191
|
-
return true;
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
return false;
|
|
1195
|
-
}
|
|
1196
|
-
var MUSTACHE_EXPRESSION_RE = /\{\{[\s\S]*?\}\}/g;
|
|
1197
|
-
var QUOTED_LITERAL_RE = /'([^']*)'|"([^"]*)"|`([^`]*)`/g;
|
|
1198
|
-
function isArbitraryValueCandidate(candidate) {
|
|
1199
|
-
return candidate.includes("[") && candidate.includes("]");
|
|
1200
|
-
}
|
|
1201
|
-
function collectUnescapedDynamicCandidates(source) {
|
|
1202
|
-
const matches = /* @__PURE__ */ new Set();
|
|
1203
|
-
for (const expression of _nullishCoalesce(source.match(MUSTACHE_EXPRESSION_RE), () => ( []))) {
|
|
1204
|
-
QUOTED_LITERAL_RE.lastIndex = 0;
|
|
1205
|
-
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
1206
|
-
while (quoted !== null) {
|
|
1207
|
-
const literal = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(quoted[1], () => ( quoted[2])), () => ( quoted[3])), () => ( ""));
|
|
1208
|
-
for (const candidate of _extractors.splitCode.call(void 0, literal, true)) {
|
|
1209
|
-
const normalized = candidate.trim();
|
|
1210
|
-
if (!normalized || !isArbitraryValueCandidate(normalized)) {
|
|
1211
|
-
continue;
|
|
1212
|
-
}
|
|
1213
|
-
matches.add(normalized);
|
|
1214
|
-
}
|
|
1215
|
-
quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
return [...matches];
|
|
1219
|
-
}
|
|
1220
|
-
function createGenerateBundleHook(context) {
|
|
1221
|
-
const state = createBundleBuildState();
|
|
1222
|
-
const cssHandlerOptionsCache = /* @__PURE__ */ new Map();
|
|
1223
|
-
return async function generateBundle(_opt, bundle) {
|
|
1224
|
-
const {
|
|
1225
|
-
opts,
|
|
1226
|
-
runtimeState,
|
|
1227
|
-
ensureBundleRuntimeClassSet,
|
|
1228
|
-
debug: debug3,
|
|
1229
|
-
getResolvedConfig
|
|
1230
|
-
} = context;
|
|
1231
|
-
const {
|
|
1232
|
-
appType,
|
|
1233
|
-
cache,
|
|
1234
|
-
mainCssChunkMatcher,
|
|
1235
|
-
onEnd,
|
|
1236
|
-
onStart,
|
|
1237
|
-
onUpdate,
|
|
1238
|
-
styleHandler,
|
|
1239
|
-
templateHandler,
|
|
1240
|
-
jsHandler,
|
|
1241
|
-
uniAppX
|
|
1242
|
-
} = opts;
|
|
1243
|
-
const getCssHandlerOptions = (file) => {
|
|
1244
|
-
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1245
|
-
const isMainChunk = mainCssChunkMatcher(file, appType);
|
|
1246
|
-
const cacheKey = `${_nullishCoalesce(majorVersion, () => ( "unknown"))}:${isMainChunk ? "1" : "0"}:${file}`;
|
|
1247
|
-
const cached = cssHandlerOptionsCache.get(cacheKey);
|
|
1248
|
-
if (cached) {
|
|
1249
|
-
return cached;
|
|
1250
|
-
}
|
|
1251
|
-
const created = {
|
|
1252
|
-
isMainChunk,
|
|
1253
|
-
postcssOptions: {
|
|
1254
|
-
options: {
|
|
1255
|
-
from: file
|
|
1256
|
-
}
|
|
1257
|
-
},
|
|
1258
|
-
majorVersion
|
|
1259
|
-
};
|
|
1260
|
-
cssHandlerOptionsCache.set(cacheKey, created);
|
|
1261
|
-
return created;
|
|
1262
|
-
};
|
|
1263
|
-
await runtimeState.patchPromise;
|
|
1264
|
-
debug3("start");
|
|
1265
|
-
onStart();
|
|
1266
|
-
const metrics = createEmptyMetrics();
|
|
1267
|
-
const forceRuntimeRefreshByEnv = _process2.default.env.WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH === "1";
|
|
1268
|
-
const disableDirtyOptimization = _process2.default.env.WEAPP_TW_VITE_DISABLE_DIRTY === "1";
|
|
1269
|
-
const disableJsPrecheck = _process2.default.env.WEAPP_TW_VITE_DISABLE_JS_PRECHECK === "1";
|
|
1270
|
-
const debugCssDiff = _process2.default.env.WEAPP_TW_VITE_DEBUG_CSS_DIFF === "1";
|
|
1271
|
-
const resolvedConfig = getResolvedConfig();
|
|
1272
|
-
const bundleFiles = Object.keys(bundle);
|
|
1273
|
-
const buildCommand = _optionalChain([resolvedConfig, 'optionalAccess', _39 => _39.command]) === "build";
|
|
1274
|
-
const useIncrementalMode = !buildCommand || hasOmittedKnownBundleFiles(bundleFiles, state.sourceHashByFile.keys());
|
|
1275
|
-
const rootDir = _optionalChain([resolvedConfig, 'optionalAccess', _40 => _40.root]) ? _path2.default.resolve(resolvedConfig.root) : _process2.default.cwd();
|
|
1276
|
-
const outDir = _optionalChain([resolvedConfig, 'optionalAccess', _41 => _41.build, 'optionalAccess', _42 => _42.outDir]) ? _path2.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
1277
|
-
const snapshot = buildBundleSnapshot(bundle, opts, outDir, state, disableDirtyOptimization || !useIncrementalMode);
|
|
1278
|
-
const useBundleRuntimeClassSet = useIncrementalMode || runtimeState.twPatcher.majorVersion === 4;
|
|
1279
|
-
const forceRuntimeRefreshBySource = useIncrementalMode && hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
1280
|
-
const processFiles = snapshot.processFiles;
|
|
1281
|
-
if (useIncrementalMode) {
|
|
1282
|
-
debug3(
|
|
1283
|
-
"dirty iteration=%d html=%d[%s] js=%d[%s] css=%d[%s] other=%d[%s]",
|
|
1284
|
-
state.iteration + 1,
|
|
1285
|
-
snapshot.changedByType.html.size,
|
|
1286
|
-
formatDebugFileList(snapshot.changedByType.html),
|
|
1287
|
-
snapshot.changedByType.js.size,
|
|
1288
|
-
formatDebugFileList(snapshot.changedByType.js),
|
|
1289
|
-
snapshot.changedByType.css.size,
|
|
1290
|
-
formatDebugFileList(snapshot.changedByType.css),
|
|
1291
|
-
snapshot.changedByType.other.size,
|
|
1292
|
-
formatDebugFileList(snapshot.changedByType.other)
|
|
1293
|
-
);
|
|
1294
|
-
debug3(
|
|
1295
|
-
"process iteration=%d html=%d[%s] js=%d[%s] css=%d[%s]",
|
|
1296
|
-
state.iteration + 1,
|
|
1297
|
-
processFiles.html.size,
|
|
1298
|
-
formatDebugFileList(processFiles.html),
|
|
1299
|
-
processFiles.js.size,
|
|
1300
|
-
formatDebugFileList(processFiles.js),
|
|
1301
|
-
processFiles.css.size,
|
|
1302
|
-
formatDebugFileList(processFiles.css)
|
|
1303
|
-
);
|
|
1304
|
-
} else {
|
|
1305
|
-
debug3(
|
|
1306
|
-
"build mode full process html=%d[%s] js=%d[%s] css=%d[%s]",
|
|
1307
|
-
processFiles.html.size,
|
|
1308
|
-
formatDebugFileList(processFiles.html),
|
|
1309
|
-
processFiles.js.size,
|
|
1310
|
-
formatDebugFileList(processFiles.js),
|
|
1311
|
-
processFiles.css.size,
|
|
1312
|
-
formatDebugFileList(processFiles.css)
|
|
1313
|
-
);
|
|
1314
|
-
}
|
|
1315
|
-
const jsEntries = snapshot.jsEntries;
|
|
1316
|
-
const normalizedJsEntries = /* @__PURE__ */ new Map();
|
|
1317
|
-
for (const [id, entry] of jsEntries) {
|
|
1318
|
-
normalizedJsEntries.set(_chunk24AGZQVRjs.normalizeOutputPathKey.call(void 0, id), entry);
|
|
1319
|
-
}
|
|
1320
|
-
const getJsEntry = (id) => _nullishCoalesce(jsEntries.get(id), () => ( normalizedJsEntries.get(_chunk24AGZQVRjs.normalizeOutputPathKey.call(void 0, id))));
|
|
1321
|
-
const moduleGraphOptions = createBundleModuleGraphOptions(outDir, jsEntries);
|
|
1322
|
-
const runtimeStart = performance.now();
|
|
1323
|
-
const runtime = useBundleRuntimeClassSet ? await ensureBundleRuntimeClassSet(snapshot, forceRuntimeRefreshByEnv) : await context.ensureRuntimeClassSet(forceRuntimeRefreshByEnv);
|
|
1324
|
-
const defaultTemplateHandlerOptions = {
|
|
1325
|
-
runtimeSet: runtime
|
|
1326
|
-
};
|
|
1327
|
-
metrics.runtimeSet = measureElapsed(runtimeStart);
|
|
1328
|
-
if (forceRuntimeRefreshBySource) {
|
|
1329
|
-
debug3(
|
|
1330
|
-
"runtimeSet forced refresh due to source changes: html=%d js=%d",
|
|
1331
|
-
snapshot.runtimeAffectingChangedByType.html.size,
|
|
1332
|
-
snapshot.runtimeAffectingChangedByType.js.size
|
|
1333
|
-
);
|
|
1334
|
-
}
|
|
1335
|
-
debug3("get runtimeSet, class count: %d", runtime.size);
|
|
1336
|
-
const runtimeSignature = _nullishCoalesce(_chunkZAA5ZG3Djs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher), () => ( "runtime:missing"));
|
|
1337
|
-
const handleLinkedUpdate = (fileName, previous, next) => {
|
|
1338
|
-
onUpdate(fileName, previous, next);
|
|
1339
|
-
debug3("js linked handle: %s", fileName);
|
|
1340
|
-
};
|
|
1341
|
-
const pendingLinkedUpdates = [];
|
|
1342
|
-
const scheduleLinkedApply = (entry, code) => {
|
|
1343
|
-
pendingLinkedUpdates.push(() => {
|
|
1344
|
-
if (entry.output.type === "chunk") {
|
|
1345
|
-
entry.output.code = code;
|
|
1346
|
-
} else {
|
|
1347
|
-
entry.output.source = code;
|
|
1348
|
-
}
|
|
1349
|
-
});
|
|
1350
|
-
};
|
|
1351
|
-
const applyLinkedUpdates = (linked) => {
|
|
1352
|
-
applyLinkedResults(linked, jsEntries, handleLinkedUpdate, scheduleLinkedApply);
|
|
1353
|
-
};
|
|
1354
|
-
const createHandlerOptions = (absoluteFilename, extra) => ({
|
|
1355
|
-
...extra,
|
|
1356
|
-
filename: absoluteFilename,
|
|
1357
|
-
tailwindcssMajorVersion: runtimeState.twPatcher.majorVersion,
|
|
1358
|
-
moduleGraph: moduleGraphOptions,
|
|
1359
|
-
babelParserOptions: {
|
|
1360
|
-
..._nullishCoalesce(_optionalChain([extra, 'optionalAccess', _43 => _43.babelParserOptions]), () => ( {})),
|
|
1361
|
-
sourceFilename: absoluteFilename
|
|
1362
|
-
}
|
|
1363
|
-
});
|
|
1364
|
-
const linkedByEntry = useIncrementalMode ? /* @__PURE__ */ new Map() : void 0;
|
|
1365
|
-
const sharedCssResultCache = /* @__PURE__ */ new Map();
|
|
1366
|
-
const tasks = [];
|
|
1367
|
-
const jsTaskFactories = [];
|
|
1368
|
-
for (const entry of snapshot.entries) {
|
|
1369
|
-
const { file, output: originalSource, source: originalEntrySource, type } = entry;
|
|
1370
|
-
if (type === "html" && originalSource.type === "asset") {
|
|
1371
|
-
metrics.html.total++;
|
|
1372
|
-
if (!processFiles.html.has(file)) {
|
|
1373
|
-
continue;
|
|
1374
|
-
}
|
|
1375
|
-
const rawSource = originalEntrySource;
|
|
1376
|
-
tasks.push(
|
|
1377
|
-
_chunkOF6MFURRjs.processCachedTask.call(void 0, {
|
|
1378
|
-
cache,
|
|
1379
|
-
cacheKey: file,
|
|
1380
|
-
hashKey: `${file}:html:${runtimeSignature}`,
|
|
1381
|
-
hash: getSnapshotHash(snapshot.sourceHashByFile, file, rawSource),
|
|
1382
|
-
applyResult(source) {
|
|
1383
|
-
originalSource.source = source;
|
|
1384
|
-
},
|
|
1385
|
-
onCacheHit() {
|
|
1386
|
-
metrics.html.cacheHits++;
|
|
1387
|
-
debug3("html cache hit: %s", file);
|
|
1388
|
-
},
|
|
1389
|
-
async transform() {
|
|
1390
|
-
const start = performance.now();
|
|
1391
|
-
let transformed = await templateHandler(rawSource, defaultTemplateHandlerOptions);
|
|
1392
|
-
let unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
1393
|
-
if (unresolvedDynamicCandidates.length > 0) {
|
|
1394
|
-
_logger.logger.warn(
|
|
1395
|
-
"\u68C0\u6D4B\u5230 WXML \u52A8\u6001\u7C7B\u540D\u672A\u5B8C\u6210\u8F6C\u8BD1\uFF0C\u5DF2\u56DE\u9000\u5230\u5B8C\u6574 runtimeSet \u91CD\u8BD5: %s -> %O",
|
|
1396
|
-
file,
|
|
1397
|
-
unresolvedDynamicCandidates
|
|
1398
|
-
);
|
|
1399
|
-
const fullRuntimeSet = await context.ensureRuntimeClassSet(true);
|
|
1400
|
-
transformed = await templateHandler(rawSource, {
|
|
1401
|
-
runtimeSet: fullRuntimeSet
|
|
1402
|
-
});
|
|
1403
|
-
unresolvedDynamicCandidates = collectUnescapedDynamicCandidates(transformed);
|
|
1404
|
-
if (unresolvedDynamicCandidates.length > 0) {
|
|
1405
|
-
_logger.logger.warn(
|
|
1406
|
-
"WXML \u52A8\u6001\u7C7B\u540D\u5728\u5B8C\u6574 runtimeSet \u91CD\u8BD5\u540E\u4ECD\u672A\u5B8C\u6210\u8F6C\u8BD1: %s -> %O",
|
|
1407
|
-
file,
|
|
1408
|
-
unresolvedDynamicCandidates
|
|
1409
|
-
);
|
|
1410
|
-
}
|
|
1411
|
-
}
|
|
1412
|
-
metrics.html.elapsed += measureElapsed(start);
|
|
1413
|
-
metrics.html.transformed++;
|
|
1414
|
-
onUpdate(file, rawSource, transformed);
|
|
1415
|
-
debug3("html handle: %s", file);
|
|
1416
|
-
return {
|
|
1417
|
-
result: transformed
|
|
1418
|
-
};
|
|
1419
|
-
}
|
|
1420
|
-
})
|
|
1421
|
-
);
|
|
1422
|
-
continue;
|
|
1423
|
-
}
|
|
1424
|
-
if (type === "css" && originalSource.type === "asset") {
|
|
1425
|
-
metrics.css.total++;
|
|
1426
|
-
const rawSource = originalEntrySource;
|
|
1427
|
-
const cssRuntimeAffectingSignature = _nullishCoalesce(snapshot.runtimeAffectingSignatureByFile.get(file), () => ( rawSource));
|
|
1428
|
-
const cssShareScope = createCssTransformShareScope(file, rawSource);
|
|
1429
|
-
const cssHandlerOptions = getCssHandlerOptions(file);
|
|
1430
|
-
const cssSharedCacheKey = `${cssShareScope}:${runtimeSignature}:${_nullishCoalesce(runtimeState.twPatcher.majorVersion, () => ( "unknown"))}:${cssHandlerOptions.isMainChunk ? "1" : "0"}:${cssRuntimeAffectingSignature}`;
|
|
1431
|
-
tasks.push(
|
|
1432
|
-
_chunkOF6MFURRjs.processCachedTask.call(void 0, {
|
|
1433
|
-
cache,
|
|
1434
|
-
cacheKey: file,
|
|
1435
|
-
hashKey: `${file}:css:${runtimeSignature}:${_nullishCoalesce(runtimeState.twPatcher.majorVersion, () => ( "unknown"))}`,
|
|
1436
|
-
hash: getSnapshotHash(snapshot.runtimeAffectingHashByFile, file, cssRuntimeAffectingSignature),
|
|
1437
|
-
applyResult(source) {
|
|
1438
|
-
originalSource.source = source;
|
|
1439
|
-
},
|
|
1440
|
-
onCacheHit() {
|
|
1441
|
-
metrics.css.cacheHits++;
|
|
1442
|
-
debug3("css cache hit: %s", file);
|
|
1443
|
-
},
|
|
1444
|
-
async transform() {
|
|
1445
|
-
if (cssSharedCacheKey) {
|
|
1446
|
-
const sharedCssTask = sharedCssResultCache.get(cssSharedCacheKey);
|
|
1447
|
-
if (sharedCssTask != null) {
|
|
1448
|
-
metrics.css.cacheHits++;
|
|
1449
|
-
debug3("css shared hit: %s", file);
|
|
1450
|
-
const sharedCss = await sharedCssTask;
|
|
1451
|
-
onUpdate(file, rawSource, sharedCss);
|
|
1452
|
-
return {
|
|
1453
|
-
result: sharedCss
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
const runTransform = async () => {
|
|
1458
|
-
const start = performance.now();
|
|
1459
|
-
await runtimeState.patchPromise;
|
|
1460
|
-
const { css: css2 } = await styleHandler(rawSource, getCssHandlerOptions(file));
|
|
1461
|
-
if (debugCssDiff) {
|
|
1462
|
-
debug3("css diff %s: %s", file, summarizeStringDiff(rawSource, css2));
|
|
1463
|
-
}
|
|
1464
|
-
metrics.css.elapsed += measureElapsed(start);
|
|
1465
|
-
metrics.css.transformed++;
|
|
1466
|
-
return css2;
|
|
1467
|
-
};
|
|
1468
|
-
const cssTask = cssSharedCacheKey ? _nullishCoalesce(sharedCssResultCache.get(cssSharedCacheKey), () => ( runTransform())) : runTransform();
|
|
1469
|
-
if (cssSharedCacheKey && !sharedCssResultCache.has(cssSharedCacheKey)) {
|
|
1470
|
-
sharedCssResultCache.set(cssSharedCacheKey, cssTask);
|
|
1471
|
-
}
|
|
1472
|
-
const css = await cssTask;
|
|
1473
|
-
onUpdate(file, rawSource, css);
|
|
1474
|
-
debug3("css handle: %s", file);
|
|
1475
|
-
return {
|
|
1476
|
-
result: css
|
|
1477
|
-
};
|
|
1478
|
-
}
|
|
1479
|
-
})
|
|
1480
|
-
);
|
|
1481
|
-
continue;
|
|
1482
|
-
}
|
|
1483
|
-
if (type !== "js") {
|
|
1484
|
-
continue;
|
|
1485
|
-
}
|
|
1486
|
-
metrics.js.total++;
|
|
1487
|
-
const shouldTransformJs = !useIncrementalMode || processFiles.js.has(file);
|
|
1488
|
-
if (!shouldTransformJs) {
|
|
1489
|
-
debug3("js skip transform (clean), replay cache: %s", file);
|
|
1490
|
-
}
|
|
1491
|
-
if (originalSource.type === "chunk") {
|
|
1492
|
-
const absoluteFile = _path2.default.resolve(outDir, file);
|
|
1493
|
-
const initialRawSource = originalEntrySource;
|
|
1494
|
-
const linkedSet = useIncrementalMode ? /* @__PURE__ */ new Set() : void 0;
|
|
1495
|
-
if (linkedByEntry && linkedSet) {
|
|
1496
|
-
linkedByEntry.set(file, linkedSet);
|
|
1497
|
-
}
|
|
1498
|
-
jsTaskFactories.push(async () => {
|
|
1499
|
-
const linkedImpactSignature = useIncrementalMode ? createLinkedImpactSignature(
|
|
1500
|
-
file,
|
|
1501
|
-
snapshot.linkedImpactsByEntry,
|
|
1502
|
-
snapshot.sourceHashByFile
|
|
1503
|
-
) : void 0;
|
|
1504
|
-
const hashSalt = createJsHashSalt(runtimeSignature, linkedImpactSignature);
|
|
1505
|
-
await _chunkOF6MFURRjs.processCachedTask.call(void 0, {
|
|
1506
|
-
cache,
|
|
1507
|
-
cacheKey: file,
|
|
1508
|
-
hashKey: `${file}:js`,
|
|
1509
|
-
hash: `${getSnapshotHash(snapshot.sourceHashByFile, file, initialRawSource)}:${hashSalt}`,
|
|
1510
|
-
applyResult(source) {
|
|
1511
|
-
originalSource.code = source;
|
|
1512
|
-
},
|
|
1513
|
-
onCacheHit() {
|
|
1514
|
-
metrics.js.cacheHits++;
|
|
1515
|
-
debug3("js cache hit: %s", file);
|
|
1516
|
-
},
|
|
1517
|
-
async transform() {
|
|
1518
|
-
const start = performance.now();
|
|
1519
|
-
const rawSource = originalSource.code;
|
|
1520
|
-
if (!shouldTransformJs) {
|
|
1521
|
-
debug3("js cache replay miss, fallback transform: %s", file);
|
|
1522
|
-
}
|
|
1523
|
-
const handlerOptions = createHandlerOptions(absoluteFile);
|
|
1524
|
-
if (!disableJsPrecheck && _chunkHVNGIKLSjs.shouldSkipJsTransform.call(void 0, rawSource, handlerOptions)) {
|
|
1525
|
-
metrics.js.elapsed += measureElapsed(start);
|
|
1526
|
-
metrics.js.transformed++;
|
|
1527
|
-
return {
|
|
1528
|
-
result: rawSource
|
|
1529
|
-
};
|
|
1530
|
-
}
|
|
1531
|
-
const { code, linked } = await jsHandler(rawSource, runtime, handlerOptions);
|
|
1532
|
-
metrics.js.elapsed += measureElapsed(start);
|
|
1533
|
-
metrics.js.transformed++;
|
|
1534
|
-
onUpdate(file, rawSource, code);
|
|
1535
|
-
debug3("js handle: %s", file);
|
|
1536
|
-
if (linked) {
|
|
1537
|
-
for (const id of Object.keys(linked)) {
|
|
1538
|
-
const linkedEntry = getJsEntry(id);
|
|
1539
|
-
if (linkedEntry && linkedSet) {
|
|
1540
|
-
linkedSet.add(linkedEntry.fileName);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
applyLinkedUpdates(linked);
|
|
1545
|
-
return {
|
|
1546
|
-
result: code
|
|
1547
|
-
};
|
|
1548
|
-
}
|
|
1549
|
-
});
|
|
1550
|
-
});
|
|
1551
|
-
} else if (uniAppX && originalSource.type === "asset") {
|
|
1552
|
-
const linkedSet = useIncrementalMode ? /* @__PURE__ */ new Set() : void 0;
|
|
1553
|
-
if (linkedByEntry && linkedSet) {
|
|
1554
|
-
linkedByEntry.set(file, linkedSet);
|
|
1555
|
-
}
|
|
1556
|
-
const baseApplyLinkedUpdates = applyLinkedUpdates;
|
|
1557
|
-
const wrappedApplyLinkedUpdates = (linked) => {
|
|
1558
|
-
if (linked) {
|
|
1559
|
-
for (const id of Object.keys(linked)) {
|
|
1560
|
-
const linkedEntry = getJsEntry(id);
|
|
1561
|
-
if (linkedEntry && linkedSet) {
|
|
1562
|
-
linkedSet.add(linkedEntry.fileName);
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
baseApplyLinkedUpdates(linked);
|
|
1567
|
-
};
|
|
1568
|
-
const factory = createUniAppXAssetTask(
|
|
1569
|
-
file,
|
|
1570
|
-
originalSource,
|
|
1571
|
-
outDir,
|
|
1572
|
-
{
|
|
1573
|
-
cache,
|
|
1574
|
-
hashKey: `${file}:js`,
|
|
1575
|
-
hashSalt: createJsHashSalt(
|
|
1576
|
-
runtimeSignature,
|
|
1577
|
-
useIncrementalMode ? createLinkedImpactSignature(
|
|
1578
|
-
file,
|
|
1579
|
-
snapshot.linkedImpactsByEntry,
|
|
1580
|
-
snapshot.sourceHashByFile
|
|
1581
|
-
) : void 0
|
|
1582
|
-
),
|
|
1583
|
-
createHandlerOptions,
|
|
1584
|
-
debug: debug3,
|
|
1585
|
-
jsHandler,
|
|
1586
|
-
onUpdate,
|
|
1587
|
-
runtimeSet: runtime,
|
|
1588
|
-
applyLinkedResults: wrappedApplyLinkedUpdates,
|
|
1589
|
-
uniAppX
|
|
1590
|
-
}
|
|
1591
|
-
);
|
|
1592
|
-
jsTaskFactories.push(async () => {
|
|
1593
|
-
const start = performance.now();
|
|
1594
|
-
if (!shouldTransformJs) {
|
|
1595
|
-
debug3("js skip transform (clean, uni-app-x), replay cache: %s", file);
|
|
1596
|
-
await factory();
|
|
1597
|
-
metrics.js.elapsed += measureElapsed(start);
|
|
1598
|
-
metrics.js.transformed++;
|
|
1599
|
-
return;
|
|
1600
|
-
}
|
|
1601
|
-
const currentSource = originalEntrySource;
|
|
1602
|
-
const absoluteFile = _path2.default.resolve(outDir, file);
|
|
1603
|
-
const precheckOptions = createHandlerOptions(absoluteFile, {
|
|
1604
|
-
uniAppX: resolveUniAppXJsTransformEnabled2(uniAppX),
|
|
1605
|
-
babelParserOptions: {
|
|
1606
|
-
plugins: ["typescript"],
|
|
1607
|
-
sourceType: "unambiguous"
|
|
1608
|
-
}
|
|
1609
|
-
});
|
|
1610
|
-
if (!disableJsPrecheck && _chunkHVNGIKLSjs.shouldSkipJsTransform.call(void 0, currentSource, precheckOptions)) {
|
|
1611
|
-
metrics.js.elapsed += measureElapsed(start);
|
|
1612
|
-
metrics.js.transformed++;
|
|
1613
|
-
return;
|
|
1614
|
-
}
|
|
1615
|
-
await factory();
|
|
1616
|
-
metrics.js.elapsed += measureElapsed(start);
|
|
1617
|
-
metrics.js.transformed++;
|
|
1618
|
-
});
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
_chunk24AGZQVRjs.pushConcurrentTaskFactories.call(void 0, tasks, jsTaskFactories);
|
|
1622
|
-
await Promise.all(tasks);
|
|
1623
|
-
for (const apply of pendingLinkedUpdates) {
|
|
1624
|
-
apply();
|
|
1625
|
-
}
|
|
1626
|
-
updateBundleBuildState(
|
|
1627
|
-
state,
|
|
1628
|
-
snapshot,
|
|
1629
|
-
useIncrementalMode ? _nullishCoalesce(linkedByEntry, () => ( /* @__PURE__ */ new Map())) : /* @__PURE__ */ new Map(),
|
|
1630
|
-
{ incremental: useIncrementalMode }
|
|
1631
|
-
);
|
|
1632
|
-
debug3(
|
|
1633
|
-
"metrics iteration=%d runtime=%sms html(total=%d transform=%d hit=%d rate=%s elapsed=%sms) js(total=%d transform=%d hit=%d rate=%s elapsed=%sms) css(total=%d transform=%d hit=%d rate=%s elapsed=%sms)",
|
|
1634
|
-
useIncrementalMode ? state.iteration : 0,
|
|
1635
|
-
formatMs(metrics.runtimeSet),
|
|
1636
|
-
metrics.html.total,
|
|
1637
|
-
metrics.html.transformed,
|
|
1638
|
-
metrics.html.cacheHits,
|
|
1639
|
-
formatCacheHitRate(metrics.html),
|
|
1640
|
-
formatMs(metrics.html.elapsed),
|
|
1641
|
-
metrics.js.total,
|
|
1642
|
-
metrics.js.transformed,
|
|
1643
|
-
metrics.js.cacheHits,
|
|
1644
|
-
formatCacheHitRate(metrics.js),
|
|
1645
|
-
formatMs(metrics.js.elapsed),
|
|
1646
|
-
metrics.css.total,
|
|
1647
|
-
metrics.css.transformed,
|
|
1648
|
-
metrics.css.cacheHits,
|
|
1649
|
-
formatCacheHitRate(metrics.css),
|
|
1650
|
-
formatMs(metrics.css.elapsed)
|
|
1651
|
-
);
|
|
1652
|
-
onEnd();
|
|
1653
|
-
debug3("end");
|
|
1654
|
-
};
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
// src/bundlers/vite/incremental-runtime-class-set.ts
|
|
1658
|
-
var _promises = require('fs/promises');
|
|
1659
|
-
var _module = require('module');
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
var _tailwindcsspatch = require('tailwindcss-patch');
|
|
1663
|
-
var debug = _chunkHVNGIKLSjs.createDebug.call(void 0, "[vite:runtime-set] ");
|
|
1664
|
-
var require2 = _module.createRequire.call(void 0, _chunkRKISS72Pjs.importMetaUrl);
|
|
1665
|
-
var EXTENSION_DOT_PREFIX_RE = /^\./;
|
|
1666
|
-
var VALIDATION_FILE_NAME = "runtime-candidates.html";
|
|
1667
|
-
var tailwindNodeModulePromise;
|
|
1668
|
-
function toPosixPath(value) {
|
|
1669
|
-
return value.replaceAll("\\", "/");
|
|
1670
|
-
}
|
|
1671
|
-
function createCssImportSource(imports) {
|
|
1672
|
-
return imports.map((value) => `@import "${toPosixPath(value)}";`).join("\n");
|
|
1673
|
-
}
|
|
1674
|
-
function isPostcssPluginImportTarget(value) {
|
|
1675
|
-
if (!value) {
|
|
1676
|
-
return false;
|
|
1677
|
-
}
|
|
1678
|
-
return value === "@tailwindcss/postcss" || value === "@tailwindcss/postcss7-compat" || value.includes("/postcss");
|
|
1679
|
-
}
|
|
1680
|
-
function resolveTailwindCssImportTarget(patcher) {
|
|
1681
|
-
const tailwindOptions = _chunkZAA5ZG3Djs.resolveTailwindcssOptions.call(void 0, patcher.options);
|
|
1682
|
-
const cssEntries = _optionalChain([tailwindOptions, 'optionalAccess', _44 => _44.v4, 'optionalAccess', _45 => _45.cssEntries, 'optionalAccess', _46 => _46.filter, 'call', _47 => _47((item) => typeof item === "string" && item.length > 0)]);
|
|
1683
|
-
if (cssEntries && cssEntries.length > 0) {
|
|
1684
|
-
return createCssImportSource(cssEntries);
|
|
1685
|
-
}
|
|
1686
|
-
const configuredPackageName = _optionalChain([tailwindOptions, 'optionalAccess', _48 => _48.packageName]);
|
|
1687
|
-
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) {
|
|
1688
|
-
return createCssImportSource([configuredPackageName]);
|
|
1689
|
-
}
|
|
1690
|
-
const packageName = _optionalChain([patcher, 'access', _49 => _49.packageInfo, 'optionalAccess', _50 => _50.name]);
|
|
1691
|
-
if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) {
|
|
1692
|
-
return createCssImportSource([packageName]);
|
|
1693
|
-
}
|
|
1694
|
-
return createCssImportSource(["tailwindcss"]);
|
|
1695
|
-
}
|
|
1696
|
-
function getProjectRoot(patcher) {
|
|
1697
|
-
return _nullishCoalesce(_optionalChain([patcher, 'access', _51 => _51.options, 'optionalAccess', _52 => _52.projectRoot]), () => ( _process2.default.cwd()));
|
|
1698
|
-
}
|
|
1699
|
-
async function importTailwindNodeModule() {
|
|
1700
|
-
if (!tailwindNodeModulePromise) {
|
|
1701
|
-
tailwindNodeModulePromise = (async () => {
|
|
1702
|
-
try {
|
|
1703
|
-
const resolved = require2.resolve("@tailwindcss/node");
|
|
1704
|
-
return await Promise.resolve().then(() => _interopRequireWildcard(require(resolved)));
|
|
1705
|
-
} catch (e6) {
|
|
1706
|
-
const tailwindcssPatchEntry = require2.resolve("tailwindcss-patch");
|
|
1707
|
-
const resolved = require2.resolve("@tailwindcss/node", {
|
|
1708
|
-
paths: [_path2.default.dirname(tailwindcssPatchEntry)]
|
|
1709
|
-
});
|
|
1710
|
-
return await Promise.resolve().then(() => _interopRequireWildcard(require(resolved)));
|
|
1711
|
-
}
|
|
1712
|
-
})();
|
|
1713
|
-
}
|
|
1714
|
-
return tailwindNodeModulePromise;
|
|
1715
|
-
}
|
|
1716
|
-
function resolveMaybeAbsolute(base, value) {
|
|
1717
|
-
if (!value) {
|
|
1718
|
-
return void 0;
|
|
1719
|
-
}
|
|
1720
|
-
return _path2.default.isAbsolute(value) ? value : _path2.default.resolve(base, value);
|
|
1721
|
-
}
|
|
1722
|
-
async function resolveTailwindCssSource(patcher) {
|
|
1723
|
-
const projectRoot = getProjectRoot(patcher);
|
|
1724
|
-
const tailwindOptions = _chunkZAA5ZG3Djs.resolveTailwindcssOptions.call(void 0, patcher.options);
|
|
1725
|
-
const configuredBase = resolveMaybeAbsolute(projectRoot, _optionalChain([tailwindOptions, 'optionalAccess', _53 => _53.v4, 'optionalAccess', _54 => _54.base]));
|
|
1726
|
-
const configDir = _optionalChain([tailwindOptions, 'optionalAccess', _55 => _55.config]) ? _path2.default.dirname(tailwindOptions.config) : void 0;
|
|
1727
|
-
const sharedFallbacks = [
|
|
1728
|
-
configuredBase,
|
|
1729
|
-
projectRoot,
|
|
1730
|
-
_optionalChain([tailwindOptions, 'optionalAccess', _56 => _56.cwd]),
|
|
1731
|
-
configDir
|
|
1732
|
-
].filter((item) => typeof item === "string" && item.length > 0);
|
|
1733
|
-
if (_optionalChain([tailwindOptions, 'optionalAccess', _57 => _57.v4, 'optionalAccess', _58 => _58.css])) {
|
|
1734
|
-
return {
|
|
1735
|
-
projectRoot,
|
|
1736
|
-
base: _nullishCoalesce(configuredBase, () => ( projectRoot)),
|
|
1737
|
-
baseFallbacks: [...new Set(sharedFallbacks)],
|
|
1738
|
-
css: tailwindOptions.v4.css
|
|
1739
|
-
};
|
|
1740
|
-
}
|
|
1741
|
-
const cssEntries = _nullishCoalesce(_optionalChain([tailwindOptions, 'optionalAccess', _59 => _59.v4, 'optionalAccess', _60 => _60.cssEntries, 'optionalAccess', _61 => _61.filter, 'call', _62 => _62((item) => typeof item === "string" && item.length > 0)]), () => ( []));
|
|
1742
|
-
if (cssEntries.length > 0) {
|
|
1743
|
-
const resolvedEntries = cssEntries.map((entry) => _nullishCoalesce(resolveMaybeAbsolute(projectRoot, entry), () => ( entry)));
|
|
1744
|
-
const cssChunks = [];
|
|
1745
|
-
const entryDirs = [];
|
|
1746
|
-
for (const entry of resolvedEntries) {
|
|
1747
|
-
try {
|
|
1748
|
-
cssChunks.push(await _promises.readFile.call(void 0, entry, "utf8"));
|
|
1749
|
-
entryDirs.push(_path2.default.dirname(entry));
|
|
1750
|
-
} catch (e7) {
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
if (cssChunks.length > 0) {
|
|
1754
|
-
const base = _nullishCoalesce(_nullishCoalesce(entryDirs[0], () => ( configuredBase)), () => ( projectRoot));
|
|
1755
|
-
const baseFallbacks = [...new Set([
|
|
1756
|
-
...entryDirs.slice(1),
|
|
1757
|
-
...sharedFallbacks
|
|
1758
|
-
].filter((item) => typeof item === "string" && item.length > 0 && item !== base))];
|
|
1759
|
-
return {
|
|
1760
|
-
projectRoot,
|
|
1761
|
-
base,
|
|
1762
|
-
baseFallbacks,
|
|
1763
|
-
css: cssChunks.join("\n")
|
|
1764
|
-
};
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
return {
|
|
1768
|
-
projectRoot,
|
|
1769
|
-
base: _nullishCoalesce(configuredBase, () => ( projectRoot)),
|
|
1770
|
-
baseFallbacks: [...new Set(sharedFallbacks)],
|
|
1771
|
-
css: resolveTailwindCssImportTarget(patcher)
|
|
1772
|
-
};
|
|
1773
|
-
}
|
|
1774
|
-
function createExtractOptions(context, tempRoot, pattern) {
|
|
1775
|
-
return {
|
|
1776
|
-
cwd: context.projectRoot,
|
|
1777
|
-
base: context.base,
|
|
1778
|
-
baseFallbacks: context.baseFallbacks,
|
|
1779
|
-
css: context.css,
|
|
1780
|
-
sources: [{
|
|
1781
|
-
base: tempRoot,
|
|
1782
|
-
pattern,
|
|
1783
|
-
negated: false
|
|
1784
|
-
}]
|
|
1785
|
-
};
|
|
1786
|
-
}
|
|
1787
|
-
function createRuntimeEntries(snapshot) {
|
|
1788
|
-
return snapshot.entries.filter((entry) => entry.type === "html" || entry.type === "js");
|
|
1789
|
-
}
|
|
1790
|
-
function collectChangedRuntimeFiles(snapshot) {
|
|
1791
|
-
return /* @__PURE__ */ new Set([
|
|
1792
|
-
...snapshot.runtimeAffectingChangedByType.html,
|
|
1793
|
-
...snapshot.runtimeAffectingChangedByType.js
|
|
1794
|
-
]);
|
|
1795
|
-
}
|
|
1796
|
-
async function writeTempEntryFile(tempRoot, file, source) {
|
|
1797
|
-
const absoluteFile = _path2.default.join(tempRoot, file);
|
|
1798
|
-
await _promises.mkdir.call(void 0, _path2.default.dirname(absoluteFile), { recursive: true });
|
|
1799
|
-
await _promises.writeFile.call(void 0, absoluteFile, source, "utf8");
|
|
1800
|
-
return file;
|
|
1801
|
-
}
|
|
1802
|
-
function resolveEntryExtension(entry) {
|
|
1803
|
-
const ext = _path2.default.extname(entry.file).replace(EXTENSION_DOT_PREFIX_RE, "");
|
|
1804
|
-
if (ext.length > 0) {
|
|
1805
|
-
return ext;
|
|
1806
|
-
}
|
|
1807
|
-
return entry.type === "html" ? "html" : "js";
|
|
1808
|
-
}
|
|
1809
|
-
function createCandidateValidationSource(candidates) {
|
|
1810
|
-
return [...new Set(candidates)].sort().join("\n");
|
|
1811
|
-
}
|
|
1812
|
-
function removeCandidateSet(candidateCountByClass, runtimeSet, candidates) {
|
|
1813
|
-
for (const className of candidates) {
|
|
1814
|
-
const count = candidateCountByClass.get(className);
|
|
1815
|
-
if (count == null) {
|
|
1816
|
-
continue;
|
|
1817
|
-
}
|
|
1818
|
-
if (count <= 1) {
|
|
1819
|
-
candidateCountByClass.delete(className);
|
|
1820
|
-
runtimeSet.delete(className);
|
|
1821
|
-
continue;
|
|
1822
|
-
}
|
|
1823
|
-
candidateCountByClass.set(className, count - 1);
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
function addCandidateSet(candidateCountByClass, runtimeSet, candidates) {
|
|
1827
|
-
for (const className of candidates) {
|
|
1828
|
-
const nextCount = (_nullishCoalesce(candidateCountByClass.get(className), () => ( 0))) + 1;
|
|
1829
|
-
candidateCountByClass.set(className, nextCount);
|
|
1830
|
-
runtimeSet.add(className);
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
function createBundleRuntimeClassSetManager(options = {}) {
|
|
1834
|
-
const customExtractCandidates = options.extractCandidates;
|
|
1835
|
-
const extractCandidates = _nullishCoalesce(customExtractCandidates, () => ( _tailwindcsspatch.extractValidCandidates));
|
|
1836
|
-
const extractRawCandidates = _nullishCoalesce(options.extractRawCandidates, () => ( _tailwindcsspatch.extractRawCandidatesWithPositions));
|
|
1837
|
-
const runtimeSet = /* @__PURE__ */ new Set();
|
|
1838
|
-
const candidateCountByClass = /* @__PURE__ */ new Map();
|
|
1839
|
-
const candidatesByFile = /* @__PURE__ */ new Map();
|
|
1840
|
-
const candidateValidityCache = /* @__PURE__ */ new Map();
|
|
1841
|
-
let runtimeSignature;
|
|
1842
|
-
let resolvedTempRoot;
|
|
1843
|
-
let validationContext;
|
|
1844
|
-
let designSystemPromise;
|
|
1845
|
-
async function reset() {
|
|
1846
|
-
runtimeSet.clear();
|
|
1847
|
-
candidateCountByClass.clear();
|
|
1848
|
-
candidatesByFile.clear();
|
|
1849
|
-
candidateValidityCache.clear();
|
|
1850
|
-
runtimeSignature = void 0;
|
|
1851
|
-
validationContext = void 0;
|
|
1852
|
-
designSystemPromise = void 0;
|
|
1853
|
-
if (resolvedTempRoot) {
|
|
1854
|
-
await _promises.rm.call(void 0, resolvedTempRoot, { recursive: true, force: true });
|
|
1855
|
-
resolvedTempRoot = void 0;
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
|
-
async function resolveValidationContextCached(patcher) {
|
|
1859
|
-
if (!validationContext) {
|
|
1860
|
-
validationContext = await resolveTailwindCssSource(patcher);
|
|
1861
|
-
}
|
|
1862
|
-
return validationContext;
|
|
1863
|
-
}
|
|
1864
|
-
async function loadDesignSystem(context) {
|
|
1865
|
-
if (!designSystemPromise) {
|
|
1866
|
-
designSystemPromise = (async () => {
|
|
1867
|
-
const { __unstable__loadDesignSystem } = await importTailwindNodeModule();
|
|
1868
|
-
let lastError;
|
|
1869
|
-
for (const base of [context.base, ...context.baseFallbacks]) {
|
|
1870
|
-
try {
|
|
1871
|
-
return await __unstable__loadDesignSystem(context.css, { base });
|
|
1872
|
-
} catch (error) {
|
|
1873
|
-
lastError = error;
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
throw lastError instanceof Error ? lastError : new Error("Failed to load Tailwind CSS design system for incremental runtime validation.");
|
|
1877
|
-
})();
|
|
1878
|
-
}
|
|
1879
|
-
return designSystemPromise;
|
|
1880
|
-
}
|
|
1881
|
-
function populateCandidateValidityCacheFromDesignSystem(designSystem, unknownCandidates) {
|
|
1882
|
-
const parsedCandidates = [...unknownCandidates].filter((candidate) => designSystem.parseCandidate(candidate).length > 0);
|
|
1883
|
-
const cssByCandidate = parsedCandidates.length > 0 ? designSystem.candidatesToCss(parsedCandidates) : [];
|
|
1884
|
-
const validCandidates = /* @__PURE__ */ new Set();
|
|
1885
|
-
for (let index = 0; index < parsedCandidates.length; index += 1) {
|
|
1886
|
-
const candidate = parsedCandidates[index];
|
|
1887
|
-
const css = cssByCandidate[index];
|
|
1888
|
-
if (candidate && typeof css === "string" && css.trim().length > 0) {
|
|
1889
|
-
validCandidates.add(candidate);
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
for (const candidate of unknownCandidates) {
|
|
1893
|
-
candidateValidityCache.set(candidate, validCandidates.has(candidate));
|
|
1894
|
-
}
|
|
1895
|
-
}
|
|
1896
|
-
async function validateUnknownCandidates(patcher, tempRoot, unknownCandidates) {
|
|
1897
|
-
if (unknownCandidates.size === 0) {
|
|
1898
|
-
return;
|
|
1899
|
-
}
|
|
1900
|
-
const context = await resolveValidationContextCached(patcher);
|
|
1901
|
-
if (!customExtractCandidates) {
|
|
1902
|
-
try {
|
|
1903
|
-
const designSystem = await loadDesignSystem(context);
|
|
1904
|
-
populateCandidateValidityCacheFromDesignSystem(designSystem, unknownCandidates);
|
|
1905
|
-
return;
|
|
1906
|
-
} catch (error) {
|
|
1907
|
-
debug("incremental design-system validation failed, fallback to extractValidCandidates: %O", error);
|
|
1908
|
-
designSystemPromise = void 0;
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
const source = createCandidateValidationSource(unknownCandidates);
|
|
1912
|
-
const pattern = await writeTempEntryFile(tempRoot, VALIDATION_FILE_NAME, source);
|
|
1913
|
-
const validCandidates = new Set(await extractCandidates(createExtractOptions(context, tempRoot, pattern)));
|
|
1914
|
-
for (const candidate of unknownCandidates) {
|
|
1915
|
-
candidateValidityCache.set(candidate, validCandidates.has(candidate));
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
async function extractEntryRawCandidates(entry) {
|
|
1919
|
-
const matches = await extractRawCandidates(entry.source, resolveEntryExtension(entry));
|
|
1920
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
1921
|
-
for (const match of matches) {
|
|
1922
|
-
const candidate = _optionalChain([match, 'optionalAccess', _63 => _63.rawCandidate]);
|
|
1923
|
-
if (typeof candidate === "string" && candidate.length > 0) {
|
|
1924
|
-
candidates.add(candidate);
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
return candidates;
|
|
1928
|
-
}
|
|
1929
|
-
async function sync(patcher, snapshot) {
|
|
1930
|
-
const nextSignature = _nullishCoalesce(_chunkZAA5ZG3Djs.getRuntimeClassSetSignature.call(void 0, patcher), () => ( "runtime:missing"));
|
|
1931
|
-
const runtimeEntries = createRuntimeEntries(snapshot);
|
|
1932
|
-
const runtimeEntriesByFile = new Map(runtimeEntries.map((entry) => [entry.file, entry]));
|
|
1933
|
-
const currentRuntimeFiles = new Set(runtimeEntriesByFile.keys());
|
|
1934
|
-
const fullRebuild = runtimeSignature !== nextSignature || candidatesByFile.size === 0;
|
|
1935
|
-
if (runtimeSignature !== nextSignature) {
|
|
1936
|
-
debug("runtime signature changed, reset incremental runtime set: %s", nextSignature);
|
|
1937
|
-
await reset();
|
|
1938
|
-
}
|
|
1939
|
-
runtimeSignature = nextSignature;
|
|
1940
|
-
const projectRoot = getProjectRoot(patcher);
|
|
1941
|
-
resolvedTempRoot = _nullishCoalesce(options.tempRoot, () => ( _path2.default.join(
|
|
1942
|
-
projectRoot,
|
|
1943
|
-
"node_modules",
|
|
1944
|
-
".cache",
|
|
1945
|
-
"weapp-tailwindcss",
|
|
1946
|
-
"vite-runtime-set"
|
|
1947
|
-
)));
|
|
1948
|
-
for (const [file, previousCandidates] of candidatesByFile) {
|
|
1949
|
-
if (currentRuntimeFiles.has(file)) {
|
|
1950
|
-
continue;
|
|
1951
|
-
}
|
|
1952
|
-
removeCandidateSet(candidateCountByClass, runtimeSet, previousCandidates);
|
|
1953
|
-
candidatesByFile.delete(file);
|
|
1954
|
-
}
|
|
1955
|
-
const changedRuntimeFiles = fullRebuild ? [...runtimeEntriesByFile.keys()] : [...collectChangedRuntimeFiles(snapshot)];
|
|
1956
|
-
if (changedRuntimeFiles.length === 0) {
|
|
1957
|
-
return new Set(runtimeSet);
|
|
1958
|
-
}
|
|
1959
|
-
const rawCandidatesByFile = /* @__PURE__ */ new Map();
|
|
1960
|
-
const unknownCandidates = /* @__PURE__ */ new Set();
|
|
1961
|
-
await Promise.all(changedRuntimeFiles.map(async (file) => {
|
|
1962
|
-
const entry = runtimeEntriesByFile.get(file);
|
|
1963
|
-
if (!entry) {
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
const candidates = await extractEntryRawCandidates(entry);
|
|
1967
|
-
rawCandidatesByFile.set(file, candidates);
|
|
1968
|
-
for (const candidate of candidates) {
|
|
1969
|
-
if (!candidateValidityCache.has(candidate)) {
|
|
1970
|
-
unknownCandidates.add(candidate);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
}));
|
|
1974
|
-
await validateUnknownCandidates(patcher, resolvedTempRoot, unknownCandidates);
|
|
1975
|
-
let rawCandidateCount = 0;
|
|
1976
|
-
for (const file of changedRuntimeFiles) {
|
|
1977
|
-
const nextRawCandidates = rawCandidatesByFile.get(file);
|
|
1978
|
-
const previousCandidates = candidatesByFile.get(file);
|
|
1979
|
-
if (previousCandidates) {
|
|
1980
|
-
removeCandidateSet(candidateCountByClass, runtimeSet, previousCandidates);
|
|
1981
|
-
}
|
|
1982
|
-
if (!nextRawCandidates || nextRawCandidates.size === 0) {
|
|
1983
|
-
candidatesByFile.delete(file);
|
|
1984
|
-
continue;
|
|
1985
|
-
}
|
|
1986
|
-
rawCandidateCount += nextRawCandidates.size;
|
|
1987
|
-
const nextCandidates = new Set(
|
|
1988
|
-
[...nextRawCandidates].filter((candidate) => candidateValidityCache.get(candidate) === true)
|
|
1989
|
-
);
|
|
1990
|
-
if (nextCandidates.size === 0) {
|
|
1991
|
-
candidatesByFile.delete(file);
|
|
1992
|
-
continue;
|
|
1993
|
-
}
|
|
1994
|
-
addCandidateSet(candidateCountByClass, runtimeSet, nextCandidates);
|
|
1995
|
-
candidatesByFile.set(file, nextCandidates);
|
|
1996
|
-
}
|
|
1997
|
-
debug(
|
|
1998
|
-
"incremental runtime set synced, changedFiles=%d rawCandidates=%d validateMisses=%d runtimeSize=%d trackedFiles=%d",
|
|
1999
|
-
changedRuntimeFiles.length,
|
|
2000
|
-
rawCandidateCount,
|
|
2001
|
-
unknownCandidates.size,
|
|
2002
|
-
runtimeSet.size,
|
|
2003
|
-
candidatesByFile.size
|
|
2004
|
-
);
|
|
2005
|
-
return new Set(runtimeSet);
|
|
2006
|
-
}
|
|
2007
|
-
return {
|
|
2008
|
-
sync,
|
|
2009
|
-
reset
|
|
2010
|
-
};
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
// src/bundlers/vite/resolve-app-type.ts
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
var PACKAGE_JSON_FILE = "package.json";
|
|
2017
|
-
var MPX_SCRIPT_RE = /\bmpx(?:-cli-service)?\b/u;
|
|
2018
|
-
var TARO_SCRIPT_RE = /\btaro\b/u;
|
|
2019
|
-
var TAILWINDCSS_VITE_MARKERS = [
|
|
2020
|
-
["src/app.mpx", "mpx"],
|
|
2021
|
-
["app.mpx", "mpx"]
|
|
2022
|
-
];
|
|
2023
|
-
function resolveDependencyNames(pkg) {
|
|
2024
|
-
return /* @__PURE__ */ new Set([
|
|
2025
|
-
...Object.keys(_nullishCoalesce(pkg.dependencies, () => ( {}))),
|
|
2026
|
-
...Object.keys(_nullishCoalesce(pkg.devDependencies, () => ( {}))),
|
|
2027
|
-
...Object.keys(_nullishCoalesce(pkg.peerDependencies, () => ( {}))),
|
|
2028
|
-
...Object.keys(_nullishCoalesce(pkg.optionalDependencies, () => ( {})))
|
|
2029
|
-
]);
|
|
2030
|
-
}
|
|
2031
|
-
function hasScriptMatch(pkg, pattern) {
|
|
2032
|
-
return Object.values(_nullishCoalesce(pkg.scripts, () => ( {}))).some((script) => pattern.test(script));
|
|
2033
|
-
}
|
|
2034
|
-
function resolveAppTypeFromPackageJson(pkg) {
|
|
2035
|
-
const dependencyNames = resolveDependencyNames(pkg);
|
|
2036
|
-
if (dependencyNames.has("weapp-vite") || [...dependencyNames].some((name) => name.startsWith("@weapp-vite/"))) {
|
|
2037
|
-
return "weapp-vite";
|
|
2038
|
-
}
|
|
2039
|
-
if ([...dependencyNames].some((name) => name.startsWith("@mpxjs/")) || hasScriptMatch(pkg, MPX_SCRIPT_RE)) {
|
|
2040
|
-
return "mpx";
|
|
2041
|
-
}
|
|
2042
|
-
if ([...dependencyNames].some((name) => name.startsWith("@tarojs/")) || hasScriptMatch(pkg, TARO_SCRIPT_RE)) {
|
|
2043
|
-
return "taro";
|
|
2044
|
-
}
|
|
2045
|
-
if (dependencyNames.has("@dcloudio/vite-plugin-uni")) {
|
|
2046
|
-
return "uni-app-vite";
|
|
2047
|
-
}
|
|
2048
|
-
if (dependencyNames.has("@dcloudio/vue-cli-plugin-uni") || dependencyNames.has("@dcloudio/uni-app") || Object.hasOwn(pkg, "uni-app")) {
|
|
2049
|
-
return "uni-app";
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
function tryReadUniAppManifest(root) {
|
|
2053
|
-
const manifestPath = _path2.default.join(root, "manifest.json");
|
|
2054
|
-
if (!_fs.existsSync.call(void 0, manifestPath)) {
|
|
2055
|
-
return;
|
|
2056
|
-
}
|
|
2057
|
-
try {
|
|
2058
|
-
return JSON.parse(_fs.readFileSync.call(void 0, manifestPath, "utf8"));
|
|
2059
|
-
} catch (e8) {
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
function tryReadPackageJson(root) {
|
|
2063
|
-
const packageJsonPath = _path2.default.join(root, PACKAGE_JSON_FILE);
|
|
2064
|
-
if (!_fs.existsSync.call(void 0, packageJsonPath)) {
|
|
2065
|
-
return;
|
|
2066
|
-
}
|
|
2067
|
-
try {
|
|
2068
|
-
return JSON.parse(_fs.readFileSync.call(void 0, packageJsonPath, "utf8"));
|
|
2069
|
-
} catch (e9) {
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
function resolveAppTypeFromMarkers(root) {
|
|
2073
|
-
for (const [relativePath, appType] of TAILWINDCSS_VITE_MARKERS) {
|
|
2074
|
-
if (_fs.existsSync.call(void 0, _path2.default.join(root, relativePath))) {
|
|
2075
|
-
return appType;
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
function resolveImplicitAppTypeFromViteRoot(root) {
|
|
2080
|
-
const resolvedRoot = _path2.default.resolve(root);
|
|
2081
|
-
if (!_fs.existsSync.call(void 0, resolvedRoot)) {
|
|
2082
|
-
return;
|
|
2083
|
-
}
|
|
2084
|
-
const markerDetected = resolveAppTypeFromMarkers(resolvedRoot);
|
|
2085
|
-
if (markerDetected) {
|
|
2086
|
-
return markerDetected;
|
|
2087
|
-
}
|
|
2088
|
-
let current = resolvedRoot;
|
|
2089
|
-
while (true) {
|
|
2090
|
-
const manifest = tryReadUniAppManifest(current);
|
|
2091
|
-
if (manifest && Object.hasOwn(manifest, "uni-app-x")) {
|
|
2092
|
-
return "uni-app-x";
|
|
2093
|
-
}
|
|
2094
|
-
const pkg = tryReadPackageJson(current);
|
|
2095
|
-
if (pkg) {
|
|
2096
|
-
const detected = resolveAppTypeFromPackageJson(pkg);
|
|
2097
|
-
if (detected) {
|
|
2098
|
-
return detected;
|
|
2099
|
-
}
|
|
2100
|
-
}
|
|
2101
|
-
const parent = _path2.default.dirname(current);
|
|
2102
|
-
if (parent === current) {
|
|
2103
|
-
break;
|
|
2104
|
-
}
|
|
2105
|
-
current = parent;
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
// src/bundlers/vite/rewrite-css-imports.ts
|
|
2110
|
-
function joinPosixPath(base, subpath) {
|
|
2111
|
-
if (base.endsWith("/")) {
|
|
2112
|
-
return `${base}${subpath}`;
|
|
2113
|
-
}
|
|
2114
|
-
return `${base}/${subpath}`;
|
|
2115
|
-
}
|
|
2116
|
-
function isCssLikeImporter(importer) {
|
|
2117
|
-
if (!importer) {
|
|
2118
|
-
return false;
|
|
2119
|
-
}
|
|
2120
|
-
const normalized = _shared.cleanUrl.call(void 0, importer);
|
|
2121
|
-
return isCSSRequest(normalized);
|
|
2122
|
-
}
|
|
2123
|
-
function createRewriteCssImportsPlugins(options) {
|
|
2124
|
-
if (!options.shouldRewrite) {
|
|
2125
|
-
return [];
|
|
2126
|
-
}
|
|
2127
|
-
const { appType, getAppType, weappTailwindcssDirPosix: weappTailwindcssDirPosix2 } = options;
|
|
2128
|
-
const resolveAppType = () => _nullishCoalesce(_optionalChain([getAppType, 'optionalCall', _64 => _64()]), () => ( appType));
|
|
2129
|
-
return [
|
|
2130
|
-
{
|
|
2131
|
-
name: `${_chunkHVNGIKLSjs.vitePluginName}:rewrite-css-imports`,
|
|
2132
|
-
enforce: "pre",
|
|
2133
|
-
resolveId: {
|
|
2134
|
-
order: "pre",
|
|
2135
|
-
handler(id, importer) {
|
|
2136
|
-
const replacement = _chunk24AGZQVRjs.resolveTailwindcssImport.call(void 0, id, weappTailwindcssDirPosix2, {
|
|
2137
|
-
join: joinPosixPath,
|
|
2138
|
-
appType: resolveAppType()
|
|
2139
|
-
});
|
|
2140
|
-
if (!replacement) {
|
|
2141
|
-
return null;
|
|
2142
|
-
}
|
|
2143
|
-
if (importer && !isCssLikeImporter(importer)) {
|
|
2144
|
-
return null;
|
|
2145
|
-
}
|
|
2146
|
-
return replacement;
|
|
2147
|
-
}
|
|
2148
|
-
},
|
|
2149
|
-
transform: {
|
|
2150
|
-
order: "pre",
|
|
2151
|
-
handler(code, id) {
|
|
2152
|
-
if (!isCSSRequest(id)) {
|
|
2153
|
-
return null;
|
|
2154
|
-
}
|
|
2155
|
-
const rewritten = _chunk24AGZQVRjs.rewriteTailwindcssImportsInCode.call(void 0, code, weappTailwindcssDirPosix2, {
|
|
2156
|
-
join: joinPosixPath,
|
|
2157
|
-
appType: resolveAppType()
|
|
2158
|
-
});
|
|
2159
|
-
if (!rewritten) {
|
|
2160
|
-
return null;
|
|
2161
|
-
}
|
|
2162
|
-
return {
|
|
2163
|
-
code: rewritten,
|
|
2164
|
-
map: null
|
|
2165
|
-
};
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
];
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
|
-
// src/bundlers/vite/index.ts
|
|
2173
|
-
var debug2 = _chunkHVNGIKLSjs.createDebug.call(void 0, );
|
|
2174
|
-
var weappTailwindcssPackageDir = _chunk24AGZQVRjs.resolvePackageDir.call(void 0, "weapp-tailwindcss");
|
|
2175
|
-
var weappTailwindcssDirPosix = slash(weappTailwindcssPackageDir);
|
|
2176
|
-
var PACKAGE_JSON_FILE2 = "package.json";
|
|
2177
|
-
function getPostcssPluginName(plugin) {
|
|
2178
|
-
if (!plugin || typeof plugin !== "object" || !("postcssPlugin" in plugin)) {
|
|
2179
|
-
return;
|
|
2180
|
-
}
|
|
2181
|
-
const { postcssPlugin } = plugin;
|
|
2182
|
-
return typeof postcssPlugin === "string" ? postcssPlugin : void 0;
|
|
2183
|
-
}
|
|
2184
|
-
function resolveImplicitTailwindcssBasedirFromViteRoot(root) {
|
|
2185
|
-
const resolvedRoot = _path2.default.resolve(root);
|
|
2186
|
-
if (!_fs.existsSync.call(void 0, resolvedRoot)) {
|
|
2187
|
-
return resolvedRoot;
|
|
2188
|
-
}
|
|
2189
|
-
const searchRoots = [];
|
|
2190
|
-
let current = resolvedRoot;
|
|
2191
|
-
while (true) {
|
|
2192
|
-
searchRoots.push(current);
|
|
2193
|
-
const parent = _path2.default.dirname(current);
|
|
2194
|
-
if (parent === current) {
|
|
2195
|
-
break;
|
|
2196
|
-
}
|
|
2197
|
-
current = parent;
|
|
2198
|
-
}
|
|
2199
|
-
const tailwindConfigPath = _chunkZAA5ZG3Djs.findTailwindConfig.call(void 0, searchRoots);
|
|
2200
|
-
if (tailwindConfigPath) {
|
|
2201
|
-
return _path2.default.dirname(tailwindConfigPath);
|
|
2202
|
-
}
|
|
2203
|
-
const packageRoot = _chunkZAA5ZG3Djs.findNearestPackageRoot.call(void 0, resolvedRoot);
|
|
2204
|
-
if (packageRoot && _fs.existsSync.call(void 0, _path2.default.join(packageRoot, PACKAGE_JSON_FILE2))) {
|
|
2205
|
-
return packageRoot;
|
|
2206
|
-
}
|
|
2207
|
-
return resolvedRoot;
|
|
2208
|
-
}
|
|
2209
|
-
function UnifiedViteWeappTailwindcssPlugin(options = {}) {
|
|
2210
|
-
const hasExplicitAppType = typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
2211
|
-
const rewriteCssImportsSpecified = Object.hasOwn(options, "rewriteCssImports");
|
|
2212
|
-
const hasExplicitTailwindcssBasedir = typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
2213
|
-
const opts = _chunkHVNGIKLSjs.getCompilerContext.call(void 0, options);
|
|
2214
|
-
const {
|
|
2215
|
-
disabled,
|
|
2216
|
-
customAttributes,
|
|
2217
|
-
onLoad,
|
|
2218
|
-
mainCssChunkMatcher,
|
|
2219
|
-
styleHandler,
|
|
2220
|
-
jsHandler,
|
|
2221
|
-
twPatcher: initialTwPatcher,
|
|
2222
|
-
refreshTailwindcssPatcher,
|
|
2223
|
-
uniAppX,
|
|
2224
|
-
disabledDefaultTemplateHandler
|
|
2225
|
-
} = opts;
|
|
2226
|
-
const uniAppXEnabled = _chunkZAA5ZG3Djs.isUniAppXEnabled.call(void 0, uniAppX);
|
|
2227
|
-
const disabledOptions = _chunk24AGZQVRjs.resolveDisabledOptions.call(void 0, disabled);
|
|
2228
|
-
const tailwindcssMajorVersion = _nullishCoalesce(initialTwPatcher.majorVersion, () => ( 0));
|
|
2229
|
-
const shouldRewriteCssImports = opts.rewriteCssImports !== false && !disabledOptions.rewriteCssImports && (rewriteCssImportsSpecified || tailwindcssMajorVersion >= 4);
|
|
2230
|
-
const rewritePlugins = createRewriteCssImportsPlugins({
|
|
2231
|
-
getAppType: () => opts.appType,
|
|
2232
|
-
shouldRewrite: shouldRewriteCssImports,
|
|
2233
|
-
weappTailwindcssDirPosix
|
|
2234
|
-
});
|
|
2235
|
-
if (disabledOptions.plugin) {
|
|
2236
|
-
return rewritePlugins.length ? rewritePlugins : void 0;
|
|
2237
|
-
}
|
|
2238
|
-
const customAttributesEntities = _chunkHVNGIKLSjs.toCustomAttributesEntities.call(void 0, customAttributes);
|
|
2239
|
-
const patchRecorderState = _chunkHVNGIKLSjs.setupPatchRecorder.call(void 0, initialTwPatcher, opts.tailwindcssBasedir, {
|
|
2240
|
-
source: "runtime",
|
|
2241
|
-
cwd: _nullishCoalesce(opts.tailwindcssBasedir, () => ( _process2.default.cwd()))
|
|
2242
|
-
});
|
|
2243
|
-
const runtimeState = {
|
|
2244
|
-
twPatcher: initialTwPatcher,
|
|
2245
|
-
patchPromise: patchRecorderState.patchPromise,
|
|
2246
|
-
refreshTailwindcssPatcher,
|
|
2247
|
-
onPatchCompleted: patchRecorderState.onPatchCompleted
|
|
2248
|
-
};
|
|
2249
|
-
let runtimeSet;
|
|
2250
|
-
let runtimeSetPromise;
|
|
2251
|
-
let resolvedConfig;
|
|
2252
|
-
let runtimeRefreshSignature;
|
|
2253
|
-
let runtimeRefreshOptionsKey;
|
|
2254
|
-
const bundleRuntimeClassSetManager = createBundleRuntimeClassSetManager();
|
|
2255
|
-
function resolveRuntimeRefreshOptions() {
|
|
2256
|
-
const configPath = _optionalChain([_chunkZAA5ZG3Djs.resolveTailwindcssOptions.call(void 0, runtimeState.twPatcher.options), 'optionalAccess', _65 => _65.config]);
|
|
2257
|
-
const signature = _chunkZAA5ZG3Djs.getRuntimeClassSetSignature.call(void 0, runtimeState.twPatcher);
|
|
2258
|
-
const optionsKey = JSON.stringify({
|
|
2259
|
-
appType: opts.appType,
|
|
2260
|
-
uniAppX: uniAppXEnabled,
|
|
2261
|
-
customAttributesEntities,
|
|
2262
|
-
disabledDefaultTemplateHandler,
|
|
2263
|
-
configPath,
|
|
2264
|
-
rewriteCssImports: shouldRewriteCssImports
|
|
2265
|
-
});
|
|
2266
|
-
const changed = signature !== runtimeRefreshSignature || optionsKey !== runtimeRefreshOptionsKey;
|
|
2267
|
-
runtimeRefreshSignature = signature;
|
|
2268
|
-
runtimeRefreshOptionsKey = optionsKey;
|
|
2269
|
-
return {
|
|
2270
|
-
changed,
|
|
2271
|
-
signature,
|
|
2272
|
-
optionsKey
|
|
2273
|
-
};
|
|
2274
|
-
}
|
|
2275
|
-
async function refreshRuntimeState(force) {
|
|
2276
|
-
const invalidation = resolveRuntimeRefreshOptions();
|
|
2277
|
-
const shouldRefresh = force || invalidation.changed;
|
|
2278
|
-
const refreshed = await _chunkHVNGIKLSjs.refreshTailwindRuntimeState.call(void 0, runtimeState, {
|
|
2279
|
-
force: shouldRefresh,
|
|
2280
|
-
clearCache: force || invalidation.changed
|
|
2281
|
-
});
|
|
2282
|
-
if (invalidation.changed) {
|
|
2283
|
-
debug2("runtime signature changed, refresh triggered. signature: %s", invalidation.signature);
|
|
2284
|
-
}
|
|
2285
|
-
if (refreshed) {
|
|
2286
|
-
runtimeSet = void 0;
|
|
2287
|
-
runtimeSetPromise = void 0;
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
async function ensureRuntimeClassSet(force = false) {
|
|
2291
|
-
const forceRuntimeRefresh = force || _process2.default.env.WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH === "1";
|
|
2292
|
-
await refreshRuntimeState(force);
|
|
2293
|
-
await runtimeState.patchPromise;
|
|
2294
|
-
if (!forceRuntimeRefresh && runtimeSet) {
|
|
2295
|
-
return runtimeSet;
|
|
2296
|
-
}
|
|
2297
|
-
if (forceRuntimeRefresh || !runtimeSetPromise) {
|
|
2298
|
-
const invalidation = resolveRuntimeRefreshOptions();
|
|
2299
|
-
const task2 = _chunkHVNGIKLSjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
|
|
2300
|
-
force: forceRuntimeRefresh || invalidation.changed,
|
|
2301
|
-
skipRefresh: forceRuntimeRefresh,
|
|
2302
|
-
clearCache: forceRuntimeRefresh || invalidation.changed
|
|
2303
|
-
});
|
|
2304
|
-
runtimeSetPromise = task2;
|
|
2305
|
-
}
|
|
2306
|
-
const task = runtimeSetPromise;
|
|
2307
|
-
try {
|
|
2308
|
-
runtimeSet = await task;
|
|
2309
|
-
return runtimeSet;
|
|
2310
|
-
} finally {
|
|
2311
|
-
if (runtimeSetPromise === task) {
|
|
2312
|
-
runtimeSetPromise = void 0;
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
async function ensureBundleRuntimeClassSet(snapshot, forceRefresh = false) {
|
|
2317
|
-
const forceRuntimeRefresh = forceRefresh || _process2.default.env.WEAPP_TW_VITE_FORCE_RUNTIME_REFRESH === "1";
|
|
2318
|
-
const invalidation = resolveRuntimeRefreshOptions();
|
|
2319
|
-
const shouldRefreshPatcher = forceRuntimeRefresh || invalidation.changed;
|
|
2320
|
-
const forceCollectBySource = snapshot.runtimeAffectingChangedByType.html.size > 0 || snapshot.runtimeAffectingChangedByType.js.size > 0;
|
|
2321
|
-
await refreshRuntimeState(shouldRefreshPatcher);
|
|
2322
|
-
await runtimeState.patchPromise;
|
|
2323
|
-
if (shouldRefreshPatcher) {
|
|
2324
|
-
runtimeSet = void 0;
|
|
2325
|
-
runtimeSetPromise = void 0;
|
|
2326
|
-
await bundleRuntimeClassSetManager.reset();
|
|
2327
|
-
}
|
|
2328
|
-
if (runtimeState.twPatcher.majorVersion === 4 && !forceRuntimeRefresh) {
|
|
2329
|
-
try {
|
|
2330
|
-
const nextRuntimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, snapshot);
|
|
2331
|
-
runtimeSet = nextRuntimeSet;
|
|
2332
|
-
return nextRuntimeSet;
|
|
2333
|
-
} catch (error) {
|
|
2334
|
-
debug2("incremental runtime set sync failed, fallback to full collect: %O", error);
|
|
2335
|
-
await bundleRuntimeClassSetManager.reset();
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
if (!forceRuntimeRefresh && !invalidation.changed && !forceCollectBySource && runtimeSet) {
|
|
2339
|
-
return runtimeSet;
|
|
2340
|
-
}
|
|
2341
|
-
const task = _chunkHVNGIKLSjs.collectRuntimeClassSet.call(void 0, runtimeState.twPatcher, {
|
|
2342
|
-
force: forceRuntimeRefresh || invalidation.changed || forceCollectBySource,
|
|
2343
|
-
skipRefresh: forceRuntimeRefresh,
|
|
2344
|
-
clearCache: forceRuntimeRefresh || invalidation.changed
|
|
2345
|
-
});
|
|
2346
|
-
runtimeSetPromise = task;
|
|
2347
|
-
try {
|
|
2348
|
-
runtimeSet = await task;
|
|
2349
|
-
return runtimeSet;
|
|
2350
|
-
} finally {
|
|
2351
|
-
if (runtimeSetPromise === task) {
|
|
2352
|
-
runtimeSetPromise = void 0;
|
|
2353
|
-
}
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
onLoad();
|
|
2357
|
-
const getResolvedConfig = () => resolvedConfig;
|
|
2358
|
-
const utsPlatform = _chunkDYLQ6UOIjs.resolveUniUtsPlatform.call(void 0, );
|
|
2359
|
-
const isIosPlatform = utsPlatform.isAppIos;
|
|
2360
|
-
const uniAppXPlugins = uniAppXEnabled ? createUniAppXPlugins({
|
|
2361
|
-
appType: _nullishCoalesce(opts.appType, () => ( "uni-app-x")),
|
|
2362
|
-
customAttributesEntities,
|
|
2363
|
-
disabledDefaultTemplateHandler,
|
|
2364
|
-
isIosPlatform,
|
|
2365
|
-
mainCssChunkMatcher,
|
|
2366
|
-
runtimeState,
|
|
2367
|
-
styleHandler,
|
|
2368
|
-
jsHandler,
|
|
2369
|
-
ensureRuntimeClassSet,
|
|
2370
|
-
getResolvedConfig,
|
|
2371
|
-
uniAppX
|
|
2372
|
-
}) : void 0;
|
|
2373
|
-
const plugins = [
|
|
2374
|
-
...rewritePlugins,
|
|
2375
|
-
{
|
|
2376
|
-
name: `${_chunkHVNGIKLSjs.vitePluginName}:post`,
|
|
2377
|
-
enforce: "post",
|
|
2378
|
-
async configResolved(config) {
|
|
2379
|
-
resolvedConfig = config;
|
|
2380
|
-
const resolvedRoot = config.root ? _path2.default.resolve(config.root) : void 0;
|
|
2381
|
-
let shouldRefreshRuntime = false;
|
|
2382
|
-
if (!hasExplicitTailwindcssBasedir && resolvedRoot) {
|
|
2383
|
-
const nextTailwindcssBasedir = resolveImplicitTailwindcssBasedirFromViteRoot(resolvedRoot);
|
|
2384
|
-
if (opts.tailwindcssBasedir !== nextTailwindcssBasedir) {
|
|
2385
|
-
const previousBasedir = opts.tailwindcssBasedir;
|
|
2386
|
-
opts.tailwindcssBasedir = nextTailwindcssBasedir;
|
|
2387
|
-
debug2(
|
|
2388
|
-
"align tailwindcss basedir with vite root: %s -> %s",
|
|
2389
|
-
_nullishCoalesce(previousBasedir, () => ( "undefined")),
|
|
2390
|
-
nextTailwindcssBasedir
|
|
2391
|
-
);
|
|
2392
|
-
shouldRefreshRuntime = true;
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
if (!hasExplicitAppType && resolvedRoot) {
|
|
2396
|
-
const nextAppType = resolveImplicitAppTypeFromViteRoot(resolvedRoot);
|
|
2397
|
-
if (nextAppType && opts.appType !== nextAppType) {
|
|
2398
|
-
const previousAppType = opts.appType;
|
|
2399
|
-
opts.appType = nextAppType;
|
|
2400
|
-
_logger.logger.info("\u6839\u636E Vite \u9879\u76EE\u6839\u76EE\u5F55\u81EA\u52A8\u63A8\u65AD appType -> %s", nextAppType);
|
|
2401
|
-
debug2(
|
|
2402
|
-
"align appType with vite root: %s -> %s",
|
|
2403
|
-
_nullishCoalesce(previousAppType, () => ( "undefined")),
|
|
2404
|
-
nextAppType
|
|
2405
|
-
);
|
|
2406
|
-
shouldRefreshRuntime = true;
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
if (shouldRefreshRuntime) {
|
|
2410
|
-
await refreshRuntimeState(true);
|
|
2411
|
-
}
|
|
2412
|
-
if (typeof config.css.postcss === "object" && Array.isArray(config.css.postcss.plugins)) {
|
|
2413
|
-
const postcssPlugins = config.css.postcss.plugins;
|
|
2414
|
-
const idx = postcssPlugins.findIndex((x) => getPostcssPluginName(x) === "postcss-html-transform");
|
|
2415
|
-
if (idx > -1) {
|
|
2416
|
-
postcssPlugins.splice(idx, 1, _htmltransform2.default.call(void 0, ));
|
|
2417
|
-
debug2("remove postcss-html-transform plugin from vite config");
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
},
|
|
2421
|
-
generateBundle: {
|
|
2422
|
-
order: "post",
|
|
2423
|
-
handler: createGenerateBundleHook({
|
|
2424
|
-
opts,
|
|
2425
|
-
runtimeState,
|
|
2426
|
-
ensureRuntimeClassSet,
|
|
2427
|
-
ensureBundleRuntimeClassSet,
|
|
2428
|
-
debug: debug2,
|
|
2429
|
-
getResolvedConfig
|
|
2430
|
-
})
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
];
|
|
2434
|
-
if (uniAppXPlugins) {
|
|
2435
|
-
plugins.push(...uniAppXPlugins);
|
|
2436
|
-
}
|
|
2437
|
-
return plugins;
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
exports.UnifiedViteWeappTailwindcssPlugin = UnifiedViteWeappTailwindcssPlugin;
|