weapp-vite 6.15.10 → 6.15.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +5 -4
- package/dist/{config-BDvKS_M_.d.mts → config-DzoHnvv-.d.mts} +20 -9
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-BOcTbMN3.mjs → createContext-CySjzbQy.mjs} +271 -127
- package/dist/{file-BSDfToRq.mjs → file-pbdfOAKg.mjs} +1 -1
- package/dist/file-slN_aOEg.mjs +2 -0
- package/dist/getInstance-BGGhJCLI.mjs +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +5 -5
- package/dist/file-cvdXNNJc.mjs +0 -2
- package/dist/getInstance-Bl0vmTQo.mjs +0 -2
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-
|
|
1
|
+
import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-CySjzbQy.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-
|
|
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-CySjzbQy.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
3
|
+
import { h as VERSION } from "./file-pbdfOAKg.mjs";
|
|
4
4
|
import { a as resolveWeappMcpConfig, o as startWeappViteMcpServer } from "./mcp-DRlj32v4.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path, { posix } from "pathe";
|
|
@@ -2114,7 +2114,8 @@ function registerPrepareCommand(cli) {
|
|
|
2114
2114
|
isDev: false,
|
|
2115
2115
|
mode: typeof options.mode === "string" ? options.mode : "development",
|
|
2116
2116
|
configFile: resolveConfigFile(options),
|
|
2117
|
-
syncSupportFiles: false
|
|
2117
|
+
syncSupportFiles: false,
|
|
2118
|
+
preloadAppEntry: false
|
|
2118
2119
|
}));
|
|
2119
2120
|
logger_default.info("已生成 .weapp-vite 支持文件。");
|
|
2120
2121
|
} catch (error) {
|
|
@@ -2124,7 +2125,7 @@ function registerPrepareCommand(cli) {
|
|
|
2124
2125
|
}
|
|
2125
2126
|
//#endregion
|
|
2126
2127
|
//#region package.json
|
|
2127
|
-
var version = "6.15.
|
|
2128
|
+
var version = "6.15.12";
|
|
2128
2129
|
//#endregion
|
|
2129
2130
|
//#region src/cli/devHotkeys/format.ts
|
|
2130
2131
|
const FULLWIDTH_ASCII_START = 65281;
|
|
@@ -39,6 +39,13 @@ declare module 'vite' {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
|
+
//#region src/utils/importMeta.d.ts
|
|
43
|
+
interface ImportMetaDefineRegistry {
|
|
44
|
+
defineEntries: Record<string, any>;
|
|
45
|
+
envObject: Record<string, any>;
|
|
46
|
+
envMemberAccess: Record<string, any>;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
42
49
|
//#region src/types/config/foundation.d.ts
|
|
43
50
|
type NpmBuildOptions = InlineConfig;
|
|
44
51
|
type MpPlatform$1 = MpPlatform;
|
|
@@ -356,6 +363,9 @@ interface ScanWxmlOptions {
|
|
|
356
363
|
*/
|
|
357
364
|
interface HandleWxmlOptions {
|
|
358
365
|
defineImportMetaEnv?: Record<string, any>;
|
|
366
|
+
importMetaDefineRegistry?: ImportMetaDefineRegistry;
|
|
367
|
+
importMetaRelativePath?: string;
|
|
368
|
+
importMetaExtension?: string;
|
|
359
369
|
removeComment?: boolean;
|
|
360
370
|
transformEvent?: boolean;
|
|
361
371
|
scriptModuleExtension?: string;
|
|
@@ -1136,12 +1146,16 @@ interface ConfigService {
|
|
|
1136
1146
|
packageManager: DetectResult;
|
|
1137
1147
|
packageInfo: PackageInfo;
|
|
1138
1148
|
setDefineEnv: (key: string, value: any) => void;
|
|
1149
|
+
setImportMetaEnvDefineOverride: (define?: Record<string, any>) => void;
|
|
1139
1150
|
load: (options?: Partial<LoadConfigOptions>) => Promise<LoadConfigResult>;
|
|
1140
1151
|
mergeWorkers: (...configs: Partial<InlineConfig>[]) => InlineConfig;
|
|
1141
1152
|
merge: (subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig | undefined>[]) => InlineConfig;
|
|
1142
1153
|
mergeWeb: (...configs: Partial<InlineConfig | undefined>[]) => InlineConfig | undefined;
|
|
1143
1154
|
mergeInlineConfig: (...configs: Partial<InlineConfig>[]) => InlineConfig;
|
|
1155
|
+
readonly importMetaDefineEntries: Record<string, any>;
|
|
1144
1156
|
readonly defineImportMetaEnv: Record<string, any>;
|
|
1157
|
+
readonly importMetaEnvDefineOverride?: Record<string, any>;
|
|
1158
|
+
readonly importMetaDefineRegistry: ImportMetaDefineRegistry;
|
|
1145
1159
|
readonly cwd: string;
|
|
1146
1160
|
readonly isDev: boolean;
|
|
1147
1161
|
readonly emitDefaultAutoImportOutputs: boolean;
|
|
@@ -1394,6 +1408,7 @@ interface RuntimeState {
|
|
|
1394
1408
|
config: {
|
|
1395
1409
|
packageInfo: PackageInfo;
|
|
1396
1410
|
defineEnv: Record<string, any>;
|
|
1411
|
+
importMetaEnvDefineOverride?: Record<string, any>;
|
|
1397
1412
|
packageManager: DetectResult;
|
|
1398
1413
|
options: LoadConfigResult;
|
|
1399
1414
|
};
|
|
@@ -1567,7 +1582,7 @@ type UserConfigFnObjectPlain<T extends UserConfig$1 = UserConfig$1> = (env: Conf
|
|
|
1567
1582
|
type UserConfigFnObject<T extends UserConfig$1 = UserConfig$1> = (env: ConfigEnv) => T;
|
|
1568
1583
|
type UserConfigFnPromise<T extends UserConfig$1 = UserConfig$1> = (env: ConfigEnv) => Promise<T>;
|
|
1569
1584
|
type UserConfigFn<T extends UserConfig$1 = UserConfig$1> = (env: ConfigEnv) => T | Promise<T>;
|
|
1570
|
-
type UserConfigExport<T extends UserConfig$1 = UserConfig$1> = T | Promise<T> |
|
|
1585
|
+
type UserConfigExport<T extends UserConfig$1 = UserConfig$1> = T | Promise<T> | UserConfigFnObject<T> | UserConfigFnPromise<T> | UserConfigFn<T>;
|
|
1571
1586
|
declare module 'vite' {
|
|
1572
1587
|
interface UserConfig {
|
|
1573
1588
|
weapp?: WeappViteConfig;
|
|
@@ -1575,14 +1590,10 @@ declare module 'vite' {
|
|
|
1575
1590
|
}
|
|
1576
1591
|
/**
|
|
1577
1592
|
* @description 为 weapp-vite 配置提供类型提示与推断
|
|
1578
|
-
* @description
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1593
|
+
* @description 注意:这里不能继续使用对象/Promise/函数的多重重载;
|
|
1594
|
+
* @description 否则 `() => ({})` 这类函数式配置里的对象字面量会丢失上下文类型,
|
|
1595
|
+
* @description 导致 `platform` 等联合字面量字段被宽化为 `string`。
|
|
1581
1596
|
*/
|
|
1582
|
-
declare function defineConfig(config:
|
|
1583
|
-
declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
|
|
1584
|
-
declare function defineConfig(config: UserConfigFnObjectPlain): UserConfigFnObjectPlain;
|
|
1585
|
-
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
1586
|
-
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
1597
|
+
declare function defineConfig<T extends UserConfigExport>(config: T): T;
|
|
1587
1598
|
//#endregion
|
|
1588
1599
|
export { WeappDebugConfig as $, JsonConfig as $t, Ref as A, WeappManagedServerTsconfigConfig as An, WeappWevuConfig as At, BindingErrorLike as B, resolveWeappViteHostMeta as Bn, GenerateExtensionsOptions as Bt, LoadConfigOptions as C, WeappLibDtsOptions as Cn, WeappRequestRuntimeConfig as Ct, MethodDefinitions$1 as D, WeappLibVueTscOptions as Dn, WeappVueConfig as Dt, InlineConfig$1 as E, WeappLibInternalDtsOptions as En, WeappSubPackageConfig as Et, RolldownPlugin as F, WeappViteHostMeta as Fn, BuildNpmPackageMeta as Ft, EntryJsonFragment as G, GenerateTemplateContext as Gt, BaseEntry as H, GenerateFilenamesOptions as Ht, RolldownPluginOption as I, WeappViteRuntime as In, ChunksConfig as It, ScanComponentItem as J, GenerateTemplateFileSource as Jt, PageEntry as K, GenerateTemplateEntry as Kt, RolldownWatchOptions as L, applyWeappViteHostMeta as Ln, CopyGlobs as Lt, RolldownBuild as M, WeappManagedTypeScriptConfig as Mn, Alias as Mt, RolldownOptions as N, WeappWebConfig as Nn, AliasOptions as Nt, Plugin$1 as O, WeappManagedAppTsconfigConfig as On, WeappVueTemplateConfig as Ot, RolldownOutput$1 as P, WEAPP_VITE_HOST_NAME as Pn, AlipayNpmMode as Pt, UserConfig$2 as Q, JsFormat as Qt, RolldownWatcher$1 as R, createWeappViteHostMeta as Rn, CopyOptions as Rt, CompilerContext as S, WeappLibConfig as Sn, WeappNpmConfig as St, ConfigEnv$1 as T, WeappLibFileName as Tn, WeappRouteRules as Tt, ComponentEntry as U, GenerateOptions as Ut, AppEntry as V, GenerateFileType as Vt, Entry as W, GenerateTemplate as Wt, ProjectConfig as X, GenerateTemplateScope as Xt, WxmlDep as Y, GenerateTemplateInlineSource as Yt, SubPackageMetaValue as Z, GenerateTemplatesConfig as Zt, definePageJson as _, SubPackageStyleConfigEntry as _n, WeappInjectRequestGlobalsTarget as _t, UserConfigFnNoEnvPlain as a, NpmBuildOptions as an, EnhanceOptions as at, ChangeEvent as b, SubPackageStyleScope as bn, WeappInjectWebRuntimeGlobalsTarget as bt, UserConfigFnPromise as c, NpmPluginPackageConfig as cn, MultiPlatformConfig as ct, Component$1 as d, ResolvedAlias as dn, WeappAppPreludeMode as dt, JsonMergeContext as en, WeappForwardConsoleConfig as et, Page$1 as f, SharedChunkDynamicImports as fn, WeappAutoRoutesConfig as ft, defineComponentJson as g, SubPackage as gn, WeappInjectRequestGlobalsConfig as gt, defineAppJson as h, SharedChunkStrategy as hn, WeappHmrConfig as ht, UserConfigFnNoEnv as i, MpPlatform$1 as in, AutoImportComponentsOption as it, ResolvedConfig as j, WeappManagedSharedTsconfigConfig as jn, WeappWorkerConfig as jt, PluginOption as k, WeappManagedNodeTsconfigConfig as kn, WeappWebRuntimeConfig as kt, defineConfig as l, NpmStrategy as ln, ScanWxmlOptions as lt, Theme$1 as m, SharedChunkOverride as mn, WeappAutoRoutesIncludePattern as mt, UserConfigExport as n, JsonMergeStage as nn, WeappViteConfig as nt, UserConfigFnObject as o, NpmDependencyPattern as on, EnhanceWxmlOptions as ot, Sitemap$1 as p, SharedChunkMode as pn, WeappAutoRoutesInclude as pt, ComponentsMap as q, GenerateTemplateFactory as qt, UserConfigFn as r, JsonMergeStrategy as rn, AutoImportComponents as rt, UserConfigFnObjectPlain as s, NpmMainPackageConfig as sn, HandleWxmlOptions as st, UserConfig$1 as t, JsonMergeFunction as tn, WeappForwardConsoleLogLevel as tt, App$1 as u, NpmSubPackageConfig as un, WeappAppPreludeConfig as ut, defineSitemapJson as v, SubPackageStyleConfigObject as vn, WeappInjectWeapiConfig as vt, ComputedDefinitions$1 as w, WeappLibEntryContext as wn, WeappRouteRule as wt, WeappVitePluginApi as x, WeappLibComponentJson as xn, WeappMcpConfig as xt, defineThemeJson as y, SubPackageStyleEntry as yn, WeappInjectWebRuntimeGlobalsConfig as yt, ViteDevServer$1 as z, isWeappViteHost as zn, GenerateDirsOptions as zt };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bn as resolveWeappViteHostMeta, Fn as WeappViteHostMeta, In as WeappViteRuntime, Ln as applyWeappViteHostMeta, Pn as WEAPP_VITE_HOST_NAME, Rn 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, 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, zn as isWeappViteHost } from "./config-
|
|
1
|
+
import { Bn as resolveWeappViteHostMeta, Fn as WeappViteHostMeta, In as WeappViteRuntime, Ln as applyWeappViteHostMeta, Pn as WEAPP_VITE_HOST_NAME, Rn 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, 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, zn as isWeappViteHost } from "./config-DzoHnvv-.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 jsExtensions, a as findJsonEntry, b as vueExtensions, 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 supportedCssLangs, y as templateExtensions } from "./file-
|
|
3
|
+
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, 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 supportedCssLangs, y as templateExtensions } from "./file-pbdfOAKg.mjs";
|
|
4
4
|
import { createRequire, isBuiltin } from "node:module";
|
|
5
5
|
import path, { posix } from "pathe";
|
|
6
6
|
import path$1, { normalize, relative, win32 } from "node:path";
|
|
@@ -688,12 +688,17 @@ const EXPLICIT_NPM_DIR_RE = /^\/(?:miniprogram_npm|node_modules)\//;
|
|
|
688
688
|
const LEADING_SLASHES_RE$3 = /^\/+/;
|
|
689
689
|
const NODE_MODULES_SEGMENT = "/node_modules/";
|
|
690
690
|
const STRIP_SCRIPT_EXTENSION_RE = /\.[cm]?[jt]sx?$/;
|
|
691
|
+
const INFERRED_MINIPROGRAM_ROOTS = ["miniprogram_dist", "miniprogram"];
|
|
691
692
|
const miniprogramRootCache = /* @__PURE__ */ new Map();
|
|
692
693
|
const packageRootCache = /* @__PURE__ */ new Map();
|
|
693
694
|
const resolveFromCurrentModule = createRequire(import.meta.url);
|
|
694
695
|
function stripScriptExtension(value) {
|
|
695
696
|
return value.replace(STRIP_SCRIPT_EXTENSION_RE, "");
|
|
696
697
|
}
|
|
698
|
+
function stripInferredMiniprogramRoot(subPath) {
|
|
699
|
+
for (const miniprogramRoot of INFERRED_MINIPROGRAM_ROOTS) if (subPath === miniprogramRoot || subPath.startsWith(`${miniprogramRoot}/`)) return subPath.slice(miniprogramRoot.length).replace(LEADING_SLASHES_RE$3, "");
|
|
700
|
+
return subPath;
|
|
701
|
+
}
|
|
697
702
|
function readMiniprogramRoot(packageRoot) {
|
|
698
703
|
const cached = miniprogramRootCache.get(packageRoot);
|
|
699
704
|
if (cached !== void 0 || miniprogramRootCache.has(packageRoot)) return cached;
|
|
@@ -740,6 +745,7 @@ function normalizeAbsoluteNodeModulesImport(importee) {
|
|
|
740
745
|
let subPath = packageTokens.slice(packageTokenCount).join("/");
|
|
741
746
|
const miniprogramRoot = readMiniprogramRoot(packageRoot);
|
|
742
747
|
if (miniprogramRoot && (subPath === miniprogramRoot || subPath.startsWith(`${miniprogramRoot}/`))) subPath = subPath.slice(miniprogramRoot.length).replace(LEADING_SLASHES_RE$3, "");
|
|
748
|
+
else subPath = stripInferredMiniprogramRoot(subPath);
|
|
743
749
|
const normalizedSubPath = stripScriptExtension(subPath);
|
|
744
750
|
return normalizedSubPath ? `${packageName}/${normalizedSubPath}` : packageName;
|
|
745
751
|
}
|
|
@@ -8009,14 +8015,14 @@ function createPackageBuilder(ctx, oxcVitePlugin) {
|
|
|
8009
8015
|
return path.resolve(root, rawOutDir);
|
|
8010
8016
|
}
|
|
8011
8017
|
function resolvePackageBuildTarget({ entry, name, options, outDir }) {
|
|
8012
|
-
const
|
|
8018
|
+
const importMetaDefineEntries = ctx.configService?.importMetaDefineEntries ?? {};
|
|
8013
8019
|
const mergedOptions = defu(options, {
|
|
8014
8020
|
configFile: false,
|
|
8015
8021
|
publicDir: false,
|
|
8016
8022
|
logLevel: "silent",
|
|
8017
8023
|
root: ctx.configService?.cwd ?? process$1.cwd(),
|
|
8018
8024
|
define: {
|
|
8019
|
-
...
|
|
8025
|
+
...importMetaDefineEntries,
|
|
8020
8026
|
"process.env.NODE_ENV": JSON.stringify("production")
|
|
8021
8027
|
},
|
|
8022
8028
|
plugins: [],
|
|
@@ -8247,6 +8253,19 @@ function resolvePlatformProjectRoot(configService) {
|
|
|
8247
8253
|
if (!configService) return "dist";
|
|
8248
8254
|
return normalizeRelativeDir(resolveProjectConfigRoot(configService.projectConfig, configService.platform) ?? "dist");
|
|
8249
8255
|
}
|
|
8256
|
+
function resolveDefaultNpmDistDir(configService) {
|
|
8257
|
+
if (!configService) return ".";
|
|
8258
|
+
if (typeof configService.outDir === "string" && configService.outDir) {
|
|
8259
|
+
if (path.isAbsolute(configService.outDir)) {
|
|
8260
|
+
const relativeOutDir = path.relative(configService.cwd, configService.outDir);
|
|
8261
|
+
if (relativeOutDir && !relativeOutDir.startsWith("..") && !path.isAbsolute(relativeOutDir)) return normalizeRelativeDir(relativeOutDir);
|
|
8262
|
+
return configService.outDir;
|
|
8263
|
+
}
|
|
8264
|
+
return normalizeRelativeDir(configService.outDir);
|
|
8265
|
+
}
|
|
8266
|
+
if (shouldUseProjectRootNpmDir(configService.platform)) return resolvePlatformProjectRoot(configService);
|
|
8267
|
+
return ".";
|
|
8268
|
+
}
|
|
8250
8269
|
function getPackNpmRelationList(ctx) {
|
|
8251
8270
|
const configService = requireConfigService(ctx, "解析 npm 关联列表前必须初始化 configService。");
|
|
8252
8271
|
const isMultiPlatformEnabled = configService.multiPlatform.enabled;
|
|
@@ -8265,9 +8284,9 @@ function getPackNpmRelationList(ctx) {
|
|
|
8265
8284
|
}];
|
|
8266
8285
|
}
|
|
8267
8286
|
if (!isMultiPlatformEnabled) {
|
|
8268
|
-
if (!hasManualRelations
|
|
8287
|
+
if (!hasManualRelations) return [{
|
|
8269
8288
|
...packNpmRelationList[0],
|
|
8270
|
-
miniprogramNpmDistDir: resolvePlatformProjectRoot(configService)
|
|
8289
|
+
miniprogramNpmDistDir: shouldUseProjectRootNpmDir(configService.platform) ? resolvePlatformProjectRoot(configService) : resolveDefaultNpmDistDir(configService)
|
|
8271
8290
|
}];
|
|
8272
8291
|
return packNpmRelationList;
|
|
8273
8292
|
}
|
|
@@ -9774,6 +9793,78 @@ function createSharedBuildConfig(configService, scanService) {
|
|
|
9774
9793
|
return { build: { rolldownOptions: { output: createSharedBuildOutput(configService, () => scanService.subPackageMap.keys()) } } };
|
|
9775
9794
|
}
|
|
9776
9795
|
//#endregion
|
|
9796
|
+
//#region src/utils/importMeta.ts
|
|
9797
|
+
const IMPORT_META_ENV_PREFIX = "import.meta.env.";
|
|
9798
|
+
function parseImportMetaDefineValue(value) {
|
|
9799
|
+
if (typeof value !== "string") return value;
|
|
9800
|
+
try {
|
|
9801
|
+
return JSON.parse(value);
|
|
9802
|
+
} catch {
|
|
9803
|
+
return value;
|
|
9804
|
+
}
|
|
9805
|
+
}
|
|
9806
|
+
function pickImportMetaEnvDefineEntries(define) {
|
|
9807
|
+
if (!define) return {};
|
|
9808
|
+
return Object.fromEntries(Object.entries(define).filter(([key]) => {
|
|
9809
|
+
return key === "import.meta.env" || key.startsWith(IMPORT_META_ENV_PREFIX);
|
|
9810
|
+
}));
|
|
9811
|
+
}
|
|
9812
|
+
function resolveImportMetaEnvObject(defineImportMetaEnv, fallbackEnv = {}) {
|
|
9813
|
+
const rawEnv = defineImportMetaEnv?.["import.meta.env"];
|
|
9814
|
+
const parsed = parseImportMetaDefineValue(rawEnv);
|
|
9815
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return fallbackEnv;
|
|
9816
|
+
return parsed;
|
|
9817
|
+
}
|
|
9818
|
+
function resolveImportMetaEnvMemberValues(defineImportMetaEnv, fallbackEnv = {}) {
|
|
9819
|
+
const values = { ...resolveImportMetaEnvObject(defineImportMetaEnv, fallbackEnv) };
|
|
9820
|
+
for (const [key, value] of Object.entries(defineImportMetaEnv ?? {})) {
|
|
9821
|
+
if (key === "import.meta.env" || !key.startsWith(IMPORT_META_ENV_PREFIX)) continue;
|
|
9822
|
+
values[key.slice(16)] = parseImportMetaDefineValue(value);
|
|
9823
|
+
}
|
|
9824
|
+
return values;
|
|
9825
|
+
}
|
|
9826
|
+
function createImportMetaDefineRegistry(options) {
|
|
9827
|
+
const baseEnv = { ...options?.baseEnv ?? {} };
|
|
9828
|
+
const explicitDefineEntries = pickImportMetaEnvDefineEntries(options?.defineEntries);
|
|
9829
|
+
const defaultDefineEntries = {};
|
|
9830
|
+
for (const [key, value] of Object.entries(baseEnv)) defaultDefineEntries[`${IMPORT_META_ENV_PREFIX}${key}`] = JSON.stringify(value);
|
|
9831
|
+
defaultDefineEntries["import.meta.env"] = JSON.stringify(baseEnv);
|
|
9832
|
+
const defineEntries = {
|
|
9833
|
+
...defaultDefineEntries,
|
|
9834
|
+
...explicitDefineEntries
|
|
9835
|
+
};
|
|
9836
|
+
return {
|
|
9837
|
+
defineEntries,
|
|
9838
|
+
envObject: resolveImportMetaEnvObject(defineEntries, baseEnv),
|
|
9839
|
+
envMemberAccess: resolveImportMetaEnvMemberValues(defineEntries, baseEnv)
|
|
9840
|
+
};
|
|
9841
|
+
}
|
|
9842
|
+
function createStaticImportMetaValues(options) {
|
|
9843
|
+
const normalizedRelativePath = normalizeRelativePath(path.extname(options.relativePath) ? options.relativePath.slice(0, -path.extname(options.relativePath).length) : options.relativePath);
|
|
9844
|
+
const normalizedExtension = options.extension.startsWith(".") ? options.extension.slice(1) : options.extension;
|
|
9845
|
+
const url = `/${normalizedRelativePath}${normalizedExtension ? `.${normalizedExtension}` : ""}`;
|
|
9846
|
+
const dirname = normalizeRelativePath(path.dirname(url)) || "/";
|
|
9847
|
+
return {
|
|
9848
|
+
filename: url,
|
|
9849
|
+
url,
|
|
9850
|
+
dirname: dirname === "." ? "/" : dirname,
|
|
9851
|
+
env: options.importMetaDefineRegistry?.envObject ?? {},
|
|
9852
|
+
envAccess: options.importMetaDefineRegistry?.envMemberAccess ?? {}
|
|
9853
|
+
};
|
|
9854
|
+
}
|
|
9855
|
+
function createStaticImportMetaReplacementMap(options) {
|
|
9856
|
+
const values = createStaticImportMetaValues(options);
|
|
9857
|
+
const defineEntries = options.importMetaDefineRegistry?.defineEntries ?? {};
|
|
9858
|
+
const envJson = typeof defineEntries["import.meta.env"] === "string" ? defineEntries["import.meta.env"] : JSON.stringify(values.env);
|
|
9859
|
+
return {
|
|
9860
|
+
...defineEntries,
|
|
9861
|
+
"import.meta.filename": JSON.stringify(values.filename),
|
|
9862
|
+
"import.meta.url": JSON.stringify(values.url),
|
|
9863
|
+
"import.meta.dirname": JSON.stringify(values.dirname),
|
|
9864
|
+
"import.meta": `{"filename":${JSON.stringify(values.filename)},"url":${JSON.stringify(values.url)},"dirname":${JSON.stringify(values.dirname)},"env":${envJson}}`
|
|
9865
|
+
};
|
|
9866
|
+
}
|
|
9867
|
+
//#endregion
|
|
9777
9868
|
//#region src/runtime/independentError.ts
|
|
9778
9869
|
const ANSI_ESCAPE_PATTERN = /\u001B\[[0-9;]*m/g;
|
|
9779
9870
|
function stripAnsi(value) {
|
|
@@ -9865,30 +9956,12 @@ function createIndependentBuildError(root, cause) {
|
|
|
9865
9956
|
}
|
|
9866
9957
|
//#endregion
|
|
9867
9958
|
//#region src/runtime/buildPlugin/independent.ts
|
|
9868
|
-
function
|
|
9869
|
-
const previous =
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
};
|
|
9873
|
-
const importMetaEnvPrefix = "import.meta.env.";
|
|
9874
|
-
for (const [key, value] of Object.entries(define)) {
|
|
9875
|
-
if (key === "import.meta.env") {
|
|
9876
|
-
try {
|
|
9877
|
-
const parsed = typeof value === "string" ? JSON.parse(value) : value;
|
|
9878
|
-
if (parsed && typeof parsed === "object") for (const [envKey, envValue] of Object.entries(parsed)) configService.setDefineEnv(envKey, envValue);
|
|
9879
|
-
} catch {}
|
|
9880
|
-
continue;
|
|
9881
|
-
}
|
|
9882
|
-
if (!key.startsWith(importMetaEnvPrefix)) continue;
|
|
9883
|
-
const envKey = key.slice(16);
|
|
9884
|
-
try {
|
|
9885
|
-
configService.setDefineEnv(envKey, typeof value === "string" ? JSON.parse(value) : value);
|
|
9886
|
-
} catch {
|
|
9887
|
-
configService.setDefineEnv(envKey, value);
|
|
9888
|
-
}
|
|
9889
|
-
}
|
|
9959
|
+
function syncImportMetaEnvDefineOverride(configService, define) {
|
|
9960
|
+
const previous = configService.importMetaEnvDefineOverride;
|
|
9961
|
+
const next = pickImportMetaEnvDefineEntries(define);
|
|
9962
|
+
configService.setImportMetaEnvDefineOverride(next);
|
|
9890
9963
|
return () => {
|
|
9891
|
-
configService.
|
|
9964
|
+
configService.setImportMetaEnvDefineOverride(previous);
|
|
9892
9965
|
};
|
|
9893
9966
|
}
|
|
9894
9967
|
function createIndependentBuilder(configService, buildState) {
|
|
@@ -9916,7 +9989,7 @@ function createIndependentBuilder(configService, buildState) {
|
|
|
9916
9989
|
return `${chunkRoot}/[name].js`;
|
|
9917
9990
|
} } }
|
|
9918
9991
|
} });
|
|
9919
|
-
const restoreDefineEnv =
|
|
9992
|
+
const restoreDefineEnv = syncImportMetaEnvDefineOverride(configService, inlineConfig.define);
|
|
9920
9993
|
let result;
|
|
9921
9994
|
try {
|
|
9922
9995
|
result = await build(inlineConfig);
|
|
@@ -11073,6 +11146,33 @@ function injectResolvedAliases(config, aliases) {
|
|
|
11073
11146
|
}
|
|
11074
11147
|
resolve.alias = aliasArray;
|
|
11075
11148
|
}
|
|
11149
|
+
function normalizeManagedPathAliasKey(key) {
|
|
11150
|
+
if (!key || key.includes("*") && !key.endsWith("/*")) return;
|
|
11151
|
+
return key.endsWith("/*") ? key.slice(0, -2) : key;
|
|
11152
|
+
}
|
|
11153
|
+
function normalizeManagedPathAliasTarget(target) {
|
|
11154
|
+
if (!target || target.includes("*") && !target.endsWith("/*")) return;
|
|
11155
|
+
return target.endsWith("/*") ? target.slice(0, -2) : target;
|
|
11156
|
+
}
|
|
11157
|
+
function collectManagedTsconfigAliases(config, cwd) {
|
|
11158
|
+
const weappTypeScript = config.weapp?.typescript;
|
|
11159
|
+
const pathSources = [weappTypeScript?.shared?.compilerOptions?.paths, weappTypeScript?.app?.compilerOptions?.paths];
|
|
11160
|
+
const aliasMap = /* @__PURE__ */ new Map();
|
|
11161
|
+
for (const pathsConfig of pathSources) {
|
|
11162
|
+
if (!pathsConfig || typeof pathsConfig !== "object") continue;
|
|
11163
|
+
for (const [key, value] of Object.entries(pathsConfig)) {
|
|
11164
|
+
const find = normalizeManagedPathAliasKey(key);
|
|
11165
|
+
const target = Array.isArray(value) ? value.find((item) => typeof item === "string") : void 0;
|
|
11166
|
+
const normalizedTarget = typeof target === "string" ? normalizeManagedPathAliasTarget(target) : void 0;
|
|
11167
|
+
if (!find || !normalizedTarget) continue;
|
|
11168
|
+
aliasMap.set(find, path.resolve(cwd, normalizedTarget));
|
|
11169
|
+
}
|
|
11170
|
+
}
|
|
11171
|
+
return Array.from(aliasMap, ([find, replacement]) => ({
|
|
11172
|
+
find,
|
|
11173
|
+
replacement
|
|
11174
|
+
}));
|
|
11175
|
+
}
|
|
11076
11176
|
function createLoadConfig(options) {
|
|
11077
11177
|
const { injectBuiltinAliases, oxcRolldownPlugin, oxcVitePlugin } = options;
|
|
11078
11178
|
return async function loadConfig(opts) {
|
|
@@ -11167,6 +11267,7 @@ function createLoadConfig(options) {
|
|
|
11167
11267
|
srcRoot: rawLibConfig.root
|
|
11168
11268
|
};
|
|
11169
11269
|
const srcRoot = config.weapp?.srcRoot ?? "";
|
|
11270
|
+
injectResolvedAliases(config, collectManagedTsconfigAliases(config, cwd));
|
|
11170
11271
|
const tsconfigPathsUsage = await inspectTsconfigPathsUsage(cwd);
|
|
11171
11272
|
if (!tsconfigPathsUsage.enabled) injectDefaultSrcAlias(config, cwd, srcRoot);
|
|
11172
11273
|
else if (tsconfigPathsUsage.references && !tsconfigPathsUsage.root) {
|
|
@@ -12986,41 +13087,6 @@ function emitNativeLayoutScriptChunkIfNeeded$1(options) {
|
|
|
12986
13087
|
return true;
|
|
12987
13088
|
}
|
|
12988
13089
|
//#endregion
|
|
12989
|
-
//#region src/utils/importMeta.ts
|
|
12990
|
-
function resolveImportMetaEnvObject(defineImportMetaEnv) {
|
|
12991
|
-
const rawEnv = defineImportMetaEnv?.["import.meta.env"];
|
|
12992
|
-
if (typeof rawEnv !== "string") return {};
|
|
12993
|
-
try {
|
|
12994
|
-
const parsed = JSON.parse(rawEnv);
|
|
12995
|
-
return parsed && typeof parsed === "object" ? parsed : {};
|
|
12996
|
-
} catch {
|
|
12997
|
-
return {};
|
|
12998
|
-
}
|
|
12999
|
-
}
|
|
13000
|
-
function createStaticImportMetaValues(options) {
|
|
13001
|
-
const normalizedRelativePath = normalizeRelativePath(path.extname(options.relativePath) ? options.relativePath.slice(0, -path.extname(options.relativePath).length) : options.relativePath);
|
|
13002
|
-
const normalizedExtension = options.extension.startsWith(".") ? options.extension.slice(1) : options.extension;
|
|
13003
|
-
const url = `/${normalizedRelativePath}${normalizedExtension ? `.${normalizedExtension}` : ""}`;
|
|
13004
|
-
const dirname = normalizeRelativePath(path.dirname(url)) || "/";
|
|
13005
|
-
return {
|
|
13006
|
-
filename: url,
|
|
13007
|
-
url,
|
|
13008
|
-
dirname: dirname === "." ? "/" : dirname,
|
|
13009
|
-
env: resolveImportMetaEnvObject(options.defineImportMetaEnv)
|
|
13010
|
-
};
|
|
13011
|
-
}
|
|
13012
|
-
function createStaticImportMetaReplacementMap(options) {
|
|
13013
|
-
const values = createStaticImportMetaValues(options);
|
|
13014
|
-
const envJson = typeof options.defineImportMetaEnv?.["import.meta.env"] === "string" ? options.defineImportMetaEnv["import.meta.env"] : JSON.stringify(values.env);
|
|
13015
|
-
return {
|
|
13016
|
-
...options.defineImportMetaEnv ?? {},
|
|
13017
|
-
"import.meta.filename": JSON.stringify(values.filename),
|
|
13018
|
-
"import.meta.url": JSON.stringify(values.url),
|
|
13019
|
-
"import.meta.dirname": JSON.stringify(values.dirname),
|
|
13020
|
-
"import.meta": `{"filename":${JSON.stringify(values.filename)},"url":${JSON.stringify(values.url)},"dirname":${JSON.stringify(values.dirname)},"env":${envJson}}`
|
|
13021
|
-
};
|
|
13022
|
-
}
|
|
13023
|
-
//#endregion
|
|
13024
13090
|
//#region src/wxs/utils.ts
|
|
13025
13091
|
function normalizeWxsFilename(value, extension = "wxs") {
|
|
13026
13092
|
const normalized = extension.startsWith(".") ? extension.slice(1) : extension;
|
|
@@ -13192,12 +13258,23 @@ function replaceDefineImportMetaEnv(code, defineImportMetaEnv) {
|
|
|
13192
13258
|
for (const range of replacementRanges.sort((left, right) => left.start - right.start)) ms.update(range.start, range.end, range.value);
|
|
13193
13259
|
return ms.toString();
|
|
13194
13260
|
}
|
|
13261
|
+
function resolveDefineImportMetaEnv(options) {
|
|
13262
|
+
if (options.importMetaDefineRegistry && options.importMetaRelativePath) return createStaticImportMetaReplacementMap({
|
|
13263
|
+
importMetaDefineRegistry: options.importMetaDefineRegistry,
|
|
13264
|
+
extension: options.importMetaExtension ?? options.templateExtension ?? "",
|
|
13265
|
+
relativePath: options.importMetaRelativePath
|
|
13266
|
+
});
|
|
13267
|
+
return options.defineImportMetaEnv;
|
|
13268
|
+
}
|
|
13195
13269
|
function createCacheKey$1(options) {
|
|
13196
13270
|
const extension = options.scriptModuleExtension ?? "";
|
|
13197
13271
|
const tag = options.scriptModuleTag ?? "";
|
|
13198
13272
|
const templateExt = options.templateExtension ?? "";
|
|
13199
|
-
const
|
|
13200
|
-
|
|
13273
|
+
const importMetaRelativePath = options.importMetaRelativePath ?? "";
|
|
13274
|
+
const importMetaExtension = options.importMetaExtension ?? "";
|
|
13275
|
+
const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(options);
|
|
13276
|
+
const defineKeys = resolvedDefineImportMetaEnv ? Object.keys(resolvedDefineImportMetaEnv).sort().map((key) => `${key}:${String(resolvedDefineImportMetaEnv[key])}`).join(",") : "";
|
|
13277
|
+
return `${options.removeComment ? 1 : 0}|${options.transformEvent ? 1 : 0}|${extension}|${tag}|${templateExt}|${importMetaExtension}|${importMetaRelativePath}|${defineKeys}`;
|
|
13201
13278
|
}
|
|
13202
13279
|
function getCachedResult(data, cacheKey) {
|
|
13203
13280
|
return handleCache.get(data)?.get(cacheKey);
|
|
@@ -13230,6 +13307,9 @@ function getCachedInlineWxsTransform(code, extension) {
|
|
|
13230
13307
|
function handleWxml(data, options) {
|
|
13231
13308
|
const opts = defu(options, {
|
|
13232
13309
|
defineImportMetaEnv: void 0,
|
|
13310
|
+
importMetaDefineRegistry: void 0,
|
|
13311
|
+
importMetaRelativePath: void 0,
|
|
13312
|
+
importMetaExtension: void 0,
|
|
13233
13313
|
removeComment: true,
|
|
13234
13314
|
transformEvent: true,
|
|
13235
13315
|
scriptModuleExtension: void 0,
|
|
@@ -13256,7 +13336,8 @@ function handleWxml(data, options) {
|
|
|
13256
13336
|
const shouldTransformScriptModuleTags = resolvedScriptTag !== "wxs" && scriptModuleTagTokens.length > 0;
|
|
13257
13337
|
const shouldRemoveConditionals = removalRanges.length > 0;
|
|
13258
13338
|
const shouldRemoveComments = opts.removeComment && commentTokens.length > 0;
|
|
13259
|
-
const
|
|
13339
|
+
const resolvedDefineImportMetaEnv = resolveDefineImportMetaEnv(opts);
|
|
13340
|
+
const shouldReplaceDefineImportMetaEnv = !!resolvedDefineImportMetaEnv && Object.keys(resolvedDefineImportMetaEnv).length > 0;
|
|
13260
13341
|
if (!shouldNormalizeImports && !shouldNormalizeTemplateImports && !shouldRemoveLang && !shouldTransformInlineWxs && !shouldTransformEvents && !shouldTransformDirectives && !shouldTransformTagNames && !shouldTransformScriptModuleTags && !shouldRemoveConditionals && !shouldRemoveComments && !shouldReplaceDefineImportMetaEnv) return setCachedResult(data, cacheKey, {
|
|
13261
13342
|
code,
|
|
13262
13343
|
components,
|
|
@@ -13291,7 +13372,7 @@ function handleWxml(data, options) {
|
|
|
13291
13372
|
}
|
|
13292
13373
|
if (shouldRemoveComments) for (const { end, start } of commentTokens) ms.remove(start, end);
|
|
13293
13374
|
return setCachedResult(data, cacheKey, {
|
|
13294
|
-
code: replaceDefineImportMetaEnv(shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(),
|
|
13375
|
+
code: replaceDefineImportMetaEnv(shouldNormalizeScriptModuleAttributes(resolvedScriptTag) ? normalizeImportSjsAttributes(ms.toString()) : ms.toString(), resolvedDefineImportMetaEnv),
|
|
13295
13376
|
components,
|
|
13296
13377
|
deps
|
|
13297
13378
|
});
|
|
@@ -13334,15 +13415,13 @@ function resolveWxmlEmitTargets(options) {
|
|
|
13334
13415
|
});
|
|
13335
13416
|
}
|
|
13336
13417
|
function emitWxmlAssetFile(options) {
|
|
13337
|
-
const { runtime, id, fileName, token, deps, emittedCodeCache,
|
|
13418
|
+
const { runtime, id, fileName, token, deps, emittedCodeCache, importMetaDefineRegistry, scriptModuleExtension, scriptModuleTag, templateExtension } = options;
|
|
13338
13419
|
runtime.addWatchFile?.(normalizeWatchPath(id));
|
|
13339
13420
|
if (deps) for (const dep of deps) runtime.addWatchFile?.(normalizeWatchPath(dep));
|
|
13340
13421
|
const result = handleWxml(token, {
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
|
|
13344
|
-
relativePath: fileName
|
|
13345
|
-
}),
|
|
13422
|
+
importMetaDefineRegistry,
|
|
13423
|
+
importMetaExtension: templateExtension,
|
|
13424
|
+
importMetaRelativePath: fileName,
|
|
13346
13425
|
scriptModuleExtension,
|
|
13347
13426
|
scriptModuleTag,
|
|
13348
13427
|
templateExtension
|
|
@@ -13374,7 +13453,7 @@ function emitWxmlAssetsWithCache(options) {
|
|
|
13374
13453
|
token,
|
|
13375
13454
|
deps: wxmlService.depsMap.get(id),
|
|
13376
13455
|
emittedCodeCache,
|
|
13377
|
-
|
|
13456
|
+
importMetaDefineRegistry: configService.importMetaDefineRegistry,
|
|
13378
13457
|
scriptModuleExtension,
|
|
13379
13458
|
scriptModuleTag,
|
|
13380
13459
|
templateExtension
|
|
@@ -28888,7 +28967,7 @@ function replaceImportMetaAccess(code, options) {
|
|
|
28888
28967
|
MemberExpression(path) {
|
|
28889
28968
|
const envPropertyName = getImportMetaEnvPropertyName(path.node);
|
|
28890
28969
|
if (envPropertyName) {
|
|
28891
|
-
const envValue = Object.hasOwn(values.
|
|
28970
|
+
const envValue = Object.hasOwn(values.envAccess, envPropertyName) ? values.envAccess[envPropertyName] : void 0;
|
|
28892
28971
|
path.replaceWith(import_lib.valueToNode(envValue));
|
|
28893
28972
|
mutated = true;
|
|
28894
28973
|
return;
|
|
@@ -28916,7 +28995,7 @@ function replaceImportMetaAccess(code, options) {
|
|
|
28916
28995
|
OptionalMemberExpression(path) {
|
|
28917
28996
|
const envPropertyName = getImportMetaEnvPropertyName(path.node);
|
|
28918
28997
|
if (envPropertyName) {
|
|
28919
|
-
const envValue = Object.hasOwn(values.
|
|
28998
|
+
const envValue = Object.hasOwn(values.envAccess, envPropertyName) ? values.envAccess[envPropertyName] : void 0;
|
|
28920
28999
|
path.replaceWith(import_lib.valueToNode(envValue));
|
|
28921
29000
|
mutated = true;
|
|
28922
29001
|
return;
|
|
@@ -28975,10 +29054,44 @@ function replaceImportMetaAccessInSfc(source, options) {
|
|
|
28975
29054
|
}
|
|
28976
29055
|
//#endregion
|
|
28977
29056
|
//#region src/plugins/core/lifecycle/emit/rewrite/literals.ts
|
|
28978
|
-
|
|
29057
|
+
const SCRIPT_ENTRY_CANDIDATES = [
|
|
29058
|
+
"index.js",
|
|
29059
|
+
"index.mjs",
|
|
29060
|
+
"index.cjs"
|
|
29061
|
+
];
|
|
29062
|
+
const SCRIPT_FILE_EXTENSIONS = [
|
|
29063
|
+
".js",
|
|
29064
|
+
".mjs",
|
|
29065
|
+
".cjs"
|
|
29066
|
+
];
|
|
29067
|
+
const SCRIPT_FILE_RE = /\.[cm]?js$/i;
|
|
29068
|
+
const resolvePackageJson = createRequire(import.meta.url);
|
|
29069
|
+
function resolveInstalledPackageEntryRoot(importee, basedir) {
|
|
29070
|
+
const parsed = parseNpmPackageSpecifier(importee);
|
|
29071
|
+
if (!parsed) return;
|
|
29072
|
+
try {
|
|
29073
|
+
const packageJsonPath = resolvePackageJson.resolve(`${parsed.packageName}/package.json`, { paths: basedir ? [basedir] : void 0 });
|
|
29074
|
+
const packageRoot = path.dirname(packageJsonPath);
|
|
29075
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
29076
|
+
const miniprogramRoot = typeof packageJson.miniprogram === "string" && packageJson.miniprogram ? packageJson.miniprogram : void 0;
|
|
29077
|
+
return {
|
|
29078
|
+
...parsed,
|
|
29079
|
+
entryRoot: miniprogramRoot ? path.resolve(packageRoot, miniprogramRoot) : packageRoot
|
|
29080
|
+
};
|
|
29081
|
+
} catch {
|
|
29082
|
+
return;
|
|
29083
|
+
}
|
|
29084
|
+
}
|
|
29085
|
+
function normalizeWeappLocalNpmImport(importee, basedir) {
|
|
28979
29086
|
const normalized = normalizeNpmImportLookupPath(importee);
|
|
28980
29087
|
const segments = normalized.split("/").filter(Boolean);
|
|
28981
29088
|
if (segments.length === 1 || segments.length === 2 && normalized.startsWith("@")) return `${normalized}/index`;
|
|
29089
|
+
if (SCRIPT_FILE_RE.test(normalized)) return normalized;
|
|
29090
|
+
const resolved = resolveInstalledPackageEntryRoot(normalized, basedir);
|
|
29091
|
+
if (!resolved?.subPath) return normalized;
|
|
29092
|
+
const targetPath = path.resolve(resolved.entryRoot, resolved.subPath);
|
|
29093
|
+
if (SCRIPT_FILE_EXTENSIONS.some((ext) => existsSync(`${targetPath}${ext}`))) return normalized;
|
|
29094
|
+
if (SCRIPT_ENTRY_CANDIDATES.some((candidate) => existsSync(path.resolve(targetPath, candidate)))) return `${normalized}/index`;
|
|
28982
29095
|
return normalized;
|
|
28983
29096
|
}
|
|
28984
29097
|
function getRequireImportLiteral(node) {
|
|
@@ -29152,8 +29265,8 @@ function matchesSubPackageDependency(dependencies, importee, fallbackDependencie
|
|
|
29152
29265
|
}
|
|
29153
29266
|
//#endregion
|
|
29154
29267
|
//#region src/plugins/core/lifecycle/emit/rewrite/localRoot.ts
|
|
29155
|
-
function toRelativeRuntimeNpmImport(fileName, root, importee) {
|
|
29156
|
-
const normalized = normalizeWeappLocalNpmImport(importee);
|
|
29268
|
+
function toRelativeRuntimeNpmImport(fileName, root, importee, basedir) {
|
|
29269
|
+
const normalized = normalizeWeappLocalNpmImport(importee, basedir);
|
|
29157
29270
|
const target = root ? `${root}/miniprogram_npm/${normalized}` : `miniprogram_npm/${normalized}`;
|
|
29158
29271
|
const relative = toPosixPath(path.relative(path.dirname(fileName), target));
|
|
29159
29272
|
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
@@ -29172,7 +29285,7 @@ function rewriteChunkNpmImportsToLocalRoot(chunk, root, dependencyPatterns, depe
|
|
|
29172
29285
|
const firstArg = args[0];
|
|
29173
29286
|
const currentValue = getRequireImportLiteral(firstArg);
|
|
29174
29287
|
if (typeof currentValue !== "string" || !matchesSubPackageDependency(dependencyPatterns, currentValue, dependencies)) return;
|
|
29175
|
-
const nextValue = toRelativeRuntimeNpmImport(chunk.fileName, root, currentValue);
|
|
29288
|
+
const nextValue = toRelativeRuntimeNpmImport(chunk.fileName, root, currentValue, options?.basedir);
|
|
29176
29289
|
if (nextValue === currentValue) return;
|
|
29177
29290
|
setRequireImportLiteral(firstArg, nextValue);
|
|
29178
29291
|
mutated = true;
|
|
@@ -29180,9 +29293,10 @@ function rewriteChunkNpmImportsToLocalRoot(chunk, root, dependencyPatterns, depe
|
|
|
29180
29293
|
if (mutated) chunk.code = generate(ast).code;
|
|
29181
29294
|
} catch {}
|
|
29182
29295
|
}
|
|
29183
|
-
function rewriteJsonNpmImportsToLocalRoot(bundle, root, dependencyPatterns, dependencies) {
|
|
29296
|
+
function rewriteJsonNpmImportsToLocalRoot(bundle, root, dependencyPatterns, dependencies, basedir, options) {
|
|
29184
29297
|
for (const output of Object.values(bundle)) {
|
|
29185
29298
|
if (output?.type !== "asset" || typeof output.fileName !== "string" || !output.fileName.endsWith(".json")) continue;
|
|
29299
|
+
if (options?.excludeRoots?.some((excludeRoot) => output.fileName === excludeRoot || output.fileName.startsWith(`${excludeRoot}/`))) continue;
|
|
29186
29300
|
if (root && (output.fileName === `${root}.json` || !output.fileName.startsWith(`${root}/`))) continue;
|
|
29187
29301
|
const source = typeof output.source === "string" ? output.source : output.source?.toString();
|
|
29188
29302
|
if (!source) continue;
|
|
@@ -29192,7 +29306,7 @@ function rewriteJsonNpmImportsToLocalRoot(bundle, root, dependencyPatterns, depe
|
|
|
29192
29306
|
let mutated = false;
|
|
29193
29307
|
for (const [componentName, importee] of Object.entries(parsed.usingComponents)) {
|
|
29194
29308
|
if (typeof importee !== "string" || !matchesSubPackageDependency(dependencyPatterns, importee, dependencies)) continue;
|
|
29195
|
-
parsed.usingComponents[componentName] = toRelativeRuntimeNpmImport(output.fileName, root, importee);
|
|
29309
|
+
parsed.usingComponents[componentName] = toRelativeRuntimeNpmImport(output.fileName, root, importee, basedir);
|
|
29196
29310
|
mutated = true;
|
|
29197
29311
|
}
|
|
29198
29312
|
if (mutated) output.source = `${JSON.stringify(parsed, null, 2)}\n`;
|
|
@@ -29515,7 +29629,7 @@ async function resolveAppPreludeCode(preludePath, options) {
|
|
|
29515
29629
|
if (hasModuleSyntax) throw new Error("[app.prelude] 当前仅支持无 import/export 的自包含脚本。");
|
|
29516
29630
|
const transformed = await transformWithOxc(source, preludePath);
|
|
29517
29631
|
const normalizedCode = (options?.relativePath ? replaceImportMetaAccess(transformed.code, {
|
|
29518
|
-
|
|
29632
|
+
importMetaDefineRegistry: options.importMetaDefineRegistry,
|
|
29519
29633
|
extension: path.extname(preludePath),
|
|
29520
29634
|
relativePath: options.relativePath
|
|
29521
29635
|
}) : transformed.code).replace(USE_STRICT_PREFIX_RE, "").trim();
|
|
@@ -29603,8 +29717,11 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
29603
29717
|
if (isPluginBuild) {
|
|
29604
29718
|
filterPluginBundleOutputs(rolldownBundle, configService);
|
|
29605
29719
|
if (!shouldRewriteBundleNpmImports(configService.platform)) {
|
|
29606
|
-
for (const output of Object.values(rolldownBundle)) if (output?.type === "chunk") rewriteChunkNpmImportsToLocalRoot(output, "", void 0, npmBuildCandidateDependencies, {
|
|
29607
|
-
|
|
29720
|
+
for (const output of Object.values(rolldownBundle)) if (output?.type === "chunk") rewriteChunkNpmImportsToLocalRoot(output, "", void 0, npmBuildCandidateDependencies, {
|
|
29721
|
+
astEngine,
|
|
29722
|
+
basedir: configService.cwd
|
|
29723
|
+
});
|
|
29724
|
+
rewriteJsonNpmImportsToLocalRoot(rolldownBundle, "", void 0, npmBuildCandidateDependencies, configService.cwd);
|
|
29608
29725
|
}
|
|
29609
29726
|
return;
|
|
29610
29727
|
}
|
|
@@ -29712,14 +29829,27 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
29712
29829
|
if (shouldRewriteBundleNpmImports(configService.platform)) rewriteBundleNpmImportsByPlatform(configService.platform, rolldownBundle, npmBuildCandidateDependencies, configService.weappViteConfig?.npm?.alipayNpmMode, { astEngine });
|
|
29713
29830
|
else {
|
|
29714
29831
|
const localSubPackageMetas = [...(scanService.subPackageMap ?? /* @__PURE__ */ new Map()).values()].filter((meta) => Array.isArray(meta?.subPackage?.dependencies) && meta.subPackage.dependencies.length > 0);
|
|
29832
|
+
const localSubPackageRoots = localSubPackageMetas.map((meta) => meta.subPackage.root).filter(Boolean);
|
|
29833
|
+
for (const output of Object.values(rolldownBundle)) {
|
|
29834
|
+
if (output?.type !== "chunk") continue;
|
|
29835
|
+
if (localSubPackageRoots.some((root) => output.fileName === root || output.fileName.startsWith(`${root}/`))) continue;
|
|
29836
|
+
rewriteChunkNpmImportsToLocalRoot(output, "", void 0, npmBuildCandidateDependencies, {
|
|
29837
|
+
astEngine,
|
|
29838
|
+
basedir: configService.cwd
|
|
29839
|
+
});
|
|
29840
|
+
}
|
|
29841
|
+
rewriteJsonNpmImportsToLocalRoot(rolldownBundle, "", void 0, npmBuildCandidateDependencies, configService.cwd, { excludeRoots: localSubPackageRoots });
|
|
29715
29842
|
for (const meta of localSubPackageMetas) {
|
|
29716
29843
|
for (const output of Object.values(rolldownBundle)) {
|
|
29717
29844
|
if (output?.type !== "chunk") continue;
|
|
29718
29845
|
const chunk = output;
|
|
29719
29846
|
if (chunk.fileName === meta.subPackage.root || !chunk.fileName.startsWith(`${meta.subPackage.root}/`)) continue;
|
|
29720
|
-
rewriteChunkNpmImportsToLocalRoot(chunk, meta.subPackage.root, meta.subPackage.dependencies, npmBuildCandidateDependencies, {
|
|
29847
|
+
rewriteChunkNpmImportsToLocalRoot(chunk, meta.subPackage.root, meta.subPackage.dependencies, npmBuildCandidateDependencies, {
|
|
29848
|
+
astEngine,
|
|
29849
|
+
basedir: configService.cwd
|
|
29850
|
+
});
|
|
29721
29851
|
}
|
|
29722
|
-
rewriteJsonNpmImportsToLocalRoot(rolldownBundle, meta.subPackage.root, meta.subPackage.dependencies, npmBuildCandidateDependencies);
|
|
29852
|
+
rewriteJsonNpmImportsToLocalRoot(rolldownBundle, meta.subPackage.root, meta.subPackage.dependencies, npmBuildCandidateDependencies, configService.cwd);
|
|
29723
29853
|
}
|
|
29724
29854
|
}
|
|
29725
29855
|
const injectWeapiGlobalName = resolveInjectWeapiGlobalName(state);
|
|
@@ -29733,7 +29863,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
29733
29863
|
}
|
|
29734
29864
|
const appPreludeOptions = resolveAppPreludeOptions(state);
|
|
29735
29865
|
injectAppPreludeCode(rolldownBundle, await resolveAppPreludeCode(scanService.appEntry?.preludePath, {
|
|
29736
|
-
|
|
29866
|
+
importMetaDefineRegistry: configService.importMetaDefineRegistry,
|
|
29737
29867
|
relativePath: scanService.appEntry?.preludePath ? configService.relativeAbsoluteSrcRoot(scanService.appEntry.preludePath) : void 0
|
|
29738
29868
|
}), {
|
|
29739
29869
|
...appPreludeOptions,
|
|
@@ -30170,7 +30300,7 @@ function createTransformHook(state) {
|
|
|
30170
30300
|
const sourceId = normalizeFsResolvedId(id);
|
|
30171
30301
|
const relativeOutputPath = sourceId ? configService.relativeOutputPath?.(sourceId) ?? configService.relativeAbsoluteSrcRoot?.(sourceId) : void 0;
|
|
30172
30302
|
const importMetaTransformOptions = relativeOutputPath ? {
|
|
30173
|
-
|
|
30303
|
+
importMetaDefineRegistry: configService.importMetaDefineRegistry,
|
|
30174
30304
|
extension: "js",
|
|
30175
30305
|
relativePath: relativeOutputPath
|
|
30176
30306
|
} : void 0;
|
|
@@ -33387,18 +33517,6 @@ function composeSourceMaps(transformedMap, originalMap) {
|
|
|
33387
33517
|
const APP_ENTRY_RE = /[\\/]app\.(?:vue|jsx|tsx)$/;
|
|
33388
33518
|
const TEMPLATE_MUSTACHE_HINT = "{{";
|
|
33389
33519
|
const TEMPLATE_EVENT_HINT_RE = /\b(?:bind|catch)[A-Za-z:_-]+=/;
|
|
33390
|
-
const PAGE_FEATURE_HOOK_HINTS = [
|
|
33391
|
-
"onPageScroll",
|
|
33392
|
-
"onPullDownRefresh",
|
|
33393
|
-
"onReachBottom",
|
|
33394
|
-
"onRouteDone",
|
|
33395
|
-
"onTabItemTap",
|
|
33396
|
-
"onResize",
|
|
33397
|
-
"onShareAppMessage",
|
|
33398
|
-
"onShareTimeline",
|
|
33399
|
-
"onAddToFavorites",
|
|
33400
|
-
"onSaveExitState"
|
|
33401
|
-
];
|
|
33402
33520
|
const PAGE_SCROLL_HOOK_HINT = "onPageScroll";
|
|
33403
33521
|
function resolveScriptlessVueEntryStub(isPage) {
|
|
33404
33522
|
return isPage ? "Page({})" : "Component({})";
|
|
@@ -33415,9 +33533,6 @@ function mayNeedTransformSetDataPick(template, options) {
|
|
|
33415
33533
|
if (new RegExp(`${escapeStringRegexp(directivePrefix)}:`).test(template)) return true;
|
|
33416
33534
|
return TEMPLATE_EVENT_HINT_RE.test(template);
|
|
33417
33535
|
}
|
|
33418
|
-
function mayNeedTransformPageFeatureInjection(script) {
|
|
33419
|
-
return PAGE_FEATURE_HOOK_HINTS.some((hint) => script.includes(hint));
|
|
33420
|
-
}
|
|
33421
33536
|
function mayNeedTransformPageScrollDiagnostics(script) {
|
|
33422
33537
|
return script.includes(PAGE_SCROLL_HOOK_HINT);
|
|
33423
33538
|
}
|
|
@@ -33583,12 +33698,10 @@ async function finalizeTransformEntryScript(options) {
|
|
|
33583
33698
|
const { result, filename, pluginCtx, configService, isPage, isApp } = options;
|
|
33584
33699
|
if (isPage && result.script) {
|
|
33585
33700
|
if (mayNeedTransformPageScrollDiagnostics(result.script)) for (const warning of collectOnPageScrollPerformanceWarnings(result.script, filename, { engine: resolveAstEngine(configService.weappViteConfig) })) logger_default.warn(warning);
|
|
33586
|
-
|
|
33587
|
-
|
|
33588
|
-
|
|
33589
|
-
|
|
33590
|
-
result.scriptMap = composeSourceMaps(injected.map, result.scriptMap);
|
|
33591
|
-
}
|
|
33701
|
+
const injected = await injectWevuPageFeaturesInJsWithViteResolver(pluginCtx, result.script, filename, { checkMtime: configService.isDev });
|
|
33702
|
+
if (injected.transformed) {
|
|
33703
|
+
result.script = injected.code;
|
|
33704
|
+
result.scriptMap = composeSourceMaps(injected.map, result.scriptMap);
|
|
33592
33705
|
}
|
|
33593
33706
|
}
|
|
33594
33707
|
if (!isApp && result.script && result.template && isAutoSetDataPickEnabled(configService.weappViteConfig) && mayNeedTransformSetDataPick(result.template, { platform: configService.platform })) {
|
|
@@ -34530,18 +34643,33 @@ function createConfigService(ctx) {
|
|
|
34530
34643
|
function setDefineEnv(key, value) {
|
|
34531
34644
|
defineEnv[key] = value;
|
|
34532
34645
|
}
|
|
34533
|
-
function
|
|
34646
|
+
function setImportMetaEnvDefineOverride(define) {
|
|
34647
|
+
configState.importMetaEnvDefineOverride = define ? pickImportMetaEnvDefineEntries(define) : void 0;
|
|
34648
|
+
}
|
|
34649
|
+
function getUserDefinedImportMetaEnv() {
|
|
34650
|
+
const userDefine = options?.config?.define;
|
|
34651
|
+
return pickImportMetaEnvDefineEntries(userDefine);
|
|
34652
|
+
}
|
|
34653
|
+
function getCurrentImportMetaExplicitDefine() {
|
|
34654
|
+
return configState.importMetaEnvDefineOverride ?? getUserDefinedImportMetaEnv();
|
|
34655
|
+
}
|
|
34656
|
+
function getImportMetaBaseEnv() {
|
|
34534
34657
|
const mpPlatform = options?.platform ?? DEFAULT_MP_PLATFORM;
|
|
34535
34658
|
const resolvedPlatform = defineEnv.PLATFORM ?? mpPlatform;
|
|
34536
|
-
|
|
34659
|
+
return {
|
|
34537
34660
|
PLATFORM: resolvedPlatform,
|
|
34538
34661
|
MP_PLATFORM: resolvedPlatform,
|
|
34539
34662
|
...defineEnv
|
|
34540
34663
|
};
|
|
34541
|
-
|
|
34542
|
-
|
|
34543
|
-
|
|
34544
|
-
|
|
34664
|
+
}
|
|
34665
|
+
function getImportMetaDefineRegistry() {
|
|
34666
|
+
return createImportMetaDefineRegistry({
|
|
34667
|
+
baseEnv: getImportMetaBaseEnv(),
|
|
34668
|
+
defineEntries: getCurrentImportMetaExplicitDefine()
|
|
34669
|
+
});
|
|
34670
|
+
}
|
|
34671
|
+
function getDefineImportMetaEnv() {
|
|
34672
|
+
return getImportMetaDefineRegistry().defineEntries;
|
|
34545
34673
|
}
|
|
34546
34674
|
function applyRuntimePlatform(runtime) {
|
|
34547
34675
|
const isWeb = runtime === "web";
|
|
@@ -34629,14 +34757,24 @@ function createConfigService(ctx) {
|
|
|
34629
34757
|
return configState.packageInfo;
|
|
34630
34758
|
},
|
|
34631
34759
|
setDefineEnv,
|
|
34760
|
+
setImportMetaEnvDefineOverride,
|
|
34632
34761
|
load,
|
|
34633
34762
|
mergeWorkers,
|
|
34634
34763
|
merge,
|
|
34635
34764
|
mergeWeb,
|
|
34636
34765
|
mergeInlineConfig,
|
|
34766
|
+
get importMetaDefineEntries() {
|
|
34767
|
+
return getDefineImportMetaEnv();
|
|
34768
|
+
},
|
|
34637
34769
|
get defineImportMetaEnv() {
|
|
34638
34770
|
return getDefineImportMetaEnv();
|
|
34639
34771
|
},
|
|
34772
|
+
get importMetaEnvDefineOverride() {
|
|
34773
|
+
return configState.importMetaEnvDefineOverride;
|
|
34774
|
+
},
|
|
34775
|
+
get importMetaDefineRegistry() {
|
|
34776
|
+
return getImportMetaDefineRegistry();
|
|
34777
|
+
},
|
|
34640
34778
|
get cwd() {
|
|
34641
34779
|
return options.cwd;
|
|
34642
34780
|
},
|
|
@@ -34793,7 +34931,7 @@ function createJsonService(ctx) {
|
|
|
34793
34931
|
cwd: configService.options.cwd,
|
|
34794
34932
|
preserveTemporaryFile: true,
|
|
34795
34933
|
rolldownOptions: {
|
|
34796
|
-
input: { define: configService.
|
|
34934
|
+
input: { define: configService.importMetaDefineEntries },
|
|
34797
34935
|
output: { exports: "named" }
|
|
34798
34936
|
}
|
|
34799
34937
|
});
|
|
@@ -35042,6 +35180,7 @@ function createRuntimeState() {
|
|
|
35042
35180
|
config: {
|
|
35043
35181
|
packageInfo: createDefaultPackageInfo(),
|
|
35044
35182
|
defineEnv: {},
|
|
35183
|
+
importMetaEnvDefineOverride: void 0,
|
|
35045
35184
|
packageManager: createDefaultPackageManager(),
|
|
35046
35185
|
options: createDefaultLoadConfigResult()
|
|
35047
35186
|
}
|
|
@@ -35172,7 +35311,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
35172
35311
|
const vueAppPath = await findVueEntry(appBasename);
|
|
35173
35312
|
let configFromVue;
|
|
35174
35313
|
if (!appConfigFile && vueAppPath) {
|
|
35175
|
-
const { extractConfigFromVue } = await import("./file-
|
|
35314
|
+
const { extractConfigFromVue } = await import("./file-slN_aOEg.mjs");
|
|
35176
35315
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
35177
35316
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
35178
35317
|
}
|
|
@@ -36152,6 +36291,11 @@ function normalizeSrcRoot(srcRoot) {
|
|
|
36152
36291
|
}
|
|
36153
36292
|
//#endregion
|
|
36154
36293
|
//#region src/runtime/tsconfigSupport/configs.ts
|
|
36294
|
+
function omitDeprecatedCompilerOptions(compilerOptions) {
|
|
36295
|
+
if (!compilerOptions || !("baseUrl" in compilerOptions)) return compilerOptions;
|
|
36296
|
+
const { baseUrl: _baseUrl, ...rest } = compilerOptions;
|
|
36297
|
+
return rest;
|
|
36298
|
+
}
|
|
36155
36299
|
function getAppTypes(ctx, legacyConfig) {
|
|
36156
36300
|
const configService = requireConfigService(ctx, "生成 app tsconfig 前必须初始化 configService。");
|
|
36157
36301
|
const packageJson = configService.packageJson;
|
|
@@ -36192,8 +36336,8 @@ function createSharedTsconfig(ctx, legacyConfig) {
|
|
|
36192
36336
|
noUncheckedSideEffectImports: true,
|
|
36193
36337
|
erasableSyntaxOnly: true,
|
|
36194
36338
|
skipLibCheck: true,
|
|
36195
|
-
...legacyConfig?.shared?.compilerOptions ?? {},
|
|
36196
|
-
...userConfig?.shared?.compilerOptions ?? {}
|
|
36339
|
+
...omitDeprecatedCompilerOptions(legacyConfig?.shared?.compilerOptions) ?? {},
|
|
36340
|
+
...omitDeprecatedCompilerOptions(userConfig?.shared?.compilerOptions) ?? {}
|
|
36197
36341
|
} };
|
|
36198
36342
|
const exclude = unique([...legacyConfig?.shared?.exclude ?? [], ...userConfig?.shared?.exclude ?? []]);
|
|
36199
36343
|
const files = unique([...legacyConfig?.shared?.files ?? [], ...userConfig?.shared?.files ?? []]);
|
|
@@ -36207,8 +36351,8 @@ function createSharedTsconfig(ctx, legacyConfig) {
|
|
|
36207
36351
|
}
|
|
36208
36352
|
function createAppTsconfig(ctx, legacyConfig) {
|
|
36209
36353
|
const userConfig = getManagedTypeScriptConfig(ctx);
|
|
36210
|
-
const legacyAppCompilerOptions = legacyConfig?.app?.compilerOptions ?? {};
|
|
36211
|
-
const userAppCompilerOptions = userConfig?.app?.compilerOptions ?? {};
|
|
36354
|
+
const legacyAppCompilerOptions = omitDeprecatedCompilerOptions(legacyConfig?.app?.compilerOptions) ?? {};
|
|
36355
|
+
const userAppCompilerOptions = omitDeprecatedCompilerOptions(userConfig?.app?.compilerOptions) ?? {};
|
|
36212
36356
|
const compilerOptions = {
|
|
36213
36357
|
tsBuildInfoFile: "../node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
36214
36358
|
target: "ES2023",
|
|
@@ -36253,8 +36397,8 @@ function createNodeTsconfig(ctx, legacyConfig) {
|
|
|
36253
36397
|
target: "ES2023",
|
|
36254
36398
|
lib: ["ES2023"],
|
|
36255
36399
|
types: ["node"],
|
|
36256
|
-
...legacyConfig?.node?.compilerOptions ?? {},
|
|
36257
|
-
...userConfig?.node?.compilerOptions ?? {}
|
|
36400
|
+
...omitDeprecatedCompilerOptions(legacyConfig?.node?.compilerOptions) ?? {},
|
|
36401
|
+
...omitDeprecatedCompilerOptions(userConfig?.node?.compilerOptions) ?? {}
|
|
36258
36402
|
};
|
|
36259
36403
|
const include = unique([
|
|
36260
36404
|
...DEFAULT_NODE_INCLUDE,
|
|
@@ -36278,8 +36422,8 @@ function createServerTsconfig(ctx, legacyConfig) {
|
|
|
36278
36422
|
target: "ES2023",
|
|
36279
36423
|
lib: ["ES2023"],
|
|
36280
36424
|
types: ["node"],
|
|
36281
|
-
...legacyConfig?.server?.compilerOptions ?? {},
|
|
36282
|
-
...userConfig?.server?.compilerOptions ?? {}
|
|
36425
|
+
...omitDeprecatedCompilerOptions(legacyConfig?.server?.compilerOptions) ?? {},
|
|
36426
|
+
...omitDeprecatedCompilerOptions(userConfig?.server?.compilerOptions) ?? {}
|
|
36283
36427
|
};
|
|
36284
36428
|
const files = unique([...legacyConfig?.server?.files ?? [], ...userConfig?.server?.files ?? []]);
|
|
36285
36429
|
const include = unique([...legacyConfig?.server?.include ?? [], ...userConfig?.server?.include ?? []]);
|
|
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
84
84
|
}
|
|
85
85
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
86
86
|
try {
|
|
87
|
-
const { getCompilerContext } = await import("./getInstance-
|
|
87
|
+
const { getCompilerContext } = await import("./getInstance-BGGhJCLI.mjs");
|
|
88
88
|
const compilerContext = getCompilerContext();
|
|
89
89
|
const service = compilerContext.autoRoutesService;
|
|
90
90
|
const reference = service?.getReference?.();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Ref, Bn as resolveWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, I as RolldownPluginOption, In as WeappViteRuntime, L as RolldownWatchOptions, Ln as applyWeappViteHostMeta, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Pn as WEAPP_VITE_HOST_NAME, R as RolldownWatcher, Rn as createWeappViteHostMeta, 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, 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, zn as isWeappViteHost } from "./config-
|
|
1
|
+
import { A as Ref, Bn as resolveWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, I as RolldownPluginOption, In as WeappViteRuntime, L as RolldownWatchOptions, Ln as applyWeappViteHostMeta, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Pn as WEAPP_VITE_HOST_NAME, R as RolldownWatcher, Rn as createWeappViteHostMeta, 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, 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, zn as isWeappViteHost } from "./config-DzoHnvv-.mjs";
|
|
2
2
|
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-DSLk7kWi.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-
|
|
1
|
+
import { t as createCompilerContext } from "./createContext-CySjzbQy.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-
|
|
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-DzoHnvv-.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 { xt as WeappMcpConfig } from "./config-
|
|
1
|
+
import { xt as WeappMcpConfig } from "./config-DzoHnvv-.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 JsonConfig, A as Ref, An as WeappManagedServerTsconfigConfig, At as WeappWevuConfig, B as BindingErrorLike, Bt as GenerateExtensionsOptions, Cn as WeappLibDtsOptions, Ct as WeappRequestRuntimeConfig, D as MethodDefinitions, Dn as WeappLibVueTscOptions, Dt as WeappVueConfig, E as InlineConfig, En as WeappLibInternalDtsOptions, Et as WeappSubPackageConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, Ft as BuildNpmPackageMeta, G as EntryJsonFragment, Gt as GenerateTemplateContext, H as BaseEntry, Ht as GenerateFilenamesOptions, I as RolldownPluginOption, In as WeappViteRuntime, It as ChunksConfig, J as ScanComponentItem, Jt as GenerateTemplateFileSource, K as PageEntry, Kt as GenerateTemplateEntry, L as RolldownWatchOptions, Lt as CopyGlobs, M as RolldownBuild, Mn as WeappManagedTypeScriptConfig, Mt as Alias, N as RolldownOptions, Nn as WeappWebConfig, Nt as AliasOptions, O as Plugin, On as WeappManagedAppTsconfigConfig, Ot as WeappVueTemplateConfig, P as RolldownOutput, Pt as AlipayNpmMode, Q as UserConfig, Qt as JsFormat, R as RolldownWatcher, Rt as CopyOptions, Sn as WeappLibConfig, St as WeappNpmConfig, T as ConfigEnv, Tn as WeappLibFileName, Tt as WeappRouteRules, U as ComponentEntry, Ut as GenerateOptions, V as AppEntry, Vt as GenerateFileType, W as Entry, Wt as GenerateTemplate, X as ProjectConfig, Xt as GenerateTemplateScope, Y as WxmlDep, Yt as GenerateTemplateInlineSource, Z as SubPackageMetaValue, Zt as GenerateTemplatesConfig, _n as SubPackageStyleConfigEntry, _t as WeappInjectRequestGlobalsTarget, an as NpmBuildOptions, at as EnhanceOptions, b as ChangeEvent, bn as SubPackageStyleScope, bt as WeappInjectWebRuntimeGlobalsTarget, cn as NpmPluginPackageConfig, ct as MultiPlatformConfig, dn as ResolvedAlias, dt as WeappAppPreludeMode, en as JsonMergeContext, et as WeappForwardConsoleConfig, fn as SharedChunkDynamicImports, ft as WeappAutoRoutesConfig, gn as SubPackage, gt as WeappInjectRequestGlobalsConfig, hn as SharedChunkStrategy, ht as WeappHmrConfig, in as MpPlatform, it as AutoImportComponentsOption, j as ResolvedConfig, jn as WeappManagedSharedTsconfigConfig, jt as WeappWorkerConfig, k as PluginOption, kn as WeappManagedNodeTsconfigConfig, kt as WeappWebRuntimeConfig, ln as NpmStrategy, lt as ScanWxmlOptions, mn as SharedChunkOverride, mt as WeappAutoRoutesIncludePattern, nn as JsonMergeStage, nt as WeappViteConfig, on as NpmDependencyPattern, ot as EnhanceWxmlOptions, pn as SharedChunkMode, pt as WeappAutoRoutesInclude, q as ComponentsMap, qt as GenerateTemplateFactory, rn as JsonMergeStrategy, rt as AutoImportComponents, sn as NpmMainPackageConfig, st as HandleWxmlOptions, tn as JsonMergeFunction, tt as WeappForwardConsoleLogLevel, un as NpmSubPackageConfig, ut as WeappAppPreludeConfig, vn as SubPackageStyleConfigObject, vt as WeappInjectWeapiConfig, w as ComputedDefinitions, wn as WeappLibEntryContext, wt as WeappRouteRule, x as WeappVitePluginApi, xn as WeappLibComponentJson, xt as WeappMcpConfig, yn as SubPackageStyleEntry, yt as WeappInjectWebRuntimeGlobalsConfig, z as ViteDevServer, zt as GenerateDirsOptions } from "./config-
|
|
3
|
+
import { $ as WeappDebugConfig, $t as JsonConfig, A as Ref, An as WeappManagedServerTsconfigConfig, At as WeappWevuConfig, B as BindingErrorLike, Bt as GenerateExtensionsOptions, Cn as WeappLibDtsOptions, Ct as WeappRequestRuntimeConfig, D as MethodDefinitions, Dn as WeappLibVueTscOptions, Dt as WeappVueConfig, E as InlineConfig, En as WeappLibInternalDtsOptions, Et as WeappSubPackageConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, Ft as BuildNpmPackageMeta, G as EntryJsonFragment, Gt as GenerateTemplateContext, H as BaseEntry, Ht as GenerateFilenamesOptions, I as RolldownPluginOption, In as WeappViteRuntime, It as ChunksConfig, J as ScanComponentItem, Jt as GenerateTemplateFileSource, K as PageEntry, Kt as GenerateTemplateEntry, L as RolldownWatchOptions, Lt as CopyGlobs, M as RolldownBuild, Mn as WeappManagedTypeScriptConfig, Mt as Alias, N as RolldownOptions, Nn as WeappWebConfig, Nt as AliasOptions, O as Plugin, On as WeappManagedAppTsconfigConfig, Ot as WeappVueTemplateConfig, P as RolldownOutput, Pt as AlipayNpmMode, Q as UserConfig, Qt as JsFormat, R as RolldownWatcher, Rt as CopyOptions, Sn as WeappLibConfig, St as WeappNpmConfig, T as ConfigEnv, Tn as WeappLibFileName, Tt as WeappRouteRules, U as ComponentEntry, Ut as GenerateOptions, V as AppEntry, Vt as GenerateFileType, W as Entry, Wt as GenerateTemplate, X as ProjectConfig, Xt as GenerateTemplateScope, Y as WxmlDep, Yt as GenerateTemplateInlineSource, Z as SubPackageMetaValue, Zt as GenerateTemplatesConfig, _n as SubPackageStyleConfigEntry, _t as WeappInjectRequestGlobalsTarget, an as NpmBuildOptions, at as EnhanceOptions, b as ChangeEvent, bn as SubPackageStyleScope, bt as WeappInjectWebRuntimeGlobalsTarget, cn as NpmPluginPackageConfig, ct as MultiPlatformConfig, dn as ResolvedAlias, dt as WeappAppPreludeMode, en as JsonMergeContext, et as WeappForwardConsoleConfig, fn as SharedChunkDynamicImports, ft as WeappAutoRoutesConfig, gn as SubPackage, gt as WeappInjectRequestGlobalsConfig, hn as SharedChunkStrategy, ht as WeappHmrConfig, in as MpPlatform, it as AutoImportComponentsOption, j as ResolvedConfig, jn as WeappManagedSharedTsconfigConfig, jt as WeappWorkerConfig, k as PluginOption, kn as WeappManagedNodeTsconfigConfig, kt as WeappWebRuntimeConfig, ln as NpmStrategy, lt as ScanWxmlOptions, mn as SharedChunkOverride, mt as WeappAutoRoutesIncludePattern, nn as JsonMergeStage, nt as WeappViteConfig, on as NpmDependencyPattern, ot as EnhanceWxmlOptions, pn as SharedChunkMode, pt as WeappAutoRoutesInclude, q as ComponentsMap, qt as GenerateTemplateFactory, rn as JsonMergeStrategy, rt as AutoImportComponents, sn as NpmMainPackageConfig, st as HandleWxmlOptions, tn as JsonMergeFunction, tt as WeappForwardConsoleLogLevel, un as NpmSubPackageConfig, ut as WeappAppPreludeConfig, vn as SubPackageStyleConfigObject, vt as WeappInjectWeapiConfig, w as ComputedDefinitions, wn as WeappLibEntryContext, wt as WeappRouteRule, x as WeappVitePluginApi, xn as WeappLibComponentJson, xt as WeappMcpConfig, yn as SubPackageStyleEntry, yt as WeappInjectWebRuntimeGlobalsConfig, z as ViteDevServer, zt as GenerateDirsOptions } from "./config-DzoHnvv-.mjs";
|
|
4
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, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, 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.15.
|
|
4
|
+
"version": "6.15.12",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"@weapp-core/logger": "3.1.1",
|
|
123
123
|
"@weapp-core/schematics": "6.0.4",
|
|
124
124
|
"@weapp-core/shared": "3.0.4",
|
|
125
|
-
"@weapp-vite/ast": "6.15.
|
|
125
|
+
"@weapp-vite/ast": "6.15.12",
|
|
126
126
|
"@weapp-vite/mcp": "1.2.1",
|
|
127
127
|
"@weapp-vite/miniprogram-automator": "1.0.3",
|
|
128
128
|
"@weapp-vite/volar": "2.1.0",
|
|
@@ -132,16 +132,16 @@
|
|
|
132
132
|
"rolldown-require": "2.0.14",
|
|
133
133
|
"vite-plugin-performance": "2.0.1",
|
|
134
134
|
"weapp-ide-cli": "5.2.4",
|
|
135
|
-
"wevu": "6.15.
|
|
135
|
+
"wevu": "6.15.12"
|
|
136
136
|
},
|
|
137
137
|
"publishConfig": {
|
|
138
138
|
"access": "public",
|
|
139
139
|
"registry": "https://registry.npmjs.org"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
|
-
"oxc-parser": "^0.
|
|
142
|
+
"oxc-parser": "^0.127.0",
|
|
143
143
|
"oxc-walker": "^0.7.0",
|
|
144
|
-
"tailwindcss": "^4.2.
|
|
144
|
+
"tailwindcss": "^4.2.4",
|
|
145
145
|
"ts-morph": "^28.0.0"
|
|
146
146
|
},
|
|
147
147
|
"scripts": {
|
package/dist/file-cvdXNNJc.mjs
DELETED