weapp-vite 6.21.0 → 6.23.0

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.
@@ -1,16 +1,16 @@
1
1
  import { n as applyWeappViteHostMeta } from "./pluginHost--CaeyWpA.mjs";
2
2
  import { n as configureLogger, r as logger_default } from "./logger-mt4mSTqV.mjs";
3
- import { C as isNativeTemplateSource, S as ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS, T as MINI_PROGRAM_PLATFORM_ADAPTERS, _ as jsExtensions, a as findJsonEntry, b as templateExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as scriptExtensions, w as isSourceStyleExtension, x as vueExtensions, y as supportedCssLangs } from "./file-Byldwig4.mjs";
3
+ import { C as isNativeTemplateSource, S as ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS, T as MINI_PROGRAM_PLATFORM_ADAPTERS, _ as jsExtensions, a as findJsonEntry, b as templateExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as scriptExtensions, w as isSourceStyleExtension, x as vueExtensions, y as supportedCssLangs } from "./file-Cr034LIZ.mjs";
4
4
  import { createRequire, isBuiltin } from "node:module";
5
5
  import { createDebug } from "obug";
6
6
  import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
7
- import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_BUNDLE_MARKER as REQUEST_GLOBAL_BUNDLE_MARKER$1, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER as REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER$1, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_REACT_EVENT_METHOD_NAME, WEAPP_VITE_EXTERNAL_OUTPUT_DIRECTORY, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX, WEAPP_VITE_LOGICAL_ENTRY_VIRTUAL_PREFIX, WEAPP_VITE_RUNTIME_CONTRACT_VERSION, WEAPP_VITE_RUNTIME_REACTIVITY_VIRTUAL_ID, WEAPP_VITE_RUNTIME_TEMPLATE_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_IDS, WEAPP_VITE_SIDECAR_OWNER_QUERY_MARKER, WEAPP_VITE_SIDECAR_QUERY_MARKER, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX, WEAPP_VITE_SIDECAR_VIRTUAL_PREFIX, WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY, WEAPP_VITE_STATEFUL_HMR_CLIENT_KEY, WEAPP_VITE_STATEFUL_HMR_CONTROL_FILE, WEAPP_VITE_STATEFUL_HMR_CONTROL_KEY, WEAPP_VITE_STATEFUL_HMR_PRELOAD_FILE, WEAPP_VITE_STATEFUL_HMR_UPDATE_FILE, WEVU_APP_SHELL_COMPONENT_BASE, WEVU_APP_SHELL_TAG_NAME, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_GLOBAL_PATH, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
7
+ import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_BUNDLE_MARKER as REQUEST_GLOBAL_BUNDLE_MARKER$1, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER as REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER$1, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_I18N_JS_FILE, WEAPP_I18N_LOCALE_DATA_KEY, WEAPP_I18N_PUBLIC_MODULE_ID, WEAPP_I18N_RUNTIME_MARKER, WEAPP_I18N_VIRTUAL_MODULE_ID, WEAPP_I18N_WXS_FILE, WEAPP_REACT_EVENT_METHOD_NAME, WEAPP_VITE_EXTERNAL_OUTPUT_DIRECTORY, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX, WEAPP_VITE_LOGICAL_ENTRY_VIRTUAL_PREFIX, WEAPP_VITE_RUNTIME_CONTRACT_VERSION, WEAPP_VITE_RUNTIME_REACTIVITY_VIRTUAL_ID, WEAPP_VITE_RUNTIME_TEMPLATE_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_IDS, WEAPP_VITE_SIDECAR_OWNER_QUERY_MARKER, WEAPP_VITE_SIDECAR_QUERY_MARKER, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX, WEAPP_VITE_SIDECAR_VIRTUAL_PREFIX, WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY, WEAPP_VITE_STATEFUL_HMR_CLIENT_KEY, WEAPP_VITE_STATEFUL_HMR_CONTROL_FILE, WEAPP_VITE_STATEFUL_HMR_CONTROL_KEY, WEAPP_VITE_STATEFUL_HMR_PRELOAD_FILE, WEAPP_VITE_STATEFUL_HMR_UPDATE_FILE, WEVU_APP_SHELL_COMPONENT_BASE, WEVU_APP_SHELL_TAG_NAME, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_GLOBAL_PATH, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY } from "@weapp-core/constants";
8
8
  import path, { posix } from "pathe";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import path$1, { normalize, relative, win32 } from "node:path";
11
- import { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, addExtension, defu, escapeStringRegexp, get, getDefaultMiniProgramPlatform, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, isEmptyObject, isObject, normalizeMiniProgramPlatform, removeExtension, removeExtensionDeep, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle } from "@weapp-core/shared";
11
+ import { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, addExtension, defu, escapeStringRegexp, escapeWxmlAttribute, escapeWxmlText, get, getDefaultMiniProgramPlatform, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, isEmptyObject, isObject, normalizeMiniProgramPlatform, removeExtension, removeExtensionDeep, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle } from "@weapp-core/shared";
12
12
  import { fs as fs$1 } from "@weapp-core/shared/fs";
