weapp-vite 6.14.3 → 6.15.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,4 +1,4 @@
1
- import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-BWIKo9nG.mjs";
1
+ import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-DZzBkyLu.mjs";
2
2
  //#region src/auto-routes.ts
3
3
  const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
4
4
  function createGetter(resolver) {
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { S as isPathInside, _ as DEFAULT_MP_PLATFORM, b as resolveMiniPlatform, c as createSharedBuildConfig, d as resolveWeappConfigFile, f as checkRuntime, g as createCjsConfigLoadError, h as parseCommentJson, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as loadViteConfigFile, n as syncProjectSupportFiles, p as getProjectConfigFileName, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as getDefaultIdeProjectRoot, x as shouldPassPlatformArgToIdeOpen, y as normalizeMiniPlatform } from "./createContext-BWIKo9nG.mjs";
1
+ import { S as isPathInside, _ as DEFAULT_MP_PLATFORM, b as resolveMiniPlatform, c as createSharedBuildConfig, d as resolveWeappConfigFile, f as checkRuntime, g as createCjsConfigLoadError, h as parseCommentJson, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as loadViteConfigFile, n as syncProjectSupportFiles, p as getProjectConfigFileName, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as getDefaultIdeProjectRoot, x as shouldPassPlatformArgToIdeOpen, y as normalizeMiniPlatform } from "./createContext-DZzBkyLu.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
3
- import { m as VERSION } from "./file-B1jggPxp.mjs";
3
+ import { m as VERSION } from "./file-DZdM8x0_.mjs";
4
4
  import { a as resolveWeappMcpConfig, o as startWeappViteMcpServer } from "./mcp-DRlj32v4.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import { defu, fs } from "@weapp-core/shared";
@@ -2068,7 +2068,7 @@ function registerPrepareCommand(cli) {
2068
2068
  }
2069
2069
  //#endregion
2070
2070
  //#region package.json
2071
- var version = "6.14.3";
2071
+ var version = "6.15.0";
2072
2072
  //#endregion
2073
2073
  //#region src/cli/devHotkeys.ts
2074
2074
  const DEV_SCREENSHOT_DIR = ".weapp-vite/dev-screenshots";
@@ -260,14 +260,16 @@ interface BuildNpmPackageMeta {
260
260
  name: string;
261
261
  entry: InputOption;
262
262
  }
263
+ type NpmDependencyPattern = string | RegExp;
264
+ type NpmStrategy = 'explicit' | 'legacy';
263
265
  interface NpmSubPackageConfig {
264
- dependencies?: (string | RegExp)[];
266
+ dependencies?: NpmDependencyPattern[];
265
267
  }
266
268
  interface NpmMainPackageConfig {
267
- dependencies?: false | (string | RegExp)[];
269
+ dependencies?: false | NpmDependencyPattern[];
268
270
  }
269
271
  interface NpmPluginPackageConfig {
270
- dependencies?: false | (string | RegExp)[];
272
+ dependencies?: false | NpmDependencyPattern[];
271
273
  }
272
274
  type JsFormat = 'cjs' | 'esm';
273
275
  type SharedChunkStrategy = 'hoist' | 'duplicate';
@@ -422,6 +424,15 @@ interface WeappInjectRequestGlobalsConfig {
422
424
  enabled?: boolean;
423
425
  targets?: WeappInjectRequestGlobalsTarget[];
424
426
  dependencies?: (string | RegExp)[];
427
+ prelude?: boolean;
428
+ }
429
+ type WeappAppPreludeMode = 'inline' | 'entry' | 'require';
430
+ /**
431
+ * @description `app.prelude` 前置注入配置
432
+ */
433
+ interface WeappAppPreludeConfig {
434
+ enabled?: boolean;
435
+ mode?: WeappAppPreludeMode;
425
436
  }
426
437
  /**
427
438
  * @description 本地 npm 构建配置
@@ -429,6 +440,8 @@ interface WeappInjectRequestGlobalsConfig {
429
440
  interface WeappNpmConfig {
430
441
  enable?: boolean;
431
442
  cache?: boolean;
443
+ strategy?: NpmStrategy;
444
+ include?: NpmDependencyPattern[];
432
445
  mainPackage?: NpmMainPackageConfig;
433
446
  pluginPackage?: NpmPluginPackageConfig;
434
447
  subPackages?: Record<string, NpmSubPackageConfig>;
@@ -464,6 +477,7 @@ interface WeappWorkerConfig {
464
477
  interface WeappVueTemplateConfig {
465
478
  removeComments?: boolean;
466
479
  simplifyWhitespace?: boolean;
480
+ htmlTagToWxml?: boolean | Record<string, string>;
467
481
  scopedSlotsCompiler?: 'auto' | 'augmented' | 'off';
468
482
  scopedSlotsRequireProps?: boolean;
469
483
  slotMultipleInstance?: boolean;
@@ -605,6 +619,7 @@ interface WeappViteConfig {
605
619
  vue?: WeappVueConfig;
606
620
  wevu?: WeappWevuConfig;
607
621
  routeRules?: WeappRouteRules;
622
+ appPrelude?: boolean | WeappAppPreludeConfig;
608
623
  injectWeapi?: boolean | WeappInjectWeapiConfig;
609
624
  injectRequestGlobals?: boolean | WeappInjectRequestGlobalsConfig;
610
625
  mcp?: boolean | WeappMcpConfig;
@@ -660,6 +675,7 @@ type Entry = AppEntry | PageEntry | ComponentEntry;
660
675
  */
661
676
  interface AppEntry extends BaseEntry {
662
677
  type: 'app';
678
+ preludePath?: string;
663
679
  themeJsonPath?: string;
664
680
  themeJson?: Theme;
665
681
  sitemapJsonPath?: string;
@@ -1527,4 +1543,4 @@ declare function defineConfig(config: UserConfigFnObjectPlain): UserConfigFnObje
1527
1543
  declare function defineConfig(config: UserConfigFn): UserConfigFn;
1528
1544
  declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
1529
1545
  //#endregion
1530
- export { WeappDebugConfig as $, NpmBuildOptions as $t, Ref as A, createWeappViteHostMeta as An, ChunksConfig as At, BindingErrorLike as B, GenerateTemplateEntry as Bt, LoadConfigOptions as C, WeappManagedSharedTsconfigConfig as Cn, WeappVueTemplateConfig as Ct, MethodDefinitions$1 as D, WeappViteHostMeta as Dn, AliasOptions as Dt, InlineConfig$1 as E, WEAPP_VITE_HOST_NAME as En, Alias as Et, RolldownPlugin as F, GenerateFileType as Ft, EntryJsonFragment as G, GenerateTemplatesConfig as Gt, BaseEntry as H, GenerateTemplateFileSource as Ht, RolldownPluginOption as I, GenerateFilenamesOptions as It, ScanComponentItem as J, JsonMergeContext as Jt, PageEntry as K, JsFormat as Kt, RolldownWatchOptions as L, GenerateOptions as Lt, RolldownBuild as M, resolveWeappViteHostMeta as Mn, CopyOptions as Mt, RolldownOptions as N, GenerateDirsOptions as Nt, Plugin$1 as O, WeappViteRuntime as On, AlipayNpmMode as Ot, RolldownOutput$1 as P, GenerateExtensionsOptions as Pt, UserConfig$2 as Q, MpPlatform as Qt, RolldownWatcher$1 as R, GenerateTemplate as Rt, CompilerContext as S, WeappManagedServerTsconfigConfig as Sn, WeappVueConfig as St, ConfigEnv$1 as T, WeappWebConfig as Tn, WeappWorkerConfig as Tt, ComponentEntry as U, GenerateTemplateInlineSource as Ut, AppEntry as V, GenerateTemplateFactory as Vt, Entry as W, GenerateTemplateScope as Wt, ProjectConfig as X, JsonMergeStage as Xt, WxmlDep as Y, JsonMergeFunction as Yt, SubPackageMetaValue as Z, JsonMergeStrategy as Zt, definePageJson as _, WeappLibFileName as _n, WeappMcpConfig as _t, UserConfigFnNoEnvPlain as a, SharedChunkMode as an, EnhanceOptions as at, ChangeEvent as b, WeappManagedAppTsconfigConfig as bn, WeappRouteRules as bt, UserConfigFnPromise as c, SubPackage as cn, MultiPlatformConfig as ct, Component$1 as d, SubPackageStyleEntry as dn, WeappAutoRoutesInclude as dt, NpmMainPackageConfig as en, WeappForwardConsoleConfig as et, Page$1 as f, SubPackageStyleScope as fn, WeappAutoRoutesIncludePattern as ft, defineComponentJson as g, WeappLibEntryContext as gn, WeappInjectWeapiConfig as gt, defineAppJson as h, WeappLibDtsOptions as hn, WeappInjectRequestGlobalsTarget as ht, UserConfigFnNoEnv as i, SharedChunkDynamicImports as in, AutoImportComponentsOption as it, ResolvedConfig as j, isWeappViteHost as jn, CopyGlobs as jt, PluginOption as k, applyWeappViteHostMeta as kn, BuildNpmPackageMeta as kt, defineConfig as l, SubPackageStyleConfigEntry as ln, ScanWxmlOptions as lt, Theme$1 as m, WeappLibConfig as mn, WeappInjectRequestGlobalsConfig as mt, UserConfigExport as n, NpmSubPackageConfig as nn, WeappViteConfig as nt, UserConfigFnObject as o, SharedChunkOverride as on, EnhanceWxmlOptions as ot, Sitemap$1 as p, WeappLibComponentJson as pn, WeappHmrConfig as pt, ComponentsMap as q, JsonConfig as qt, UserConfigFn as r, ResolvedAlias as rn, AutoImportComponents as rt, UserConfigFnObjectPlain as s, SharedChunkStrategy as sn, HandleWxmlOptions as st, UserConfig$1 as t, NpmPluginPackageConfig as tn, WeappForwardConsoleLogLevel as tt, App$1 as u, SubPackageStyleConfigObject as un, WeappAutoRoutesConfig as ut, defineSitemapJson as v, WeappLibInternalDtsOptions as vn, WeappNpmConfig as vt, ComputedDefinitions$1 as w, WeappManagedTypeScriptConfig as wn, WeappWevuConfig as wt, WeappVitePluginApi as x, WeappManagedNodeTsconfigConfig as xn, WeappSubPackageConfig as xt, defineThemeJson as y, WeappLibVueTscOptions as yn, WeappRouteRule as yt, ViteDevServer$1 as z, GenerateTemplateContext as zt };
1546
+ export { WeappDebugConfig as $, JsonMergeStrategy as $t, Ref as A, WEAPP_VITE_HOST_NAME as An, AlipayNpmMode as At, BindingErrorLike as B, GenerateTemplate as Bt, LoadConfigOptions as C, WeappLibVueTscOptions as Cn, WeappSubPackageConfig as Ct, MethodDefinitions$1 as D, WeappManagedSharedTsconfigConfig as Dn, WeappWorkerConfig as Dt, InlineConfig$1 as E, WeappManagedServerTsconfigConfig as En, WeappWevuConfig as Et, RolldownPlugin as F, isWeappViteHost as Fn, GenerateDirsOptions as Ft, EntryJsonFragment as G, GenerateTemplateInlineSource as Gt, BaseEntry as H, GenerateTemplateEntry as Ht, RolldownPluginOption as I, resolveWeappViteHostMeta as In, GenerateExtensionsOptions as It, ScanComponentItem as J, JsFormat as Jt, PageEntry as K, GenerateTemplateScope as Kt, RolldownWatchOptions as L, GenerateFileType as Lt, RolldownBuild as M, WeappViteRuntime as Mn, ChunksConfig as Mt, RolldownOptions as N, applyWeappViteHostMeta as Nn, CopyGlobs as Nt, Plugin$1 as O, WeappManagedTypeScriptConfig as On, Alias as Ot, RolldownOutput$1 as P, createWeappViteHostMeta as Pn, CopyOptions as Pt, UserConfig$2 as Q, JsonMergeStage as Qt, RolldownWatcher$1 as R, GenerateFilenamesOptions as Rt, CompilerContext as S, WeappLibInternalDtsOptions as Sn, WeappRouteRules as St, ConfigEnv$1 as T, WeappManagedNodeTsconfigConfig as Tn, WeappVueTemplateConfig as Tt, ComponentEntry as U, GenerateTemplateFactory as Ut, AppEntry as V, GenerateTemplateContext as Vt, Entry as W, GenerateTemplateFileSource as Wt, ProjectConfig as X, JsonMergeContext as Xt, WxmlDep as Y, JsonConfig as Yt, SubPackageMetaValue as Z, JsonMergeFunction as Zt, definePageJson as _, WeappLibComponentJson as _n, WeappInjectRequestGlobalsTarget as _t, UserConfigFnNoEnvPlain as a, NpmStrategy as an, EnhanceOptions as at, ChangeEvent as b, WeappLibEntryContext as bn, WeappNpmConfig as bt, UserConfigFnPromise as c, SharedChunkDynamicImports as cn, MultiPlatformConfig as ct, Component$1 as d, SharedChunkStrategy as dn, WeappAppPreludeMode as dt, MpPlatform as en, WeappForwardConsoleConfig as et, Page$1 as f, SubPackage as fn, WeappAutoRoutesConfig as ft, defineComponentJson as g, SubPackageStyleScope as gn, WeappInjectRequestGlobalsConfig as gt, defineAppJson as h, SubPackageStyleEntry as hn, WeappHmrConfig as ht, UserConfigFnNoEnv as i, NpmPluginPackageConfig as in, AutoImportComponentsOption as it, ResolvedConfig as j, WeappViteHostMeta as jn, BuildNpmPackageMeta as jt, PluginOption as k, WeappWebConfig as kn, AliasOptions as kt, defineConfig as l, SharedChunkMode as ln, ScanWxmlOptions as lt, Theme$1 as m, SubPackageStyleConfigObject as mn, WeappAutoRoutesIncludePattern as mt, UserConfigExport as n, NpmDependencyPattern as nn, WeappViteConfig as nt, UserConfigFnObject as o, NpmSubPackageConfig as on, EnhanceWxmlOptions as ot, Sitemap$1 as p, SubPackageStyleConfigEntry as pn, WeappAutoRoutesInclude as pt, ComponentsMap as q, GenerateTemplatesConfig as qt, UserConfigFn as r, NpmMainPackageConfig as rn, AutoImportComponents as rt, UserConfigFnObjectPlain as s, ResolvedAlias as sn, HandleWxmlOptions as st, UserConfig$1 as t, NpmBuildOptions as tn, WeappForwardConsoleLogLevel as tt, App$1 as u, SharedChunkOverride as un, WeappAppPreludeConfig as ut, defineSitemapJson as v, WeappLibConfig as vn, WeappInjectWeapiConfig as vt, ComputedDefinitions$1 as w, WeappManagedAppTsconfigConfig as wn, WeappVueConfig as wt, WeappVitePluginApi as x, WeappLibFileName as xn, WeappRouteRule as xt, defineThemeJson as y, WeappLibDtsOptions as yn, WeappMcpConfig as yt, ViteDevServer$1 as z, GenerateOptions as zt };
package/dist/config.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { An as createWeappViteHostMeta, Dn as WeappViteHostMeta, En as WEAPP_VITE_HOST_NAME, Mn as resolveWeappViteHostMeta, On as WeappViteRuntime, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, jn as isWeappViteHost, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-BMpfbpQb.mjs";
1
+ import { An as WEAPP_VITE_HOST_NAME, Fn as isWeappViteHost, In as resolveWeappViteHostMeta, Mn as WeappViteRuntime, Nn as applyWeappViteHostMeta, Pn as createWeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, jn as WeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-c4UHLLoh.mjs";
2
2
  export { App, Component, Page, Sitemap, Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, WeappViteConfig, WeappViteHostMeta, WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
@@ -1,6 +1,6 @@
1
1
  import { n as applyWeappViteHostMeta } from "./pluginHost-BzPJL4F-.mjs";
2
2
  import { n as configureLogger, r as logger_default } from "./logger-CgxdNjvb.mjs";
3
- import { _ as supportedCssLangs, a as findJsonEntry, c as inlineAutoRoutesImports, g as jsExtensions, h as configExtensions, i as findJsEntry, l as isJsOrTs, n as extractConfigFromVue, o as findTemplateEntry, p as touch, r as findCssEntry, s as findVueEntry, t as changeFileExtension, u as isTemplate, v as templateExtensions, y as vueExtensions } from "./file-B1jggPxp.mjs";
3
+ import { _ as supportedCssLangs, a as findJsonEntry, c as inlineAutoRoutesImports, g as jsExtensions, h as configExtensions, i as findJsEntry, l as isJsOrTs, n as extractConfigFromVue, o as findTemplateEntry, p as touch, r as findCssEntry, s as findVueEntry, t as changeFileExtension, u as isTemplate, v as templateExtensions, y as vueExtensions } from "./file-DZdM8x0_.mjs";
4
4
  import { createRequire, isBuiltin } from "node:module";
5
5
  import { addExtension, defu, fs, get, isEmptyObject, isObject, objectHash, removeExtension, removeExtensionDeep, set } from "@weapp-core/shared";
6
6
  import { LRUCache } from "lru-cache";
@@ -17,7 +17,7 @@ import { VUE_COMPONENT_TAG_RE, WE_VU_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassSt
17
17
  import process$1 from "node:process";
18
18
  import { parse as parse$1, stringify } from "comment-json";
19
19
  import fs$1, { readFile, readdir, rm } from "node:fs/promises";
20
- import { build, createLogger, createServer, loadConfigFromFile, preprocessCSS } from "vite";
20
+ import { build, createLogger, createServer, loadConfigFromFile, preprocessCSS, transformWithOxc } from "vite";
21
21
  import { createHash } from "node:crypto";
22
22
  import { fileURLToPath } from "node:url";
23
23
  import semverGte from "semver/functions/gte.js";
@@ -8269,6 +8269,7 @@ function getPackNpmRelationList(ctx) {
8269
8269
  const LEADING_SLASHES_RE$2 = /^\/+/;
8270
8270
  const WINDOWS_PATH_RE = /\\|^[A-Z]:[\\/]/i;
8271
8271
  const TRAILING_SLASHES_RE$1 = /\/+$/;
8272
+ const DEFAULT_NPM_STRATEGY = "explicit";
8272
8273
  function matchDependencyName(patterns, dep) {
8273
8274
  return patterns.some((pattern) => {
8274
8275
  if (typeof pattern === "string") return pattern === dep;
@@ -8286,6 +8287,13 @@ function matchDependencyPath(patterns, value) {
8286
8287
  return pattern.test(value);
8287
8288
  });
8288
8289
  }
8290
+ function dedupeDependencies(dependencies) {
8291
+ return [...new Set(dependencies)];
8292
+ }
8293
+ function createDependencyRecord(dependencies) {
8294
+ if (dependencies.length === 0) return;
8295
+ return Object.fromEntries(dependencies.map((dep) => [dep, "*"]));
8296
+ }
8289
8297
  function resolveCopyFilterRelativePath(sourceRoot, sourcePath) {
8290
8298
  const normalizedRoot = normalizePath$1(sourceRoot).replace(TRAILING_SLASHES_RE$1, "");
8291
8299
  const normalizedPath = normalizePath$1(sourcePath);
@@ -8301,6 +8309,47 @@ function resolveTargetDependencies(allDependencies, patterns) {
8301
8309
  for (const pattern of patterns) if (typeof pattern === "string") selected.add(pattern);
8302
8310
  return [...selected];
8303
8311
  }
8312
+ function resolveNpmStrategy(ctx) {
8313
+ return ctx.configService?.weappViteConfig?.npm?.strategy ?? DEFAULT_NPM_STRATEGY;
8314
+ }
8315
+ function resolveConfiguredDependencyPatterns(ctx) {
8316
+ const npmConfig = ctx.configService?.weappViteConfig?.npm;
8317
+ const patterns = [...npmConfig?.include ?? []];
8318
+ if (ctx.configService?.pluginOnly) {
8319
+ if (Array.isArray(npmConfig?.pluginPackage?.dependencies)) patterns.push(...npmConfig.pluginPackage.dependencies);
8320
+ return patterns;
8321
+ }
8322
+ if (Array.isArray(npmConfig?.mainPackage?.dependencies)) patterns.push(...npmConfig.mainPackage.dependencies);
8323
+ for (const config of Object.values(npmConfig?.subPackages ?? {})) if (Array.isArray(config?.dependencies)) patterns.push(...config.dependencies);
8324
+ return patterns;
8325
+ }
8326
+ function resolveDeclaredDependencies(pkgJson) {
8327
+ return dedupeDependencies([...Object.keys(pkgJson.dependencies ?? {}), ...Object.keys(pkgJson.devDependencies ?? {})]);
8328
+ }
8329
+ function isMiniprogramPackage(pkg) {
8330
+ return Reflect.has(pkg, "miniprogram") && typeof pkg.miniprogram === "string";
8331
+ }
8332
+ function resolveMiniprogramCandidateDependenciesSync(allDependencies, cwd) {
8333
+ return allDependencies.filter((dep) => {
8334
+ let packageInfo = null;
8335
+ try {
8336
+ packageInfo = getPackageInfoSync(dep, cwd ? { paths: [cwd] } : void 0);
8337
+ } catch {
8338
+ packageInfo = null;
8339
+ }
8340
+ return !!packageInfo && isMiniprogramPackage(packageInfo.packageJson);
8341
+ });
8342
+ }
8343
+ function resolveNpmBuildCandidateDependenciesSync(ctx, pkgJson) {
8344
+ if (resolveNpmStrategy(ctx) === "legacy") return Object.keys(pkgJson.dependencies ?? {});
8345
+ const declaredDependencies = resolveDeclaredDependencies(pkgJson);
8346
+ const explicitlyIncludedDependencies = resolveTargetDependencies(declaredDependencies, resolveConfiguredDependencyPatterns(ctx));
8347
+ return dedupeDependencies([...resolveMiniprogramCandidateDependenciesSync(declaredDependencies, ctx.configService?.cwd), ...explicitlyIncludedDependencies]);
8348
+ }
8349
+ function resolveNpmBuildCandidateDependencyRecordSync(ctx, pkgJson) {
8350
+ if (!pkgJson) return;
8351
+ return createDependencyRecord(resolveNpmBuildCandidateDependenciesSync(ctx, pkgJson));
8352
+ }
8304
8353
  function hasSameDependencySet(source, target) {
8305
8354
  if (source.length !== target.length) return false;
8306
8355
  return source.every((dep) => target.includes(dep));
@@ -8327,6 +8376,26 @@ function createNpmService(ctx) {
8327
8376
  const oxcVitePlugin = createOxcRuntimeSupport().vitePlugin;
8328
8377
  const cache = createDependenciesCache(ctx);
8329
8378
  const builder = createPackageBuilder(ctx, oxcVitePlugin);
8379
+ async function resolveMiniprogramCandidateDependencies(allDependencies, cwd) {
8380
+ return (await Promise.all(allDependencies.map(async (dep) => {
8381
+ let packageInfo = null;
8382
+ try {
8383
+ packageInfo = await getPackageInfo(dep, cwd ? { paths: [cwd] } : void 0);
8384
+ } catch {
8385
+ packageInfo = null;
8386
+ }
8387
+ if (packageInfo && builder.isMiniprogramPackage(packageInfo.packageJson)) return dep;
8388
+ return null;
8389
+ }))).filter((dep) => typeof dep === "string");
8390
+ }
8391
+ async function resolveBuildCandidateDependencies(pkgJson) {
8392
+ const syncCandidates = resolveNpmBuildCandidateDependenciesSync(ctx, pkgJson);
8393
+ if (resolveNpmStrategy(ctx) === "legacy") return syncCandidates;
8394
+ const declaredDependencies = resolveDeclaredDependencies(pkgJson);
8395
+ const miniprogramDependencies = await resolveMiniprogramCandidateDependencies(declaredDependencies, ctx.configService?.cwd);
8396
+ const explicitlyIncludedDependencies = resolveTargetDependencies(declaredDependencies, resolveConfiguredDependencyPatterns(ctx));
8397
+ return dedupeDependencies([...miniprogramDependencies, ...explicitlyIncludedDependencies]);
8398
+ }
8330
8399
  async function build(options) {
8331
8400
  if (!ctx.configService?.weappViteConfig?.npm?.enable) return;
8332
8401
  debug$2?.("buildNpm start");
@@ -8342,65 +8411,63 @@ function createNpmService(ctx) {
8342
8411
  const outDir = path.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir, npmDistDirName);
8343
8412
  const cachedSourceOutDir = resolveNpmSourceCacheOutDir(ctx.configService.cwd, npmDistDirName);
8344
8413
  const localSubPackageOutRoot = ctx.configService.outDir || path.resolve(ctx.configService.cwd, mainRelation.miniprogramNpmDistDir);
8345
- if (pkgJson.dependencies) {
8346
- const allDependencies = Object.keys(pkgJson.dependencies);
8347
- const mainDependencies = resolveTargetDependencies(allDependencies, ctx.configService.pluginOnly ? resolvePluginPackageDependencyPatterns(ctx) : resolveMainPackageDependencyPatterns(ctx));
8348
- const sourceOutDir = hasSameDependencySet(allDependencies, mainDependencies) ? outDir : cachedSourceOutDir;
8349
- const localSubPackageMetas = [...ctx.scanService?.subPackageMap.values() ?? []].filter((meta) => Array.isArray(meta.subPackage.dependencies) && meta.subPackage.dependencies.length > 0);
8350
- const buildTargetDependencies = async (args) => {
8351
- const isDependenciesCacheOutdate = !await fs.pathExists(args.npmDistDir) || await cache.checkDependenciesCacheOutdate(args.cacheKey);
8352
- if (isDependenciesCacheOutdate) await fs.remove(args.npmDistDir);
8353
- if (args.dependencies.length === 0) {
8354
- await fs.remove(args.npmDistDir);
8355
- await cache.writeDependenciesCache(args.cacheKey);
8356
- return;
8357
- }
8358
- await Promise.all(args.dependencies.map((dep) => {
8359
- return builder.buildPackage({
8360
- dep,
8361
- outDir: args.npmDistDir,
8362
- options,
8363
- isDependenciesCacheOutdate
8364
- });
8365
- }));
8414
+ const allDependencies = await resolveBuildCandidateDependencies(pkgJson);
8415
+ const mainDependencies = resolveTargetDependencies(allDependencies, ctx.configService.pluginOnly ? resolvePluginPackageDependencyPatterns(ctx) : resolveMainPackageDependencyPatterns(ctx));
8416
+ const sourceOutDir = hasSameDependencySet(allDependencies, mainDependencies) ? outDir : cachedSourceOutDir;
8417
+ const localSubPackageMetas = [...ctx.scanService?.subPackageMap.values() ?? []].filter((meta) => Array.isArray(meta.subPackage.dependencies) && meta.subPackage.dependencies.length > 0);
8418
+ const buildTargetDependencies = async (args) => {
8419
+ const isDependenciesCacheOutdate = !await fs.pathExists(args.npmDistDir) || await cache.checkDependenciesCacheOutdate(args.cacheKey);
8420
+ if (isDependenciesCacheOutdate) await fs.remove(args.npmDistDir);
8421
+ if (args.dependencies.length === 0) {
8422
+ await fs.remove(args.npmDistDir);
8366
8423
  await cache.writeDependenciesCache(args.cacheKey);
8367
- };
8368
- if (sourceOutDir !== outDir) await buildTargetDependencies({
8369
- cacheKey: "__all__",
8370
- dependencies: allDependencies,
8371
- npmDistDir: sourceOutDir
8372
- });
8373
- await buildTargetDependencies({
8374
- cacheKey: ctx.configService.pluginOnly ? "__plugin__" : void 0,
8375
- dependencies: mainDependencies,
8376
- npmDistDir: outDir
8377
- });
8378
- if (mainDependencies.length === 0) await Promise.all(subRelations.map((relation) => {
8379
- return fs.remove(path.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName));
8424
+ return;
8425
+ }
8426
+ await Promise.all(args.dependencies.map((dep) => {
8427
+ return builder.buildPackage({
8428
+ dep,
8429
+ outDir: args.npmDistDir,
8430
+ options,
8431
+ isDependenciesCacheOutdate
8432
+ });
8380
8433
  }));
8381
- else await Promise.all(subRelations.map(async (relation) => {
8382
- const targetDir = path.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName);
8434
+ await cache.writeDependenciesCache(args.cacheKey);
8435
+ };
8436
+ if (sourceOutDir !== outDir) await buildTargetDependencies({
8437
+ cacheKey: "__all__",
8438
+ dependencies: allDependencies,
8439
+ npmDistDir: sourceOutDir
8440
+ });
8441
+ await buildTargetDependencies({
8442
+ cacheKey: ctx.configService.pluginOnly ? "__plugin__" : void 0,
8443
+ dependencies: mainDependencies,
8444
+ npmDistDir: outDir
8445
+ });
8446
+ if (mainDependencies.length === 0) await Promise.all(subRelations.map((relation) => {
8447
+ return fs.remove(path.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName));
8448
+ }));
8449
+ else await Promise.all(subRelations.map(async (relation) => {
8450
+ const targetDir = path.resolve(ctx.configService.cwd, relation.miniprogramNpmDistDir, npmDistDirName);
8451
+ await fs.remove(targetDir);
8452
+ await fs.copy(outDir, targetDir, { overwrite: true });
8453
+ }));
8454
+ for (const meta of localSubPackageMetas) {
8455
+ const targetDir = path.resolve(localSubPackageOutRoot, meta.subPackage.root, npmDistDirName);
8456
+ if (await cache.checkDependenciesCacheOutdate(meta.subPackage.root) || !await fs.pathExists(targetDir)) {
8383
8457
  await fs.remove(targetDir);
8384
- await fs.copy(outDir, targetDir, { overwrite: true });
8385
- }));
8386
- for (const meta of localSubPackageMetas) {
8387
- const targetDir = path.resolve(localSubPackageOutRoot, meta.subPackage.root, npmDistDirName);
8388
- if (await cache.checkDependenciesCacheOutdate(meta.subPackage.root) || !await fs.pathExists(targetDir)) {
8389
- await fs.remove(targetDir);
8390
- await fs.copy(sourceOutDir, targetDir, {
8391
- overwrite: true,
8392
- filter: (src) => {
8393
- if (Array.isArray(meta.subPackage.dependencies)) {
8394
- const relPath = resolveCopyFilterRelativePath(sourceOutDir, String(src));
8395
- if (relPath === "") return true;
8396
- return matchDependencyPath(meta.subPackage.dependencies, relPath);
8397
- }
8398
- return true;
8458
+ await fs.copy(sourceOutDir, targetDir, {
8459
+ overwrite: true,
8460
+ filter: (src) => {
8461
+ if (Array.isArray(meta.subPackage.dependencies)) {
8462
+ const relPath = resolveCopyFilterRelativePath(sourceOutDir, String(src));
8463
+ if (relPath === "") return true;
8464
+ return matchDependencyPath(meta.subPackage.dependencies, relPath);
8399
8465
  }
8400
- });
8401
- }
8402
- await cache.writeDependenciesCache(meta.subPackage.root);
8466
+ return true;
8467
+ }
8468
+ });
8403
8469
  }
8470
+ await cache.writeDependenciesCache(meta.subPackage.root);
8404
8471
  }
8405
8472
  }
8406
8473
  debug$2?.("buildNpm end");
@@ -8908,12 +8975,12 @@ function reserveUniqueFileName(reservedFileNames, fileName) {
8908
8975
  return candidate;
8909
8976
  }
8910
8977
  function rewriteChunkImportSpecifiersInCode(sourceCode, options) {
8911
- const { sourceFileName, sourceFileNames, targetFileName, imports, dynamicImports, runtimeFileName } = options;
8978
+ const { sourceFileName, sourceFileNames, targetFileName, imports, dynamicImports, runtimeFileName, resolveImportTarget } = options;
8912
8979
  const sourceFileNameCandidates = (sourceFileNames ?? [sourceFileName ?? ""]).filter(Boolean);
8913
8980
  const specifiers = new Set([...imports, ...dynamicImports].filter(Boolean));
8914
8981
  let rewrittenCode = sourceCode;
8915
8982
  for (const specifier of specifiers) {
8916
- const targetImportPath = createRelativeImportPath(targetFileName, posix.basename(specifier) === ROLLDOWN_RUNTIME_FILE_NAME$1 ? runtimeFileName : specifier);
8983
+ const targetImportPath = createRelativeImportPath(targetFileName, posix.basename(specifier) === ROLLDOWN_RUNTIME_FILE_NAME$1 ? runtimeFileName : resolveImportTarget?.(specifier) ?? specifier);
8917
8984
  if (!targetImportPath) continue;
8918
8985
  for (const sourceCandidate of sourceFileNameCandidates) {
8919
8986
  const sourceImportPath = createRelativeImportPath(sourceCandidate, specifier);
@@ -8948,6 +9015,80 @@ function applySharedChunkStrategy(bundle, options) {
8948
9015
  if (!this) throw new Error("applySharedChunkStrategy 需要 PluginContext。");
8949
9016
  const subPackageRoots = Array.from(options.subPackageRoots).filter(Boolean);
8950
9017
  const reservedFileNames = new Set(Object.keys(bundle));
9018
+ const localizedDuplicateFileMap = /* @__PURE__ */ new Map();
9019
+ const pendingLocalizedDuplicates = [];
9020
+ const emittedLocalizedDuplicateFiles = /* @__PURE__ */ new Set();
9021
+ const ensureLocalizedDuplicate = (root, sourceFileName) => {
9022
+ const sourceRoot = resolveSubPackagePrefix(sourceFileName, subPackageRoots);
9023
+ if (!sourceRoot || sourceRoot === root) return sourceFileName;
9024
+ const key = `${root}::${sourceFileName}`;
9025
+ const existing = localizedDuplicateFileMap.get(key);
9026
+ if (existing) return existing;
9027
+ const sourceOutput = bundle[sourceFileName];
9028
+ if (sourceOutput?.type !== "chunk") return sourceFileName;
9029
+ const duplicateBaseName = createCrossSubPackageDuplicateBaseName(sourceRoot, sourceFileName);
9030
+ const targetFileName = reserveUniqueFileName(reservedFileNames, posix.join(root, SUB_PACKAGE_SHARED_DIR, duplicateBaseName));
9031
+ localizedDuplicateFileMap.set(key, targetFileName);
9032
+ pendingLocalizedDuplicates.push({
9033
+ root,
9034
+ sourceFileName,
9035
+ targetFileName,
9036
+ chunk: sourceOutput
9037
+ });
9038
+ return targetFileName;
9039
+ };
9040
+ const rewriteDuplicatedChunkSource = (args) => {
9041
+ let rewrittenSource = rewriteChunkImportSpecifiersInCode(args.chunk.code ?? "", {
9042
+ sourceFileNames: createChunkSourceFileNameCandidates(args.sourceFileName),
9043
+ targetFileName: args.targetFileName,
9044
+ imports: args.chunk.imports,
9045
+ dynamicImports: args.chunk.dynamicImports,
9046
+ runtimeFileName: args.runtimeFileName,
9047
+ resolveImportTarget: (specifier) => {
9048
+ return ensureLocalizedDuplicate(args.root, specifier);
9049
+ }
9050
+ });
9051
+ for (const specifier of [...args.chunk.imports, ...args.chunk.dynamicImports]) {
9052
+ const localizedSpecifier = ensureLocalizedDuplicate(args.root, specifier);
9053
+ if (!localizedSpecifier || localizedSpecifier === specifier) continue;
9054
+ rewrittenSource = rewriteChunkImportSpecifiersInCode(rewrittenSource, {
9055
+ sourceFileName: args.targetFileName,
9056
+ targetFileName: args.targetFileName,
9057
+ imports: [specifier],
9058
+ dynamicImports: [],
9059
+ runtimeFileName: args.runtimeFileName,
9060
+ resolveImportTarget: () => localizedSpecifier
9061
+ });
9062
+ }
9063
+ return rewrittenSource;
9064
+ };
9065
+ const emitDuplicatedChunkAsset = (args) => {
9066
+ if (emittedLocalizedDuplicateFiles.has(args.targetFileName)) return;
9067
+ const runtimeFileName = posix.join(args.root, ROLLDOWN_RUNTIME_FILE_NAME);
9068
+ const duplicatedSource = rewriteDuplicatedChunkSource({
9069
+ root: args.root,
9070
+ sourceFileName: args.sourceFileName,
9071
+ targetFileName: args.targetFileName,
9072
+ chunk: args.chunk,
9073
+ runtimeFileName
9074
+ });
9075
+ this.emitFile({
9076
+ type: "asset",
9077
+ fileName: args.targetFileName,
9078
+ source: duplicatedSource
9079
+ });
9080
+ const sourceMapAssetInfo = findSourceMapAsset(bundle, collectSourceMapKeys(args.sourceFileName, args.chunk));
9081
+ const resolvedSourceMap = resolveSourceMapSource(args.chunk.map, sourceMapAssetInfo?.asset.source);
9082
+ if (resolvedSourceMap) {
9083
+ const sourceMapFileName = reserveUniqueFileName(reservedFileNames, `${args.targetFileName}.map`);
9084
+ this.emitFile({
9085
+ type: "asset",
9086
+ fileName: sourceMapFileName,
9087
+ source: cloneSourceLike(resolvedSourceMap)
9088
+ });
9089
+ }
9090
+ emittedLocalizedDuplicateFiles.add(args.targetFileName);
9091
+ };
8951
9092
  const entries = Object.entries(bundle);
8952
9093
  for (const [fileName, output] of entries) {
8953
9094
  if (!isSharedVirtualChunk(fileName, output)) continue;
@@ -9048,27 +9189,12 @@ function applySharedChunkStrategy(bundle, options) {
9048
9189
  });
9049
9190
  }
9050
9191
  for (const [root, { newFileName, importers: importerFiles }] of importerMap.entries()) {
9051
- const runtimeFileName = posix.join(root, ROLLDOWN_RUNTIME_FILE_NAME);
9052
- const duplicatedSource = rewriteChunkImportSpecifiersInCode(originalCode, {
9053
- sourceFileNames: createChunkSourceFileNameCandidates(fileName),
9192
+ emitDuplicatedChunkAsset({
9193
+ root,
9194
+ sourceFileName: fileName,
9054
9195
  targetFileName: newFileName,
9055
- imports: chunk.imports,
9056
- dynamicImports: chunk.dynamicImports,
9057
- runtimeFileName
9058
- });
9059
- this.emitFile({
9060
- type: "asset",
9061
- fileName: newFileName,
9062
- source: duplicatedSource
9196
+ chunk
9063
9197
  });
9064
- if (resolvedSourceMap) {
9065
- const sourceMapFileName = reserveUniqueFileName(reservedFileNames, `${newFileName}.map`);
9066
- this.emitFile({
9067
- type: "asset",
9068
- fileName: sourceMapFileName,
9069
- source: cloneSourceLike(resolvedSourceMap)
9070
- });
9071
- }
9072
9198
  for (const importerFile of importerFiles) importerToChunk.set(importerFile, newFileName);
9073
9199
  duplicates.push({
9074
9200
  fileName: newFileName,
@@ -9096,14 +9222,16 @@ function applySharedChunkStrategy(bundle, options) {
9096
9222
  localizeCrossSubPackageChunkLeaks.call(this, bundle, {
9097
9223
  subPackageRoots,
9098
9224
  reservedFileNames,
9225
+ localizedDuplicateFileMap,
9099
9226
  onDuplicate: options.onDuplicate
9100
9227
  });
9228
+ for (const task of pendingLocalizedDuplicates) emitDuplicatedChunkAsset(task);
9101
9229
  }
9102
9230
  function isSharedVirtualChunk(fileName, output) {
9103
9231
  return output?.type === "chunk" && fileName.startsWith(`weapp_shared_virtual/`);
9104
9232
  }
9105
9233
  function localizeCrossSubPackageChunkLeaks(bundle, options) {
9106
- const { subPackageRoots, reservedFileNames, onDuplicate } = options;
9234
+ const { subPackageRoots, reservedFileNames, localizedDuplicateFileMap, onDuplicate } = options;
9107
9235
  if (subPackageRoots.length === 0) return;
9108
9236
  const entries = Object.entries(bundle);
9109
9237
  for (const [fileName, output] of entries) {
@@ -9129,28 +9257,36 @@ function localizeCrossSubPackageChunkLeaks(bundle, options) {
9129
9257
  const importerToChunk = /* @__PURE__ */ new Map();
9130
9258
  const duplicates = [];
9131
9259
  for (const [targetRoot, importerFiles] of crossRootImporters.entries()) {
9132
- const duplicateBaseName = createCrossSubPackageDuplicateBaseName(sourceRoot, fileName);
9133
- const uniqueFileName = reserveUniqueFileName(reservedFileNames, posix.join(targetRoot, SUB_PACKAGE_SHARED_DIR, duplicateBaseName));
9260
+ const duplicateKey = `${targetRoot}::${fileName}`;
9261
+ const existingDuplicateFileName = localizedDuplicateFileMap.get(duplicateKey);
9262
+ const uniqueFileName = existingDuplicateFileName ?? (() => {
9263
+ const duplicateBaseName = createCrossSubPackageDuplicateBaseName(sourceRoot, fileName);
9264
+ const createdFileName = reserveUniqueFileName(reservedFileNames, posix.join(targetRoot, "weapp-shared", duplicateBaseName));
9265
+ localizedDuplicateFileMap.set(duplicateKey, createdFileName);
9266
+ return createdFileName;
9267
+ })();
9134
9268
  const runtimeFileName = posix.join(targetRoot, ROLLDOWN_RUNTIME_FILE_NAME);
9135
- const duplicatedSource = rewriteChunkImportSpecifiersInCode(chunk.code ?? "", {
9136
- sourceFileName: fileName,
9137
- targetFileName: uniqueFileName,
9138
- imports: chunk.imports,
9139
- dynamicImports: chunk.dynamicImports,
9140
- runtimeFileName
9141
- });
9142
- this.emitFile({
9143
- type: "asset",
9144
- fileName: uniqueFileName,
9145
- source: duplicatedSource
9146
- });
9147
- if (resolvedSourceMap) {
9148
- const sourceMapFileName = reserveUniqueFileName(reservedFileNames, `${uniqueFileName}.map`);
9269
+ if (!existingDuplicateFileName) {
9270
+ const duplicatedSource = rewriteChunkImportSpecifiersInCode(chunk.code ?? "", {
9271
+ sourceFileName: fileName,
9272
+ targetFileName: uniqueFileName,
9273
+ imports: chunk.imports,
9274
+ dynamicImports: chunk.dynamicImports,
9275
+ runtimeFileName
9276
+ });
9149
9277
  this.emitFile({
9150
9278
  type: "asset",
9151
- fileName: sourceMapFileName,
9152
- source: cloneSourceLike(resolvedSourceMap)
9279
+ fileName: uniqueFileName,
9280
+ source: duplicatedSource
9153
9281
  });
9282
+ if (resolvedSourceMap) {
9283
+ const sourceMapFileName = reserveUniqueFileName(reservedFileNames, `${uniqueFileName}.map`);
9284
+ this.emitFile({
9285
+ type: "asset",
9286
+ fileName: sourceMapFileName,
9287
+ source: cloneSourceLike(resolvedSourceMap)
9288
+ });
9289
+ }
9154
9290
  }
9155
9291
  for (const importerFile of importerFiles) importerToChunk.set(importerFile, uniqueFileName);
9156
9292
  duplicates.push({
@@ -10146,6 +10282,7 @@ function getWeappViteConfig() {
10146
10282
  ],
10147
10283
  unhandledErrors: true
10148
10284
  },
10285
+ appPrelude: {},
10149
10286
  injectRequestGlobals: {},
10150
10287
  chunks: {
10151
10288
  sharedStrategy: "duplicate",
@@ -12692,6 +12829,21 @@ function isInsideMustache(code, start, end) {
12692
12829
  if (open < 0) return false;
12693
12830
  return code.indexOf("}}", open + 2) >= end;
12694
12831
  }
12832
+ function getMustacheBounds(code, start, end) {
12833
+ const open = code.lastIndexOf("{{", start);
12834
+ if (open < 0) return null;
12835
+ const close = code.indexOf("}}", end);
12836
+ if (close < 0) return null;
12837
+ return {
12838
+ open,
12839
+ close
12840
+ };
12841
+ }
12842
+ function isWholeMustacheExpression(code, start, end, expression) {
12843
+ const bounds = getMustacheBounds(code, start, end);
12844
+ if (!bounds) return false;
12845
+ return code.slice(bounds.open + 2, bounds.close).trim() === expression;
12846
+ }
12695
12847
  function getMustacheOuterQuote(code, start) {
12696
12848
  const open = code.lastIndexOf("{{", start);
12697
12849
  if (open <= 0) return null;
@@ -12702,22 +12854,38 @@ function getMustacheOuterQuote(code, start) {
12702
12854
  }
12703
12855
  return null;
12704
12856
  }
12705
- function toQuotedLiteral(value, quote) {
12857
+ function toQuotedLiteral(value, quote, outerQuote = null) {
12706
12858
  try {
12707
12859
  const parsed = JSON.parse(value);
12708
- if (typeof parsed !== "string") return value;
12709
- const escaped = parsed.replace(/\\/g, "\\\\").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
12860
+ let escaped = (typeof parsed === "string" ? parsed : JSON.stringify(parsed)).replace(/\\/g, "\\\\").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
12861
+ if (outerQuote === "\"") escaped = escaped.replace(/"/g, "&quot;");
12862
+ else if (outerQuote === "'") escaped = escaped.replace(/'/g, "&apos;");
12710
12863
  return quote === "'" ? `'${escaped.replace(/'/g, "\\'")}'` : `"${escaped.replace(/"/g, "\\\"")}"`;
12711
12864
  } catch {
12712
12865
  return value;
12713
12866
  }
12714
12867
  }
12868
+ function toMustacheReplacementValue(code, start, end, expression, value) {
12869
+ try {
12870
+ const parsed = JSON.parse(value);
12871
+ const outerQuote = getMustacheOuterQuote(code, start);
12872
+ if (typeof parsed === "string") return toQuotedLiteral(value, outerQuote === "'" ? "\"" : "'", outerQuote);
12873
+ if (isWholeMustacheExpression(code, start, end, expression)) {
12874
+ if (typeof parsed === "number") return Number.isFinite(parsed) ? String(parsed) : value;
12875
+ if (typeof parsed === "boolean") return parsed ? "true" : "false";
12876
+ if (parsed == null) return "null";
12877
+ }
12878
+ return String(value);
12879
+ } catch {
12880
+ return value;
12881
+ }
12882
+ }
12715
12883
  function replaceDefineImportMetaEnv(code, defineImportMetaEnv) {
12716
12884
  if (!defineImportMetaEnv || Object.keys(defineImportMetaEnv).length === 0) return code;
12717
12885
  const entries = Object.entries(defineImportMetaEnv).sort(([leftKey], [rightKey]) => rightKey.length - leftKey.length);
12718
12886
  const replacementRanges = [];
12719
12887
  for (const [key, value] of entries) {
12720
- if (!key.startsWith("import.meta")) continue;
12888
+ if (!(key === "import.meta.url" || key === "import.meta.dirname" || key.startsWith("import.meta.env.")) || key === "import.meta.env") continue;
12721
12889
  const pattern = new RegExp(escapeRegExp(key), "g");
12722
12890
  for (const match of code.matchAll(pattern)) {
12723
12891
  const start = match.index ?? -1;
@@ -12730,7 +12898,7 @@ function replaceDefineImportMetaEnv(code, defineImportMetaEnv) {
12730
12898
  replacementRanges.push({
12731
12899
  start,
12732
12900
  end,
12733
- value: isInsideMustache(code, start, end) ? toQuotedLiteral(String(value), getMustacheOuterQuote(code, start) === "'" ? "\"" : "'") : String(value)
12901
+ value: isInsideMustache(code, start, end) ? toMustacheReplacementValue(code, start, end, key, String(value)) : String(value)
12734
12902
  });
12735
12903
  }
12736
12904
  }
@@ -13951,7 +14119,8 @@ function resolveInjectRequestGlobalsOptions(config, packageJson) {
13951
14119
  if ((config && typeof config === "object" ? config.enabled : config) === true) return {
13952
14120
  mode: "explicit",
13953
14121
  targets: resolveTargets(config),
13954
- dependencyPatterns: resolveDependencyPatterns(config)
14122
+ dependencyPatterns: resolveDependencyPatterns(config),
14123
+ prelude: config && typeof config === "object" ? config.prelude === true : false
13955
14124
  };
13956
14125
  const autoRules = resolveAutoRules(config);
13957
14126
  const matchedTargets = /* @__PURE__ */ new Set();
@@ -13962,7 +14131,8 @@ function resolveInjectRequestGlobalsOptions(config, packageJson) {
13962
14131
  if (matchedTargets.size === 0) return null;
13963
14132
  return {
13964
14133
  mode: "auto",
13965
- targets: [...matchedTargets]
14134
+ targets: [...matchedTargets],
14135
+ prelude: config && typeof config === "object" ? config.prelude === true : false
13966
14136
  };
13967
14137
  }
13968
14138
  function resolveRequestGlobalsRuntimeModuleId() {
@@ -13973,6 +14143,15 @@ function resolveRequestGlobalsBindingTargets(targets) {
13973
14143
  if (targets.some((target) => target === "fetch" || target === "Request" || target === "Response" || target === "XMLHttpRequest")) bindingTargets.push("URL", "URLSearchParams", "Blob", "FormData");
13974
14144
  return [...new Set(bindingTargets)].filter((target) => REQUEST_GLOBAL_FREE_BINDING_TARGETS.has(target));
13975
14145
  }
14146
+ /**
14147
+ * @description 生成“被动局部绑定”代码。
14148
+ * @description 这层能力不能退化成只在 app.js 顶部安装全局对象。
14149
+ * @description 原因是 axios / graphql-request / socket.io-client 一类依赖经常会:
14150
+ * @description 1. 在模块初始化阶段直接读取自由变量;
14151
+ * @description 2. 在各自 chunk 作用域里执行 `typeof XMLHttpRequest` / `typeof fetch` / `new URL()`;
14152
+ * @description 3. 在全局对象完成安装前就完成环境探测并缓存结果。
14153
+ * @description 因此这里必须把 fetch / XMLHttpRequest / WebSocket / URL 等名字绑定到实际使用它们的产物作用域内。
14154
+ */
13976
14155
  function createRequestGlobalsPassiveBindingsCode(targets) {
13977
14156
  const bindingTargets = resolveRequestGlobalsBindingTargets(targets);
13978
14157
  if (bindingTargets.length === 0) return "";
@@ -14112,6 +14291,15 @@ const REQUEST_GLOBAL_ENTRY_NAME_RE = /\.[^/.]+$/;
14112
14291
  const REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE = /([A-Za-z_$][\w$]*)\s*=\s*require\((`([^`]+)`|'([^']+)'|"([^"]+)")\)/g;
14113
14292
  const DYNAMIC_GLOBAL_RESOLUTION_RE = /Function\(\s*(?:`return this`|'return this'|"return this")\s*\)\(\)/g;
14114
14293
  const BROWSER_GLOBAL_HOST_TERNARY_RE = /typeof self<[`'"]u[`'"]\?self:typeof window<[`'"]u[`'"]\?window:globalThis/g;
14294
+ const AXIOS_MODULE_ID_RE = /[/\\](?:\.pnpm[/\\][^/\\]+[/\\]node_modules[/\\])?axios[/\\]/u;
14295
+ const APP_PRELUDE_CHUNK_MARKER = "__weappViteAppPreludeRuntime__";
14296
+ const APP_PRELUDE_GUARD_KEY = "__weappViteAppPreludeInstalled__";
14297
+ const APP_PRELUDE_REQUIRE_MARKER = "__weappViteAppPreludeRequire__";
14298
+ const APP_PRELUDE_REQUIRE_FILE_BASENAME = "app.prelude.js";
14299
+ const REQUEST_GLOBAL_PRELUDE_MARKER = "__weappViteRequestGlobalsPrelude__";
14300
+ const REQUEST_GLOBAL_PRELUDE_GUARD_KEY = "__weappViteRequestGlobalsPreludeInstalled__";
14301
+ const DIRECTIVE_PROLOGUE_RE = /^(?:(['"])(?:\\.|(?!\1)[^\\])*\1;?\s*)+/u;
14302
+ const USE_STRICT_PREFIX_RE = /^(?:['"]use strict['"];\s*)+/u;
14115
14303
  function resolveInjectWeapiGlobalName(state) {
14116
14304
  const injectWeapi = state.ctx.configService.weappViteConfig?.injectWeapi;
14117
14305
  if (!injectWeapi) return null;
@@ -14363,7 +14551,7 @@ function injectRequestGlobalsPassiveBindings(bundle, installerChunks, targets, e
14363
14551
  if (chunk.code.includes("__weappViteRequestGlobalsPassiveBindings__") || chunk.code.includes("__weappViteRequestGlobalsLocalBindings__") || chunk.code.includes("__weappViteRequestGlobalsBundleInstalled__")) continue;
14364
14552
  const entryName = chunk.fileName.replace(REQUEST_GLOBAL_ENTRY_NAME_RE, "");
14365
14553
  const entryType = entriesMap?.get(entryName)?.type;
14366
- if (entryType === "page" || entryType === "component") continue;
14554
+ if (entryType === "page" || entryType === "component" || entryType === "app") continue;
14367
14555
  chunk.code = `/* __weappViteRequestGlobalsPassiveBindings__ */ ${passiveBindingsCode}\n${chunk.code}`;
14368
14556
  }
14369
14557
  }
@@ -14376,7 +14564,7 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, ent
14376
14564
  const chunk = output;
14377
14565
  const entryName = chunk.fileName.replace(REQUEST_GLOBAL_ENTRY_NAME_RE, "");
14378
14566
  const entryType = entriesMap?.get(entryName)?.type;
14379
- if (entryType !== "page" && entryType !== "component") continue;
14567
+ if (entryType !== "page" && entryType !== "component" && entryType !== "app") continue;
14380
14568
  if (chunk.code.includes("__weappViteRequestGlobalsLocalBindings__")) continue;
14381
14569
  let requireImportLiteral = null;
14382
14570
  let exportName;
@@ -14399,6 +14587,77 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, ent
14399
14587
  ].join(";")};\n${chunk.code}`;
14400
14588
  }
14401
14589
  }
14590
+ function resolveRequestGlobalsInstallerImport(chunk, installerChunks) {
14591
+ for (const requireMatch of chunk.code.matchAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE)) {
14592
+ const importee = requireMatch[3] ?? requireMatch[4] ?? requireMatch[5];
14593
+ if (!importee) continue;
14594
+ const installerChunkFileName = normalizeRelativeChunkImport(chunk.fileName, importee);
14595
+ const exportName = installerChunks.get(installerChunkFileName);
14596
+ if (!exportName) continue;
14597
+ return {
14598
+ exportName,
14599
+ requireImportLiteral: requireMatch[2] ?? null
14600
+ };
14601
+ }
14602
+ return null;
14603
+ }
14604
+ function createRequestGlobalsPreludeCode(chunk, installerChunks, targets) {
14605
+ if (targets.length === 0 || chunk.code.includes(REQUEST_GLOBAL_PRELUDE_MARKER)) return;
14606
+ const bindingTargets = resolveRequestGlobalsBindingTargets(targets);
14607
+ if (bindingTargets.length === 0) return;
14608
+ const installerName = resolveRequestGlobalsInstallerName(chunk.code);
14609
+ const exportName = resolveRequestGlobalsExportName(chunk.code);
14610
+ let installerHostCode;
14611
+ if (installerName && exportName) installerHostCode = `${installerName}({ targets: ${JSON.stringify(targets)} }) || globalThis`;
14612
+ else {
14613
+ const installerImport = resolveRequestGlobalsInstallerImport(chunk, installerChunks);
14614
+ if (!installerImport?.requireImportLiteral || !installerImport.exportName) return;
14615
+ installerHostCode = `require(${installerImport.requireImportLiteral})[${JSON.stringify(installerImport.exportName)}]({ targets: ${JSON.stringify(targets)} }) || globalThis`;
14616
+ }
14617
+ return [
14618
+ `/* ${REQUEST_GLOBAL_PRELUDE_MARKER} */`,
14619
+ `(() => {`,
14620
+ ` if (globalThis[${JSON.stringify(REQUEST_GLOBAL_PRELUDE_GUARD_KEY)}]) {`,
14621
+ ` return`,
14622
+ ` }`,
14623
+ ` globalThis[${JSON.stringify(REQUEST_GLOBAL_PRELUDE_GUARD_KEY)}] = true`,
14624
+ ` const __weappVitePreludeRequestGlobalsHost__ = ${installerHostCode}`,
14625
+ ` const __weappViteRequestGlobalsActuals__ = globalThis.__weappViteRequestGlobalsActuals__ || (globalThis.__weappViteRequestGlobalsActuals__ = Object.create(null))`,
14626
+ ...bindingTargets.map((target) => ` __weappViteRequestGlobalsActuals__[${JSON.stringify(target)}] = __weappVitePreludeRequestGlobalsHost__.${target}`),
14627
+ `})();`
14628
+ ].join("\n");
14629
+ }
14630
+ function injectAxiosFetchAdapterEnv(bundle) {
14631
+ const axiosEnvPatchCode = [
14632
+ "/* __weappViteAxiosFetchAdapterEnv__ */",
14633
+ "let __weappViteAxiosExport__ = null",
14634
+ "for (const __weappViteAxiosKey__ in exports) {",
14635
+ " const __weappViteAxiosCandidate__ = exports[__weappViteAxiosKey__]",
14636
+ " if (__weappViteAxiosCandidate__ && typeof __weappViteAxiosCandidate__ === \"function\" && __weappViteAxiosCandidate__.Axios && __weappViteAxiosCandidate__.defaults) {",
14637
+ " __weappViteAxiosExport__ = __weappViteAxiosCandidate__",
14638
+ " break",
14639
+ " }",
14640
+ "}",
14641
+ "if (__weappViteAxiosExport__) {",
14642
+ " __weappViteAxiosExport__.defaults.env = {",
14643
+ " ...(__weappViteAxiosExport__.defaults.env ?? {}),",
14644
+ " Request,",
14645
+ " Response,",
14646
+ " fetch,",
14647
+ " }",
14648
+ "}",
14649
+ ""
14650
+ ].join("\n");
14651
+ for (const output of Object.values(bundle)) {
14652
+ if (output?.type !== "chunk") continue;
14653
+ const chunk = output;
14654
+ if (chunk.code.includes("__weappViteAxiosFetchAdapterEnv__")) continue;
14655
+ const moduleIds = Array.isArray(chunk.moduleIds) ? chunk.moduleIds : [];
14656
+ const normalizedFileName = toPosixPath(chunk.fileName);
14657
+ if (!(moduleIds.some((id) => AXIOS_MODULE_ID_RE.test(id)) || normalizedFileName === "axios.js" || normalizedFileName.endsWith("/axios.js"))) continue;
14658
+ chunk.code = `${chunk.code}\n${axiosEnvPatchCode}`;
14659
+ }
14660
+ }
14402
14661
  function toRelativeRuntimeNpmImport(fileName, root, importee) {
14403
14662
  const normalized = normalizeWeappLocalNpmImport(importee);
14404
14663
  const target = root ? `${root}/miniprogram_npm/${normalized}` : `miniprogram_npm/${normalized}`;
@@ -14446,6 +14705,126 @@ function rewriteJsonNpmImportsToLocalRoot(bundle, root, dependencyPatterns, depe
14446
14705
  } catch {}
14447
14706
  }
14448
14707
  }
14708
+ function prependChunkCodePreservingDirectives(code, injectedCode) {
14709
+ const directiveMatch = code.match(DIRECTIVE_PROLOGUE_RE);
14710
+ if (!directiveMatch?.[0]) return `${injectedCode}\n${code}`;
14711
+ const directivePrologue = directiveMatch[0];
14712
+ return `${directivePrologue}${injectedCode}\n${code.slice(directivePrologue.length)}`;
14713
+ }
14714
+ function resolveAppPreludeOptions(state) {
14715
+ const option = state.ctx.configService.weappViteConfig?.appPrelude;
14716
+ if (option === false) return {
14717
+ enabled: false,
14718
+ mode: "inline"
14719
+ };
14720
+ if (option === true || option == null) return {
14721
+ enabled: true,
14722
+ mode: "inline"
14723
+ };
14724
+ return {
14725
+ enabled: option.enabled !== false,
14726
+ mode: option.mode ?? "inline"
14727
+ };
14728
+ }
14729
+ function collectAppPreludeEntryChunkFileNames(state) {
14730
+ const entryChunkFileNames = /* @__PURE__ */ new Set();
14731
+ for (const entry of state.entriesMap.values()) {
14732
+ if (!entry || entry.type !== "app" && entry.type !== "page" && entry.type !== "component") continue;
14733
+ const relative = state.ctx.configService.relativeAbsoluteSrcRoot(entry.path);
14734
+ entryChunkFileNames.add(changeFileExtension(relative, ".js"));
14735
+ }
14736
+ return entryChunkFileNames;
14737
+ }
14738
+ async function resolveAppPreludeCode(preludePath) {
14739
+ if (!preludePath) return;
14740
+ const source = await readFile(preludePath, "utf8");
14741
+ if (!source.trim()) return;
14742
+ const ast = parseJsLike(source);
14743
+ let hasModuleSyntax = false;
14744
+ traverse(ast, {
14745
+ ImportDeclaration() {
14746
+ hasModuleSyntax = true;
14747
+ },
14748
+ ExportAllDeclaration() {
14749
+ hasModuleSyntax = true;
14750
+ },
14751
+ ExportDefaultDeclaration() {
14752
+ hasModuleSyntax = true;
14753
+ },
14754
+ ExportNamedDeclaration() {
14755
+ hasModuleSyntax = true;
14756
+ }
14757
+ });
14758
+ if (hasModuleSyntax) throw new Error("[app.prelude] 当前仅支持无 import/export 的自包含脚本。");
14759
+ const extension = path.extname(preludePath).toLowerCase();
14760
+ const normalizedCode = (await transformWithOxc(source, preludePath, {
14761
+ charset: "utf8",
14762
+ format: "cjs",
14763
+ loader: extension === ".ts" || extension === ".mts" || extension === ".cts" ? "ts" : extension === ".jsx" ? "jsx" : extension === ".tsx" ? "tsx" : "js",
14764
+ minify: false,
14765
+ sourcemap: false,
14766
+ target: "es2020",
14767
+ treeShaking: false
14768
+ })).code.replace(USE_STRICT_PREFIX_RE, "").trim();
14769
+ if (!normalizedCode) return;
14770
+ return [
14771
+ `/* ${APP_PRELUDE_CHUNK_MARKER} */`,
14772
+ `(() => {`,
14773
+ ` if (globalThis[${JSON.stringify(APP_PRELUDE_GUARD_KEY)}]) {`,
14774
+ ` return`,
14775
+ ` }`,
14776
+ ` globalThis[${JSON.stringify(APP_PRELUDE_GUARD_KEY)}] = true`,
14777
+ normalizedCode,
14778
+ `})();`
14779
+ ].join("\n");
14780
+ }
14781
+ function resolveAppPreludeRequireFileName(fileName, state) {
14782
+ const matchedIndependentRoot = state.subPackageMeta?.subPackage.root;
14783
+ if (matchedIndependentRoot) return `${matchedIndependentRoot}/${APP_PRELUDE_REQUIRE_FILE_BASENAME}`;
14784
+ const matchedRoot = [...state.ctx.scanService.subPackageMap?.keys() ?? []].filter(Boolean).sort((left, right) => right.length - left.length).find((root) => fileName === root || fileName.startsWith(`${root}/`));
14785
+ if (!matchedRoot) return APP_PRELUDE_REQUIRE_FILE_BASENAME;
14786
+ return `${matchedRoot}/${APP_PRELUDE_REQUIRE_FILE_BASENAME}`;
14787
+ }
14788
+ function createAppPreludeRequireStatement(chunkFileName, preludeFileName) {
14789
+ const relativePath = toPosixPath(path.relative(path.dirname(chunkFileName), preludeFileName));
14790
+ const requestPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
14791
+ return `/* ${APP_PRELUDE_REQUIRE_MARKER} */require(${JSON.stringify(requestPath)})`;
14792
+ }
14793
+ function emitAppPreludeRequireAssets(bundle, appPreludeCode, state, emitFile) {
14794
+ if (!appPreludeCode) return;
14795
+ const preludeFileNames = /* @__PURE__ */ new Set();
14796
+ if (state.subPackageMeta?.subPackage.root) preludeFileNames.add(`${state.subPackageMeta.subPackage.root}/${APP_PRELUDE_REQUIRE_FILE_BASENAME}`);
14797
+ else {
14798
+ preludeFileNames.add(APP_PRELUDE_REQUIRE_FILE_BASENAME);
14799
+ for (const root of state.ctx.scanService.subPackageMap.keys()) {
14800
+ if (!root) continue;
14801
+ preludeFileNames.add(`${root}/${APP_PRELUDE_REQUIRE_FILE_BASENAME}`);
14802
+ }
14803
+ }
14804
+ for (const fileName of preludeFileNames) {
14805
+ if (bundle[fileName]) continue;
14806
+ emitFile?.({
14807
+ type: "asset",
14808
+ fileName,
14809
+ source: `${appPreludeCode}\n`
14810
+ });
14811
+ }
14812
+ }
14813
+ function injectAppPreludeCode(bundle, appPreludeCode, options, state, requestGlobalsPreludeOptions, emitFile) {
14814
+ if (!options.enabled) return;
14815
+ const entryChunkFileNames = options.mode === "entry" ? collectAppPreludeEntryChunkFileNames(state) : void 0;
14816
+ if (options.mode === "require" && appPreludeCode) emitAppPreludeRequireAssets(bundle, appPreludeCode, state, emitFile);
14817
+ for (const output of Object.values(bundle)) {
14818
+ if (output?.type !== "chunk") continue;
14819
+ const chunk = output;
14820
+ if (chunk.code.includes(APP_PRELUDE_CHUNK_MARKER) || chunk.code.includes(APP_PRELUDE_REQUIRE_MARKER)) continue;
14821
+ const isTargetEntryChunk = chunk.isEntry === true || entryChunkFileNames?.has(chunk.fileName) === true;
14822
+ if (entryChunkFileNames && !isTargetEntryChunk) continue;
14823
+ const injectedCode = [requestGlobalsPreludeOptions.enabled ? createRequestGlobalsPreludeCode(chunk, requestGlobalsPreludeOptions.installerChunks, requestGlobalsPreludeOptions.targets) : void 0, options.mode === "require" ? appPreludeCode ? createAppPreludeRequireStatement(chunk.fileName, resolveAppPreludeRequireFileName(chunk.fileName, state)) : void 0 : appPreludeCode].filter(Boolean).join("\n");
14824
+ if (!injectedCode) continue;
14825
+ chunk.code = prependChunkCodePreservingDirectives(chunk.code, injectedCode);
14826
+ }
14827
+ }
14449
14828
  function createRenderStartHook(state) {
14450
14829
  const { ctx, subPackageMeta, buildTarget } = state;
14451
14830
  return function renderStart() {
@@ -14471,6 +14850,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
14471
14850
  const { scanService, configService } = ctx;
14472
14851
  const astEngine = resolveAstEngine(configService.weappViteConfig);
14473
14852
  const injectRequestGlobalsOptions = resolveInjectRequestGlobalsOptions(configService.weappViteConfig?.injectRequestGlobals, configService.packageJson);
14853
+ const npmBuildCandidateDependencies = resolveNpmBuildCandidateDependencyRecordSync(ctx, configService.packageJson);
14474
14854
  return async function generateBundle(_options, bundle) {
14475
14855
  const rolldownBundle = bundle;
14476
14856
  await flushIndependentBuilds.call(this, state);
@@ -14479,9 +14859,9 @@ function createGenerateBundleHook(state, isPluginBuild) {
14479
14859
  if (!shouldRewriteBundleNpmImports(configService.platform)) {
14480
14860
  for (const output of Object.values(rolldownBundle)) {
14481
14861
  if (output?.type !== "chunk") continue;
14482
- rewriteChunkNpmImportsToLocalRoot(output, "", void 0, configService.packageJson.dependencies, { astEngine });
14862
+ rewriteChunkNpmImportsToLocalRoot(output, "", void 0, npmBuildCandidateDependencies, { astEngine });
14483
14863
  }
14484
- rewriteJsonNpmImportsToLocalRoot(rolldownBundle, "", void 0, configService.packageJson.dependencies);
14864
+ rewriteJsonNpmImportsToLocalRoot(rolldownBundle, "", void 0, npmBuildCandidateDependencies);
14485
14865
  }
14486
14866
  return;
14487
14867
  }
@@ -14586,7 +14966,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
14586
14966
  configService,
14587
14967
  entriesMap: state.entriesMap
14588
14968
  });
14589
- if (shouldRewriteBundleNpmImports(configService.platform)) rewriteBundleNpmImportsByPlatform(configService.platform, rolldownBundle, configService.packageJson.dependencies, configService.weappViteConfig?.npm?.alipayNpmMode, { astEngine });
14969
+ if (shouldRewriteBundleNpmImports(configService.platform)) rewriteBundleNpmImportsByPlatform(configService.platform, rolldownBundle, npmBuildCandidateDependencies, configService.weappViteConfig?.npm?.alipayNpmMode, { astEngine });
14590
14970
  else {
14591
14971
  const localSubPackageMetas = [...(scanService.subPackageMap ?? /* @__PURE__ */ new Map()).values()].filter((meta) => Array.isArray(meta?.subPackage?.dependencies) && meta.subPackage.dependencies.length > 0);
14592
14972
  for (const meta of localSubPackageMetas) {
@@ -14594,19 +14974,29 @@ function createGenerateBundleHook(state, isPluginBuild) {
14594
14974
  if (output?.type !== "chunk") continue;
14595
14975
  const chunk = output;
14596
14976
  if (chunk.fileName === meta.subPackage.root || !chunk.fileName.startsWith(`${meta.subPackage.root}/`)) continue;
14597
- rewriteChunkNpmImportsToLocalRoot(chunk, meta.subPackage.root, meta.subPackage.dependencies, configService.packageJson.dependencies, { astEngine });
14977
+ rewriteChunkNpmImportsToLocalRoot(chunk, meta.subPackage.root, meta.subPackage.dependencies, npmBuildCandidateDependencies, { astEngine });
14598
14978
  }
14599
- rewriteJsonNpmImportsToLocalRoot(rolldownBundle, meta.subPackage.root, meta.subPackage.dependencies, configService.packageJson.dependencies);
14979
+ rewriteJsonNpmImportsToLocalRoot(rolldownBundle, meta.subPackage.root, meta.subPackage.dependencies, npmBuildCandidateDependencies);
14600
14980
  }
14601
14981
  }
14602
14982
  const injectWeapiGlobalName = resolveInjectWeapiGlobalName(state);
14603
14983
  if (injectWeapiGlobalName) rewriteBundlePlatformApi(rolldownBundle, injectWeapiGlobalName, { astEngine });
14604
14984
  rewriteBundleDynamicGlobalResolution(rolldownBundle);
14985
+ const installerChunks = injectRequestGlobalsOptions?.targets?.length ? injectRequestGlobalsBundleRuntime(rolldownBundle, injectRequestGlobalsOptions.targets) : /* @__PURE__ */ new Map();
14605
14986
  if (injectRequestGlobalsOptions?.targets?.length) {
14606
- const installerChunks = injectRequestGlobalsBundleRuntime(rolldownBundle, injectRequestGlobalsOptions.targets);
14607
14987
  injectRequestGlobalsPassiveBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, state.entriesMap);
14608
14988
  injectRequestGlobalsLocalBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, state.entriesMap);
14609
- }
14989
+ injectAxiosFetchAdapterEnv(rolldownBundle);
14990
+ }
14991
+ const appPreludeOptions = resolveAppPreludeOptions(state);
14992
+ injectAppPreludeCode(rolldownBundle, await resolveAppPreludeCode(scanService.appEntry?.preludePath), {
14993
+ ...appPreludeOptions,
14994
+ enabled: appPreludeOptions.enabled || injectRequestGlobalsOptions?.prelude === true
14995
+ }, state, {
14996
+ enabled: injectRequestGlobalsOptions?.prelude === true,
14997
+ installerChunks,
14998
+ targets: injectRequestGlobalsOptions?.targets ?? []
14999
+ }, (asset) => this.emitFile(asset));
14610
15000
  refreshModuleGraph(this, state);
14611
15001
  if (configService.weappViteConfig?.debug?.watchFiles) {
14612
15002
  const watcherService = ctx.watcherService;
@@ -14909,10 +15299,10 @@ function createLoadHook(state) {
14909
15299
  const requestGlobalsTargets = resolveRequestGlobalsTargets();
14910
15300
  const passiveRequestGlobalsTargets = result && typeof result === "object" && "code" in result ? resolvePassiveRequestGlobalsTargets(result.code) : [];
14911
15301
  if (requestGlobalsTargets.length === 0 && passiveRequestGlobalsTargets.length > 0) return injectRequestGlobalsIntoLoadResult(result, sourceId, passiveRequestGlobalsTargets, { passiveLocalBindings: true });
14912
- if (!injectOptions || configService.weappLibConfig?.enabled) return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets);
14913
- if (!await ensureWeapiAvailable(this, sourceId)) return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets);
15302
+ if (!injectOptions || configService.weappLibConfig?.enabled) return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, { localBindings: true });
15303
+ if (!await ensureWeapiAvailable(this, sourceId)) return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, { localBindings: true });
14914
15304
  if (result && typeof result === "object" && "code" in result) {
14915
- const requestGlobalsInjectedResult = injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets);
15305
+ const requestGlobalsInjectedResult = injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, { localBindings: true });
14916
15306
  const platform = getMiniProgramPlatformGlobalKey(configService.platform) ?? "";
14917
15307
  const injectedCode = createWeapiInjectionCode({
14918
15308
  globalName: injectOptions.globalName,
@@ -30694,6 +31084,7 @@ function createCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, con
30694
31084
  const scopedSlotsCompiler = configService.weappViteConfig?.vue?.template?.scopedSlotsCompiler ?? "auto";
30695
31085
  const scopedSlotsRequireProps = configService.weappViteConfig?.vue?.template?.scopedSlotsRequireProps ?? scopedSlotsCompiler !== "augmented";
30696
31086
  const slotMultipleInstance = configService.weappViteConfig?.vue?.template?.slotMultipleInstance ?? true;
31087
+ const htmlTagToWxml = configService.weappViteConfig?.vue?.template?.htmlTagToWxml;
30697
31088
  const classStyleRuntimeConfig = configService.weappViteConfig?.vue?.template?.classStyleRuntime ?? "js";
30698
31089
  const objectLiteralBindMode = configService.weappViteConfig?.vue?.template?.objectLiteralBindMode ?? "runtime";
30699
31090
  const mustacheInterpolation = configService.weappViteConfig?.vue?.template?.mustacheInterpolation ?? "compact";
@@ -30731,6 +31122,7 @@ function createCompileVueFileOptions(ctx, pluginCtx, vuePath, isPage, isApp, con
30731
31122
  },
30732
31123
  template: {
30733
31124
  platform: templatePlatformOptions.templatePlatform,
31125
+ htmlTagToWxml,
30734
31126
  scopedSlotsCompiler,
30735
31127
  scopedSlotsRequireProps,
30736
31128
  slotMultipleInstance,
@@ -33133,6 +33525,13 @@ function arrangePlugins(config, ctx, subPackageMeta) {
33133
33525
  //#endregion
33134
33526
  //#region src/runtime/config/internal/merge/miniprogram.ts
33135
33527
  const PACKAGE_NAME_REGEX = /[-/\\^$*+?.()|[\]{}]/g;
33528
+ const PATH_SEPARATOR_SPLIT_REGEX = /[/\\]+/;
33529
+ function escapeRegex(value) {
33530
+ return value.replace(PACKAGE_NAME_REGEX, "\\$&");
33531
+ }
33532
+ function createAbsolutePathPattern(value) {
33533
+ return value.split(PATH_SEPARATOR_SPLIT_REGEX).map((segment) => escapeRegex(segment)).join("[/\\\\]+");
33534
+ }
33136
33535
  function resolveMiniprogramWatchInclude(options) {
33137
33536
  const watchInclude = [path.join(options.cwd, options.srcRoot, "**")];
33138
33537
  if (!options.pluginRoot) return watchInclude;
@@ -33149,9 +33548,17 @@ function mergeMiniprogram(options, ...configs) {
33149
33548
  return createLogger("warn");
33150
33549
  };
33151
33550
  const external = [];
33152
- if (packageJson?.dependencies) external.push(...Object.keys(packageJson.dependencies).map((pkg) => {
33153
- return new RegExp(`^${pkg.replace(PACKAGE_NAME_REGEX, "\\$&")}(\\/|$)`);
33154
- }));
33551
+ const npmBuildCandidates = packageJson ? resolveNpmBuildCandidateDependenciesSync(ctx, packageJson) : [];
33552
+ if (npmBuildCandidates.length > 0) {
33553
+ const builtinAliases = resolveBuiltinPackageAliases();
33554
+ external.push(...npmBuildCandidates.map((pkg) => {
33555
+ return new RegExp(`^${escapeRegex(pkg)}(\\/|$)`);
33556
+ }), ...builtinAliases.filter(({ find }) => {
33557
+ return npmBuildCandidates.some((dep) => find === dep || find.startsWith(`${dep}/`));
33558
+ }).map(({ replacement }) => {
33559
+ return new RegExp(`^${createAbsolutePathPattern(replacement)}(?:\\?.*)?$`);
33560
+ }));
33561
+ }
33155
33562
  const rolldownOptions = {
33156
33563
  external,
33157
33564
  plugins: oxcRolldownPlugin ? [oxcRolldownPlugin] : void 0
@@ -34228,6 +34635,16 @@ function resolveSubPackageEntries(subPackage) {
34228
34635
  function resolveScanAppBasename(absoluteSrcRoot) {
34229
34636
  return path.resolve(absoluteSrcRoot, "app");
34230
34637
  }
34638
+ function resolveScanAppPreludeBasename(absoluteSrcRoot) {
34639
+ return path.resolve(absoluteSrcRoot, "app.prelude");
34640
+ }
34641
+ async function resolveScanAppPreludePath(absoluteSrcRoot) {
34642
+ const basename = resolveScanAppPreludeBasename(absoluteSrcRoot);
34643
+ for (const extension of jsExtensions) {
34644
+ const candidate = `${basename}.${extension}`;
34645
+ if (await fs.pathExists(candidate)) return candidate;
34646
+ }
34647
+ }
34231
34648
  function resolveScanPluginBasename(absolutePluginRoot) {
34232
34649
  return absolutePluginRoot ? path.resolve(absolutePluginRoot, "plugin") : void 0;
34233
34650
  }
@@ -34316,10 +34733,11 @@ function createScanService(ctx) {
34316
34733
  let { path: appConfigFile } = await findJsonEntry(appBasename);
34317
34734
  const discoveredAppConfigFile = appConfigFile;
34318
34735
  const { path: appEntryPath } = await findJsEntry(appBasename);
34736
+ const appPreludePath = await resolveScanAppPreludePath(appDirname);
34319
34737
  const vueAppPath = await findVueEntry(appBasename);
34320
34738
  let configFromVue;
34321
34739
  if (!appConfigFile && vueAppPath) {
34322
- const { extractConfigFromVue } = await import("./file-CLt_iCyi.mjs");
34740
+ const { extractConfigFromVue } = await import("./file-BKp0PdYt.mjs");
34323
34741
  configFromVue = await extractConfigFromVue(vueAppPath);
34324
34742
  if (configFromVue) appConfigFile = vueAppPath;
34325
34743
  }
@@ -34343,6 +34761,7 @@ function createScanService(ctx) {
34343
34761
  if (isObject(config)) {
34344
34762
  const resolvedAppEntry = {
34345
34763
  path: appEntryPath || vueAppPath,
34764
+ preludePath: appPreludePath,
34346
34765
  json: config,
34347
34766
  jsonPath: appConfigFile,
34348
34767
  type: "app"
@@ -0,0 +1,2 @@
1
+ import { n as extractConfigFromVue } from "./file-DZdM8x0_.mjs";
2
+ export { extractConfigFromVue };
@@ -86,7 +86,7 @@ function resolveAutoRoutesMacroImportPath() {
86
86
  }
87
87
  async function resolveAutoRoutesInlineSnapshot() {
88
88
  try {
89
- const { getCompilerContext } = await import("./getInstance-CoI8eyed.mjs");
89
+ const { getCompilerContext } = await import("./getInstance-CIT2xNbn.mjs");
90
90
  const compilerContext = getCompilerContext();
91
91
  const service = compilerContext.autoRoutesService;
92
92
  const reference = service?.getReference?.();
@@ -0,0 +1,2 @@
1
+ import { i as getCompilerContext } from "./createContext-DZzBkyLu.mjs";
2
+ export { getCompilerContext };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as Ref, An as createWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, Dn as WeappViteHostMeta, E as InlineConfig, En as WEAPP_VITE_HOST_NAME, F as RolldownPlugin, I as RolldownPluginOption, L as RolldownWatchOptions, M as RolldownBuild, Mn as resolveWeappViteHostMeta, N as RolldownOptions, O as Plugin, On as WeappViteRuntime, P as RolldownOutput, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, jn as isWeappViteHost, k as PluginOption, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-BMpfbpQb.mjs";
1
+ import { A as Ref, An as WEAPP_VITE_HOST_NAME, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fn as isWeappViteHost, I as RolldownPluginOption, In as resolveWeappViteHostMeta, L as RolldownWatchOptions, M as RolldownBuild, Mn as WeappViteRuntime, N as RolldownOptions, Nn as applyWeappViteHostMeta, O as Plugin, P as RolldownOutput, Pn as createWeappViteHostMeta, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, jn as WeappViteHostMeta, k as PluginOption, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-c4UHLLoh.mjs";
2
2
  import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-58wbbRDf.mjs";
3
3
 
4
4
  //#region src/createContext.d.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createCompilerContext } from "./createContext-BWIKo9nG.mjs";
1
+ import { t as createCompilerContext } from "./createContext-DZzBkyLu.mjs";
2
2
  import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-wnfVS9jE.mjs";
3
3
  import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BzPJL4F-.mjs";
4
4
  import { t as defineConfig } from "./config-B2xtjEug.mjs";
package/dist/json.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-BMpfbpQb.mjs";
1
+ import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-c4UHLLoh.mjs";
2
2
  export { App, Component, Page, Sitemap, Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
package/dist/mcp.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _t as WeappMcpConfig } from "./config-BMpfbpQb.mjs";
1
+ import { yt as WeappMcpConfig } from "./config-c4UHLLoh.mjs";
2
2
  import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
3
3
 
4
4
  //#region src/mcp.d.ts
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { c as Resolver } from "./index-6QUk3Zbc.mjs";
2
2
  import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-DiEBrMtj.mjs";
3
- import { $ as WeappDebugConfig, $t as NpmBuildOptions, A as Ref, At as ChunksConfig, B as BindingErrorLike, Bt as GenerateTemplateEntry, Cn as WeappManagedSharedTsconfigConfig, Ct as WeappVueTemplateConfig, D as MethodDefinitions, Dn as WeappViteHostMeta, Dt as AliasOptions, E as InlineConfig, Et as Alias, F as RolldownPlugin, Ft as GenerateFileType, G as EntryJsonFragment, Gt as GenerateTemplatesConfig, H as BaseEntry, Ht as GenerateTemplateFileSource, I as RolldownPluginOption, It as GenerateFilenamesOptions, J as ScanComponentItem, Jt as JsonMergeContext, K as PageEntry, Kt as JsFormat, L as RolldownWatchOptions, Lt as GenerateOptions, M as RolldownBuild, Mt as CopyOptions, N as RolldownOptions, Nt as GenerateDirsOptions, O as Plugin, On as WeappViteRuntime, Ot as AlipayNpmMode, P as RolldownOutput, Pt as GenerateExtensionsOptions, Q as UserConfig, Qt as MpPlatform, R as RolldownWatcher, Rt as GenerateTemplate, Sn as WeappManagedServerTsconfigConfig, St as WeappVueConfig, T as ConfigEnv, Tn as WeappWebConfig, Tt as WeappWorkerConfig, U as ComponentEntry, Ut as GenerateTemplateInlineSource, V as AppEntry, Vt as GenerateTemplateFactory, W as Entry, Wt as GenerateTemplateScope, X as ProjectConfig, Xt as JsonMergeStage, Y as WxmlDep, Yt as JsonMergeFunction, Z as SubPackageMetaValue, Zt as JsonMergeStrategy, _n as WeappLibFileName, _t as WeappMcpConfig, an as SharedChunkMode, at as EnhanceOptions, b as ChangeEvent, bn as WeappManagedAppTsconfigConfig, bt as WeappRouteRules, cn as SubPackage, ct as MultiPlatformConfig, dn as SubPackageStyleEntry, dt as WeappAutoRoutesInclude, en as NpmMainPackageConfig, et as WeappForwardConsoleConfig, fn as SubPackageStyleScope, ft as WeappAutoRoutesIncludePattern, gn as WeappLibEntryContext, gt as WeappInjectWeapiConfig, hn as WeappLibDtsOptions, ht as WeappInjectRequestGlobalsTarget, in as SharedChunkDynamicImports, it as AutoImportComponentsOption, j as ResolvedConfig, jt as CopyGlobs, k as PluginOption, kt as BuildNpmPackageMeta, ln as SubPackageStyleConfigEntry, lt as ScanWxmlOptions, mn as WeappLibConfig, mt as WeappInjectRequestGlobalsConfig, nn as NpmSubPackageConfig, nt as WeappViteConfig, on as SharedChunkOverride, ot as EnhanceWxmlOptions, pn as WeappLibComponentJson, pt as WeappHmrConfig, q as ComponentsMap, qt as JsonConfig, rn as ResolvedAlias, rt as AutoImportComponents, sn as SharedChunkStrategy, st as HandleWxmlOptions, tn as NpmPluginPackageConfig, tt as WeappForwardConsoleLogLevel, un as SubPackageStyleConfigObject, ut as WeappAutoRoutesConfig, vn as WeappLibInternalDtsOptions, vt as WeappNpmConfig, w as ComputedDefinitions, wn as WeappManagedTypeScriptConfig, wt as WeappWevuConfig, x as WeappVitePluginApi, xn as WeappManagedNodeTsconfigConfig, xt as WeappSubPackageConfig, yn as WeappLibVueTscOptions, yt as WeappRouteRule, z as ViteDevServer, zt as GenerateTemplateContext } from "./config-BMpfbpQb.mjs";
4
- export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, ComputedDefinitions, ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmMainPackageConfig, NpmPluginPackageConfig, NpmSubPackageConfig, PageEntry, Plugin, PluginOption, ProjectConfig, Ref, ResolvedAlias, ResolvedConfig, Resolver, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, ViteDevServer, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
3
+ import { $ as WeappDebugConfig, $t as JsonMergeStrategy, A as Ref, At as AlipayNpmMode, B as BindingErrorLike, Bt as GenerateTemplate, Cn as WeappLibVueTscOptions, Ct as WeappSubPackageConfig, D as MethodDefinitions, Dn as WeappManagedSharedTsconfigConfig, Dt as WeappWorkerConfig, E as InlineConfig, En as WeappManagedServerTsconfigConfig, Et as WeappWevuConfig, F as RolldownPlugin, Ft as GenerateDirsOptions, G as EntryJsonFragment, Gt as GenerateTemplateInlineSource, H as BaseEntry, Ht as GenerateTemplateEntry, I as RolldownPluginOption, It as GenerateExtensionsOptions, J as ScanComponentItem, Jt as JsFormat, K as PageEntry, Kt as GenerateTemplateScope, L as RolldownWatchOptions, Lt as GenerateFileType, M as RolldownBuild, Mn as WeappViteRuntime, Mt as ChunksConfig, N as RolldownOptions, Nt as CopyGlobs, O as Plugin, On as WeappManagedTypeScriptConfig, Ot as Alias, P as RolldownOutput, Pt as CopyOptions, Q as UserConfig, Qt as JsonMergeStage, R as RolldownWatcher, Rt as GenerateFilenamesOptions, Sn as WeappLibInternalDtsOptions, St as WeappRouteRules, T as ConfigEnv, Tn as WeappManagedNodeTsconfigConfig, Tt as WeappVueTemplateConfig, U as ComponentEntry, Ut as GenerateTemplateFactory, V as AppEntry, Vt as GenerateTemplateContext, W as Entry, Wt as GenerateTemplateFileSource, X as ProjectConfig, Xt as JsonMergeContext, Y as WxmlDep, Yt as JsonConfig, Z as SubPackageMetaValue, Zt as JsonMergeFunction, _n as WeappLibComponentJson, _t as WeappInjectRequestGlobalsTarget, an as NpmStrategy, at as EnhanceOptions, b as ChangeEvent, bn as WeappLibEntryContext, bt as WeappNpmConfig, cn as SharedChunkDynamicImports, ct as MultiPlatformConfig, dn as SharedChunkStrategy, dt as WeappAppPreludeMode, en as MpPlatform, et as WeappForwardConsoleConfig, fn as SubPackage, ft as WeappAutoRoutesConfig, gn as SubPackageStyleScope, gt as WeappInjectRequestGlobalsConfig, hn as SubPackageStyleEntry, ht as WeappHmrConfig, in as NpmPluginPackageConfig, it as AutoImportComponentsOption, j as ResolvedConfig, jn as WeappViteHostMeta, jt as BuildNpmPackageMeta, k as PluginOption, kn as WeappWebConfig, kt as AliasOptions, ln as SharedChunkMode, lt as ScanWxmlOptions, mn as SubPackageStyleConfigObject, mt as WeappAutoRoutesIncludePattern, nn as NpmDependencyPattern, nt as WeappViteConfig, on as NpmSubPackageConfig, ot as EnhanceWxmlOptions, pn as SubPackageStyleConfigEntry, pt as WeappAutoRoutesInclude, q as ComponentsMap, qt as GenerateTemplatesConfig, rn as NpmMainPackageConfig, rt as AutoImportComponents, sn as ResolvedAlias, st as HandleWxmlOptions, tn as NpmBuildOptions, tt as WeappForwardConsoleLogLevel, un as SharedChunkOverride, ut as WeappAppPreludeConfig, vn as WeappLibConfig, vt as WeappInjectWeapiConfig, w as ComputedDefinitions, wn as WeappManagedAppTsconfigConfig, wt as WeappVueConfig, x as WeappVitePluginApi, xn as WeappLibFileName, xt as WeappRouteRule, yn as WeappLibDtsOptions, yt as WeappMcpConfig, z as ViteDevServer, zt as GenerateOptions } from "./config-c4UHLLoh.mjs";
4
+ export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, ComputedDefinitions, ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, Plugin, PluginOption, ProjectConfig, Ref, ResolvedAlias, ResolvedConfig, Resolver, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, ViteDevServer, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.14.3",
4
+ "version": "6.15.0",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -100,7 +100,7 @@
100
100
  "fdir": "^6.5.0",
101
101
  "htmlparser2": "^12.0.0",
102
102
  "local-pkg": "^1.1.2",
103
- "lru-cache": "^11.3.2",
103
+ "lru-cache": "^11.3.3",
104
104
  "magic-string": "^0.30.21",
105
105
  "merge": "^2.1.1",
106
106
  "p-queue": "^9.1.2",
@@ -108,11 +108,11 @@
108
108
  "pathe": "^2.0.3",
109
109
  "picomatch": "^4.0.4",
110
110
  "postcss": "^8.5.9",
111
- "rolldown": "1.0.0-rc.13",
111
+ "rolldown": "1.0.0-rc.15",
112
112
  "rolldown-plugin-dts": "0.23.2",
113
113
  "semver": "^7.7.4",
114
114
  "typescript": "^6.0.2",
115
- "vite": "8.0.7",
115
+ "vite": "8.0.8",
116
116
  "vite-tsconfig-paths": "^6.1.1",
117
117
  "vue": "^3.5.32",
118
118
  "vue-tsc": "^3.2.6",
@@ -120,17 +120,17 @@
120
120
  "@weapp-core/logger": "3.1.1",
121
121
  "@weapp-core/schematics": "6.0.4",
122
122
  "@weapp-core/shared": "3.0.3",
123
- "@weapp-vite/ast": "6.14.3",
123
+ "@weapp-vite/ast": "6.15.0",
124
124
  "@weapp-vite/mcp": "1.2.1",
125
125
  "@weapp-vite/miniprogram-automator": "1.0.2",
126
126
  "@weapp-vite/volar": "2.0.8",
127
- "@weapp-vite/web": "1.3.12",
127
+ "@weapp-vite/web": "1.3.13",
128
128
  "@wevu/api": "0.2.3",
129
129
  "@wevu/web-apis": "1.2.2",
130
- "rolldown-require": "2.0.12",
130
+ "rolldown-require": "2.0.13",
131
131
  "vite-plugin-performance": "2.0.1",
132
132
  "weapp-ide-cli": "5.2.2",
133
- "wevu": "6.14.3"
133
+ "wevu": "6.15.0"
134
134
  },
135
135
  "publishConfig": {
136
136
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { n as extractConfigFromVue } from "./file-B1jggPxp.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { i as getCompilerContext } from "./createContext-BWIKo9nG.mjs";
2
- export { getCompilerContext };