weapp-vite 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-6X6X4NDH.mjs} +145 -68
- package/dist/{chunk-ZRLZHOL5.mjs → chunk-PEN3BLSY.mjs} +2 -2
- package/dist/{chunk-4ZIYVTHH.mjs → chunk-RSPHXR3C.mjs} +1 -1
- package/dist/cli.cjs +146 -69
- package/dist/cli.mjs +3 -3
- 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 +146 -69
- 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 +6 -5
|
@@ -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(),
|
|
@@ -22512,7 +22547,7 @@ var NpmService2 = class {
|
|
|
22512
22547
|
NODE_ENV: "production"
|
|
22513
22548
|
}
|
|
22514
22549
|
});
|
|
22515
|
-
const resolvedOptions = this.configService.
|
|
22550
|
+
const resolvedOptions = this.configService.weappViteConfig?.npm?.tsup?.(mergedOptions, {
|
|
22516
22551
|
entry: index,
|
|
22517
22552
|
name: dep
|
|
22518
22553
|
});
|
|
@@ -22548,6 +22583,7 @@ init_esm_shims();
|
|
|
22548
22583
|
import { get as get2, isObject as isObject5, removeExtension as removeExtension4, set as set2 } from "@weapp-core/shared";
|
|
22549
22584
|
import fs11 from "fs-extra";
|
|
22550
22585
|
import path13 from "pathe";
|
|
22586
|
+
import { ModuleKind, Project, ScriptTarget } from "ts-morph";
|
|
22551
22587
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
22552
22588
|
var c3 = arguments.length, r5 = c3 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
|
|
22553
22589
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r5 = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -22645,9 +22681,7 @@ var ScanService2 = class {
|
|
|
22645
22681
|
this.autoImportService.potentialComponentMap.clear();
|
|
22646
22682
|
this.wxmlService.wxmlComponentsMap.clear();
|
|
22647
22683
|
}
|
|
22648
|
-
async
|
|
22649
|
-
debug?.("scanAppEntry start");
|
|
22650
|
-
this.resetEntries();
|
|
22684
|
+
async loadAppEntry() {
|
|
22651
22685
|
const appDirname = path13.resolve(this.configService.cwd, this.configService.srcRoot);
|
|
22652
22686
|
const appBasename = path13.resolve(appDirname, "app");
|
|
22653
22687
|
const appConfigFile = await findJsonEntry(appBasename);
|
|
@@ -22655,20 +22689,14 @@ var ScanService2 = class {
|
|
|
22655
22689
|
if (appEntryPath && appConfigFile) {
|
|
22656
22690
|
const config = await this.jsonService.read(appConfigFile);
|
|
22657
22691
|
if (isObject5(config)) {
|
|
22658
|
-
if (this.entriesSet.has(appEntryPath)) {
|
|
22659
|
-
return;
|
|
22660
|
-
}
|
|
22661
|
-
this.entriesSet.add(appEntryPath);
|
|
22662
22692
|
const appEntry = {
|
|
22663
22693
|
path: appEntryPath,
|
|
22664
22694
|
json: config,
|
|
22665
22695
|
jsonPath: appConfigFile,
|
|
22666
22696
|
type: "app"
|
|
22667
22697
|
};
|
|
22668
|
-
this.entries.push(appEntry);
|
|
22669
22698
|
this.appEntry = appEntry;
|
|
22670
|
-
|
|
22671
|
-
const { pages, subpackages = [], subPackages = [], sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
|
|
22699
|
+
const { sitemapLocation = "sitemap.json", themeLocation = "theme.json" } = config;
|
|
22672
22700
|
if (sitemapLocation) {
|
|
22673
22701
|
const sitemapJsonPath = await findJsonEntry(path13.resolve(appDirname, sitemapLocation));
|
|
22674
22702
|
if (sitemapJsonPath) {
|
|
@@ -22683,58 +22711,75 @@ var ScanService2 = class {
|
|
|
22683
22711
|
appEntry.themeJson = await this.jsonService.read(themeJsonPath);
|
|
22684
22712
|
}
|
|
22685
22713
|
}
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
|
|
22714
|
+
return appEntry;
|
|
22715
|
+
}
|
|
22716
|
+
} else {
|
|
22717
|
+
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 `);
|
|
22718
|
+
}
|
|
22719
|
+
}
|
|
22720
|
+
async scanAppEntry() {
|
|
22721
|
+
debug?.("scanAppEntry start");
|
|
22722
|
+
this.resetEntries();
|
|
22723
|
+
const appDirname = path13.resolve(this.configService.cwd, this.configService.srcRoot);
|
|
22724
|
+
if (this.appEntry) {
|
|
22725
|
+
const { path: appEntryPath, json: config } = this.appEntry;
|
|
22726
|
+
if (this.entriesSet.has(appEntryPath)) {
|
|
22727
|
+
return;
|
|
22728
|
+
}
|
|
22729
|
+
this.entriesSet.add(appEntryPath);
|
|
22730
|
+
this.entries.push(this.appEntry);
|
|
22731
|
+
this.pagesSet = this.initPagesSet();
|
|
22732
|
+
const { pages, subpackages = [], subPackages = [] } = config;
|
|
22733
|
+
const subs = [
|
|
22734
|
+
...subpackages,
|
|
22735
|
+
...subPackages
|
|
22736
|
+
];
|
|
22737
|
+
await this.usingComponentsHandler(this.appEntry, appDirname);
|
|
22738
|
+
if (Array.isArray(pages)) {
|
|
22739
|
+
for (const page of pages) {
|
|
22740
|
+
await this.scanComponentEntry(page, appDirname);
|
|
22695
22741
|
}
|
|
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);
|
|
22742
|
+
}
|
|
22743
|
+
for (const sub of subs) {
|
|
22744
|
+
if (sub.independent || this.configService.weappViteConfig?.subPackages?.[sub.root]?.independent) {
|
|
22745
|
+
const meta = {
|
|
22746
|
+
entries: [],
|
|
22747
|
+
entriesSet: /* @__PURE__ */ new Set(),
|
|
22748
|
+
// 合并选项
|
|
22749
|
+
subPackage: {
|
|
22750
|
+
...sub,
|
|
22751
|
+
dependencies: this.configService.weappViteConfig?.subPackages?.[sub.root].dependencies
|
|
22714
22752
|
}
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
|
|
22719
|
-
await this.scanComponentEntry(path13.join(sub.root, page), appDirname);
|
|
22720
|
-
}
|
|
22753
|
+
};
|
|
22754
|
+
if (Array.isArray(sub.pages)) {
|
|
22755
|
+
for (const page of sub.pages) {
|
|
22756
|
+
await this.scanComponentEntry(path13.join(sub.root, page), appDirname, meta);
|
|
22721
22757
|
}
|
|
22722
|
-
|
|
22723
|
-
|
|
22758
|
+
}
|
|
22759
|
+
if (sub.entry) {
|
|
22760
|
+
await this.scanComponentEntry(path13.join(sub.root, sub.entry), appDirname, meta);
|
|
22761
|
+
}
|
|
22762
|
+
this.subPackageService.metaMap[sub.root] = meta;
|
|
22763
|
+
} else {
|
|
22764
|
+
if (Array.isArray(sub.pages)) {
|
|
22765
|
+
for (const page of sub.pages) {
|
|
22766
|
+
await this.scanComponentEntry(path13.join(sub.root, page), appDirname);
|
|
22724
22767
|
}
|
|
22725
22768
|
}
|
|
22769
|
+
if (sub.entry) {
|
|
22770
|
+
await this.scanComponentEntry(path13.join(sub.root, sub.entry), appDirname);
|
|
22771
|
+
}
|
|
22726
22772
|
}
|
|
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
22773
|
}
|
|
22774
|
+
if (get2(this.appEntry, "json.tabBar.custom")) {
|
|
22775
|
+
await this.scanComponentEntry("custom-tab-bar/index", appDirname);
|
|
22776
|
+
}
|
|
22777
|
+
if (get2(this.appEntry, "json.appBar")) {
|
|
22778
|
+
await this.scanComponentEntry("app-bar/index", appDirname);
|
|
22779
|
+
}
|
|
22780
|
+
debug?.("scanAppEntry end");
|
|
22736
22781
|
} else {
|
|
22737
|
-
throw new Error(`\
|
|
22782
|
+
throw new Error(`\u6CA1\u6709\u5148\u6267\u884C loadAppEntry \u65B9\u6CD5\u52A0\u8F7D\u5168\u5C40 app.json \u914D\u7F6E`);
|
|
22738
22783
|
}
|
|
22739
22784
|
}
|
|
22740
22785
|
// usingComponents
|
|
@@ -22824,8 +22869,8 @@ var ScanService2 = class {
|
|
|
22824
22869
|
}
|
|
22825
22870
|
set2(jsonFragment.json, `usingComponents.${value.name}`, value.from);
|
|
22826
22871
|
}
|
|
22827
|
-
} else if (Array.isArray(this.configService.
|
|
22828
|
-
for (const resolver of this.configService.
|
|
22872
|
+
} else if (Array.isArray(this.configService.weappViteConfig?.enhance?.autoImportComponents?.resolvers)) {
|
|
22873
|
+
for (const resolver of this.configService.weappViteConfig.enhance.autoImportComponents.resolvers) {
|
|
22829
22874
|
const value = resolver(depComponentName, baseName);
|
|
22830
22875
|
if (value) {
|
|
22831
22876
|
if (!(isObject5(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name))) {
|
|
@@ -22842,6 +22887,38 @@ var ScanService2 = class {
|
|
|
22842
22887
|
}
|
|
22843
22888
|
debug?.("scanComponentEntry end", componentEntry, partialEntry);
|
|
22844
22889
|
}
|
|
22890
|
+
// https://developers.weixin.qq.com/miniprogram/dev/framework/workers.html
|
|
22891
|
+
get workersOptions() {
|
|
22892
|
+
return this.appEntry?.json?.workers;
|
|
22893
|
+
}
|
|
22894
|
+
get workersDir() {
|
|
22895
|
+
return typeof this.workersOptions === "object" ? this.workersOptions.path : this.workersOptions;
|
|
22896
|
+
}
|
|
22897
|
+
// https://cn.vitejs.dev/guide/build.html#library-mode
|
|
22898
|
+
// miniprogram_dist
|
|
22899
|
+
// miniprogram
|
|
22900
|
+
// 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
|
|
22901
|
+
// #endregion
|
|
22902
|
+
workersBuild(files) {
|
|
22903
|
+
if (this.workersDir && files.length) {
|
|
22904
|
+
const project = new Project({
|
|
22905
|
+
compilerOptions: {
|
|
22906
|
+
target: ScriptTarget.ES5,
|
|
22907
|
+
module: ModuleKind.CommonJS,
|
|
22908
|
+
outDir: path13.resolve(this.configService.outDir, this.workersDir),
|
|
22909
|
+
strict: true,
|
|
22910
|
+
allowJs: true
|
|
22911
|
+
},
|
|
22912
|
+
skipAddingFilesFromTsConfig: true
|
|
22913
|
+
});
|
|
22914
|
+
for (const file of files) {
|
|
22915
|
+
project.addSourceFileAtPath(file);
|
|
22916
|
+
}
|
|
22917
|
+
const result = project.emitToMemory();
|
|
22918
|
+
const sourceFiles = result.getFiles();
|
|
22919
|
+
return sourceFiles;
|
|
22920
|
+
}
|
|
22921
|
+
}
|
|
22845
22922
|
};
|
|
22846
22923
|
ScanService2 = _ts_decorate7([
|
|
22847
22924
|
Kt(),
|
|
@@ -23051,7 +23128,7 @@ var WxmlService2 = class {
|
|
|
23051
23128
|
const wxml = await fs12.readFile(filepath, "utf8");
|
|
23052
23129
|
const res = scanWxml(wxml, {
|
|
23053
23130
|
platform: this.configService.platform,
|
|
23054
|
-
...this.configService.
|
|
23131
|
+
...this.configService.weappViteConfig?.enhance?.wxml === true ? {} : this.configService.weappViteConfig?.enhance?.wxml
|
|
23055
23132
|
});
|
|
23056
23133
|
this.tokenMap.set(filepath, res);
|
|
23057
23134
|
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
|
});
|