13
- import { BABEL_TS_MODULE_PARSER_OPTIONS, analyzeScript, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parse, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
13
+ import { BABEL_TS_MODULE_PARSER_OPTIONS, analyzeScript as analyzeScript$1, analyzeScripts, collectComponentPropsFromCode, collectRequireTokens, collectScriptSetupImportsFromCode, generate, mayContainPlatformApiIdentifierByText, mayContainStaticRequireLiteral, parse, parseJsLikeWithEngine, platformApiIdentifiers } from "@weapp-vite/ast";
14
14
  import { collectOnPageScrollPerformanceWarnings } from "@weapp-vite/ast/operations/onPageScroll";
15
15
  import { collectSetDataPickKeysFromTemplateCode } from "@weapp-vite/ast/operations/setDataPick";
16
16
  import { BABEL_TS_MODULE_PARSER_OPTIONS as BABEL_TS_MODULE_PARSER_OPTIONS$1, generate as generate$1, getVisitorKeys, parse as parse$3, parseJsLike, traverse } from "@weapp-vite/ast/babel";
@@ -49,6 +49,7 @@ import { objectHash } from "@weapp-core/shared/node";
49
49
  import { wrapPlugin } from "vite-plugin-performance";
50
50
  import { performance as performance$1 } from "node:perf_hooks";
51
51
  import postcss from "postcss";
52
+ import { compileI18nCatalog, generateI18nCatalogModuleSource, generateI18nRuntimeSource, generateI18nWxsSource } from "@weapp-vite/i18n/compiler";
52
53
  import { weappWebPlugin } from "@weapp-vite/web";
53
54
  import { bundleRequire } from "rolldown-require";
54
55
  //#region src/debugger.ts
@@ -7964,6 +7965,47 @@ function resolveNpmStrategyMode(ctx) {
7964
7965
  return resolveNpmStrategy(ctx);
7965
7966
  }
7966
7967
  //#endregion
7968
+ //#region src/runtime/watch/options.ts
7969
+ /**
7970
+ * 解析主 watcher 与 sidecar watcher 共享的轮询配置。
7971
+ */
7972
+ function resolvePollingWatchOptions(configService) {
7973
+ const buildWatch = configService.inlineConfig?.build?.watch;
7974
+ const chokidar = buildWatch && typeof buildWatch === "object" && "chokidar" in buildWatch ? buildWatch.chokidar : void 0;
7975
+ const serverWatch = configService.inlineConfig?.server?.watch;
7976
+ const envUsePolling = process.env.CHOKIDAR_USEPOLLING;
7977
+ const envInterval = process.env.CHOKIDAR_INTERVAL;
7978
+ const envBinaryInterval = process.env.CHOKIDAR_BINARY_INTERVAL;
7979
+ const usePollingCandidate = chokidar?.usePolling ?? serverWatch?.usePolling ?? (envUsePolling === "1" || envUsePolling === "true" ? true : envUsePolling === "0" || envUsePolling === "false" ? false : void 0);
7980
+ const intervalCandidate = chokidar?.interval ?? serverWatch?.interval ?? (envInterval ? Number(envInterval) : void 0);
7981
+ const binaryIntervalCandidate = chokidar?.binaryInterval ?? serverWatch?.binaryInterval ?? (envBinaryInterval ? Number(envBinaryInterval) : void 0);
7982
+ return {
7983
+ usePolling: typeof usePollingCandidate === "boolean" ? usePollingCandidate : void 0,
7984
+ interval: typeof intervalCandidate === "number" && Number.isFinite(intervalCandidate) ? intervalCandidate : void 0,
7985
+ binaryInterval: typeof binaryIntervalCandidate === "number" && Number.isFinite(binaryIntervalCandidate) ? binaryIntervalCandidate : void 0
7986
+ };
7987
+ }
7988
+ function createSidecarWatchOptions(configService, input) {
7989
+ const polling = resolvePollingWatchOptions(configService);
7990
+ return {
7991
+ ...input,
7992
+ ...polling.usePolling !== void 0 ? { usePolling: polling.usePolling } : {},
7993
+ ...typeof polling.interval === "number" ? { interval: polling.interval } : {},
7994
+ ...typeof polling.binaryInterval === "number" ? { binaryInterval: polling.binaryInterval } : {}
7995
+ };
7996
+ }
7997
+ /**
7998
+ * 合并用户配置并排除 Vite 开发服务器不应监听的构建输出目录。
7999
+ */
8000
+ function createViteWatchIgnored(root, outDir, ignored) {
8001
+ const normalizedRoot = normalizeFsResolvedId(root);
8002
+ const normalizedOutDir = normalizeFsResolvedId(path.isAbsolute(outDir) ? outDir : path.resolve(root, outDir));
8003
+ return [...ignored === void 0 ? [] : Array.isArray(ignored) ? ignored : [ignored], (id) => {
8004
+ const normalizedId = normalizeFsResolvedId(path.isAbsolute(id) ? id : path.resolve(normalizedRoot, id));
8005
+ return isPathInside(normalizedOutDir, normalizedId);
8006
+ }];
8007
+ }
8008
+ //#endregion
7967
8009
  //#region src/moduleGraph/logicalEntry.ts
7968
8010
  function createLogicalEntryModuleCode(entry, dependencies) {
7969
8011
  const source = JSON.stringify(entry.sourceId);
@@ -8074,6 +8116,9 @@ function createProviderPlugin(ctx, config, onChange) {
8074
8116
  };
8075
8117
  }
8076
8118
  async function createDevModuleGraphProvider(ctx, buildConfig, onChange) {
8119
+ const configService = ctx.configService;
8120
+ const userWatch = buildConfig.server?.watch;
8121
+ const ignored = configService?.outDir ? createViteWatchIgnored(buildConfig.root ?? configService.cwd, configService.outDir, userWatch?.ignored) : userWatch?.ignored;
8077
8122
  const server = await createServer({
8078
8123
  ...buildConfig,
8079
8124
  appType: "custom",
@@ -8083,7 +8128,11 @@ async function createDevModuleGraphProvider(ctx, buildConfig, onChange) {
8083
8128
  server: {
8084
8129
  ...buildConfig.server ?? {},
8085
8130
  hmr: true,
8086
- middlewareMode: true
8131
+ middlewareMode: true,
8132
+ watch: {
8133
+ ...userWatch ?? {},
8134
+ ...ignored !== void 0 ? { ignored } : {}
8135
+ }
8087
8136
  },
8088
8137
  build: {
8089
8138
  ...buildConfig.build ?? {},
@@ -9221,6 +9270,12 @@ function createRuntimeState() {
9221
9270
  const emptyAutoRoutesSnapshot = createEmptyAutoRoutesSnapshot();
9222
9271
  const emptyAutoRoutesArtifacts = createAutoRoutesArtifacts(emptyAutoRoutesSnapshot);
9223
9272
  return {
9273
+ glassEasel: {
9274
+ detected: false,
9275
+ diagnostics: /* @__PURE__ */ new Map(),
9276
+ warnedDiagnostics: /* @__PURE__ */ new Set(),
9277
+ silent: false
9278
+ },
9224
9279
  autoRoutes: {
9225
9280
  routes: emptyAutoRoutesSnapshot,
9226
9281
  serialized: emptyAutoRoutesArtifacts.serialized,
@@ -9245,7 +9300,10 @@ function createRuntimeState() {
9245
9300
  build: {
9246
9301
  queue: new PQueue({ autoStart: false }),
9247
9302
  npmBuilt: false,
9248
- independent: { outputs: /* @__PURE__ */ new Map() },
9303
+ independent: {
9304
+ outputs: /* @__PURE__ */ new Map(),
9305
+ pendingOutputs: []
9306
+ },
9249
9307
  output: {
9250
9308
  emittedSource: /* @__PURE__ */ new Map(),
9251
9309
  wevuInternalRuntimeFileName: void 0,
@@ -9333,6 +9391,10 @@ function createRuntimeState() {
9333
9391
  //#region src/runtime/resetRuntimeState.ts
9334
9392
  function resetRuntimeStateForFreshBuild(runtimeState) {
9335
9393
  const fresh = createRuntimeState();
9394
+ runtimeState.glassEasel.detected = false;
9395
+ runtimeState.glassEasel.diagnostics.clear();
9396
+ runtimeState.glassEasel.warnedDiagnostics.clear();
9397
+ runtimeState.glassEasel.silent = false;
9336
9398
  const autoRoutes = runtimeState.autoRoutes;
9337
9399
  autoRoutes.routes = fresh.autoRoutes.routes;
9338
9400
  autoRoutes.serialized = fresh.autoRoutes.serialized;
@@ -11988,13 +12050,7 @@ const EVENT_NAMES = {
11988
12050
  onTapCapture: "capture-bind:tap"
11989
12051
  };
11990
12052
  const EVENT_PROP_RE = /^on[A-Z]/;
11991
- const IDENTIFIER_RE = /^[A-Z_$][\w$]*$/i;
11992
- function escapeAttribute(value) {
11993
- return value.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;");
11994
- }
11995
- function escapeText(value) {
11996
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
11997
- }
12053
+ const IDENTIFIER_RE$1 = /^[A-Z_$][\w$]*$/i;
11998
12054
  function normalizeJsxText(value) {
11999
12055
  return value.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).join(" ");
12000
12056
  }
@@ -12043,7 +12099,7 @@ function resolveNativeEvent(name) {
12043
12099
  return `${capture ? "capture-bind" : "bind"}:${toKebabCase$1(eventName)}`;
12044
12100
  }
12045
12101
  function renderBindingExpression(slot, name) {
12046
- return IDENTIFIER_RE.test(name) ? `slots.${slot}.${name}` : `slots.${slot}['${name}']`;
12102
+ return IDENTIFIER_RE$1.test(name) ? `slots.${slot}.${name}` : `slots.${slot}['${name}']`;
12047
12103
  }
12048
12104
  function compileAttributes(element, slot, bindingFields, tagKind) {
12049
12105
  const output = [];
@@ -12065,13 +12121,13 @@ function compileAttributes(element, slot, bindingFields, tagKind) {
12065
12121
  if (name === "style" && t.isObjectExpression(expression)) {
12066
12122
  const style = compileStaticStyle(expression);
12067
12123
  if (style !== void 0) {
12068
- output.push(`style="${escapeAttribute(style)}"`);
12124
+ output.push(`style="${escapeWxmlAttribute(style)}"`);
12069
12125
  continue;
12070
12126
  }
12071
12127
  }
12072
12128
  const staticValue = readStaticPrimitive(expression);
12073
12129
  if (staticValue !== void 0) {
12074
- output.push(`${outputName}="${escapeAttribute(String(staticValue))}"`);
12130
+ output.push(`${outputName}="${escapeWxmlAttribute(String(staticValue))}"`);
12075
12131
  continue;
12076
12132
  }
12077
12133
  bindingFields.add(name);
@@ -12085,13 +12141,13 @@ function isDynamicTextExpression(node) {
12085
12141
  }
12086
12142
  function compileStaticChildren(children, context) {
12087
12143
  return children.map((child) => {
12088
- if (t.isJSXText(child)) return escapeText(normalizeJsxText(child.value));
12144
+ if (t.isJSXText(child)) return escapeWxmlText(normalizeJsxText(child.value));
12089
12145
  if (t.isJSXElement(child)) return compileStaticElement(child, context);
12090
12146
  if (t.isJSXFragment(child)) return compileStaticFragment(child, context);
12091
12147
  if (t.isJSXExpressionContainer(child)) {
12092
12148
  if (t.isJSXEmptyExpression(child.expression)) return "";
12093
12149
  const value = readStaticPrimitive(child.expression);
12094
- if (value !== void 0) return escapeText(String(value));
12150
+ if (value !== void 0) return escapeWxmlText(String(value));
12095
12151
  throw new Error("static template 的容器节点暂不支持动态结构表达式");
12096
12152
  }
12097
12153
  return "";
@@ -12401,36 +12457,6 @@ function createReactPlugin(ctx) {
12401
12457
  }];
12402
12458
  }
12403
12459
  //#endregion
12404
- //#region src/runtime/watch/options.ts
12405
- /**
12406
- * 解析主 watcher 与 sidecar watcher 共享的轮询配置。
12407
- */
12408
- function resolvePollingWatchOptions(configService) {
12409
- const buildWatch = configService.inlineConfig?.build?.watch;
12410
- const chokidar = buildWatch && typeof buildWatch === "object" && "chokidar" in buildWatch ? buildWatch.chokidar : void 0;
12411
- const serverWatch = configService.inlineConfig?.server?.watch;
12412
- const envUsePolling = process.env.CHOKIDAR_USEPOLLING;
12413
- const envInterval = process.env.CHOKIDAR_INTERVAL;
12414
- const envBinaryInterval = process.env.CHOKIDAR_BINARY_INTERVAL;
12415
- const usePollingCandidate = chokidar?.usePolling ?? serverWatch?.usePolling ?? (envUsePolling === "1" || envUsePolling === "true" ? true : envUsePolling === "0" || envUsePolling === "false" ? false : void 0);
12416
- const intervalCandidate = chokidar?.interval ?? serverWatch?.interval ?? (envInterval ? Number(envInterval) : void 0);
12417
- const binaryIntervalCandidate = chokidar?.binaryInterval ?? serverWatch?.binaryInterval ?? (envBinaryInterval ? Number(envBinaryInterval) : void 0);
12418
- return {
12419
- usePolling: typeof usePollingCandidate === "boolean" ? usePollingCandidate : void 0,
12420
- interval: typeof intervalCandidate === "number" && Number.isFinite(intervalCandidate) ? intervalCandidate : void 0,
12421
- binaryInterval: typeof binaryIntervalCandidate === "number" && Number.isFinite(binaryIntervalCandidate) ? binaryIntervalCandidate : void 0
12422
- };
12423
- }
12424
- function createSidecarWatchOptions(configService, input) {
12425
- const polling = resolvePollingWatchOptions(configService);
12426
- return {
12427
- ...input,
12428
- ...polling.usePolling !== void 0 ? { usePolling: polling.usePolling } : {},
12429
- ...typeof polling.interval === "number" ? { interval: polling.interval } : {},
12430
- ...typeof polling.binaryInterval === "number" ? { binaryInterval: polling.binaryInterval } : {}
12431
- };
12432
- }
12433
- //#endregion
12434
12460
  //#region src/runtime/statefulHmr/outputWriter.ts
12435
12461
  /**
12436
12462
  * @description 通过独立的 Vite write 阶段持久化 DevEngine 已生成的文件,不重新解析业务源码。
@@ -13118,7 +13144,7 @@ async function runStatefulHmrDev(ctx, buildOptions, restart, snapshots) {
13118
13144
  port: 0,
13119
13145
  watch: {
13120
13146
  ...buildOptions.server?.watch ?? {},
13121
- ignored: createStatefulHmrWatchIgnored(buildOptions.root ?? configService.cwd, configService.outDir, buildOptions.server?.watch?.ignored)
13147
+ ignored: createViteWatchIgnored(buildOptions.root ?? configService.cwd, configService.outDir, buildOptions.server?.watch?.ignored)
13122
13148
  }
13123
13149
  },
13124
13150
  build: {
@@ -13138,14 +13164,6 @@ async function runStatefulHmrDev(ctx, buildOptions, restart, snapshots) {
13138
13164
  throw error;
13139
13165
  }
13140
13166
  }
13141
- function createStatefulHmrWatchIgnored(root, outDir, ignored) {
13142
- const normalizedRoot = normalizeFsResolvedId(root);
13143
- const normalizedOutDir = normalizeFsResolvedId(path.isAbsolute(outDir) ? outDir : path.resolve(root, outDir));
13144
- return [...ignored === void 0 ? [] : Array.isArray(ignored) ? ignored : [ignored], (id) => {
13145
- const normalizedId = normalizeFsResolvedId(path.isAbsolute(id) ? id : path.resolve(normalizedRoot, id));
13146
- return isPathInside(normalizedOutDir, normalizedId);
13147
- }];
13148
- }
13149
13167
  var StatefulHmrSession = class {
13150
13168
  ctx;
13151
13169
  server;
@@ -14556,6 +14574,8 @@ const SCRIPT_MODULE_IMPORT_RE = /\.(?:wxs|sjs)(?:\.[jt]s)?$/i;
14556
14574
  const COMMENT_IFDEF_RE = /#ifdef\s+(\w+)/;
14557
14575
  const COMMENT_ENDIF_RE = /#endif/;
14558
14576
  const MP_DIRECTIVE_NAME_RE = /^([a-z]+):(if|elif|else|for|for-item|for-index|key)$/;
14577
+ const LEGACY_WEAPP_DIRECTIVE_NAME_RE = /^wx-(if|for)$/;
14578
+ const GLASS_EASEL_ESCAPE_RE = /\\["']/;
14559
14579
  const SUPPORTED_MP_DIRECTIVE_PREFIXES = new Set(getSupportedMiniProgramDirectivePrefixes());
14560
14580
  function toKebabCaseTagName(tagName) {
14561
14581
  return tagName.replace(TAG_NAME_LOWER_TO_UPPER_RE, "$1-$2").replace(TAG_NAME_MULTI_UPPER_RE, "$1-$2").toLowerCase();
@@ -14577,20 +14597,27 @@ function parseWxml(options) {
14577
14597
  const conditionalStack = [];
14578
14598
  const commentTokens = [];
14579
14599
  const inlineWxsTokens = [];
14600
+ const templateTokens = [];
14601
+ const scriptModules = [];
14580
14602
  const scriptModuleTagTokens = [];
14581
14603
  const wxsImportNormalizeTokens = [];
14582
14604
  const removeWxsLangAttrTokens = [];
14583
14605
  const templateImportNormalizeTokens = [];
14584
14606
  const eventTokens = [];
14585
14607
  const directiveTokens = [];
14608
+ const glassEaselFindings = [];
14586
14609
  const tagNameTokens = [];
14587
14610
  const tagStack = [];
14611
+ const loopStack = [];
14612
+ let loopDepth = 0;
14613
+ let currentHasLoopDirective = false;
14588
14614
  const parser = new Parser({
14589
14615
  onopentagname(name) {
14590
14616
  tagStack.push(name);
14591
14617
  currentTagName = name;
14592
14618
  importAttrs = getScriptModuleImportAttrs(currentTagName) ?? getTemplateImportAttrs(currentTagName);
14593
14619
  tagStartIndex = parser.startIndex;
14620
+ currentHasLoopDirective = false;
14594
14621
  if (normalizeComponentTagName && shouldNormalizeTagName(name)) {
14595
14622
  const normalized = toKebabCaseTagName(name);
14596
14623
  if (normalized !== name) tagNameTokens.push({
@@ -14607,6 +14634,36 @@ function parseWxml(options) {
14607
14634
  },
14608
14635
  onattribute(name, value, quote) {
14609
14636
  attrs[name] = value;
14637
+ const legacyDirectiveMatch = LEGACY_WEAPP_DIRECTIVE_NAME_RE.exec(name);
14638
+ if (legacyDirectiveMatch) {
14639
+ const start = parser.startIndex;
14640
+ const end = start + name.length;
14641
+ directiveTokens.push({
14642
+ start,
14643
+ end,
14644
+ value: `${directivePrefix}:${legacyDirectiveMatch[1]}`
14645
+ });
14646
+ glassEaselFindings.push({
14647
+ code: "GE002",
14648
+ severity: "warning",
14649
+ message: `${name} 不受 glass-easel 支持,已安全归一化为 ${directivePrefix}:${legacyDirectiveMatch[1]}。`,
14650
+ start,
14651
+ normalized: true
14652
+ });
14653
+ }
14654
+ if (name === "wx:for" || name === "wx-for" || name === "let:for") currentHasLoopDirective = true;
14655
+ const rawAttribute = source.slice(parser.startIndex, parser.endIndex + 1);
14656
+ if (GLASS_EASEL_ESCAPE_RE.test(rawAttribute)) glassEaselFindings.push({
14657
+ code: "GE004",
14658
+ severity: "error",
14659
+ message: "属性仍使用反斜杠转义引号,请改用 &quot;、&apos; 或调整属性外层引号。",
14660
+ start: parser.startIndex
14661
+ });
14662
+ if (!currentTagName || !isScriptModuleTagName(currentTagName)) templateTokens.push({
14663
+ start: parser.startIndex,
14664
+ end: parser.endIndex + 1,
14665
+ value
14666
+ });
14610
14667
  if (importAttrs && currentTagName) {
14611
14668
  for (const attrName of importAttrs) if (attrName === name) {
14612
14669
  deps.push({
@@ -14666,7 +14723,22 @@ function parseWxml(options) {
14666
14723
  value
14667
14724
  });
14668
14725
  },
14726
+ onopentag(name, attributes) {
14727
+ if (name === "include" && loopDepth > 0) glassEaselFindings.push({
14728
+ code: "GE003",
14729
+ severity: "error",
14730
+ message: "wx:for 作用域内的 <include> 无法向 glass-easel 传递循环变量,请改用 <template>。",
14731
+ start: tagStartIndex
14732
+ });
14733
+ loopStack.push(currentHasLoopDirective);
14734
+ if (currentHasLoopDirective) loopDepth += 1;
14735
+ if (isScriptModuleTagName(name)) scriptModules.push({
14736
+ attrs: attributes,
14737
+ tagName: name
14738
+ });
14739
+ },
14669
14740
  onclosetag(name) {
14741
+ if (loopStack.pop()) loopDepth -= 1;
14670
14742
  currentTagName = tagStack.pop();
14671
14743
  if (currentTagName) {
14672
14744
  const componentName = normalizeComponentTagName && shouldNormalizeTagName(currentTagName) ? toKebabCaseTagName(currentTagName) : currentTagName;
@@ -14713,6 +14785,11 @@ function parseWxml(options) {
14713
14785
  end: parser.endIndex,
14714
14786
  value: data
14715
14787
  });
14788
+ else templateTokens.push({
14789
+ start: parser.startIndex,
14790
+ end: parser.endIndex + 1,
14791
+ value: data
14792
+ });
14716
14793
  },
14717
14794
  oncomment(data) {
14718
14795
  let match = COMMENT_IFDEF_RE.exec(data);
@@ -14747,6 +14824,8 @@ function parseWxml(options) {
14747
14824
  removalRanges,
14748
14825
  commentTokens,
14749
14826
  inlineWxsTokens,
14827
+ scriptModules,
14828
+ templateTokens,
14750
14829
  wxsImportNormalizeTokens,
14751
14830
  removeWxsLangAttrTokens,
14752
14831
  templateImportNormalizeTokens,
@@ -14754,6 +14833,7 @@ function parseWxml(options) {
14754
14833
  eventTokens,
14755
14834
  directiveTokens,
14756
14835
  tagNameTokens,
14836
+ glassEaselFindings,
14757
14837
  code: source
14758
14838
  } };
14759
14839
  }
@@ -15502,6 +15582,7 @@ function createIndependentBuilder(configService, buildState) {
15502
15582
  mode: configService.mode,
15503
15583
  configFile: configService.configFilePath,
15504
15584
  cliPlatform: configService.platform,
15585
+ inlineConfig: { weapp: { platform: configService.platform } },
15505
15586
  projectConfigPath: configService.projectConfigPath
15506
15587
  });
15507
15588
  const isolatedConfigService = isolatedCtx.configService;
@@ -18113,8 +18194,9 @@ function createLoadConfig(options) {
18113
18194
  }
18114
18195
  const loadedConfig = loaded?.config ?? {};
18115
18196
  let weappLoaded;
18197
+ const reuseLoadedWeappConfig = shouldReuseLoadedWeappConfig(weappConfigFilePath, loaded?.path);
18116
18198
  if (weappConfigFilePath) {
18117
- if (shouldReuseLoadedWeappConfig(weappConfigFilePath, loaded?.path)) weappLoaded = loaded;
18199
+ if (reuseLoadedWeappConfig) weappLoaded = loaded;
18118
18200
  else try {
18119
18201
  weappLoaded = await loadConfigFileWithFallback({
18120
18202
  command: isDev ? "serve" : "build",
@@ -18130,7 +18212,7 @@ function createLoadConfig(options) {
18130
18212
  throw error;
18131
18213
  }
18132
18214
  }
18133
- const mergedLoadedConfig = weappLoaded?.config ? defu(weappLoaded.config, loadedConfig) : loadedConfig;
18215
+ const mergedLoadedConfig = weappLoaded?.config ? reuseLoadedWeappConfig ? loadedConfig : defu(weappLoaded.config, loadedConfig) : loadedConfig;
18134
18216
  const config = defu(inlineConfig, {
18135
18217
  mode,
18136
18218
  configFile: false
@@ -18661,6 +18743,28 @@ async function copyEsModuleDirectoryForAlipay(sourceRoot, targetRoot) {
18661
18743
  return true;
18662
18744
  }
18663
18745
  //#endregion
18746
+ //#region src/runtime/npmPlugin/builder/packageFiles.ts
18747
+ function normalizePattern$1(pattern) {
18748
+ return pattern.replaceAll("\\", "/");
18749
+ }
18750
+ function createNpmPackageFileMatcher(config) {
18751
+ const include = config?.include?.length ? picomatch(config.include.map(normalizePattern$1), { dot: true }) : () => true;
18752
+ const exclude = config?.exclude?.length ? picomatch(config.exclude.map(normalizePattern$1), { dot: true }) : () => false;
18753
+ return (relativePath) => {
18754
+ const normalizedPath = normalizePattern$1(relativePath);
18755
+ return include(normalizedPath) && !exclude(normalizedPath);
18756
+ };
18757
+ }
18758
+ function createNpmPackageCopyFilter(sourceRoot, config) {
18759
+ if (!config?.include?.length && !config?.exclude?.length) return;
18760
+ const matches = createNpmPackageFileMatcher(config);
18761
+ return async (sourcePath) => {
18762
+ const relativePath = path.relative(sourceRoot, sourcePath);
18763
+ if (!relativePath) return true;
18764
+ return (await fs$1.stat(sourcePath)).isDirectory() || matches(relativePath);
18765
+ };
18766
+ }
18767
+ //#endregion
18664
18768
  //#region src/runtime/npmPlugin/builder/packageBuilder.ts
18665
18769
  function toPluginArray(plugins) {
18666
18770
  const queue = [];
@@ -18762,9 +18866,12 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
18762
18866
  outDir
18763
18867
  }).options);
18764
18868
  }
18765
- async function copyBuild({ from, to }) {
18869
+ async function copyBuild({ from, to, name }) {
18766
18870
  await fs$1.remove(to);
18767
- await fs$1.copy(from, to, { overwrite: true });
18871
+ await fs$1.copy(from, to, {
18872
+ filter: createNpmPackageCopyFilter(from, ctx.configService?.weappViteConfig?.npm?.packageFiles?.[name]),
18873
+ overwrite: true
18874
+ });
18768
18875
  }
18769
18876
  let buildPackage;
18770
18877
  async function runBuildPackage({ dep, outDir, options, isDependenciesCacheOutdate }) {
@@ -18907,6 +19014,7 @@ function createDependenciesCache(ctx) {
18907
19014
  const configService = requireConfigService(ctx, "读取依赖缓存哈希前必须初始化 configService。");
18908
19015
  return objectHash({
18909
19016
  dependencies: configService.packageJson.dependencies ?? {},
19017
+ packageFiles: configService.weappViteConfig?.npm?.packageFiles ?? {},
18910
19018
  scope: serializeDependencyScope(resolveDependencyScope(root))
18911
19019
  });
18912
19020
  }
@@ -25170,28 +25278,6 @@ function refreshPartialSharedChunkImporters(bundle, state, entryIds) {
25170
25278
  appendSharedChunkImporters(bundle, state, refreshedEntryIds, previousImporters, previousDependencies);
25171
25279
  }
25172
25280
  //#endregion
25173
- //#region src/plugins/core/helpers/independent.ts
25174
- async function flushIndependentBuilds(state) {
25175
- const { subPackageMeta, pendingIndependentBuilds } = state;
25176
- if (subPackageMeta || pendingIndependentBuilds.length === 0) return;
25177
- const outputs = await Promise.all(pendingIndependentBuilds);
25178
- for (const { rollup } of outputs) {
25179
- const bundleOutputs = Array.isArray(rollup?.output) ? rollup.output : [];
25180
- for (const output of bundleOutputs) if (output.type === "chunk") this.emitFile({
25181
- type: "asset",
25182
- source: output.code,
25183
- fileName: output.fileName,
25184
- name: output.name
25185
- });
25186
- else this.emitFile({
25187
- type: "asset",
25188
- source: output.source,
25189
- fileName: output.fileName
25190
- });
25191
- }
25192
- state.pendingIndependentBuilds = [];
25193
- }
25194
- //#endregion
25195
25281
  //#region src/runtime/config/internal/injectRequestGlobals.ts
25196
25282
  const FULL_REQUEST_GLOBAL_TARGETS = [
25197
25283
  "fetch",
@@ -25426,18 +25512,6 @@ function createRequestGlobalsPassiveBindingsCode(targets, explicitBindingTargets
25426
25512
  if (target === "performance") return `var performance = ${REQUEST_GLOBAL_EXPOSE_HELPER}("performance",${actualRef}&&typeof ${actualRef}.now==="function"&&${actualRef}?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${actualRef}:globalThis.performance&&typeof globalThis.performance.now==="function"&&globalThis.performance?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.performance:__weappViteRequestGlobalsLazyObject("performance",["now"]))`;
25427
25513
  if (target === "crypto") return `var crypto = ${REQUEST_GLOBAL_EXPOSE_HELPER}("crypto",${actualRef}&&typeof ${actualRef}.getRandomValues==="function"&&${actualRef}?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${actualRef}:globalThis.crypto&&typeof globalThis.crypto.getRandomValues==="function"&&globalThis.crypto?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.crypto:__weappViteRequestGlobalsLazyObject("crypto",["getRandomValues"]))`;
25428
25514
  if (target === "URL") return `var URL = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URL",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["123","fake://abc"],"fake://abc/123")?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URL,["123","fake://abc"],"fake://abc/123")?globalThis.URL:${placeholderFactory})`;
25429
- if (target === "URLSearchParams") return `var URLSearchParams = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URLSearchParams",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["client=graphql-request"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URLSearchParams,["client=graphql-request"])?globalThis.URLSearchParams:${placeholderFactory})`;
25430
- if (target === "Blob") return `var Blob = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Blob",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Blob,[])?globalThis.Blob:${placeholderFactory})`;
25431
- if (target === "File") return `var File = ${REQUEST_GLOBAL_EXPOSE_HELPER}("File",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[[],"request-globals.bin"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.File,[[],"request-globals.bin"])?globalThis.File:${placeholderFactory})`;
25432
- if (target === "FormData") return `var FormData = ${REQUEST_GLOBAL_EXPOSE_HELPER}("FormData",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.FormData,[])?globalThis.FormData:${placeholderFactory})`;
25433
- if (target === "Headers") return `var Headers = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Headers",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Headers,[])?globalThis.Headers:${placeholderFactory})`;
25434
- if (target === "Request") return `var Request = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Request",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["https://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Request,["https://request-globals.invalid"])?globalThis.Request:${placeholderFactory})`;
25435
- if (target === "Response") return `var Response = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Response",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[null])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Response,[null])?globalThis.Response:${placeholderFactory})`;
25436
- if (target === "TextEncoder") return `var TextEncoder = ${REQUEST_GLOBAL_EXPOSE_HELPER}("TextEncoder",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.TextEncoder,[])?globalThis.TextEncoder:${placeholderFactory})`;
25437
- if (target === "TextDecoder") return `var TextDecoder = ${REQUEST_GLOBAL_EXPOSE_HELPER}("TextDecoder",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.TextDecoder,[])?globalThis.TextDecoder:${placeholderFactory})`;
25438
- if (target === "XMLHttpRequest") return `var XMLHttpRequest = ${REQUEST_GLOBAL_EXPOSE_HELPER}("XMLHttpRequest",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.XMLHttpRequest,[])?globalThis.XMLHttpRequest:${placeholderFactory})`;
25439
- if (target === "WebSocket") return `var WebSocket = ${REQUEST_GLOBAL_EXPOSE_HELPER}("WebSocket",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["wss://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.WebSocket,["wss://request-globals.invalid"])?globalThis.WebSocket:${placeholderFactory})`;
25440
- if (target === "AbortController") return `var AbortController = ${REQUEST_GLOBAL_EXPOSE_HELPER}("AbortController",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.AbortController,[])?globalThis.AbortController:${placeholderFactory})`;
25441
25515
  return `var ${target} = ${REQUEST_GLOBAL_EXPOSE_HELPER}(${JSON.stringify(target)},typeof ${actualRef}==="function"&&${actualRef}?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${actualRef}:typeof globalThis.${target}==="function"&&globalThis.${target}?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.${target}:${placeholderFactory})`;
25442
25516
  }).join(";")};`;
25443
25517
  }
@@ -25945,9 +26019,6 @@ function relativeToRoot(pathname, root) {
25945
26019
  if (pathname === root) return "";
25946
26020
  if (pathname.startsWith(`${root}/`)) return pathname.slice(root.length + 1);
25947
26021
  }
25948
- function isMainAppStyleFile(fileName) {
25949
- return !fileName.includes("/") && path.posix.basename(fileName, path.posix.extname(fileName)) === "app";
25950
- }
25951
26022
  function getStyleMatcher(entry) {
25952
26023
  const cached = styleMatcherCache.get(entry);
25953
26024
  if (cached) return cached;
@@ -25975,7 +26046,6 @@ function findSharedStylesForModule(modulePath, fileName, sharedStyles) {
25975
26046
  for (const [root, entries] of sharedStyles.entries()) {
25976
26047
  const normalizedRoot = normalizeRoot(root);
25977
26048
  if (root && !normalizedRoot) continue;
25978
- if (!normalizedRoot && isMainAppStyleFile(sanitizedFile)) continue;
25979
26049
  if (!isWithinRoot(sanitizedFile, normalizedRoot)) continue;
25980
26050
  const relativeModule = relativeToRoot(sanitizedModule, normalizedRoot);
25981
26051
  const relativeFile = relativeToRoot(sanitizedFile, normalizedRoot);
@@ -26441,6 +26511,457 @@ function css(ctx) {
26441
26511
  }];
26442
26512
  }
26443
26513
  //#endregion
26514
+ //#region src/analyze/glassEasel/index.ts
26515
+ const MIGRATION_GUIDE = "https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/glass-easel/migration.html";
26516
+ const TEMPLATE_FILE_RE = /\.(?:wxml|axml|swan|ttml|jxml|qml|ksml|xhsml)$/i;
26517
+ function isRecord(value) {
26518
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26519
+ }
26520
+ function getOutputSource(output) {
26521
+ if (output.type === "chunk") return output.code;
26522
+ if (typeof output.source === "string") return output.source;
26523
+ return Buffer.from(output.source).toString("utf8");
26524
+ }
26525
+ function offsetToLocation(source, offset) {
26526
+ const lines = source.slice(0, offset).split(/\r?\n/);
26527
+ return {
26528
+ line: lines.length,
26529
+ column: (lines[lines.length - 1]?.length ?? 0) + 1
26530
+ };
26531
+ }
26532
+ function diagnosticKey(diagnostic) {
26533
+ return [
26534
+ diagnostic.code,
26535
+ diagnostic.file,
26536
+ diagnostic.line ?? 0,
26537
+ diagnostic.column ?? 0,
26538
+ diagnostic.message
26539
+ ].join(":");
26540
+ }
26541
+ function registerDiagnostic(ctx, diagnostic) {
26542
+ const key = diagnosticKey(diagnostic);
26543
+ ctx.runtimeState.glassEasel.diagnostics.set(key, diagnostic);
26544
+ if (ctx.runtimeState.glassEasel.silent || ctx.runtimeState.glassEasel.warnedDiagnostics.has(key)) return;
26545
+ ctx.runtimeState.glassEasel.warnedDiagnostics.add(key);
26546
+ logger_default.warn(`[${diagnostic.code}] ${diagnostic.file}${diagnostic.line ? `:${diagnostic.line}:${diagnostic.column}` : ""} ${diagnostic.message}`);
26547
+ }
26548
+ function analyzeJsonConfig(file, source) {
26549
+ let config;
26550
+ try {
26551
+ config = JSON.parse(source);
26552
+ } catch {
26553
+ return {
26554
+ detected: false,
26555
+ diagnostics: []
26556
+ };
26557
+ }
26558
+ if (!isRecord(config)) return {
26559
+ detected: false,
26560
+ diagnostics: []
26561
+ };
26562
+ if (!(file === "app.json" || file.endsWith("/app.json") || file === "plugin.json" || file.endsWith("/plugin.json") || config.component !== true) || config.glassEaselWebview !== true) return {
26563
+ detected: false,
26564
+ diagnostics: []
26565
+ };
26566
+ if (config.componentFramework === "glass-easel") return {
26567
+ detected: true,
26568
+ diagnostics: []
26569
+ };
26570
+ return {
26571
+ detected: true,
26572
+ diagnostics: [{
26573
+ code: "GE001",
26574
+ severity: "error",
26575
+ file,
26576
+ message: "WebView glass-easel 需成对配置 componentFramework: \"glass-easel\" 与 glassEaselWebview: true。"
26577
+ }]
26578
+ };
26579
+ }
26580
+ function getMemberPropertyName(node) {
26581
+ if (!node || node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") return;
26582
+ if (!node.computed && node.property?.type === "Identifier") return node.property.name;
26583
+ if (node.property?.type === "StringLiteral") return node.property.value;
26584
+ }
26585
+ function isWxCreateSelectorQueryCall(node) {
26586
+ if (!node || node.type !== "CallExpression") return false;
26587
+ const callee = node.callee;
26588
+ return getMemberPropertyName(callee) === "createSelectorQuery" && callee.object?.type === "Identifier" && callee.object.name === "wx";
26589
+ }
26590
+ function analyzeScript(file, source) {
26591
+ const diagnostics = [];
26592
+ try {
26593
+ const ast = parseJsLike(source);
26594
+ traverse(ast, { CallExpression(callPath) {
26595
+ const node = callPath.node;
26596
+ const method = getMemberPropertyName(node.callee);
26597
+ if (method === "select" || method === "selectAll") {
26598
+ const selector = node.arguments?.[0];
26599
+ if (selector?.type === "StringLiteral" && /(?:^|[\s>+~,])[.#]\d/.test(selector.value)) diagnostics.push({
26600
+ code: "GE005",
26601
+ severity: "error",
26602
+ file,
26603
+ line: selector.loc?.start.line,
26604
+ column: selector.loc ? selector.loc.start.column + 1 : void 0,
26605
+ message: `SelectorQuery 选择器 ${JSON.stringify(selector.value)} 含数字开头的 id 或 class。`
26606
+ });
26607
+ }
26608
+ if (method === "in" && isWxCreateSelectorQueryCall(node.callee.object) && node.arguments?.[0]?.type === "ThisExpression") diagnostics.push({
26609
+ code: "GE006",
26610
+ severity: "warning",
26611
+ file,
26612
+ line: node.loc?.start.line,
26613
+ column: node.loc ? node.loc.start.column + 1 : void 0,
26614
+ message: "可将 wx.createSelectorQuery().in(this) 改为 this.createSelectorQuery(),减少兼容层开销。"
26615
+ });
26616
+ } });
26617
+ } catch {}
26618
+ return diagnostics;
26619
+ }
26620
+ function analyzeGlassEaselBundle(ctx, bundle) {
26621
+ const entries = Object.entries(bundle);
26622
+ const localDiagnostics = [];
26623
+ let detected = ctx.runtimeState.glassEasel.detected;
26624
+ for (const [bundleFileName, output] of entries) {
26625
+ const file = output.fileName || bundleFileName;
26626
+ if (!file.endsWith(".json")) continue;
26627
+ const result = analyzeJsonConfig(file, getOutputSource(output));
26628
+ detected ||= result.detected;
26629
+ localDiagnostics.push(...result.diagnostics);
26630
+ }
26631
+ ctx.runtimeState.glassEasel.detected = detected;
26632
+ if (!detected) return;
26633
+ for (const [sourceFile, token] of ctx.runtimeState.wxml.tokenMap) for (const finding of token.glassEaselFindings ?? []) {
26634
+ if (finding.code !== "GE002") continue;
26635
+ localDiagnostics.push({
26636
+ code: finding.code,
26637
+ severity: finding.severity,
26638
+ message: finding.message,
26639
+ file: ctx.configService.relativeAbsoluteSrcRoot(sourceFile),
26640
+ ...offsetToLocation(token.code, finding.start),
26641
+ normalized: finding.normalized
26642
+ });
26643
+ }
26644
+ for (const [bundleFileName, output] of entries) {
26645
+ const file = output.fileName || bundleFileName;
26646
+ const source = getOutputSource(output);
26647
+ if (TEMPLATE_FILE_RE.test(file)) {
26648
+ const token = scanWxml(source, { platform: ctx.configService.platform });
26649
+ for (const finding of token.glassEaselFindings ?? []) localDiagnostics.push({
26650
+ code: finding.code,
26651
+ severity: finding.severity,
26652
+ message: finding.message,
26653
+ file,
26654
+ ...offsetToLocation(source, finding.start),
26655
+ normalized: finding.normalized
26656
+ });
26657
+ } else if (output.type === "chunk") localDiagnostics.push(...analyzeScript(file, source));
26658
+ }
26659
+ for (const diagnostic of localDiagnostics) registerDiagnostic(ctx, diagnostic);
26660
+ }
26661
+ function createGlassEaselAnalyzeResult(ctx) {
26662
+ const diagnostics = Array.from(ctx.runtimeState.glassEasel.diagnostics.values()).sort((left, right) => left.file.localeCompare(right.file) || (left.line ?? 0) - (right.line ?? 0) || left.code.localeCompare(right.code));
26663
+ return {
26664
+ detected: ctx.runtimeState.glassEasel.detected,
26665
+ minimumBaseLibrary: "3.8.12",
26666
+ migrationGuide: MIGRATION_GUIDE,
26667
+ diagnostics,
26668
+ summary: {
26669
+ errors: diagnostics.filter((item) => item.severity === "error").length,
26670
+ warnings: diagnostics.filter((item) => item.severity === "warning").length
26671
+ }
26672
+ };
26673
+ }
26674
+ //#endregion
26675
+ //#region src/i18n/config.ts
26676
+ const IDENTIFIER_RE = /^[A-Z_$][\w$]*$/i;
26677
+ function normalizeName(value, fallback, field) {
26678
+ const resolved = value?.trim() || fallback;
26679
+ if (!IDENTIFIER_RE.test(resolved)) throw new Error(`weapp.i18n.${field} 必须是合法标识符,当前值为 \`${resolved}\`。`);
26680
+ return resolved;
26681
+ }
26682
+ function resolveWeappI18nConfig(config) {
26683
+ if (!config || typeof config !== "object") throw new Error("weapp.i18n 必须是配置对象。");
26684
+ const defaultLocale = config.defaultLocale?.trim();
26685
+ if (!defaultLocale) throw new Error("weapp.i18n.defaultLocale 为必填项。");
26686
+ const include = (Array.isArray(config.include) ? config.include : [config.include ?? "**/i18n/*.json"]).map((item) => item.trim()).filter(Boolean);
26687
+ if (!include.length) throw new Error("weapp.i18n.include 至少需要一个有效 glob。");
26688
+ return {
26689
+ defaultLocale,
26690
+ fallbackLocale: config.fallbackLocale?.trim() || defaultLocale,
26691
+ include,
26692
+ functionName: normalizeName(config.functionName, "t", "functionName"),
26693
+ moduleName: normalizeName(config.moduleName, "i18n", "moduleName")
26694
+ };
26695
+ }
26696
+ //#endregion
26697
+ //#region src/i18n/template.ts
26698
+ function resolveAssetSource(fileName, assetFileName) {
26699
+ const relative = path.posix.relative(path.posix.dirname(fileName), assetFileName);
26700
+ return relative.startsWith(".") ? relative : `./${relative}`;
26701
+ }
26702
+ function collectCallReplacements(expression, expressionOffset, options) {
26703
+ let ast;
26704
+ try {
26705
+ ast = parse$3(`(${expression})`, { sourceType: "module" });
26706
+ } catch {
26707
+ return [];
26708
+ }
26709
+ const calls = [];
26710
+ traverse(ast, { CallExpression(callPath) {
26711
+ const node = callPath.node;
26712
+ if (node.callee.type !== "Identifier" || node.callee.name !== options.functionName) return;
26713
+ const start = (node.start ?? 1) - 1;
26714
+ const end = (node.end ?? 1) - 1;
26715
+ calls.push({
26716
+ end,
26717
+ start
26718
+ });
26719
+ } });
26720
+ if (!calls.length) return [];
26721
+ const renderSegment = (start, end) => {
26722
+ const nestedCalls = calls.filter((call) => call.start >= start && call.end <= end).filter((call) => {
26723
+ return !calls.some((parent) => parent !== call && parent.start >= start && parent.end <= end && parent.start <= call.start && parent.end >= call.end);
26724
+ }).sort((left, right) => left.start - right.start);
26725
+ let cursor = start;
26726
+ let rendered = "";
26727
+ for (const call of nestedCalls) {
26728
+ rendered += expression.slice(cursor, call.start);
26729
+ const openParen = expression.slice(call.start, call.end).indexOf("(");
26730
+ const argsStart = call.start + openParen + 1;
26731
+ const args = openParen >= 0 ? renderSegment(argsStart, call.end - 1).trim() : "";
26732
+ rendered += `${options.moduleName}.t(${options.localeDataKey}${args ? `, ${args}` : ""})`;
26733
+ cursor = call.end;
26734
+ }
26735
+ return rendered + expression.slice(cursor, end);
26736
+ };
26737
+ return [{
26738
+ start: expressionOffset,
26739
+ end: expressionOffset + expression.length,
26740
+ value: renderSegment(0, expression.length)
26741
+ }];
26742
+ }
26743
+ function collectMustacheRanges(source, start, end) {
26744
+ const ranges = [];
26745
+ for (let cursor = start; cursor < end - 1;) {
26746
+ if (source[cursor] !== "{" || source[cursor + 1] !== "{") {
26747
+ cursor++;
26748
+ continue;
26749
+ }
26750
+ const expressionStart = cursor + 2;
26751
+ let expressionEnd = expressionStart;
26752
+ let braceDepth = 0;
26753
+ let escaped = false;
26754
+ let quote = "";
26755
+ for (; expressionEnd < end - 1; expressionEnd++) {
26756
+ const char = source[expressionEnd];
26757
+ if (quote) {
26758
+ if (escaped) escaped = false;
26759
+ else if (char === "\\") escaped = true;
26760
+ else if (char === quote) quote = "";
26761
+ continue;
26762
+ }
26763
+ if (char === "'" || char === "\"" || char === "`") quote = char;
26764
+ else if (char === "{") braceDepth++;
26765
+ else if (char === "}" && braceDepth > 0) braceDepth--;
26766
+ else if (char === "}" && source[expressionEnd + 1] === "}") {
26767
+ ranges.push({
26768
+ expressionEnd,
26769
+ expressionStart
26770
+ });
26771
+ cursor = expressionEnd + 2;
26772
+ break;
26773
+ }
26774
+ }
26775
+ if (expressionEnd >= end - 1) break;
26776
+ }
26777
+ return ranges;
26778
+ }
26779
+ function transformI18nTemplate(source, options) {
26780
+ const token = scanWxml(source, { platform: "weapp" });
26781
+ const replacements = [];
26782
+ for (const templateToken of token.templateTokens ?? []) for (const range of collectMustacheRanges(source, templateToken.start, templateToken.end)) {
26783
+ const expression = source.slice(range.expressionStart, range.expressionEnd);
26784
+ replacements.push(...collectCallReplacements(expression, range.expressionStart, options));
26785
+ }
26786
+ if (!replacements.length) return source;
26787
+ if (token.scriptModules?.some((scriptModule) => {
26788
+ return scriptModule.attrs.module === options.moduleName;
26789
+ })) throw new Error(`${options.fileName} 已存在 module=\"${options.moduleName}\" 的 WXS 模块,无法注入 i18n。`);
26790
+ const ms = new MagicString(source);
26791
+ for (const replacement of replacements.sort((left, right) => right.start - left.start)) ms.update(replacement.start, replacement.end, replacement.value);
26792
+ const src = resolveAssetSource(options.fileName, options.assetFileName);
26793
+ return `<wxs module="${options.moduleName}" src="${src}"/>\n${ms.toString()}`;
26794
+ }
26795
+ //#endregion
26796
+ //#region src/plugins/i18n.ts
26797
+ const TEMPLATE_MODULE_RE = /\.(?:vue|wxml)(?:\?|$)/;
26798
+ function withPackageRoot(root, fileName) {
26799
+ const normalizedRoot = root.replace(/^\/+|\/+$/g, "");
26800
+ return normalizedRoot ? `${normalizedRoot}/${fileName}` : fileName;
26801
+ }
26802
+ function resolveCurrentPackageRoot(subPackageMeta) {
26803
+ return subPackageMeta?.subPackage.root?.replace(/^\/+|\/+$/g, "") ?? "";
26804
+ }
26805
+ function resolveOutputPackageRoot(ctx, fileName, subPackageMeta) {
26806
+ const currentRoot = resolveCurrentPackageRoot(subPackageMeta);
26807
+ if (currentRoot) return currentRoot;
26808
+ const normalized = toPosixPath(fileName).replace(/^\/+/, "");
26809
+ return [...ctx.scanService.subPackageMap.keys()].map((root) => root.replace(/^\/+|\/+$/g, "")).filter((root) => normalized === root || normalized.startsWith(`${root}/`)).sort((left, right) => right.length - left.length)[0] ?? "";
26810
+ }
26811
+ function resolveEmittedPackageRoots(ctx, subPackageMeta) {
26812
+ const currentRoot = resolveCurrentPackageRoot(subPackageMeta);
26813
+ if (currentRoot) return [currentRoot];
26814
+ return ["", ...[...ctx.scanService.subPackageMap.keys()].filter((root) => !ctx.scanService.independentSubPackageMap.has(root))];
26815
+ }
26816
+ async function loadI18nCatalog(ctx, config) {
26817
+ const root = ctx.configService.absoluteSrcRoot;
26818
+ const matcher = picomatch(config.include, { dot: false });
26819
+ const files = (await new fdir({
26820
+ includeDirs: false,
26821
+ pathSeparator: "/"
26822
+ }).withFullPaths().crawl(root).withPromise()).filter((file) => matcher(toPosixPath(path.relative(root, file)))).sort();
26823
+ if (!files.length) throw new Error(`weapp.i18n 未找到 locale 文件,include: ${config.include.join(", ")}。`);
26824
+ const inputs = [];
26825
+ for (const filePath of files) {
26826
+ let messages;
26827
+ try {
26828
+ messages = JSON.parse(await fs$1.readFile(filePath, "utf8"));
26829
+ } catch (error) {
26830
+ throw new Error(`无法解析 i18n 文件 \`${ctx.configService.relativeCwd(filePath)}\`:${String(error)}`);
26831
+ }
26832
+ inputs.push({
26833
+ filePath: ctx.configService.relativeCwd(filePath),
26834
+ locale: path.basename(filePath, path.extname(filePath)),
26835
+ messages
26836
+ });
26837
+ }
26838
+ return {
26839
+ catalog: compileI18nCatalog(inputs, config),
26840
+ files
26841
+ };
26842
+ }
26843
+ function matchesI18nLocaleFile(ctx, config, filePath) {
26844
+ const relativePath = toPosixPath(path.relative(ctx.configService.absoluteSrcRoot, filePath));
26845
+ return !relativePath.startsWith("../") && picomatch(config.include, { dot: false })(relativePath);
26846
+ }
26847
+ function transformI18nOutputTemplate(ctx, fileName, source, subPackageMeta) {
26848
+ const rawConfig = ctx.configService.weappViteConfig?.i18n;
26849
+ if (!rawConfig || ctx.configService.platform !== "weapp") return source;
26850
+ const config = resolveWeappI18nConfig(rawConfig);
26851
+ return transformI18nTemplate(source, {
26852
+ assetFileName: withPackageRoot(resolveOutputPackageRoot(ctx, fileName, subPackageMeta), WEAPP_I18N_WXS_FILE),
26853
+ fileName,
26854
+ functionName: config.functionName,
26855
+ localeDataKey: WEAPP_I18N_LOCALE_DATA_KEY,
26856
+ moduleName: config.moduleName
26857
+ });
26858
+ }
26859
+ function i18n(ctx, subPackageMeta) {
26860
+ const state = { files: [] };
26861
+ const resolvedId = `\0${WEAPP_I18N_VIRTUAL_MODULE_ID}:${resolveCurrentPackageRoot(subPackageMeta) || "main"}`;
26862
+ async function refreshCatalog(pluginContext) {
26863
+ if (!state.config) return;
26864
+ const loaded = await loadI18nCatalog(ctx, state.config);
26865
+ state.catalog = loaded.catalog;
26866
+ state.files = loaded.files;
26867
+ for (const file of state.files) pluginContext?.addWatchFile?.(file);
26868
+ }
26869
+ return [{
26870
+ name: "weapp-vite:i18n",
26871
+ enforce: "pre",
26872
+ async buildStart() {
26873
+ const rawConfig = ctx.configService.weappViteConfig?.i18n;
26874
+ if (!rawConfig) return;
26875
+ if (ctx.configService.platform !== "weapp") throw new Error("weapp.i18n v1 仅支持 platform = \"weapp\"。");
26876
+ state.config = resolveWeappI18nConfig(rawConfig);
26877
+ await refreshCatalog(this);
26878
+ this.emitFile({
26879
+ type: "chunk",
26880
+ id: WEAPP_I18N_PUBLIC_MODULE_ID,
26881
+ fileName: withPackageRoot(resolveCurrentPackageRoot(subPackageMeta), WEAPP_I18N_JS_FILE),
26882
+ preserveSignature: "exports-only"
26883
+ });
26884
+ },
26885
+ watchChange(id) {
26886
+ if (state.config && matchesI18nLocaleFile(ctx, state.config, id)) state.catalog = void 0;
26887
+ },
26888
+ async handleHotUpdate(hotContext) {
26889
+ if (!state.config || !matchesI18nLocaleFile(ctx, state.config, hotContext.file)) return;
26890
+ await refreshCatalog();
26891
+ const affectedModules = [];
26892
+ const runtimeModule = hotContext.server.moduleGraph.getModuleById(resolvedId);
26893
+ if (runtimeModule) {
26894
+ hotContext.server.moduleGraph.invalidateModule(runtimeModule);
26895
+ affectedModules.push(runtimeModule);
26896
+ }
26897
+ for (const module of hotContext.server.moduleGraph.idToModuleMap.values()) if (module.id && TEMPLATE_MODULE_RE.test(module.id)) {
26898
+ hotContext.server.moduleGraph.invalidateModule(module);
26899
+ affectedModules.push(module);
26900
+ }
26901
+ return affectedModules;
26902
+ },
26903
+ resolveId(id) {
26904
+ if (id === WEAPP_I18N_PUBLIC_MODULE_ID && ctx.configService.weappViteConfig?.i18n) return resolvedId;
26905
+ },
26906
+ load(id) {
26907
+ if (id !== resolvedId) return;
26908
+ if (!state.catalog) throw new Error("i18n runtime 在 locale catalog 初始化前被加载。");
26909
+ return generateI18nRuntimeSource(state.catalog);
26910
+ },
26911
+ generateBundle() {
26912
+ if (!state.catalog) return;
26913
+ const wxsSource = generateI18nWxsSource(state.catalog);
26914
+ const catalogSource = generateI18nCatalogModuleSource(state.catalog);
26915
+ const currentRoot = resolveCurrentPackageRoot(subPackageMeta);
26916
+ for (const root of resolveEmittedPackageRoots(ctx, subPackageMeta)) {
26917
+ this.emitFile({
26918
+ type: "asset",
26919
+ fileName: withPackageRoot(root, WEAPP_I18N_WXS_FILE),
26920
+ source: wxsSource
26921
+ });
26922
+ if (root !== currentRoot) this.emitFile({
26923
+ type: "asset",
26924
+ fileName: withPackageRoot(root, WEAPP_I18N_JS_FILE),
26925
+ source: `${catalogSource}// ${WEAPP_I18N_RUNTIME_MARKER}\n`
26926
+ });
26927
+ }
26928
+ }
26929
+ }];
26930
+ }
26931
+ //#endregion
26932
+ //#region src/plugins/outputFinalizer/independent.ts
26933
+ function toEmittedAsset(output) {
26934
+ if (output.type === "chunk") return {
26935
+ type: "asset",
26936
+ fileName: output.fileName,
26937
+ name: output.name,
26938
+ source: output.code
26939
+ };
26940
+ const name = output.names[0] ?? output.name;
26941
+ const originalFileName = output.originalFileNames[0] ?? output.originalFileName;
26942
+ return {
26943
+ type: "asset",
26944
+ fileName: output.fileName,
26945
+ source: output.source,
26946
+ ...name ? { name } : {},
26947
+ ...originalFileName ? { originalFileName } : {},
26948
+ needsCodeReference: output.needsCodeReference
26949
+ };
26950
+ }
26951
+ function getBundleOutputs(output) {
26952
+ return Array.isArray(output.output) ? output.output : [];
26953
+ }
26954
+ async function flushIndependentOutputs(ctx, subPackageMeta, emitAsset) {
26955
+ if (subPackageMeta) return;
26956
+ const independentState = ctx.runtimeState?.build?.independent;
26957
+ if (!independentState) return;
26958
+ const pendingOutputs = independentState.pendingOutputs;
26959
+ if (pendingOutputs.length === 0) return;
26960
+ independentState.pendingOutputs = [];
26961
+ const outputs = await Promise.all(pendingOutputs);
26962
+ for (const output of outputs) for (const bundleOutput of getBundleOutputs(output)) emitAsset(toEmittedAsset(bundleOutput));
26963
+ }
26964
+ //#endregion
26444
26965
  //#region src/plugins/outputFinalizer.ts
26445
26966
  const PREPROCESSOR_STYLE_ASSET_RE = /\.(?:less|sass|scss|styl|stylus|pcss|postcss|sss)$/i;
26446
26967
  const TEMPLATE_ASSET_RE = /\.(?:wxml|axml|swan|ttml|jxml|qml|ksml|xhsml)$/i;
@@ -26462,7 +26983,9 @@ const TEMPLATE_STATIC_REWRITE_MARKERS = [
26462
26983
  ".qml",
26463
26984
  ".ksml",
26464
26985
  ".xhsml",
26465
- "import.meta."
26986
+ "import.meta.",
26987
+ "wx-if",
26988
+ "wx-for"
26466
26989
  ];
26467
26990
  const TEMPLATE_DIRECTIVE_PREFIXES = getSupportedMiniProgramDirectivePrefixes();
26468
26991
  const GRAPH_ONLY_OUTPUT_MARKERS = [WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX];
@@ -26569,22 +27092,23 @@ function normalizePreprocessorStyleAssets(bundle, styleExtension, emitAsset) {
26569
27092
  if (!styleExtension) return;
26570
27093
  normalizePreprocessorStyleAssetEntries(bundle, collectOutputFinalizerAssetEntries(bundle).preprocessorStyleAssets, styleExtension, emitAsset);
26571
27094
  }
26572
- function normalizeTemplateAssetEntries(ctx, entries) {
27095
+ function normalizeTemplateAssetEntries(ctx, entries, subPackageMeta) {
26573
27096
  const { configService } = ctx;
26574
- for (const { output } of entries) {
27097
+ for (const { bundleFileName, output } of entries) {
26575
27098
  const source = output.source;
26576
27099
  const code = typeof source === "string" ? source : source instanceof Uint8Array ? Buffer.from(source).toString("utf8") : void 0;
26577
27100
  if (code === void 0) continue;
26578
- if (!mayNeedTemplateNormalization(code, configService?.platform)) continue;
26579
- const result = handleWxml(scanWxml(code, { platform: configService?.platform }), {
27101
+ let normalized = code;
27102
+ if (mayNeedTemplateNormalization(code, configService?.platform)) normalized = handleWxml(scanWxml(code, { platform: configService?.platform }), {
26580
27103
  scriptModuleExtension: configService?.outputExtensions?.wxs,
26581
27104
  scriptModuleTag: resolveScriptModuleTagName({
26582
27105
  platform: configService?.platform,
26583
27106
  scriptModuleExtension: configService?.outputExtensions?.wxs
26584
27107
  }),
26585
27108
  templateExtension: configService?.outputExtensions?.wxml
26586
- });
26587
- if (result.code !== code) output.source = result.code;
27109
+ }).code;
27110
+ const transformed = transformI18nOutputTemplate(ctx, output.fileName || bundleFileName, normalized, subPackageMeta);
27111
+ if (transformed !== code) output.source = transformed;
26588
27112
  }
26589
27113
  }
26590
27114
  function pruneUneventedDevHmrChunks(ctx, bundle) {
@@ -26615,7 +27139,7 @@ function pruneUnchangedDevHmrOutputs(ctx, bundle, rewriteOptions, options) {
26615
27139
  cache.set(fileName, source);
26616
27140
  }
26617
27141
  }
26618
- function createOutputFinalizerPlugin(ctx) {
27142
+ function createOutputFinalizerPlugin(ctx, subPackageMeta) {
26619
27143
  const wevuRuntimeRewriteOptions = {
26620
27144
  get runtimeFileName() {
26621
27145
  return ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileName;
@@ -26643,17 +27167,19 @@ function createOutputFinalizerPlugin(ctx) {
26643
27167
  enforce: "post",
26644
27168
  generateBundle: {
26645
27169
  order: "post",
26646
- handler(_options, bundle) {
27170
+ async handler(_options, bundle) {
26647
27171
  const outputBundle = bundle;
26648
27172
  rewriteWevuInternalRuntimeImports(bundle, wevuRuntimeRewriteOptions);
26649
27173
  stabilizeWevuRuntimeChunkAccess(bundle);
26650
27174
  restoreNativePageLayoutOutputs(ctx, outputBundle);
26651
27175
  normalizeGraphOnlyAssets(ctx, outputBundle, (asset) => this.emitFile(asset));
26652
27176
  const assetEntries = collectOutputFinalizerAssetEntries(outputBundle);
27177
+ if (ctx.configService.platform === "weapp") analyzeGlassEaselBundle(ctx, outputBundle);
26653
27178
  normalizePreprocessorStyleAssetEntries(outputBundle, assetEntries.preprocessorStyleAssets, ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
26654
- normalizeTemplateAssetEntries(ctx, assetEntries.templateAssets);
27179
+ normalizeTemplateAssetEntries(ctx, assetEntries.templateAssets, subPackageMeta);
26655
27180
  pruneUnchangedDevHmrOutputs(ctx, outputBundle, wevuRuntimeRewriteOptions, { runtimeRewriteDone: true });
26656
27181
  syncOutputChunkSourceMapAssets(outputBundle);
27182
+ await flushIndependentOutputs(ctx, subPackageMeta, (asset) => this.emitFile(asset));
26657
27183
  }
26658
27184
  }
26659
27185
  };
@@ -26934,7 +27460,7 @@ function rememberChunkScriptAnalysis(chunk, analysis, options) {
26934
27460
  function getChunkScriptAnalysis(chunk, options) {
26935
27461
  const cached = options?.cache?.get(chunk);
26936
27462
  if (cached?.code === chunk.code) return cached.analysis;
26937
- const analysis = mayNeedChunkScriptAnalysis(chunk.code) ? analyzeScript(chunk.code, { engine: options?.astEngine }) : {
27463
+ const analysis = mayNeedChunkScriptAnalysis(chunk.code) ? analyzeScript$1(chunk.code, { engine: options?.astEngine }) : {
26938
27464
  hasPlatformApiAccess: false,
26939
27465
  hasStaticRequireLiteral: false
26940
27466
  };
@@ -27890,10 +28416,14 @@ function emitAppPreludeRequireAssets(bundle, appPreludeCode, state, requestGloba
27890
28416
  return output?.type === "chunk" && resolveAppPreludeRequireFileName(output.fileName, state) === fileName;
27891
28417
  });
27892
28418
  const sortedScopeChunks = [...scopeChunks.filter((chunk) => !requestGlobalsPreludeOptions.installerChunks.has(toPosixPath(chunk.fileName))), ...scopeChunks.filter((chunk) => requestGlobalsPreludeOptions.installerChunks.has(toPosixPath(chunk.fileName)))];
27893
- const requestGlobalsPreludeCode = requestGlobalsPreludeOptions.enabled ? sortedScopeChunks.map((chunk) => createRequestGlobalsPreludeAssetCode(fileName, chunk, requestGlobalsPreludeOptions.installerChunks, requestGlobalsPreludeOptions.targets, requestGlobalsPreludeOptions.mode, requestGlobalsPreludeOptions.networkDefaults)).find(Boolean) : void 0;
27894
- if (requestGlobalsPreludeCode) {
27895
- const installerImport = scopeChunks.map((chunk) => resolveRequestGlobalsInstallerImport(chunk, requestGlobalsPreludeOptions.installerChunks)).find(Boolean);
27896
- if (installerImport?.installerChunkFileName) preservedRequestGlobalsInstallerChunks.add(installerImport.installerChunkFileName);
28419
+ let requestGlobalsPreludeCode;
28420
+ if (requestGlobalsPreludeOptions.enabled) for (const chunk of sortedScopeChunks) {
28421
+ const code = createRequestGlobalsPreludeAssetCode(fileName, chunk, requestGlobalsPreludeOptions.installerChunks, requestGlobalsPreludeOptions.targets, requestGlobalsPreludeOptions.mode, requestGlobalsPreludeOptions.networkDefaults);
28422
+ if (!code) continue;
28423
+ requestGlobalsPreludeCode = code;
28424
+ const installerChunkFileName = resolveRequestGlobalsInstallerImport(chunk, requestGlobalsPreludeOptions.installerChunks)?.installerChunkFileName ?? (requestGlobalsPreludeOptions.installerChunks.has(toPosixPath(chunk.fileName)) ? toPosixPath(chunk.fileName) : void 0);
28425
+ if (installerChunkFileName) preservedRequestGlobalsInstallerChunks.add(installerChunkFileName);
28426
+ break;
27897
28427
  }
27898
28428
  const source = [requestGlobalsPreludeCode, appPreludeCode].filter(Boolean).join("\n");
27899
28429
  emitFile?.({
@@ -28156,7 +28686,6 @@ function createGenerateBundleHook(state, isPluginBuild) {
28156
28686
  ctx.moduleGraphService?.bindPluginContext(this);
28157
28687
  const rolldownBundle = bundle;
28158
28688
  const scriptAnalysisCache = /* @__PURE__ */ new WeakMap();
28159
- await flushIndependentBuilds.call(this, state);
28160
28689
  const hasChunkOutput = pruneHmrMetadataOnlyChunks(rolldownBundle, state);
28161
28690
  await emitCurrentStyleSidecarAsset.call(this, state, rolldownBundle);
28162
28691
  const assetOnlyDevHmrBundle = isAssetOnlyDevHmrBundle(hasChunkOutput, state);
@@ -28779,7 +29308,6 @@ function createOptionsHook(state) {
28779
29308
  const { scanService, configService, buildService } = ctx;
28780
29309
  return async function options(options) {
28781
29310
  if (this) ctx.moduleGraphService?.bindPluginContext(this);
28782
- state.pendingIndependentBuilds = [];
28783
29311
  state.hmrRootInputIds ??= /* @__PURE__ */ new Set();
28784
29312
  state.hmrRootInputIds.clear();
28785
29313
  let scannedInput;
@@ -28824,21 +29352,17 @@ function createOptionsHook(state) {
28824
29352
  type: "app"
28825
29353
  }]));
28826
29354
  else {
29355
+ const independentState = ctx.runtimeState.build.independent;
29356
+ independentState.pendingOutputs = [];
28827
29357
  scanService.loadSubPackages();
28828
29358
  const dirtyIndependentRoots = scanService.drainIndependentDirtyRoots();
28829
- const pendingIndependentBuilds = [];
28830
29359
  const previousSubPackageRoot = configService.currentSubPackageRoot;
28831
29360
  for (const root of dirtyIndependentRoots) {
28832
29361
  const meta = scanService.independentSubPackageMap.get(root);
28833
29362
  if (!meta) continue;
28834
- const buildTask = buildService.buildIndependentBundle(root, meta).then((rollup) => {
28835
- return {
28836
- meta,
28837
- rollup
28838
- };
28839
- });
29363
+ const buildTask = buildService.buildIndependentBundle(root, meta);
28840
29364
  buildTask.catch(() => {});
28841
- pendingIndependentBuilds.push(buildTask);
29365
+ independentState.pendingOutputs.push(buildTask);
28842
29366
  try {
28843
29367
  await buildTask;
28844
29368
  } catch {}
@@ -28847,7 +29371,6 @@ function createOptionsHook(state) {
28847
29371
  ...configService.options,
28848
29372
  currentSubPackageRoot: previousSubPackageRoot
28849
29373
  };
28850
- state.pendingIndependentBuilds = pendingIndependentBuilds;
28851
29374
  scannedInput = await collectMainLogicalInputs(state, appEntry);
28852
29375
  }
28853
29376
  }
@@ -29998,7 +30521,6 @@ function weappVite(ctx, subPackageMeta) {
29998
30521
  jsonEmitFilesMap,
29999
30522
  resolvedEntryMap,
30000
30523
  requireAsyncEmittedChunks: /* @__PURE__ */ new Set(),
30001
- pendingIndependentBuilds: [],
30002
30524
  watchFilesSnapshot: [],
30003
30525
  buildTarget,
30004
30526
  hmrState,
@@ -30788,6 +31310,20 @@ function shouldDelegateComponentRegistration(ctx, vuePath, isPage, isApp, config
30788
31310
  function isVueTransformSourceMapEnabled(configService) {
30789
31311
  return Boolean(configService.inlineConfig?.build?.sourcemap);
30790
31312
  }
31313
+ function resolveSfcStylePreprocessOptions(configService) {
31314
+ const options = configService.inlineConfig?.css?.preprocessorOptions;
31315
+ if (!options) return;
31316
+ const root = path.resolve(configService.cwd, configService.inlineConfig?.root ?? ".");
31317
+ const nodeModules = path.resolve(root, "node_modules");
31318
+ return Object.fromEntries(Object.entries(options).map(([language, languageOptions]) => {
31319
+ if (!["sass", "scss"].includes(language)) return [language, languageOptions];
31320
+ const loadPaths = Array.isArray(languageOptions.loadPaths) ? languageOptions.loadPaths.filter((value) => typeof value === "string") : [];
31321
+ return [language, {
31322
+ ...languageOptions,
31323
+ loadPaths: Array.from(/* @__PURE__ */ new Set([...loadPaths, nodeModules]))
31324
+ }];
31325
+ }));
31326
+ }
30791
31327
  function resolveVueTemplatePlatformOptions(options) {
30792
31328
  const supportsWxs = options.wxsEnabled && typeof options.wxsExtension === "string" && options.wxsExtension.length > 0;
30793
31329
  const resolvedWxsExtension = supportsWxs ? options.wxsExtension : void 0;
@@ -30840,6 +31376,8 @@ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, conf
30840
31376
  const objectLiteralBindMode = configService.weappViteConfig?.vue?.template?.objectLiteralBindMode ?? "runtime";
30841
31377
  const mustacheInterpolation = configService.weappViteConfig?.vue?.template?.mustacheInterpolation ?? "compact";
30842
31378
  const functionPropNames = configService.weappViteConfig?.vue?.template?.functionPropNames;
31379
+ const i18nConfig = configService.platform === "weapp" ? configService.weappViteConfig?.i18n : void 0;
31380
+ const templateSafeCallNames = i18nConfig ? [i18nConfig.functionName ?? "t"] : void 0;
30843
31381
  const formatWxmlConfig = configService.weappViteConfig?.vue?.template?.formatWxml ?? "auto";
30844
31382
  const formatWxml = formatWxmlConfig === "auto" ? configService.isDev : formatWxmlConfig;
30845
31383
  const wxsEnabled = configService.weappViteConfig?.wxs !== false;
@@ -30963,10 +31501,12 @@ function buildCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, conf
30963
31501
  objectLiteralBindMode,
30964
31502
  mustacheInterpolation,
30965
31503
  functionPropNames,
31504
+ templateSafeCallNames,
30966
31505
  formatWxml,
30967
31506
  wxsExtension: templatePlatformOptions.wxsExtension,
30968
31507
  classStyleWxsSrc
30969
31508
  },
31509
+ style: { preprocessOptions: resolveSfcStylePreprocessOptions(configService) },
30970
31510
  json: {
30971
31511
  kind: jsonKind,
30972
31512
  defaults: jsonConfig?.defaults,
@@ -31349,9 +31889,17 @@ async function loadTransformStyleBlock(options) {
31349
31889
  if (!block) return null;
31350
31890
  const dependencies = syncVueSfcStyleDependencies(ctx, filename, styles);
31351
31891
  ctx.moduleGraphService.replaceEntryDependencies(filename, "style", dependencies);
31892
+ const compiled = await compileVueStyleToWxss(block, {
31893
+ id: generateScopedId(filename),
31894
+ filename,
31895
+ scoped: block.scoped,
31896
+ modules: block.module,
31897
+ preprocessOptions: resolveSfcStylePreprocessOptions(configService)?.[block.lang || "css"]
31898
+ });
31899
+ for (const dependency of compiled.dependencies ?? []) pluginCtx.addWatchFile?.(dependency);
31352
31900
  return {
31353
- code: block.content,
31354
- map: null
31901
+ code: compiled.code,
31902
+ map: compiled.map ? JSON.parse(compiled.map) : null
31355
31903
  };
31356
31904
  }
31357
31905
  //#endregion
@@ -31505,18 +32053,20 @@ function logTransformFileError(filename, error) {
31505
32053
  function hasCssModules(styleBlocks) {
31506
32054
  return styleBlocks?.some((styleBlock) => Boolean(styleBlock.module)) === true;
31507
32055
  }
31508
- function refreshStyleOnlyVueTransformResult(result, filename, styleBlocks) {
32056
+ async function refreshStyleOnlyVueTransformResult(result, filename, styleBlocks, stylePreprocessOptions) {
31509
32057
  if (!styleBlocks || hasCssModules(styleBlocks)) return false;
31510
32058
  if (!styleBlocks.length) {
31511
32059
  result.style = void 0;
31512
32060
  return true;
31513
32061
  }
31514
32062
  const scopedId = generateScopedId(filename);
31515
- result.style = styleBlocks.map((styleBlock) => compileVueStyleToWxss(styleBlock, {
32063
+ result.style = (await Promise.all(styleBlocks.map(async (styleBlock) => await compileVueStyleToWxss(styleBlock, {
31516
32064
  id: scopedId,
32065
+ filename,
31517
32066
  scoped: styleBlock.scoped,
31518
- modules: styleBlock.module
31519
- }).code.trim()).filter(Boolean).join("\n\n") || void 0;
32067
+ modules: styleBlock.module,
32068
+ preprocessOptions: stylePreprocessOptions?.[styleBlock.lang || "css"]
32069
+ })))).map((result) => result.code.trim()).filter(Boolean).join("\n\n") || void 0;
31520
32070
  return true;
31521
32071
  }
31522
32072
  //#endregion
@@ -31666,7 +32216,7 @@ async function refreshCompiledVueEntryCacheInDev(options) {
31666
32216
  source,
31667
32217
  checkMtime: configService.isDev
31668
32218
  });
31669
- if (!refreshStyleOnlyVueTransformResult(cached.result, filename, descriptor.styles)) cached.styleIndependentSignature = void 0;
32219
+ if (!await refreshStyleOnlyVueTransformResult(cached.result, filename, descriptor.styles, resolveSfcStylePreprocessOptions(configService))) cached.styleIndependentSignature = void 0;
31670
32220
  else {
31671
32221
  cached.source = source;
31672
32222
  cached.styleIndependentSignature = currentStyleIndependentSignature;
@@ -32482,7 +33032,7 @@ async function tryReuseVueCompilation(options) {
32482
33032
  pluginCtx,
32483
33033
  configService
32484
33034
  }));
32485
- if (!refreshStyleOnlyVueTransformResult(cachedResult, filename, refreshedStyleBlocks)) {
33035
+ if (!await refreshStyleOnlyVueTransformResult(cachedResult, filename, refreshedStyleBlocks, resolveSfcStylePreprocessOptions(configService))) {
32486
33036
  cachedCompilation.styleIndependentSignature = void 0;
32487
33037
  canReturnCachedCompilation = false;
32488
33038
  } else {
@@ -32524,7 +33074,7 @@ async function tryReuseVueCompilation(options) {
32524
33074
  pluginCtx,
32525
33075
  configService
32526
33076
  }));
32527
- if (!refreshStyleOnlyVueTransformResult(cachedResult, filename, styleBlocks)) cachedCompilation.styleIndependentSignature = void 0;
33077
+ if (!await refreshStyleOnlyVueTransformResult(cachedResult, filename, styleBlocks, resolveSfcStylePreprocessOptions(configService))) cachedCompilation.styleIndependentSignature = void 0;
32528
33078
  else {
32529
33079
  cachedCompilation.source = source;
32530
33080
  cachedCompilation.result = cachedResult;
@@ -33164,8 +33714,8 @@ function vitePluginWeapp(ctx, subPackageMeta) {
33164
33714
  if (autoRoutesEnabled && !libModeEnabled) groups.push(autoRoutes(ctx));
33165
33715
  groups.push(autoImport(ctx));
33166
33716
  }
33167
- groups.push(weappVite(ctx, subPackageMeta), wxs(ctx), css(ctx));
33168
- groups.push([createOutputFinalizerPlugin(ctx)]);
33717
+ groups.push(i18n(ctx, subPackageMeta), weappVite(ctx, subPackageMeta), wxs(ctx), css(ctx));
33718
+ groups.push([createOutputFinalizerPlugin(ctx, subPackageMeta)]);
33169
33719
  const assembled = attachRuntimePlugins(ctx, flatten(groups));
33170
33720
  if (subPackageMeta) return assembled;
33171
33721
  return applyInspect(ctx, assembled);
@@ -34188,7 +34738,7 @@ async function loadAppEntry(ctx, scanState) {
34188
34738
  const { path: appEntryPath } = appEntry;
34189
34739
  let configFromVue;
34190
34740
  if (!appConfigFile && vueAppPath) {
34191
- const { extractConfigFromVue } = await import("./file-C-jjrMsb.mjs");
34741
+ const { extractConfigFromVue } = await import("./file-DWR7zIBT.mjs");
34192
34742
  configFromVue = await extractConfigFromVue(vueAppPath);
34193
34743
  if (configFromVue) appConfigFile = vueAppPath;
34194
34744
  }
@@ -34460,6 +35010,13 @@ function inferScopeFromRelativePath(relativePath) {
34460
35010
  }
34461
35011
  //#endregion
34462
35012
  //#region src/runtime/scanPlugin/styleEntries/index.ts
35013
+ function hasExplicitIncludePattern(include, normalizedRoot) {
35014
+ return (include === void 0 ? [] : Array.isArray(include) ? include : [include]).some((pattern) => normalizePattern(pattern, normalizedRoot) !== void 0);
35015
+ }
35016
+ function appendExcludePattern(exclude, pattern) {
35017
+ if (exclude === void 0) return [pattern];
35018
+ return Array.isArray(exclude) ? [...exclude, pattern] : [exclude, pattern];
35019
+ }
34463
35020
  function isSupportedSharedStyleExtension(absolutePath) {
34464
35021
  return SUPPORTED_SHARED_STYLE_EXTS.has(path.extname(absolutePath).toLowerCase());
34465
35022
  }
@@ -34502,6 +35059,7 @@ function normalizeStyleEntries(styles, root, configService, options) {
34502
35059
  const posixOutput = toPosixPath(outputRelativePath);
34503
35060
  addStyleEntry({
34504
35061
  ...descriptor,
35062
+ exclude: options.excludeRootAppByDefault && !hasExplicitIncludePattern(descriptor.include, normalizedRoot) ? appendExcludePattern(descriptor.exclude, "app.*") : descriptor.exclude,
34505
35063
  scope: resolveStyleEntryScope(descriptor, posixOutput, normalizedRoot)
34506
35064
  }, absolutePath, posixOutput, normalizedRoot, options.warningPrefix, dedupe, normalized);
34507
35065
  }
@@ -34513,14 +35071,16 @@ function normalizeSubPackageStyleEntries(styles, subPackage, configService) {
34513
35071
  if (!root) return;
34514
35072
  return normalizeStyleEntries(styles, root, configService, {
34515
35073
  warningPrefix: `[分包] 分包 ${root} `,
34516
- appendDefaultEntries: true
35074
+ appendDefaultEntries: true,
35075
+ excludeRootAppByDefault: false
34517
35076
  });
34518
35077
  }
34519
35078
  function normalizeMainPackageStyleEntries(styles, configService) {
34520
35079
  if (styles === void 0) return;
34521
35080
  return normalizeStyleEntries(styles, "", configService, {
34522
35081
  warningPrefix: "[样式] 主包 ",
34523
- appendDefaultEntries: false
35082
+ appendDefaultEntries: false,
35083
+ excludeRootAppByDefault: true
34524
35084
  });
34525
35085
  }
34526
35086
  //#endregion
@@ -34551,9 +35111,11 @@ function loadSubPackages(ctx) {
34551
35111
  const normalizedRoot = subPackage.root ? normalizeRoot(subPackage.root) : void 0;
34552
35112
  const subPackageConfig = normalizedRoot ? configService.weappViteConfig?.subPackages?.[normalizedRoot] : void 0;
34553
35113
  const npmSubPackageConfig = normalizedRoot ? configService.weappViteConfig?.npm?.subPackages?.[normalizedRoot] : void 0;
35114
+ const independent = subPackage.independent ?? subPackageConfig?.independent;
34554
35115
  const resolvedSubPackage = {
34555
35116
  ...subPackage,
34556
35117
  ...normalizedRoot ? { root: normalizedRoot } : {},
35118
+ ...independent === void 0 ? {} : { independent },
34557
35119
  dependencies: npmSubPackageConfig?.dependencies,
34558
35120
  inlineConfig: subPackageConfig?.inlineConfig
34559
35121
  };
@@ -34566,7 +35128,7 @@ function loadSubPackages(ctx) {
34566
35128
  meta.watchSharedStyles = subPackageConfig?.watchSharedStyles ?? true;
34567
35129
  if (normalizedRoot) {
34568
35130
  subPackageMap.set(normalizedRoot, meta);
34569
- if (subPackage.independent) {
35131
+ if (resolvedSubPackage.independent) {
34570
35132
  independentSubPackageMap.set(normalizedRoot, meta);
34571
35133
  if (scanState.isDirty) independentDirtyRoots.add(normalizedRoot);
34572
35134
  }
@@ -35192,4 +35754,4 @@ async function createCompilerContext(options) {
35192
35754
  return ctx;
35193
35755
  }
35194
35756
  //#endregion
35195
- export { shouldPassPlatformArgToIdeOpen as A, findPreloadRuleKey as C, parseCommentJson as D, loadViteConfigFile as E, createCjsConfigLoadError as O, collectPreloadPages as S, suggestPreloadRules as T, resolveHmrProfileJsonPath as _, formatBytes as a, checkRuntime as b, getSupportedWeappViteTargetDescriptors as c, getBackendForCapability as d, resolveBackendExecution as f, SHARED_CHUNK_VIRTUAL_PREFIX as g, createSharedBuildConfig as h, setActiveCompilerContextKey as i, isPathInside as j, getDefaultIdeProjectRoot as k, isWebPlatform as l, syncManagedTsconfigBootstrapFiles as m, getCompilerContext as n, WEB_PLATFORM_ALIASES as o, syncProjectSupportFiles as p, resetCompilerContext as r, getSupportedWeappVitePlatforms as s, createCompilerContext as t, resolveWeappViteTarget as u, getRouteRuntimeGlobalKeys as v, resolvePreloadPackageIdentifier as w, getProjectConfigFileName as x, resolveWeappConfigFile as y };
35757
+ export { getDefaultIdeProjectRoot as A, collectPreloadPages as C, loadViteConfigFile as D, suggestPreloadRules as E, isPathInside as M, parseCommentJson as O, getProjectConfigFileName as S, resolvePreloadPackageIdentifier as T, SHARED_CHUNK_VIRTUAL_PREFIX as _, createGlassEaselAnalyzeResult as a, resolveWeappConfigFile as b, getSupportedWeappVitePlatforms as c, resolveWeappViteTarget as d, getBackendForCapability as f, createSharedBuildConfig as g, syncManagedTsconfigBootstrapFiles as h, setActiveCompilerContextKey as i, shouldPassPlatformArgToIdeOpen as j, createCjsConfigLoadError as k, getSupportedWeappViteTargetDescriptors as l, syncProjectSupportFiles as m, getCompilerContext as n, formatBytes as o, resolveBackendExecution as p, resetCompilerContext as r, WEB_PLATFORM_ALIASES as s, createCompilerContext as t, isWebPlatform as u, resolveHmrProfileJsonPath as v, findPreloadRuleKey as w, checkRuntime as x, getRouteRuntimeGlobalKeys as y };