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