weapp-vite 1.9.2 → 2.0.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/index.d.cts CHANGED
@@ -1,17 +1,14 @@
1
- import { C as CompilerContextOptions } from './config-D__5C2s3.cjs';
2
- import { C as CompilerContext } from './CompilerContext-C0ZHcUt-.cjs';
1
+ import { L as LoadConfigOptions, C as CompilerContext } from './CompilerContext-D9i0PEsF.cjs';
2
+ import './types-dS68tjL6.cjs';
3
+ import './config-DYSwq1ku.cjs';
3
4
  import 'vite';
4
- import '@weapp-core/schematics';
5
- import 'pkg-types';
6
5
  import 'tsup';
7
6
  import 'vite-tsconfig-paths';
8
- import './types-dS68tjL6.cjs';
7
+ import '@weapp-core/schematics';
8
+ import 'pkg-types';
9
9
  import 'rollup';
10
+ import 'node:buffer';
10
11
 
11
- interface CreateCompilerContextOptions {
12
- loadConfig?: boolean;
13
- }
14
-
15
- declare function createCompilerContext(options?: CompilerContextOptions, opts?: CreateCompilerContextOptions): Promise<CompilerContext>;
12
+ declare function createCompilerContext(options?: Partial<LoadConfigOptions>): Promise<CompilerContext>;
16
13
 
17
- export { CompilerContext, type CreateCompilerContextOptions, createCompilerContext };
14
+ export { createCompilerContext };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,14 @@
1
- import { C as CompilerContextOptions } from './config-YkkDB5_Y.js';
2
- import { C as CompilerContext } from './CompilerContext-DzZuTlqZ.js';
1
+ import { L as LoadConfigOptions, C as CompilerContext } from './CompilerContext-BpoRCDyM.js';
2
+ import './types-dS68tjL6.js';
3
+ import './config-BM_dhf8V.js';
3
4
  import 'vite';
4
- import '@weapp-core/schematics';
5
- import 'pkg-types';
6
5
  import 'tsup';
7
6
  import 'vite-tsconfig-paths';
8
- import './types-dS68tjL6.js';
7
+ import '@weapp-core/schematics';
8
+ import 'pkg-types';
9
9
  import 'rollup';
10
+ import 'node:buffer';
10
11
 
11
- interface CreateCompilerContextOptions {
12
- loadConfig?: boolean;
13
- }
14
-
15
- declare function createCompilerContext(options?: CompilerContextOptions, opts?: CreateCompilerContextOptions): Promise<CompilerContext>;
12
+ declare function createCompilerContext(options?: Partial<LoadConfigOptions>): Promise<CompilerContext>;
16
13
 
17
- export { CompilerContext, type CreateCompilerContextOptions, createCompilerContext };
14
+ export { createCompilerContext };
package/dist/index.mjs CHANGED
@@ -1,15 +1,14 @@
1
1
  import {
2
- CompilerContext,
3
2
  createCompilerContext
4
- } from "./chunk-I36YQNJ7.mjs";
5
- import "./chunk-2FYXPWJ7.mjs";
3
+ } from "./chunk-EO33M7LR.mjs";
4
+ import "./chunk-5E4BX2PC.mjs";
6
5
  import {
7
6
  init_esm_shims
8
- } from "./chunk-WKC6OQ3Q.mjs";
7
+ } from "./chunk-3HVIVQUO.mjs";
9
8
 
10
9
  // src/index.ts
11
10
  init_esm_shims();
11
+ import "reflect-metadata";
12
12
  export {
13
- CompilerContext,
14
13
  createCompilerContext
15
14
  };
package/dist/json.cjs CHANGED
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,21 +28,21 @@ __export(json_exports, {
27
28
  defineThemeJson: () => defineThemeJson
28
29
  });
29
30
  module.exports = __toCommonJS(json_exports);
