weapp-vite 2.0.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CompilerContext-DmT_Gh0j.d.ts → CompilerContext-BjnJU9GL.d.ts} +13 -2
- package/dist/{CompilerContext-Dc4zbR7V.d.cts → CompilerContext-DWFbNP11.d.cts} +13 -2
- package/dist/auto-import-components/resolvers.mjs +1 -1
- package/dist/{chunk-PWDBZWAF.mjs → chunk-6ZIOYCGJ.mjs} +148 -69
- package/dist/{chunk-ZRLZHOL5.mjs → chunk-PEN3BLSY.mjs} +2 -2
- package/dist/{chunk-4ZIYVTHH.mjs → chunk-RSPHXR3C.mjs} +1 -1
- package/dist/cli.cjs +150 -73
- package/dist/cli.mjs +4 -6
- package/dist/{config-DYSwq1ku.d.cts → config-Cvwqemwg.d.cts} +1 -1
- package/dist/{config-BM_dhf8V.d.ts → config-EPV0G671.d.ts} +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.mjs +2 -2
- package/dist/index.cjs +149 -70
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +3 -3
- package/dist/json.d.cts +3 -2
- package/dist/json.d.ts +3 -2
- package/dist/json.mjs +1 -1
- package/package.json +5 -4
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { R as ResolvedValue } from './types-dS68tjL6.js';
|
|
2
|
-
import { E as Entry, S as SubPackageMetaValue, R as ResolvedAlias, P as ProjectConfig, M as MpPlatform, a as SubPackage, A as AppEntry, b as ScanWxmlOptions } from './config-
|
|
2
|
+
import { E as Entry, S as SubPackageMetaValue, R as ResolvedAlias, P as ProjectConfig, M as MpPlatform, W as WeappViteConfig, a as SubPackage, A as AppEntry, b as ScanWxmlOptions } from './config-EPV0G671.js';
|
|
3
3
|
import { PackageJson } from 'pkg-types';
|
|
4
4
|
import { InlineConfig } from 'vite';
|
|
5
5
|
import { RollupWatcher, RollupOutput } from 'rollup';
|
|
6
6
|
import { Options } from 'tsup';
|
|
7
|
+
import * as ts_morph from 'ts-morph';
|
|
7
8
|
import { Buffer } from 'node:buffer';
|
|
8
9
|
|
|
9
10
|
interface WxmlDep {
|
|
@@ -102,6 +103,7 @@ declare class ConfigService {
|
|
|
102
103
|
get mpDistRoot(): string;
|
|
103
104
|
get outDir(): string;
|
|
104
105
|
get inlineConfig(): InlineConfig;
|
|
106
|
+
get weappViteConfig(): WeappViteConfig | undefined;
|
|
105
107
|
get packageJson(): PackageJson;
|
|
106
108
|
get projectConfig(): ProjectConfig;
|
|
107
109
|
get srcRoot(): string;
|
|
@@ -117,6 +119,7 @@ declare class JsonService {
|
|
|
117
119
|
private readonly configService;
|
|
118
120
|
constructor(configService: ConfigService);
|
|
119
121
|
read(filepath: string): Promise<any>;
|
|
122
|
+
resolve(entry: Partial<Pick<Entry, 'json' | 'jsonPath' | 'type'>>): string | undefined;
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
declare class NpmService {
|
|
@@ -152,7 +155,8 @@ declare class ScanService {
|
|
|
152
155
|
private usingComponentsHandler;
|
|
153
156
|
resetEntries(): void;
|
|
154
157
|
resetAutoImport(): void;
|
|
155
|
-
|
|
158
|
+
loadAppEntry(): Promise<AppEntry | undefined>;
|
|
159
|
+
scanAppEntry(): Promise<void>;
|
|
156
160
|
/**
|
|
157
161
|
* 扫描并处理组件入口文件。
|
|
158
162
|
* @param componentEntry 组件入口文件名
|
|
@@ -164,6 +168,13 @@ declare class ScanService {
|
|
|
164
168
|
* 同时处理引入组件的情况,自动注入 usingComponents。
|
|
165
169
|
*/
|
|
166
170
|
scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
|
|
171
|
+
get workersOptions(): string | {
|
|
172
|
+
[k: string]: unknown;
|
|
173
|
+
path?: string;
|
|
174
|
+
isSubpackage?: boolean;
|
|
175
|
+
} | undefined;
|
|
176
|
+
get workersDir(): string | undefined;
|
|
177
|
+
workersBuild(files: string[]): ts_morph.MemoryEmitResultFile[] | undefined;
|
|
167
178
|
}
|
|
168
179
|
|
|
169
180
|
declare class SubPackageService {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { R as ResolvedValue } from './types-dS68tjL6.cjs';
|
|
2
|
-
import { E as Entry, S as SubPackageMetaValue, R as ResolvedAlias, P as ProjectConfig, M as MpPlatform, a as SubPackage, A as AppEntry, b as ScanWxmlOptions } from './config-
|
|
2
|
+
import { E as Entry, S as SubPackageMetaValue, R as ResolvedAlias, P as ProjectConfig, M as MpPlatform, W as WeappViteConfig, a as SubPackage, A as AppEntry, b as ScanWxmlOptions } from './config-Cvwqemwg.cjs';
|
|
3
3
|
import { PackageJson } from 'pkg-types';
|
|
4
4
|
import { InlineConfig } from 'vite';
|
|
5
5
|
import { RollupWatcher, RollupOutput } from 'rollup';
|
|
6
6
|
import { Options } from 'tsup';
|
|
7
|
+
import * as ts_morph from 'ts-morph';
|
|
7
8
|
import { Buffer } from 'node:buffer';
|
|
8
9
|
|
|
9
10
|
interface WxmlDep {
|
|
@@ -102,6 +103,7 @@ declare class ConfigService {
|
|
|
102
103
|
get mpDistRoot(): string;
|
|
103
104
|
get outDir(): string;
|
|
104
105
|
get inlineConfig(): InlineConfig;
|
|
106
|
+
get weappViteConfig(): WeappViteConfig | undefined;
|
|
105
107
|
get packageJson(): PackageJson;
|
|
106
108
|
get projectConfig(): ProjectConfig;
|
|
107
109
|
get srcRoot(): string;
|
|
@@ -117,6 +119,7 @@ declare class JsonService {
|
|
|
117
119
|
private readonly configService;
|
|
118
120
|
constructor(configService: ConfigService);
|
|
119
121
|
read(filepath: string): Promise<any>;
|
|
122
|
+
resolve(entry: Partial<Pick<Entry, 'json' | 'jsonPath' | 'type'>>): string | undefined;
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
declare class NpmService {
|
|
@@ -152,7 +155,8 @@ declare class ScanService {
|
|
|
152
155
|
private usingComponentsHandler;
|
|
153
156
|
resetEntries(): void;
|
|
154
157
|
resetAutoImport(): void;
|
|
155
|
-
|
|
158
|
+
loadAppEntry(): Promise<AppEntry | undefined>;
|
|
159
|
+
scanAppEntry(): Promise<void>;
|
|
156
160
|
/**
|
|
157
161
|
* 扫描并处理组件入口文件。
|
|
158
162
|
* @param componentEntry 组件入口文件名
|
|
@@ -164,6 +168,13 @@ declare class ScanService {
|
|
|
164
168
|
* 同时处理引入组件的情况,自动注入 usingComponents。
|
|
165
169
|
*/
|
|
166
170
|
scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
|
|
171
|
+
get workersOptions(): string | {
|
|
172
|
+
[k: string]: unknown;
|
|
173
|
+
path?: string;
|
|
174
|
+
isSubpackage?: boolean;
|
|
175
|
+
} | undefined;
|
|
176
|
+
get workersDir(): string | undefined;
|
|
177
|
+
workersBuild(files: string[]): ts_morph.MemoryEmitResultFile[] | undefined;
|
|
167
178
|
}
|
|
168
179
|
|
|
169
180
|
declare class SubPackageService {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__name,
|
|
4
4
|
__toESM,
|
|
5
5
|
init_esm_shims
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PEN3BLSY.mjs";
|
|
7
7
|
|
|
8
8
|
// ../../node_modules/.pnpm/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js
|
|
9
9
|
var require_Reflect = __commonJS({
|
|
@@ -3582,8 +3582,8 @@ var AutoImportService2 = class {
|
|
|
3582
3582
|
}
|
|
3583
3583
|
}
|
|
3584
3584
|
filter(id, _meta) {
|
|
3585
|
-
if (this.configService.
|
|
3586
|
-
const isMatch = pm(this.configService.
|
|
3585
|
+
if (this.configService.weappViteConfig?.enhance?.autoImportComponents?.globs) {
|
|
3586
|
+
const isMatch = pm(this.configService.weappViteConfig.enhance.autoImportComponents.globs, {
|
|
3587
3587
|
cwd: this.configService.cwd,
|
|
3588
3588
|
windows: true,
|
|
3589
3589
|
posixSlashes: true
|
|
@@ -14187,7 +14187,7 @@ var debouncedLoggerSuccess = (0, import_debounce.default)((message) => {
|
|
|
14187
14187
|
return logger_default.success(message);
|
|
14188
14188
|
}, 25);
|
|
14189
14189
|
function vitePluginWeapp(ctx, subPackageMeta) {
|
|
14190
|
-
const { configService, subPackageService, autoImportService, scanService, wxmlService } = ctx;
|
|
14190
|
+
const { configService, subPackageService, autoImportService, scanService, wxmlService, jsonService } = ctx;
|
|
14191
14191
|
let configResolved;
|
|
14192
14192
|
function getInputOption(entries2) {
|
|
14193
14193
|
return entries2.reduce((acc, cur) => {
|
|
@@ -14200,6 +14200,7 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14200
14200
|
let entries;
|
|
14201
14201
|
const cachedEmittedFiles = [];
|
|
14202
14202
|
const cachedWatchFiles = [];
|
|
14203
|
+
const cachedWorkerFiles = [];
|
|
14203
14204
|
async function handleWxsDeps(deps, absPath) {
|
|
14204
14205
|
for (const wxsDep of deps.filter((x4) => x4.tagName === "wxs")) {
|
|
14205
14206
|
if (jsExtensions.includes(wxsDep.attrs.lang) || /\.wxs\.[jt]s$/.test(wxsDep.value)) {
|
|
@@ -14262,8 +14263,12 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14262
14263
|
}
|
|
14263
14264
|
},
|
|
14264
14265
|
async options(options) {
|
|
14266
|
+
if (!subPackageMeta) {
|
|
14267
|
+
await scanService.loadAppEntry();
|
|
14268
|
+
}
|
|
14265
14269
|
cachedEmittedFiles.length = 0;
|
|
14266
14270
|
cachedWatchFiles.length = 0;
|
|
14271
|
+
cachedWorkerFiles.length = 0;
|
|
14267
14272
|
scanService.resetAutoImport();
|
|
14268
14273
|
const { build: build4, weapp } = configResolved;
|
|
14269
14274
|
const ignore = [
|
|
@@ -14281,6 +14286,9 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14281
14286
|
"**/*.{wxml,html,wxs}",
|
|
14282
14287
|
"**/*.{png,jpg,jpeg,gif,svg,webp}"
|
|
14283
14288
|
];
|
|
14289
|
+
if (scanService.workersDir) {
|
|
14290
|
+
assetGlobs.push(path6.join(scanService.workersDir, "**/*.{js,ts}"));
|
|
14291
|
+
}
|
|
14284
14292
|
assetGlobs.push(...resolveGlobs(weapp?.copy?.include));
|
|
14285
14293
|
const patterns = assetGlobs.map((x4) => {
|
|
14286
14294
|
return path6.join(targetDir, x4);
|
|
@@ -14298,6 +14306,7 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14298
14306
|
const absPath = path6.resolve(configService.cwd, relPath);
|
|
14299
14307
|
cachedWatchFiles.push(absPath);
|
|
14300
14308
|
const isWxs = relPath.endsWith(".wxs");
|
|
14309
|
+
const isWorker = isJsOrTs(relPath) && scanService.workersDir && relPath.startsWith(scanService.workersDir);
|
|
14301
14310
|
const fileName = configService.relativeSrcRoot(relPath);
|
|
14302
14311
|
if (isTemplateRequest(relPath)) {
|
|
14303
14312
|
if (weapp?.enhance?.autoImportComponents && autoImportService.filter(relPath, subPackageMeta)) {
|
|
@@ -14314,6 +14323,12 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14314
14323
|
absPath,
|
|
14315
14324
|
fileName
|
|
14316
14325
|
});
|
|
14326
|
+
} else if (isWorker) {
|
|
14327
|
+
cachedWorkerFiles.push({
|
|
14328
|
+
relPath,
|
|
14329
|
+
absPath,
|
|
14330
|
+
fileName
|
|
14331
|
+
});
|
|
14317
14332
|
} else {
|
|
14318
14333
|
mediaFiles.push({
|
|
14319
14334
|
relPath,
|
|
@@ -14352,7 +14367,7 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14352
14367
|
return !wxmlService.tokenMap.has(x4.absPath);
|
|
14353
14368
|
});
|
|
14354
14369
|
const additionalWxmlFiles = excludedWxmlFiles.filter((x4) => {
|
|
14355
|
-
return configService.
|
|
14370
|
+
return configService.weappViteConfig?.isAdditionalWxml?.(x4.absPath);
|
|
14356
14371
|
});
|
|
14357
14372
|
debug2?.(`additionalWxmlFiles:`, additionalWxmlFiles);
|
|
14358
14373
|
await Promise.all([
|
|
@@ -14414,7 +14429,7 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14414
14429
|
this.emitFile({
|
|
14415
14430
|
type: "asset",
|
|
14416
14431
|
fileName,
|
|
14417
|
-
source:
|
|
14432
|
+
source: jsonService.resolve(entry)
|
|
14418
14433
|
});
|
|
14419
14434
|
}
|
|
14420
14435
|
}
|
|
@@ -14428,10 +14443,10 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14428
14443
|
this.emitFile({
|
|
14429
14444
|
type: "asset",
|
|
14430
14445
|
fileName,
|
|
14431
|
-
source:
|
|
14446
|
+
source: jsonService.resolve({
|
|
14432
14447
|
json: appEntry.sitemapJson,
|
|
14433
14448
|
jsonPath: appEntry.sitemapJsonPath
|
|
14434
|
-
}
|
|
14449
|
+
})
|
|
14435
14450
|
});
|
|
14436
14451
|
}
|
|
14437
14452
|
}
|
|
@@ -14442,16 +14457,30 @@ function vitePluginWeapp(ctx, subPackageMeta) {
|
|
|
14442
14457
|
this.emitFile({
|
|
14443
14458
|
type: "asset",
|
|
14444
14459
|
fileName,
|
|
14445
|
-
source:
|
|
14460
|
+
source: jsonService.resolve({
|
|
14446
14461
|
json: appEntry.themeJson,
|
|
14447
14462
|
jsonPath: appEntry.themeJsonPath
|
|
14448
|
-
}
|
|
14463
|
+
})
|
|
14449
14464
|
});
|
|
14450
14465
|
}
|
|
14451
14466
|
}
|
|
14452
14467
|
}
|
|
14453
14468
|
}
|
|
14454
14469
|
}
|
|
14470
|
+
if (scanService.workersDir && cachedWorkerFiles.length) {
|
|
14471
|
+
const workerFiles = scanService.workersBuild(cachedWorkerFiles.map((x4) => x4.absPath));
|
|
14472
|
+
if (workerFiles) {
|
|
14473
|
+
for (let i2 = 0; i2 < workerFiles.length; i2++) {
|
|
14474
|
+
const workerFile = workerFiles[i2];
|
|
14475
|
+
const fileName = configService.relativeSrcRoot(configService.relativeCwd(cachedWorkerFiles[i2].absPath));
|
|
14476
|
+
this.emitFile({
|
|
14477
|
+
type: "prebuilt-chunk",
|
|
14478
|
+
fileName,
|
|
14479
|
+
code: workerFile.text
|
|
14480
|
+
});
|
|
14481
|
+
}
|
|
14482
|
+
}
|
|
14483
|
+
}
|
|
14455
14484
|
debug2?.("buildEnd end");
|
|
14456
14485
|
},
|
|
14457
14486
|
resolveId(source) {
|
|
@@ -14706,6 +14735,9 @@ var ConfigService2 = class {
|
|
|
14706
14735
|
get inlineConfig() {
|
|
14707
14736
|
return this.options.config;
|
|
14708
14737
|
}
|
|
14738
|
+
get weappViteConfig() {
|
|
14739
|
+
return this.inlineConfig.weapp;
|
|
14740
|
+
}
|
|
14709
14741
|
get packageJson() {
|
|
14710
14742
|
return this.options.packageJson;
|
|
14711
14743
|
}
|
|
@@ -15261,6 +15293,9 @@ var JsonService2 = class {
|
|
|
15261
15293
|
logger_default.error(error);
|
|
15262
15294
|
}
|
|
15263
15295
|
}
|
|
15296
|
+
resolve(entry) {
|
|
15297
|
+
return resolveJson(entry, this.configService.aliasEntries);
|
|
15298
|
+
}
|
|
15264
15299
|
};
|
|
15265
15300
|
JsonService2 = _ts_decorate5([
|
|
15266
15301
|
Kt(),
|
|
@@ -22510,9 +22545,11 @@ var NpmService2 = class {
|
|
|
22510
22545
|
// https://tsup.egoist.dev/#compile-time-environment-variables
|
|
22511
22546
|
env: {
|
|
22512
22547
|
NODE_ENV: "production"
|
|
22513
|
-
}
|
|
22548
|
+
},
|
|
22549
|
+
minify: true,
|
|
22550
|
+
target: "es6"
|
|
22514
22551
|
});
|
|
22515
|
-
const resolvedOptions = this.configService.
|
|
22552
|
+
const resolvedOptions = this.configService.weappViteConfig?.npm?.tsup?.(mergedOptions, {
|
|
22516
22553
|
entry: index,
|
|
22517
22554
|
name: dep
|
|
22518
22555
|
});
|
|
@@ -22548,6 +22585,7 @@ init_esm_shims();
|
|
|
22548
22585
|
import { get as get2, isObject as isObject5, removeExtension as removeExtension4, set as set2 } from "@weapp-core/shared";
|
|
22549
22586
|
import fs11 from "fs-extra";
|
|
22550
22587
|
import path13 from "pathe";
|
|
22588
|
+
import { ModuleKind, Project, ScriptTarget } from "ts-morph";
|
|
22551
22589
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
22552
22590
|
var c3 = arguments.length, r5 = c3 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
|
|
22553
22591
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r5 = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -22645,9 +22683,7 @@ var ScanService2 = class {
|
|
|
22645
22683
|
this.autoImportService.potentialComponentMap.clear();
|
|
22646
22684
|
this.wxmlService.wxmlComponentsMap.clear();
|
|
22647
22685
|
}
|
|
22648
|
-
async
|
|
22649
|
-
debug?.("scanAppEntry start");
|
|
22650
|
-
this.resetEntries();
|
|
22686
|
+
async loadAppEntry() {
|
|
22651
22687
|
const appDirname = path13.resolve(this.configService.cwd, this.configService.srcRoot);
|
|
22652
22688
|
const appBasename = path13.resolve(appDirname, "app");
|
|
22653
22689
|
const appConfigFile = await findJsonEntry(appBasename);
|
|
@@ -22655,20 +22691,14 @@ var ScanService2 = class {
|
|
|
22655
22691
|
if (appEntryPath && appConfigFile) {
|
|
22656
22692
|
const config = await this.jsonService.read(appConfigFile);
|
|
22657
22693
|
if (isObject5(config)) {
|
|
22658
|
-
if (this.entriesSet.has(appEntryPath)) {
|
|
22659
|
-
return;
|
|
22660
|
-
}
|
|
22661
|
-
this.entriesSet.add(appEntryPath);
|
|
22662
22694
|
const appEntry = {
|
|
22663
22695
|
path: appEntryPath,
|
|
22664
22696
|
json: config,
|
|
22665
22697
|
jsonPath: appConfigFile,
|
|
22666
22698
|
type: "app"
|
|
22667
22699
|
};
|
|
22668
|
-
this.entries.push(appEntry);
|
|
22669
22700
|
this.appEntry = appEntry;
|
|
22670
|
-
|
|
22671
|
-
const { pages, subpackages = [], subPackages = [], sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
|
|
22701
|
+
const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
|
|
22672
22702
|
if (sitemapLocation) {
|
|
22673
22703
|
const sitemapJsonPath = await findJsonEntry(path13.resolve(appDirname, sitemapLocation));
|
|
22674
22704
|
if (sitemapJsonPath) {
|
|
@@ -22683,58 +22713,75 @@ var ScanService2 = class {
|
|
|
22683
22713
|
appEntry.themeJson = await this.jsonService.read(themeJsonPath);
|
|
22684
22714
|
}
|
|
22685
22715
|
}
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
|
|
22716
|
+
return appEntry;
|
|
22717
|
+
}
|
|
22718
|
+
} else {
|
|
22719
|
+
throw new Error(`\u5728 ${appDirname} \u76EE\u5F55\u4E0B\u6CA1\u6709\u627E\u5230 \`app.json\`, \u8BF7\u786E\u4FDD\u4F60\u521D\u59CB\u5316\u4E86\u5C0F\u7A0B\u5E8F\u9879\u76EE\uFF0C\u6216\u8005\u5728 \`vite.config.ts\` \u4E2D\u8BBE\u7F6E\u7684\u6B63\u786E\u7684 \`weapp.srcRoot\` \u914D\u7F6E\u8DEF\u5F84 `);
|
|
22720
|
+
}
|
|
22721
|
+
}
|
|
22722
|
+
async scanAppEntry() {
|
|
22723
|
+
debug?.("scanAppEntry start");
|
|
22724
|
+
this.resetEntries();
|
|
22725
|
+
const appDirname = path13.resolve(this.configService.cwd, this.configService.srcRoot);
|
|
22726
|
+
if (this.appEntry) {
|
|
22727
|
+
const { path: appEntryPath, json: config } = this.appEntry;
|
|
22728
|
+
if (this.entriesSet.has(appEntryPath)) {
|
|
22729
|
+
return;
|
|
22730
|
+
}
|
|
22731
|
+
this.entriesSet.add(appEntryPath);
|
|
22732
|
+
this.entries.push(this.appEntry);
|
|
22733
|
+
this.pagesSet = this.initPagesSet();
|
|
22734
|
+
const { pages, subpackages = [], subPackages = [] } = config;
|
|
22735
|
+
const subs = [
|
|
22736
|
+
...subpackages,
|
|
22737
|
+
...subPackages
|
|
22738
|
+
];
|
|
22739
|
+
await this.usingComponentsHandler(this.appEntry, appDirname);
|
|
22740
|
+
if (Array.isArray(pages)) {
|
|
22741
|
+
for (const page of pages) {
|
|
22742
|
+
await this.scanComponentEntry(page, appDirname);
|
|
22695
22743
|
}
|
|
22696
|
-
|
|
22697
|
-
|
|
22698
|
-
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22702
|
-
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
};
|
|
22707
|
-
if (Array.isArray(sub.pages)) {
|
|
22708
|
-
for (const page of sub.pages) {
|
|
22709
|
-
await this.scanComponentEntry(path13.join(sub.root, page), appDirname, meta);
|
|
22710
|
-
}
|
|
22711
|
-
}
|
|
22712
|
-
if (sub.entry) {
|
|
22713
|
-
await this.scanComponentEntry(path13.join(sub.root, sub.entry), appDirname, meta);
|
|
22744
|
+
}
|
|
22745
|
+
for (const sub of subs) {
|
|
22746
|
+
if (sub.independent || this.configService.weappViteConfig?.subPackages?.[sub.root]?.independent) {
|
|
22747
|
+
const meta = {
|
|
22748
|
+
entries: [],
|
|
22749
|
+
entriesSet: /* @__PURE__ */ new Set(),
|
|
22750
|
+
// 合并选项
|
|
22751
|
+
subPackage: {
|
|
22752
|
+
...sub,
|
|
22753
|
+
dependencies: this.configService.weappViteConfig?.subPackages?.[sub.root].dependencies
|
|
22714
22754
|
}
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
await this.scanComponentEntry(path13.join(sub.root, page), appDirname);
|
|
22720
|
-
}
|
|
22755
|
+
};
|
|
22756
|
+
if (Array.isArray(sub.pages)) {
|
|
22757
|
+
for (const page of sub.pages) {
|
|
22758
|
+
await this.scanComponentEntry(path13.join(sub.root, page), appDirname, meta);
|
|
22721
22759
|
}
|
|
22722
|
-
|
|
22723
|
-
|
|
22760
|
+
}
|
|
22761
|
+
if (sub.entry) {
|
|
22762
|
+
await this.scanComponentEntry(path13.join(sub.root, sub.entry), appDirname, meta);
|
|
22763
|
+
}
|
|
22764
|
+
this.subPackageService.metaMap[sub.root] = meta;
|
|
22765
|
+
} else {
|
|
22766
|
+
if (Array.isArray(sub.pages)) {
|
|
22767
|
+
for (const page of sub.pages) {
|
|
22768
|
+
await this.scanComponentEntry(path13.join(sub.root, page), appDirname);
|
|
22724
22769
|
}
|
|
22725
22770
|
}
|
|
22771
|
+
if (sub.entry) {
|
|
22772
|
+
await this.scanComponentEntry(path13.join(sub.root, sub.entry), appDirname);
|
|
22773
|
+
}
|
|
22726
22774
|
}
|
|
22727
|
-
if (get2(appEntry, "json.tabBar.custom")) {
|
|
22728
|
-
await this.scanComponentEntry("custom-tab-bar/index", appDirname);
|
|
22729
|
-
}
|
|
22730
|
-
if (get2(appEntry, "json.appBar")) {
|
|
22731
|
-
await this.scanComponentEntry("app-bar/index", appDirname);
|
|
22732
|
-
}
|
|
22733
|
-
debug?.("scanAppEntry end");
|
|
22734
|
-
return appEntry;
|
|
22735
22775
|
}
|
|
22776
|
+
if (get2(this.appEntry, "json.tabBar.custom")) {
|
|
22777
|
+
await this.scanComponentEntry("custom-tab-bar/index", appDirname);
|
|
22778
|
+
}
|
|
22779
|
+
if (get2(this.appEntry, "json.appBar")) {
|
|
22780
|
+
await this.scanComponentEntry("app-bar/index", appDirname);
|
|
22781
|
+
}
|
|
22782
|
+
debug?.("scanAppEntry end");
|
|
22736
22783
|
} else {
|
|
22737
|
-
throw new Error(`\
|
|
22784
|
+
throw new Error(`\u6CA1\u6709\u5148\u6267\u884C loadAppEntry \u65B9\u6CD5\u52A0\u8F7D\u5168\u5C40 app.json \u914D\u7F6E`);
|
|
22738
22785
|
}
|
|
22739
22786
|
}
|
|
22740
22787
|
// usingComponents
|
|
@@ -22824,8 +22871,8 @@ var ScanService2 = class {
|
|
|
22824
22871
|
}
|
|
22825
22872
|
set2(jsonFragment.json, `usingComponents.${value.name}`, value.from);
|
|
22826
22873
|
}
|
|
22827
|
-
} else if (Array.isArray(this.configService.
|
|
22828
|
-
for (const resolver of this.configService.
|
|
22874
|
+
} else if (Array.isArray(this.configService.weappViteConfig?.enhance?.autoImportComponents?.resolvers)) {
|
|
22875
|
+
for (const resolver of this.configService.weappViteConfig.enhance.autoImportComponents.resolvers) {
|
|
22829
22876
|
const value = resolver(depComponentName, baseName);
|
|
22830
22877
|
if (value) {
|
|
22831
22878
|
if (!(isObject5(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name))) {
|
|
@@ -22842,6 +22889,38 @@ var ScanService2 = class {
|
|
|
22842
22889
|
}
|
|
22843
22890
|
debug?.("scanComponentEntry end", componentEntry, partialEntry);
|
|
22844
22891
|
}
|
|
22892
|
+
// https://developers.weixin.qq.com/miniprogram/dev/framework/workers.html
|
|
22893
|
+
get workersOptions() {
|
|
22894
|
+
return this.appEntry?.json?.workers;
|
|
22895
|
+
}
|
|
22896
|
+
get workersDir() {
|
|
22897
|
+
return typeof this.workersOptions === "object" ? this.workersOptions.path : this.workersOptions;
|
|
22898
|
+
}
|
|
22899
|
+
// https://cn.vitejs.dev/guide/build.html#library-mode
|
|
22900
|
+
// miniprogram_dist
|
|
22901
|
+
// miniprogram
|
|
22902
|
+
// https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9B%B8%E5%85%B3%E7%A4%BA%E4%BE%8B
|
|
22903
|
+
// #endregion
|
|
22904
|
+
workersBuild(files) {
|
|
22905
|
+
if (this.workersDir && files.length) {
|
|
22906
|
+
const project = new Project({
|
|
22907
|
+
compilerOptions: {
|
|
22908
|
+
target: ScriptTarget.ES5,
|
|
22909
|
+
module: ModuleKind.CommonJS,
|
|
22910
|
+
outDir: path13.resolve(this.configService.outDir, this.workersDir),
|
|
22911
|
+
strict: true,
|
|
22912
|
+
allowJs: true
|
|
22913
|
+
},
|
|
22914
|
+
skipAddingFilesFromTsConfig: true
|
|
22915
|
+
});
|
|
22916
|
+
for (const file of files) {
|
|
22917
|
+
project.addSourceFileAtPath(file);
|
|
22918
|
+
}
|
|
22919
|
+
const result = project.emitToMemory();
|
|
22920
|
+
const sourceFiles = result.getFiles();
|
|
22921
|
+
return sourceFiles;
|
|
22922
|
+
}
|
|
22923
|
+
}
|
|
22845
22924
|
};
|
|
22846
22925
|
ScanService2 = _ts_decorate7([
|
|
22847
22926
|
Kt(),
|
|
@@ -23051,7 +23130,7 @@ var WxmlService2 = class {
|
|
|
23051
23130
|
const wxml = await fs12.readFile(filepath, "utf8");
|
|
23052
23131
|
const res = scanWxml(wxml, {
|
|
23053
23132
|
platform: this.configService.platform,
|
|
23054
|
-
...this.configService.
|
|
23133
|
+
...this.configService.weappViteConfig?.enhance?.wxml === true ? {} : this.configService.weappViteConfig?.enhance?.wxml
|
|
23055
23134
|
});
|
|
23056
23135
|
this.tokenMap.set(filepath, res);
|
|
23057
23136
|
await this.addDeps(filepath, res.deps.filter((x4) => isImportTag(x4.tagName) && isTemplate(x4.value)).map((x4) => path14.resolve(dirname3, x4.value)));
|
|
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
mod
|
|
29
29
|
));
|
|
30
30
|
|
|
31
|
-
// ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.
|
|
31
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.7_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js
|
|
32
32
|
var init_esm_shims = __esm({
|
|
33
|
-
"../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.
|
|
33
|
+
"../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.7_jiti@2.4.2_postcss@8.4.49_tsx@4.19.2_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js"() {
|
|
34
34
|
"use strict";
|
|
35
35
|
}
|
|
36
36
|
});
|