@esmx/core 3.0.0-rc.60 → 3.0.0-rc.63
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/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/app.d.ts +27 -27
- package/dist/core.d.ts +274 -272
- package/dist/core.mjs +235 -232
- package/dist/pack-config.d.ts +92 -92
- package/dist/render-context.d.ts +465 -465
- package/dist/render-context.mjs +338 -338
- package/dist/utils/cache.d.ts +15 -15
- package/dist/utils/import-map.d.ts +31 -1
- package/dist/utils/import-map.mjs +18 -0
- package/dist/utils/import-map.test.mjs +577 -1
- package/dist/utils/middleware.d.ts +19 -19
- package/dist/utils/static-import-lexer.d.ts +12 -12
- package/dist/utils/static-import-lexer.mjs +1 -1
- package/package.json +3 -3
- package/src/app.ts +34 -34
- package/src/core.ts +320 -317
- package/src/pack-config.ts +92 -92
- package/src/render-context.ts +465 -465
- package/src/utils/cache.ts +15 -15
- package/src/utils/import-map.test.ts +713 -1
- package/src/utils/import-map.ts +53 -1
- package/src/utils/middleware.ts +19 -19
- package/src/utils/static-import-lexer.ts +18 -18
package/dist/pack-config.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { Esmx } from './core';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Package configuration interface.
|
|
4
|
+
* Used to package build artifacts into standard npm .tgz format packages.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
6
|
+
* Features:
|
|
7
|
+
* - **Standardization**: Uses npm standard .tgz packaging format
|
|
8
|
+
* - **Completeness**: Contains all necessary files including module source code, type declarations, and configuration files
|
|
9
|
+
* - **Compatibility**: Fully compatible with npm ecosystem, supporting standard package management workflows
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
* - CI/CD
|
|
11
|
+
* Use Cases:
|
|
12
|
+
* - Module packaging and publishing
|
|
13
|
+
* - Version release management
|
|
14
|
+
* - CI/CD process integration
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
@@ -20,7 +20,7 @@ import type { Esmx } from './core';
|
|
|
20
20
|
*
|
|
21
21
|
* export default {
|
|
22
22
|
* modules: {
|
|
23
|
-
* //
|
|
23
|
+
* // Configure modules to export
|
|
24
24
|
* exports: [
|
|
25
25
|
* 'root:src/components/button.vue',
|
|
26
26
|
* 'root:src/utils/format.ts',
|
|
@@ -28,22 +28,22 @@ import type { Esmx } from './core';
|
|
|
28
28
|
* 'pkg:vue-router'
|
|
29
29
|
* ]
|
|
30
30
|
* },
|
|
31
|
-
* //
|
|
31
|
+
* // Packaging configuration
|
|
32
32
|
* pack: {
|
|
33
|
-
* //
|
|
33
|
+
* // Enable packaging functionality
|
|
34
34
|
* enable: true,
|
|
35
35
|
*
|
|
36
|
-
* //
|
|
36
|
+
* // Output multiple versions simultaneously
|
|
37
37
|
* outputs: [
|
|
38
38
|
* 'dist/versions/latest.tgz',
|
|
39
39
|
* 'dist/versions/1.0.0.tgz'
|
|
40
40
|
* ],
|
|
41
41
|
*
|
|
42
|
-
* //
|
|
42
|
+
* // Customize package.json
|
|
43
43
|
* packageJson: async (esmx, pkg) => {
|
|
44
44
|
* pkg.name = '@your-scope/your-app';
|
|
45
45
|
* pkg.version = '1.0.0';
|
|
46
|
-
* //
|
|
46
|
+
* // Add build scripts
|
|
47
47
|
* pkg.scripts = {
|
|
48
48
|
* "prepare": "npm run build",
|
|
49
49
|
* "build": "npm run build:dts && npm run build:ssr",
|
|
@@ -53,21 +53,21 @@ import type { Esmx } from './core';
|
|
|
53
53
|
* return pkg;
|
|
54
54
|
* },
|
|
55
55
|
*
|
|
56
|
-
* //
|
|
56
|
+
* // Pre-packaging preparation
|
|
57
57
|
* onBefore: async (esmx, pkg) => {
|
|
58
|
-
* //
|
|
59
|
-
* await fs.writeFile('dist/README.md', '# Your App\n\
|
|
60
|
-
* //
|
|
58
|
+
* // Add necessary files
|
|
59
|
+
* await fs.writeFile('dist/README.md', '# Your App\n\nModule export description...');
|
|
60
|
+
* // Execute type checking
|
|
61
61
|
* await runTypeCheck();
|
|
62
62
|
* },
|
|
63
63
|
*
|
|
64
|
-
* //
|
|
64
|
+
* // Post-packaging processing
|
|
65
65
|
* onAfter: async (esmx, pkg, file) => {
|
|
66
|
-
* //
|
|
66
|
+
* // Publish to private npm registry
|
|
67
67
|
* await publishToRegistry(file, {
|
|
68
68
|
* registry: 'https://npm.your-registry.com/'
|
|
69
69
|
* });
|
|
70
|
-
* //
|
|
70
|
+
* // Or deploy to static server
|
|
71
71
|
* await uploadToServer(file, 'https://static.example.com/packages');
|
|
72
72
|
* }
|
|
73
73
|
* }
|
|
@@ -76,30 +76,30 @@ import type { Esmx } from './core';
|
|
|
76
76
|
*/
|
|
77
77
|
export interface PackConfig {
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
79
|
+
* Whether to enable packaging functionality.
|
|
80
|
+
* When enabled, build artifacts will be packaged into standard npm .tgz format packages.
|
|
81
81
|
* @default false
|
|
82
82
|
*/
|
|
83
83
|
enable?: boolean;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* - string:
|
|
88
|
-
* - string[]:
|
|
89
|
-
* - boolean: true
|
|
85
|
+
* Specify the output package file path.
|
|
86
|
+
* Supports the following configuration methods:
|
|
87
|
+
* - string: Single output path, e.g., 'dist/versions/my-app.tgz'
|
|
88
|
+
* - string[]: Multiple output paths for generating multiple versions simultaneously
|
|
89
|
+
* - boolean: When true, uses default path 'dist/client/versions/latest.tgz'
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
92
|
* ```ts
|
|
93
|
-
* //
|
|
93
|
+
* // Single output
|
|
94
94
|
* outputs: 'dist/app.tgz'
|
|
95
95
|
*
|
|
96
|
-
* //
|
|
96
|
+
* // Multiple versions
|
|
97
97
|
* outputs: [
|
|
98
98
|
* 'dist/versions/latest.tgz',
|
|
99
99
|
* 'dist/versions/1.0.0.tgz'
|
|
100
100
|
* ]
|
|
101
101
|
*
|
|
102
|
-
* //
|
|
102
|
+
* // Use default path
|
|
103
103
|
* outputs: true
|
|
104
104
|
* ```
|
|
105
105
|
*
|
|
@@ -107,34 +107,34 @@ export interface PackConfig {
|
|
|
107
107
|
*/
|
|
108
108
|
outputs?: string | string[] | boolean;
|
|
109
109
|
/**
|
|
110
|
-
* package.json
|
|
111
|
-
*
|
|
110
|
+
* package.json processing function.
|
|
111
|
+
* Called before packaging to customize the content of package.json.
|
|
112
112
|
*
|
|
113
|
-
*
|
|
114
|
-
* -
|
|
115
|
-
* -
|
|
116
|
-
* -
|
|
117
|
-
* -
|
|
113
|
+
* Common use cases:
|
|
114
|
+
* - Modify package name and version
|
|
115
|
+
* - Add or update dependencies
|
|
116
|
+
* - Add custom fields
|
|
117
|
+
* - Configure publishing related information
|
|
118
118
|
*
|
|
119
|
-
* @param esmx - Esmx
|
|
120
|
-
* @param pkgJson -
|
|
121
|
-
* @returns
|
|
119
|
+
* @param esmx - Esmx instance
|
|
120
|
+
* @param pkgJson - Original package.json content
|
|
121
|
+
* @returns Processed package.json content
|
|
122
122
|
*
|
|
123
123
|
* @example
|
|
124
124
|
* ```ts
|
|
125
125
|
* packageJson: async (esmx, pkg) => {
|
|
126
|
-
* //
|
|
126
|
+
* // Set package information
|
|
127
127
|
* pkg.name = 'my-app';
|
|
128
128
|
* pkg.version = '1.0.0';
|
|
129
|
-
* pkg.description = '
|
|
129
|
+
* pkg.description = 'My Application';
|
|
130
130
|
*
|
|
131
|
-
* //
|
|
131
|
+
* // Add dependencies
|
|
132
132
|
* pkg.dependencies = {
|
|
133
133
|
* 'vue': '^3.0.0',
|
|
134
134
|
* 'express': '^4.17.1'
|
|
135
135
|
* };
|
|
136
136
|
*
|
|
137
|
-
* //
|
|
137
|
+
* // Add publishing configuration
|
|
138
138
|
* pkg.publishConfig = {
|
|
139
139
|
* registry: 'https://registry.example.com'
|
|
140
140
|
* };
|
|
@@ -145,63 +145,63 @@ export interface PackConfig {
|
|
|
145
145
|
*/
|
|
146
146
|
packageJson?: (esmx: Esmx, pkgJson: Record<string, any>) => Promise<Record<string, any>>;
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
148
|
+
* Pre-packaging hook function.
|
|
149
|
+
* Called before generating .tgz file to execute preparation work.
|
|
150
150
|
*
|
|
151
|
-
*
|
|
152
|
-
* -
|
|
153
|
-
* -
|
|
154
|
-
* -
|
|
155
|
-
* -
|
|
151
|
+
* Common use cases:
|
|
152
|
+
* - Add additional files (README, LICENSE, etc.)
|
|
153
|
+
* - Execute tests or build validation
|
|
154
|
+
* - Generate documentation or metadata
|
|
155
|
+
* - Clean up temporary files
|
|
156
156
|
*
|
|
157
|
-
* @param esmx - Esmx
|
|
158
|
-
* @param pkgJson -
|
|
157
|
+
* @param esmx - Esmx instance
|
|
158
|
+
* @param pkgJson - Processed package.json content
|
|
159
159
|
*
|
|
160
160
|
* @example
|
|
161
161
|
* ```ts
|
|
162
162
|
* onBefore: async (esmx, pkg) => {
|
|
163
|
-
* //
|
|
163
|
+
* // Add documentation
|
|
164
164
|
* await fs.writeFile('dist/README.md', '# My App');
|
|
165
165
|
* await fs.writeFile('dist/LICENSE', 'MIT License');
|
|
166
166
|
*
|
|
167
|
-
* //
|
|
167
|
+
* // Execute tests
|
|
168
168
|
* await runTests();
|
|
169
169
|
*
|
|
170
|
-
* //
|
|
170
|
+
* // Generate documentation
|
|
171
171
|
* await generateDocs();
|
|
172
172
|
* }
|
|
173
173
|
* ```
|
|
174
174
|
*/
|
|
175
175
|
onBefore?: (esmx: Esmx, pkgJson: Record<string, any>) => Promise<void>;
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
177
|
+
* Post-packaging hook function.
|
|
178
|
+
* Called after .tgz file is generated to handle packaging artifacts.
|
|
179
179
|
*
|
|
180
|
-
*
|
|
181
|
-
* -
|
|
182
|
-
* -
|
|
183
|
-
* -
|
|
184
|
-
* -
|
|
180
|
+
* Common use cases:
|
|
181
|
+
* - Publish to npm registry (public or private)
|
|
182
|
+
* - Upload to static asset server
|
|
183
|
+
* - Execute version management
|
|
184
|
+
* - Trigger CI/CD processes
|
|
185
185
|
*
|
|
186
|
-
* @param esmx - Esmx
|
|
187
|
-
* @param pkgJson -
|
|
188
|
-
* @param file -
|
|
186
|
+
* @param esmx - Esmx instance
|
|
187
|
+
* @param pkgJson - Final package.json content
|
|
188
|
+
* @param file - Generated .tgz file content
|
|
189
189
|
*
|
|
190
190
|
* @example
|
|
191
191
|
* ```ts
|
|
192
192
|
* onAfter: async (esmx, pkg, file) => {
|
|
193
|
-
* //
|
|
193
|
+
* // Publish to npm private registry
|
|
194
194
|
* await publishToRegistry(file, {
|
|
195
195
|
* registry: 'https://registry.example.com'
|
|
196
196
|
* });
|
|
197
197
|
*
|
|
198
|
-
* //
|
|
198
|
+
* // Upload to static asset server
|
|
199
199
|
* await uploadToServer(file, 'https://assets.example.com/packages');
|
|
200
200
|
*
|
|
201
|
-
* //
|
|
201
|
+
* // Create version tag
|
|
202
202
|
* await createGitTag(pkg.version);
|
|
203
203
|
*
|
|
204
|
-
* //
|
|
204
|
+
* // Trigger deployment process
|
|
205
205
|
* await triggerDeploy(pkg.version);
|
|
206
206
|
* }
|
|
207
207
|
* ```
|
|
@@ -209,42 +209,42 @@ export interface PackConfig {
|
|
|
209
209
|
onAfter?: (esmx: Esmx, pkgJson: Record<string, any>, file: Buffer) => Promise<void>;
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
|
-
* PackConfig
|
|
213
|
-
*
|
|
212
|
+
* Internal interface after PackConfig configuration is parsed.
|
|
213
|
+
* Standardizes user configuration, sets default values, for internal framework use.
|
|
214
214
|
*
|
|
215
|
-
*
|
|
216
|
-
* -
|
|
217
|
-
* -
|
|
218
|
-
* -
|
|
215
|
+
* Main processing:
|
|
216
|
+
* - Ensure all optional fields have default values
|
|
217
|
+
* - Unify output path format
|
|
218
|
+
* - Standardize callback functions
|
|
219
219
|
*/
|
|
220
220
|
export interface ParsedPackConfig {
|
|
221
221
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
222
|
+
* Whether to enable packaging functionality.
|
|
223
|
+
* Always has a definite boolean value after parsing.
|
|
224
224
|
* @default false
|
|
225
225
|
*/
|
|
226
226
|
enable: boolean;
|
|
227
227
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* -
|
|
231
|
-
* -
|
|
232
|
-
* -
|
|
228
|
+
* Parsed output file path list.
|
|
229
|
+
* Converts all output formats uniformly to string arrays:
|
|
230
|
+
* - Boolean true → ['dist/client/versions/latest.tgz']
|
|
231
|
+
* - String → [input string]
|
|
232
|
+
* - String array → remains unchanged
|
|
233
233
|
*/
|
|
234
234
|
outputs: string[];
|
|
235
235
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
236
|
+
* Standardized package.json processing function.
|
|
237
|
+
* Uses default function when not configured, keeping original content unchanged.
|
|
238
238
|
*/
|
|
239
239
|
packageJson: (esmx: Esmx, pkgJson: Record<string, any>) => Promise<Record<string, any>>;
|
|
240
240
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
241
|
+
* Standardized pre-packaging hook function.
|
|
242
|
+
* Uses empty function when not configured.
|
|
243
243
|
*/
|
|
244
244
|
onBefore: (esmx: Esmx, pkgJson: Record<string, any>) => Promise<void>;
|
|
245
245
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
246
|
+
* Standardized post-packaging hook function.
|
|
247
|
+
* Uses empty function when not configured.
|
|
248
248
|
*/
|
|
249
249
|
onAfter: (esmx: Esmx, pkgJson: Record<string, any>, file: Buffer) => Promise<void>;
|
|
250
250
|
}
|