30
- var defineAppJson = (config) => {
31
+ var defineAppJson = /* @__PURE__ */ __name((config) => {
31
32
  return config;
32
- };
33
- var definePageJson = (config) => {
33
+ }, "defineAppJson");
34
+ var definePageJson = /* @__PURE__ */ __name((config) => {
34
35
  return config;
35
- };
36
- var defineComponentJson = (config) => {
36
+ }, "definePageJson");
37
+ var defineComponentJson = /* @__PURE__ */ __name((config) => {
37
38
  return config;
38
- };
39
- var defineSitemapJson = (config) => {
39
+ }, "defineComponentJson");
40
+ var defineSitemapJson = /* @__PURE__ */ __name((config) => {
40
41
  return config;
41
- };
42
- var defineThemeJson = (config) => {
42
+ }, "defineSitemapJson");
43
+ var defineThemeJson = /* @__PURE__ */ __name((config) => {
43
44
  return config;
44
- };
45
+ }, "defineThemeJson");
45
46
  // Annotate the CommonJS export names for ESM import in node:
46
47
  0 && (module.exports = {
47
48
  defineAppJson,
package/dist/json.d.cts CHANGED
@@ -1,17 +1,16 @@
1
1
  import { App, Page, Component, Sitemap, Theme } from '@weapp-core/schematics';
2
2
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
3
- import { C as CompilerContext } from './CompilerContext-C0ZHcUt-.cjs';
4
- import 'pkg-types';
5
- import 'rollup';
3
+ import { C as CompilerContext } from './CompilerContext-D9i0PEsF.cjs';
6
4
  import './types-dS68tjL6.cjs';
7
- import './config-D__5C2s3.cjs';
5
+ import './config-DYSwq1ku.cjs';
8
6
  import 'vite';
9
7
  import 'tsup';
10
8
  import 'vite-tsconfig-paths';
9
+ import 'pkg-types';
10
+ import 'rollup';
11
+ import 'node:buffer';
11
12
 
12
- interface ReturnSelf<T> {
13
- (config: T): T;
14
- }
13
+ type ReturnSelf<T> = (config: T) => T;
15
14
  type ConfigFn<T> = T | ((ctx: CompilerContext) => T);
16
15
  type DefineJsonFn<T> = ReturnSelf<ConfigFn<T>>;
17
16
  declare const defineAppJson: DefineJsonFn<App>;
package/dist/json.d.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  import { App, Page, Component, Sitemap, Theme } from '@weapp-core/schematics';
2
2
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
3
- import { C as CompilerContext } from './CompilerContext-DzZuTlqZ.js';
4
- import 'pkg-types';
5
- import 'rollup';
3
+ import { C as CompilerContext } from './CompilerContext-BpoRCDyM.js';
6
4
  import './types-dS68tjL6.js';
7
- import './config-YkkDB5_Y.js';
5
+ import './config-BM_dhf8V.js';
8
6
  import 'vite';
9
7
  import 'tsup';
10
8
  import 'vite-tsconfig-paths';
9
+ import 'pkg-types';
10
+ import 'rollup';
11
+ import 'node:buffer';
11
12
 
12
- interface ReturnSelf<T> {
13
- (config: T): T;
14
- }
13
+ type ReturnSelf<T> = (config: T) => T;
15
14
  type ConfigFn<T> = T | ((ctx: CompilerContext) => T);
16
15
  type DefineJsonFn<T> = ReturnSelf<ConfigFn<T>>;
17
16
  declare const defineAppJson: DefineJsonFn<App>;
package/dist/json.mjs CHANGED
@@ -1,24 +1,25 @@
1
1
  import {
2
+ __name,
2
3
  init_esm_shims
3
- } from "./chunk-WKC6OQ3Q.mjs";
4
+ } from "./chunk-3HVIVQUO.mjs";
4
5
 
5
6
  // src/json.ts
6
7
  init_esm_shims();
7
- var defineAppJson = (config) => {
8
+ var defineAppJson = /* @__PURE__ */ __name((config) => {
8
9
  return config;
9
- };
10
- var definePageJson = (config) => {
10
+ }, "defineAppJson");
11
+ var definePageJson = /* @__PURE__ */ __name((config) => {
11
12
  return config;
12
- };
13
- var defineComponentJson = (config) => {
13
+ }, "definePageJson");
14
+ var defineComponentJson = /* @__PURE__ */ __name((config) => {
14
15
  return config;
15
- };
16
- var defineSitemapJson = (config) => {
16
+ }, "defineComponentJson");
17
+ var defineSitemapJson = /* @__PURE__ */ __name((config) => {
17
18
  return config;
18
- };
19
- var defineThemeJson = (config) => {
19
+ }, "defineSitemapJson");
20
+ var defineThemeJson = /* @__PURE__ */ __name((config) => {
20
21
  return config;
21
- };
22
+ }, "defineThemeJson");
22
23
  export {
23
24
  defineAppJson,
24
25
  defineComponentJson,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "1.9.2",
4
+ "version": "2.0.0",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -50,10 +50,25 @@
50
50
  },
51
51
  "./package.json": "./package.json"
52
52
  },
