@vc-shell/config-generator 1.1.4 → 1.1.6
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/CHANGELOG.md +13 -0
- package/README.md +154 -0
- package/dist/index.d.ts +26 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -2
- package/dist/index.js.map +1 -1
- package/dist/templates/vite.dynamic-module.appconfig.d.ts +20 -0
- package/dist/templates/vite.dynamic-module.appconfig.d.ts.map +1 -0
- package/dist/templates/vite.dynamic-module.appconfig.js +132 -0
- package/dist/templates/vite.dynamic-module.appconfig.js.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [1.1.6](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.5...v1.1.6) (2025-05-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add Vite configuration generator for dynamic modules with compatibility options ([0a4822e](https://github.com/VirtoCommerce/vc-shell/commit/0a4822e219f2fa120b476f420badf6b068891fdb))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [1.1.5](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.4...v1.1.5) (2025-05-07)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## [1.1.4](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.3...v1.1.4) (2025-04-30)
|
|
2
15
|
|
|
3
16
|
|
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# VC-Shell Vite Configuration Generator
|
|
2
|
+
|
|
3
|
+
This package provides a set of pre-configured Vite configurations for VC-Shell projects, simplifying the setup for different types of builds.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vc-shell/config-generator --save-dev
|
|
9
|
+
# or
|
|
10
|
+
yarn add -D @vc-shell/config-generator
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Available Configurations
|
|
14
|
+
|
|
15
|
+
The package provides three main types of configurations:
|
|
16
|
+
|
|
17
|
+
1. **Application Configuration** - for primary VC-Shell applications
|
|
18
|
+
2. **Library Configuration** - for creating libraries and packages
|
|
19
|
+
3. **Dynamic Modules Configuration** - for creating modules that can be loaded dynamically at runtime
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Application Configuration
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
// vite.config.js
|
|
27
|
+
import { getApplicationConfiguration } from '@vc-shell/config-generator';
|
|
28
|
+
|
|
29
|
+
export default getApplicationConfiguration({
|
|
30
|
+
// Custom settings (optional)
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Library Configuration
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
// vite.config.js
|
|
38
|
+
import { getLibraryConfiguration } from '@vc-shell/config-generator';
|
|
39
|
+
|
|
40
|
+
export default getLibraryConfiguration({
|
|
41
|
+
// Custom settings (optional)
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Dynamic Modules Configuration
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// vite.config.js
|
|
49
|
+
import { getDynamicModuleConfiguration } from '@vc-shell/config-generator';
|
|
50
|
+
|
|
51
|
+
export default getDynamicModuleConfiguration({
|
|
52
|
+
// Compatibility configuration is required
|
|
53
|
+
compatibility: {
|
|
54
|
+
// Framework version compatibility (required)
|
|
55
|
+
framework: '^1.1.0',
|
|
56
|
+
|
|
57
|
+
// Compatibility with other modules (optional)
|
|
58
|
+
modules: {
|
|
59
|
+
'@vc-shell/module-catalog': '^1.0.0'
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// Compatibility with applications (required)
|
|
63
|
+
apps: {
|
|
64
|
+
'vendor-portal-new': '^2.0.0'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
// Additional configuration options (optional)
|
|
69
|
+
entry: './src/index.ts',
|
|
70
|
+
outDir: 'dist/modules',
|
|
71
|
+
moduleName: 'MyCustomModule',
|
|
72
|
+
|
|
73
|
+
// Additional external dependencies
|
|
74
|
+
externals: ['axios', 'chart.js']
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Dynamic Modules Configuration Options
|
|
79
|
+
|
|
80
|
+
| Option | Type | Description |
|
|
81
|
+
|--------|------|-------------|
|
|
82
|
+
| `entry` | `string` | Module entry point (default: `./index.ts`) |
|
|
83
|
+
| `outDir` | `string` | Output directory (default: `dist/packages/modules`) |
|
|
84
|
+
| `moduleName` | `string` | Module name for UMD build (default: derived from package.json) |
|
|
85
|
+
| `compatibility` | `object` | **Required:** Compatibility constraints for the module |
|
|
86
|
+
| `compatibility.framework` | `string` | **Required:** Compatible framework version range |
|
|
87
|
+
| `compatibility.modules` | `object` | Compatible version ranges for other modules |
|
|
88
|
+
| `compatibility.apps` | `object` | **Required:** Compatible application version ranges |
|
|
89
|
+
| `externals` | `string[]` | Additional external dependencies |
|
|
90
|
+
|
|
91
|
+
## Dynamic Modules Configuration Features
|
|
92
|
+
|
|
93
|
+
### Version Metadata
|
|
94
|
+
|
|
95
|
+
The configuration automatically adds version and compatibility information to the module build:
|
|
96
|
+
|
|
97
|
+
1. Adds a global variable `window.__VC_SHELL_MODULE_VERSION_INFO__` with version information
|
|
98
|
+
2. Creates a `version.json` file with version and compatibility metadata
|
|
99
|
+
3. Updates `manifest.json`, adding a reference to the version file
|
|
100
|
+
|
|
101
|
+
### Output Format
|
|
102
|
+
|
|
103
|
+
Modules are built in UMD format to ensure compatibility with various runtime environments.
|
|
104
|
+
|
|
105
|
+
### External Dependencies
|
|
106
|
+
|
|
107
|
+
By default, the following libraries are excluded from the build:
|
|
108
|
+
- Vue
|
|
109
|
+
- Vue Router
|
|
110
|
+
- Vee-Validate
|
|
111
|
+
- Vue I18n
|
|
112
|
+
- Moment.js
|
|
113
|
+
- Lodash
|
|
114
|
+
- VueUse
|
|
115
|
+
- VC-Shell Framework
|
|
116
|
+
|
|
117
|
+
## Examples
|
|
118
|
+
|
|
119
|
+
### Dynamic Module Configuration Example
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
// vite.config.js
|
|
123
|
+
import { getDynamicModuleConfiguration } from '@vc-shell/config-generator';
|
|
124
|
+
|
|
125
|
+
export default getDynamicModuleConfiguration({
|
|
126
|
+
entry: './src/main.ts',
|
|
127
|
+
outDir: 'dist/custom-module',
|
|
128
|
+
moduleName: 'VcCustomModule',
|
|
129
|
+
|
|
130
|
+
compatibility: {
|
|
131
|
+
framework: '^1.2.0',
|
|
132
|
+
modules: {
|
|
133
|
+
'@vc-shell/module-catalog': '^1.0.0',
|
|
134
|
+
'@vc-shell/module-auth': '^1.5.0'
|
|
135
|
+
},
|
|
136
|
+
apps: {
|
|
137
|
+
'vendor-portal-new': '^2.0.0',
|
|
138
|
+
'admin-portal': '^1.5.0'
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
externals: [
|
|
143
|
+
'axios',
|
|
144
|
+
'chart.js'
|
|
145
|
+
],
|
|
146
|
+
|
|
147
|
+
// Any additional Vite configuration options
|
|
148
|
+
build: {
|
|
149
|
+
minify: 'esbuild',
|
|
150
|
+
sourcemap: true,
|
|
151
|
+
chunkSizeWarningLimit: 800
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { UserConfig } from "vite";
|
|
2
|
+
import { DynamicModuleOptions } from "./types.js";
|
|
2
3
|
declare function getLibraryConfiguration(options?: UserConfig): Record<string, any>;
|
|
3
4
|
declare function getApplicationConfiguration(options?: UserConfig): Record<string, any>;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Generate a Vite configuration for a dynamic module
|
|
7
|
+
*
|
|
8
|
+
* @param options - Custom configuration options
|
|
9
|
+
* @returns Vite configuration
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* // vite.config.js
|
|
14
|
+
* import { getDynamicModuleConfiguration } from '@vc-shell/dynamic-modules-config';
|
|
15
|
+
*
|
|
16
|
+
* export default getDynamicModuleConfiguration({
|
|
17
|
+
* // Custom configuration options
|
|
18
|
+
* compatibility: {
|
|
19
|
+
* framework: '^1.1.0',
|
|
20
|
+
* apps: {
|
|
21
|
+
* 'vendor-portal-new': '^2.0.0'
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function getDynamicModuleConfiguration(options: DynamicModuleOptions): Record<string, any>;
|
|
28
|
+
export type { DynamicModuleOptions, CompatibilityOptions } from "./types.js";
|
|
29
|
+
export { getLibraryConfiguration, getApplicationConfiguration, getDynamicModuleConfiguration };
|
|
5
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,UAAU,EAAE,MAAM,MAAM,CAAC;AAM/C,iBAAS,uBAAuB,CAAC,OAAO,GAAE,UAAe,uBAGxD;AAED,iBAAS,2BAA2B,CAAC,OAAO,GAAE,UAAe,uBAG5D;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,UAAU,EAAE,MAAM,MAAM,CAAC;AAK/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAM/C,iBAAS,uBAAuB,CAAC,OAAO,GAAE,UAAe,uBAGxD;AAED,iBAAS,2BAA2B,CAAC,OAAO,GAAE,UAAe,uBAG5D;AAiBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,6BAA6B,CAAC,OAAO,EAAE,oBAAoB,uBASnE;AAED,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,11 @@ import applicationConfiguration from "./templates/vite.application.appconfig.js"
|
|
|
2
2
|
import libraryConfiguration from "./templates/vite.library.appconfig.js";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { mergeConfig } from "vite";
|
|
5
|
-
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { cwd } from "node:process";
|
|
8
|
+
import dynamicModuleConfiguration from "./templates/vite.dynamic-module.appconfig.js";
|
|
9
|
+
const packageJson = fs.readFileSync(cwd() + "/package.json");
|
|
6
10
|
const name = JSON.parse(packageJson.toString()).name;
|
|
7
11
|
const version = JSON.parse(packageJson.toString()).version;
|
|
8
12
|
function getLibraryConfiguration(options = {}) {
|
|
@@ -16,5 +20,47 @@ function getApplicationConfiguration(options = {}) {
|
|
|
16
20
|
function getConfiguration(configuration = {}, options) {
|
|
17
21
|
return mergeConfig(configuration, options);
|
|
18
22
|
}
|
|
19
|
-
|
|
23
|
+
// Get package.json from current working directory
|
|
24
|
+
const getPackageJson = () => {
|
|
25
|
+
try {
|
|
26
|
+
const packageJsonPath = join(cwd(), "package.json");
|
|
27
|
+
return JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error("Error reading package.json:", error);
|
|
31
|
+
return { name: "unknown-module", version: "0.0.0", dependencies: {} };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Generate a Vite configuration for a dynamic module
|
|
36
|
+
*
|
|
37
|
+
* @param options - Custom configuration options
|
|
38
|
+
* @returns Vite configuration
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```js
|
|
42
|
+
* // vite.config.js
|
|
43
|
+
* import { getDynamicModuleConfiguration } from '@vc-shell/dynamic-modules-config';
|
|
44
|
+
*
|
|
45
|
+
* export default getDynamicModuleConfiguration({
|
|
46
|
+
* // Custom configuration options
|
|
47
|
+
* compatibility: {
|
|
48
|
+
* framework: '^1.1.0',
|
|
49
|
+
* apps: {
|
|
50
|
+
* 'vendor-portal-new': '^2.0.0'
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
function getDynamicModuleConfiguration(options) {
|
|
57
|
+
console.log(`Building dynamic module with options:`, options);
|
|
58
|
+
const pkg = getPackageJson();
|
|
59
|
+
const name = pkg.name;
|
|
60
|
+
const version = pkg.version;
|
|
61
|
+
console.log(`Module: ${name}@${version}`);
|
|
62
|
+
const baseConfig = dynamicModuleConfiguration(pkg, options);
|
|
63
|
+
return mergeConfig(baseConfig, options);
|
|
64
|
+
}
|
|
65
|
+
export { getLibraryConfiguration, getApplicationConfiguration, getDynamicModuleConfiguration };
|
|
20
66
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,MAAM,wCAAwC,CAAC;AAC9E,OAAO,oBAAoB,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAc,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,MAAM,wC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AAc,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACxE,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAS,6BAA6B,CAAC,OAA6B;IAClE,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,OAAO,CAAC,CAAC;IAC9D,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACtB,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC;IAE1C,MAAM,UAAU,GAAG,0BAA0B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,OAAO,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC;AAID,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UserConfig } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vite configuration for building dynamic modules
|
|
4
|
+
*/
|
|
5
|
+
export default function dynamicModuleConfiguration(pkg: {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
dependencies?: Record<string, string>;
|
|
9
|
+
}, options: UserConfig & {
|
|
10
|
+
entry?: string;
|
|
11
|
+
outDir?: string;
|
|
12
|
+
moduleName?: string;
|
|
13
|
+
compatibility: {
|
|
14
|
+
framework: string;
|
|
15
|
+
modules?: Record<string, string>;
|
|
16
|
+
apps: Record<string, string>;
|
|
17
|
+
};
|
|
18
|
+
externals?: string[];
|
|
19
|
+
}): UserConfig;
|
|
20
|
+
//# sourceMappingURL=vite.dynamic-module.appconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.dynamic-module.appconfig.d.ts","sourceRoot":"","sources":["../../src/templates/vite.dynamic-module.appconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,MAAM,CAAC;AAmBhD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAC7E,OAAO,EAAE,UAAU,GAAG;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC9B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,cAiIF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { resolve, join, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { cwd } from "node:process";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import vue from "@vitejs/plugin-vue";
|
|
7
|
+
// Default external dependencies
|
|
8
|
+
const DEFAULT_EXTERNALS = [
|
|
9
|
+
"vue",
|
|
10
|
+
"vue-router",
|
|
11
|
+
"vee-validate",
|
|
12
|
+
"vue-i18n",
|
|
13
|
+
"moment",
|
|
14
|
+
"lodash-es",
|
|
15
|
+
"@vueuse/core",
|
|
16
|
+
"@vc-shell/framework",
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Creates a Vite configuration for building dynamic modules
|
|
20
|
+
*/
|
|
21
|
+
export default function dynamicModuleConfiguration(pkg, options) {
|
|
22
|
+
const { name, version, dependencies = {} } = pkg;
|
|
23
|
+
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
// Validate required compatibility settings
|
|
25
|
+
if (!options.compatibility || !options.compatibility.framework || !options.compatibility.apps) {
|
|
26
|
+
throw new Error("Required compatibility options are missing. You must specify compatibility.framework and compatibility.apps values.");
|
|
27
|
+
}
|
|
28
|
+
// Extract customization options with defaults
|
|
29
|
+
const { entry = "./index.ts", outDir = "dist/packages/modules", moduleName = "VcShellDynamicModules", compatibility, externals = [], } = options;
|
|
30
|
+
// Merge default externals with custom ones
|
|
31
|
+
const allExternals = [...DEFAULT_EXTERNALS, ...externals, /node_modules/];
|
|
32
|
+
console.log(resolve(cwd(), entry), cwd(), entry);
|
|
33
|
+
return defineConfig({
|
|
34
|
+
build: {
|
|
35
|
+
manifest: "manifest.json",
|
|
36
|
+
copyPublicDir: false,
|
|
37
|
+
sourcemap: true,
|
|
38
|
+
minify: false,
|
|
39
|
+
lib: {
|
|
40
|
+
entry: resolve(cwd(), entry),
|
|
41
|
+
fileName: (format, name) => `${name}.js`,
|
|
42
|
+
formats: ["umd"],
|
|
43
|
+
name: moduleName,
|
|
44
|
+
},
|
|
45
|
+
outDir: join(cwd(), outDir),
|
|
46
|
+
rollupOptions: {
|
|
47
|
+
output: {
|
|
48
|
+
globals: {
|
|
49
|
+
vue: "Vue",
|
|
50
|
+
"vue-router": "VueRouter",
|
|
51
|
+
"vee-validate": "VeeValidate",
|
|
52
|
+
"vue-i18n": "VueI18n",
|
|
53
|
+
moment: "moment",
|
|
54
|
+
"lodash-es": "_",
|
|
55
|
+
"@vueuse/core": "VueUse",
|
|
56
|
+
"@vc-shell/framework": "VcShellFramework",
|
|
57
|
+
},
|
|
58
|
+
// Add version information to generated code
|
|
59
|
+
banner: () => {
|
|
60
|
+
const versionInfo = {
|
|
61
|
+
version,
|
|
62
|
+
compatibleWith: {
|
|
63
|
+
framework: compatibility.framework,
|
|
64
|
+
modules: compatibility.modules || {},
|
|
65
|
+
},
|
|
66
|
+
appCompatibility: compatibility.apps,
|
|
67
|
+
};
|
|
68
|
+
return `
|
|
69
|
+
/* Module Version Info */
|
|
70
|
+
(function() {
|
|
71
|
+
if (typeof window !== 'undefined') {
|
|
72
|
+
window.__VC_SHELL_MODULE_VERSION_INFO__ = window.__VC_SHELL_MODULE_VERSION_INFO__ || {};
|
|
73
|
+
window.__VC_SHELL_MODULE_VERSION_INFO__["${name}"] = ${JSON.stringify(versionInfo)};
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
76
|
+
`;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
external: allExternals,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
plugins: [
|
|
83
|
+
vue(),
|
|
84
|
+
{
|
|
85
|
+
name: "module-version-plugin",
|
|
86
|
+
apply: "build",
|
|
87
|
+
enforce: "post",
|
|
88
|
+
// Modify manifest.json after it is created
|
|
89
|
+
closeBundle: async () => {
|
|
90
|
+
const manifestPath = join(cwd(), outDir, "manifest.json");
|
|
91
|
+
if (fs.existsSync(manifestPath)) {
|
|
92
|
+
try {
|
|
93
|
+
// Read generated manifest
|
|
94
|
+
const manifestContent = await fs.promises.readFile(manifestPath, "utf-8");
|
|
95
|
+
const manifest = JSON.parse(manifestContent);
|
|
96
|
+
// Add file with metadata about version
|
|
97
|
+
const versionFileName = "version.json";
|
|
98
|
+
const versionFilePath = join(cwd(), outDir, versionFileName);
|
|
99
|
+
// Create information about version
|
|
100
|
+
const versionInfo = {
|
|
101
|
+
version,
|
|
102
|
+
compatibleWith: {
|
|
103
|
+
framework: compatibility.framework,
|
|
104
|
+
modules: compatibility.modules || {},
|
|
105
|
+
},
|
|
106
|
+
appCompatibility: compatibility.apps,
|
|
107
|
+
};
|
|
108
|
+
// Write file with version
|
|
109
|
+
await fs.promises.writeFile(versionFilePath, JSON.stringify(versionInfo, null, 2));
|
|
110
|
+
// Add information about version file to manifest
|
|
111
|
+
manifest[versionFileName] = {
|
|
112
|
+
file: versionFileName,
|
|
113
|
+
src: versionFileName,
|
|
114
|
+
isVersionInfo: true, // Add special marker
|
|
115
|
+
};
|
|
116
|
+
// Write updated manifest
|
|
117
|
+
await fs.promises.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
|
|
118
|
+
console.log(`✓ Version information added to manifest: ${manifestPath}`);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
console.error("Error updating manifest with version info:", error);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.warn(`Manifest file not found at ${manifestPath}`);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=vite.dynamic-module.appconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.dynamic-module.appconfig.js","sourceRoot":"","sources":["../../src/templates/vite.dynamic-module.appconfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,oBAAoB,CAAC;AAErC,gCAAgC;AAChC,MAAM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,CAAC;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { UserConfig } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Compatibility options for dynamic modules
|
|
4
|
+
*/
|
|
5
|
+
export interface CompatibilityOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Compatible framework version range
|
|
8
|
+
* @example "^1.1.0"
|
|
9
|
+
*/
|
|
10
|
+
framework: string;
|
|
11
|
+
/**
|
|
12
|
+
* Compatible modules version ranges
|
|
13
|
+
* @example { "@vc-shell/module-catalog": "^1.0.0" }
|
|
14
|
+
*/
|
|
15
|
+
modules?: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Compatible applications version ranges
|
|
18
|
+
* @example { "vendor-portal-new": "^2.0.0" }
|
|
19
|
+
*/
|
|
20
|
+
apps: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Dynamic module configuration options
|
|
24
|
+
*/
|
|
25
|
+
export interface DynamicModuleOptions extends UserConfig {
|
|
26
|
+
/**
|
|
27
|
+
* Entry point for the module
|
|
28
|
+
* @default "./index.ts"
|
|
29
|
+
*/
|
|
30
|
+
entry?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Output directory for the module
|
|
33
|
+
* @default "dist/packages/modules"
|
|
34
|
+
*/
|
|
35
|
+
outDir?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Module name for UMD build
|
|
38
|
+
* @default Derived from package name
|
|
39
|
+
*/
|
|
40
|
+
moduleName?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Compatibility constraints for the module
|
|
43
|
+
* @required Both framework and apps fields are required
|
|
44
|
+
*/
|
|
45
|
+
compatibility: CompatibilityOptions;
|
|
46
|
+
/**
|
|
47
|
+
* Additional external dependencies
|
|
48
|
+
* @default []
|
|
49
|
+
*/
|
|
50
|
+
externals?: string[];
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,EAAE,oBAAoB,CAAC;IAEpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/config-generator",
|
|
3
3
|
"description": "Generate Vite configurations",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"vue": "^3.5.13"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@vc-shell/ts-config": "^1.1.
|
|
22
|
+
"@vc-shell/ts-config": "^1.1.6",
|
|
23
23
|
"http-proxy-middleware": "^3.0.2",
|
|
24
24
|
"tsc-alias": "^1.8.8",
|
|
25
25
|
"typescript": "^5.8.3"
|