53
+ "main": "./dist/index.cjs",
54
+ "module": "./dist/index.mjs",
55
+ "types": "./dist/index.d.ts",
56
+ "weapp-vite-dev": {
57
+ "bin": {
58
+ "weapp-vite": "dev/bin.js"
59
+ },
60
+ "exports": {
61
+ ".": "./src/index.ts",
62
+ "./config": "./src/config.ts",
63
+ "./json": "./src/json.ts",
64
+ "./client": {
65
+ "types": "./client.d.ts"
66
+ },
67
+ "./auto-import-components/resolvers": "./src/auto-import-components/resolvers/index.ts"
68
+ }
69
+ },
53
70
  "bin": {
54
71
  "weapp-vite": "bin/weapp-vite.js",
55
- "weapp-vite-esm": "bin/weapp-vite-esm.js",
56
- "weapp-vite-cjs": "bin/weapp-vite-cjs.js",
57
72
  "wv": "bin/weapp-vite.js"
58
73
  },
59
74
  "files": [
@@ -77,20 +92,22 @@
77
92
  "esbuild": "^0.24.2",
78
93
  "fdir": "^6.4.2",
79
94
  "fs-extra": "^11.2.0",
80
- "htmlparser2": "^9.1.0",
95
+ "htmlparser2": "^10.0.0",
96
+ "inversify": "^6.2.1",
81
97
  "local-pkg": "^0.5.1",
82
98
  "magic-string": "^0.30.17",
83
99
  "pathe": "^1.1.2",
84
100
  "picomatch": "^4.0.2",
85
101
  "postcss": "^8.4.49",
102
+ "reflect-metadata": "^0.2.2",
86
103
  "tsup": "^8.3.5",
87
104
  "vite": "^5.4.11",
88
105
  "vite-tsconfig-paths": "^5.1.4",
89
- "@weapp-core/init": "^1.1.12",
90
- "@weapp-core/logger": "^1.0.1",
106
+ "@weapp-core/init": "^1.1.14",
107
+ "@weapp-core/logger": "^1.0.2",
91
108
  "@weapp-core/schematics": "^1.0.7",
92
109
  "@weapp-core/shared": "^1.0.4",
93
- "weapp-ide-cli": "^2.0.7"
110
+ "weapp-ide-cli": "^2.0.8"
94
111
  },
95
112
  "publishConfig": {
96
113
  "access": "public",
@@ -103,8 +120,5 @@
103
120
  "test:dev": "vitest",
104
121
  "test": "vitest run",
105
122
  "sync": "cnpm sync weapp-vite"
106
- },
107
- "main": "./dist/index.cjs",
108
- "module": "./dist/index.mjs",
109
- "types": "./dist/index.d.ts"
123
+ }
110
124
  }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require('../dist/cli.cjs')
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import '../dist/cli.mjs'
@@ -1,128 +0,0 @@
1
- import { PackageJson } from 'pkg-types';
2
- import { RollupOutput, RollupWatcher } from 'rollup';
3
- import { R as ResolvedValue } from './types-dS68tjL6.cjs';
4
- import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, a as ComponentsMap, C as CompilerContextOptions, b as SubPackage } from './config-D__5C2s3.cjs';
5
- import { InlineConfig } from 'vite';
6
- import { Options } from 'tsup';
7
-
8
- interface OutputExtensions {
9
- js: string;
10
- json: string;
11
- wxml: string;
12
- wxss: string;
13
- wxs?: string;
14
- }
15
-
16
- declare class CompilerContext {
17
- /**
18
- * loadDefaultConfig 的时候会被重新赋予
19
- */
20
- inlineConfig: InlineConfig;
21
- cwd: string;
22
- isDev: boolean;
23
- projectConfig: ProjectConfig;
24
- mode: string;
25
- packageJson: PackageJson;
26
- private rollupWatcherMap;
27
- entriesSet: Set<string>;
28
- entries: Entry[];
29
- potentialComponentMap: Map<string, {
30
- entry: Entry;
31
- value: ResolvedValue;
32
- }>;
33
- appEntry?: AppEntry;
34
- subPackageMeta: Record<string, SubPackageMetaValue>;
35
- aliasEntries: ResolvedAlias[];
36
- platform: MpPlatform;
37
- outputExtensions: OutputExtensions;
38
- /**
39
- * esbuild 定义的环境变量
40
- */
41
- defineEnv: Record<string, any>;
42
- wxmlComponentsMap: Map<string, ComponentsMap>;
43
- /**
44
- * CompilerContext 类的构造函数,用于初始化编译上下文。
45
- * @param options - 可选的编译上下文选项,包括当前工作目录、是否为开发环境、内联配置、项目配置、模式、package.json 和平台等信息。
46
- * 如果未提供选项,则使用默认值进行初始化。
47
- * @property cwd - 当前工作目录。
48
- * @property inlineConfig - 内联配置。
49
- * @property isDev - 是否为开发环境。
50
- * @property projectConfig - 项目配置。
51
- * @property mode - 编译模式。
52
- * @property packageJson - package.json 文件内容。
53
- * @property rollupWatcherMap - Rollup 监视器映射。
54
- * @property subPackageMeta - 子包元数据。
55
- * @property entriesSet - 入口文件集合。
56
- * @property entries - 入口文件数组。
57
- * @property potentialComponentMap - 潜在组件映射。
58
- * @property aliasEntries - 别名入口数组。
59
- * @property platform - 平台类型。
60
- * @property outputExtensions - 输出文件扩展名。
61
- * @property defineEnv - 定义的环境变量。
62
- * @property wxmlComponentsMap - WXML 组件映射。
63
- */
64
- constructor(options?: CompilerContextOptions);
65
- /**
66
- * 插件真正计算出来的 define options
67
- */
68
- /**
69
- * 获取编译上下文中的环境变量定义,用于在小程序环境中暴露全局变量。
70
- * 该函数将当前平台、用户自定义的环境变量合并,并将其转换为 import.meta.env 对象的属性。
71
- * @returns {Record<string, any>} 包含所有环境变量的对象,键为 import.meta.env 下的属性名,值为对应的环境变量值。
72
- */
73
- get defineImportMetaEnv(): Record<string, any>;
74
- setDefineEnv(key: string, value: any): void;
75
- get srcRoot(): string;
76
- relativeCwd(p: string): string;
77
- relativeSrcRoot(p: string): string;
78
- /**
79
- * @description 写在 projectConfig 里面的 miniprogramRoot / srcMiniprogramRoot
80
- * 默认为 'dist'
81
- *
82
- */
83
- get mpDistRoot(): string | undefined;
84
- get outDir(): string;
85
- private runDev;
86
- getConfig(subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig>[]): InlineConfig;
87
- getPagesSet(): Set<string>;
88
- runProd(): Promise<RollupOutput | RollupOutput[]>;
89
- build(): Promise<void>;
90
- /**
91
- * @deps [this.scanComponentEntry]
92
- * @param entry
93
- * @param relDir
94
- */
95
- private usingComponentsHandler;
96
- resetEntries(): void;
97
- resetAutoImport(): void;
98
- resolvedComponentName(entry: string): string | undefined;
99
- scanPotentialComponentEntries(filePath: string): Promise<void>;
100
- scanAppEntry(): Promise<AppEntry | undefined>;
101
- /**
102
- * 扫描并处理组件入口文件。
103
- * @param componentEntry 组件入口文件名
104
- * @param dirname 当前目录路径
105
- * @param subPackageMeta 分包元信息(可选)
106
- * @returns Promise<void>
107
- *
108
- * 该函数用于扫描并处理组件入口文件,包括查找 JS 入口、JSON 配置文件、模板入口等。
109
- * 同时处理引入组件的情况,自动注入 usingComponents。
110
- */
111
- scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
112
- setRollupWatcher(watcher: RollupWatcher, root?: string): void;
113
- autoImportFilter(id: string, meta?: SubPackageMetaValue): boolean;
114
- buildSubPackage(): Promise<void>;
115
- /**
116
- * 不修改 ctx
117
- */
118
- readCommentJson(filepath: string): Promise<any>;
119
- buildNpm(subPackage?: SubPackage, options?: Options): Promise<void>;
120
- loadDefaultConfig(): Promise<void>;
121
- get dependenciesCacheFilePath(): string;
122
- get dependenciesCacheHash(): string;
123
- writeDependenciesCache(): void;
124
- readDependenciesCache(): Promise<void>;
125
- checkDependenciesCacheOutdate(): Promise<boolean>;
126
- }
127
-
128
- export { CompilerContext as C };
@@ -1,128 +0,0 @@
1
- import { PackageJson } from 'pkg-types';
2
- import { RollupOutput, RollupWatcher } from 'rollup';
3
- import { R as ResolvedValue } from './types-dS68tjL6.js';
4
- import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, a as ComponentsMap, C as CompilerContextOptions, b as SubPackage } from './config-YkkDB5_Y.js';
5
- import { InlineConfig } from 'vite';
6
- import { Options } from 'tsup';
7
-
8
- interface OutputExtensions {
9
- js: string;
10
- json: string;
11
- wxml: string;
12
- wxss: string;
13
- wxs?: string;
14
- }
15
-
16
- declare class CompilerContext {
17
- /**
18
- * loadDefaultConfig 的时候会被重新赋予
19
- */
20
- inlineConfig: InlineConfig;
21
- cwd: string;
22
- isDev: boolean;
23
- projectConfig: ProjectConfig;
24
- mode: string;
25
- packageJson: PackageJson;
26
- private rollupWatcherMap;
27
- entriesSet: Set<string>;
28
- entries: Entry[];
29
- potentialComponentMap: Map<string, {
30
- entry: Entry;
31
- value: ResolvedValue;
32
- }>;
33
- appEntry?: AppEntry;
34
- subPackageMeta: Record<string, SubPackageMetaValue>;
35
- aliasEntries: ResolvedAlias[];
36
- platform: MpPlatform;
37
- outputExtensions: OutputExtensions;
38
- /**
39
- * esbuild 定义的环境变量
40
- */
41
- defineEnv: Record<string, any>;
42
- wxmlComponentsMap: Map<string, ComponentsMap>;
43
- /**
44
- * CompilerContext 类的构造函数,用于初始化编译上下文。
45
- * @param options - 可选的编译上下文选项,包括当前工作目录、是否为开发环境、内联配置、项目配置、模式、package.json 和平台等信息。
46
- * 如果未提供选项,则使用默认值进行初始化。
47
- * @property cwd - 当前工作目录。
48
- * @property inlineConfig - 内联配置。
49
- * @property isDev - 是否为开发环境。
50
- * @property projectConfig - 项目配置。
51
- * @property mode - 编译模式。
52
- * @property packageJson - package.json 文件内容。
53
- * @property rollupWatcherMap - Rollup 监视器映射。
54
- * @property subPackageMeta - 子包元数据。
55
- * @property entriesSet - 入口文件集合。
56
- * @property entries - 入口文件数组。
57
- * @property potentialComponentMap - 潜在组件映射。
58
- * @property aliasEntries - 别名入口数组。
59
- * @property platform - 平台类型。
60
- * @property outputExtensions - 输出文件扩展名。
61
- * @property defineEnv - 定义的环境变量。
62
- * @property wxmlComponentsMap - WXML 组件映射。
63
- */
64
- constructor(options?: CompilerContextOptions);
65
- /**
66
- * 插件真正计算出来的 define options
67
- */
68
- /**
69
- * 获取编译上下文中的环境变量定义,用于在小程序环境中暴露全局变量。
70
- * 该函数将当前平台、用户自定义的环境变量合并,并将其转换为 import.meta.env 对象的属性。
71
- * @returns {Record<string, any>} 包含所有环境变量的对象,键为 import.meta.env 下的属性名,值为对应的环境变量值。
72
- */
73
- get defineImportMetaEnv(): Record<string, any>;
74
- setDefineEnv(key: string, value: any): void;
75
- get srcRoot(): string;
76
- relativeCwd(p: string): string;
77
- relativeSrcRoot(p: string): string;
78
- /**
79
- * @description 写在 projectConfig 里面的 miniprogramRoot / srcMiniprogramRoot
80
- * 默认为 'dist'
81
- *
82
- */
83
- get mpDistRoot(): string | undefined;
84
- get outDir(): string;
85
- private runDev;
86
- getConfig(subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig>[]): InlineConfig;
87
- getPagesSet(): Set<string>;
88
- runProd(): Promise<RollupOutput | RollupOutput[]>;
89
- build(): Promise<void>;
90
- /**
91
- * @deps [this.scanComponentEntry]
92
- * @param entry
93
- * @param relDir
94
- */
95
- private usingComponentsHandler;
96
- resetEntries(): void;
97
- resetAutoImport(): void;
98
- resolvedComponentName(entry: string): string | undefined;
99
- scanPotentialComponentEntries(filePath: string): Promise<void>;
100
- scanAppEntry(): Promise<AppEntry | undefined>;
101
- /**
102
- * 扫描并处理组件入口文件。
103
- * @param componentEntry 组件入口文件名
104
- * @param dirname 当前目录路径
105
- * @param subPackageMeta 分包元信息(可选)
106
- * @returns Promise<void>
107
- *
108
- * 该函数用于扫描并处理组件入口文件,包括查找 JS 入口、JSON 配置文件、模板入口等。
109
- * 同时处理引入组件的情况,自动注入 usingComponents。
110
- */
111
- scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
112
- setRollupWatcher(watcher: RollupWatcher, root?: string): void;
113
- autoImportFilter(id: string, meta?: SubPackageMetaValue): boolean;
114
- buildSubPackage(): Promise<void>;
115
- /**
116
- * 不修改 ctx
117
- */
118
- readCommentJson(filepath: string): Promise<any>;
119
- buildNpm(subPackage?: SubPackage, options?: Options): Promise<void>;
120
- loadDefaultConfig(): Promise<void>;
121
- get dependenciesCacheFilePath(): string;
122
- get dependenciesCacheHash(): string;
123
- writeDependenciesCache(): void;
124
- readDependenciesCache(): Promise<void>;
125
- checkDependenciesCacheOutdate(): Promise<boolean>;
126
- }
127
-
128
- export { CompilerContext as C };