@onecx/accelerator 8.3.1 → 8.4.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/package.json +1 -1
- package/src/lib/utils/get-onecx-shared-library-config.d.ts +95 -0
- package/src/lib/utils/get-onecx-shared-library-config.js +261 -0
- package/src/lib/utils/get-onecx-shared-library-config.js.map +1 -0
- package/src/lib/utils/get-onecx-shared-recommendations.d.ts +9 -0
- package/src/lib/utils/get-onecx-shared-recommendations.js +11 -0
- package/src/lib/utils/get-onecx-shared-recommendations.js.map +1 -1
- package/src/version.d.ts +1 -1
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { SharedLibraryConfig } from "./get-onecx-shared-recommendations";
|
|
2
|
+
/**
|
|
3
|
+
* Callbacks that can be passed to the SharedLibraryConfigOptions function to customize its behavior.
|
|
4
|
+
* @property {function} configCallback - A function that receives the package name and current shared configuration, returning a modified configuration. Must return a SharedLibraryConfig object.
|
|
5
|
+
* @property {function} packageFilterCallback - A function that takes a package name and returns a boolean. Return true to EXCLUDE the package, false to INCLUDE it, use onecxPackageFilter to use default blacklist.
|
|
6
|
+
*/
|
|
7
|
+
export interface SharedLibraryConfigOptions {
|
|
8
|
+
configCallback?: (packageName: string, currentConfig: SharedLibraryConfig) => SharedLibraryConfig;
|
|
9
|
+
packageFilterCallback?: (packageName: string) => boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* onecxPackageFilter is the default OneCX package filter.
|
|
13
|
+
* @param {string} packageName - The full package name to check against the default blacklist.
|
|
14
|
+
* @returns {boolean} - Returns `true` if the package is on the default blacklist, `false` otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export declare function onecxPackageFilter(packageName: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Generates a shared library configuration object for all dependencies (main + subpackages if needed).
|
|
19
|
+
* @param {Record<string, string>} dependencies - Map of dependency names to versions
|
|
20
|
+
* @param {boolean} shouldGenerateSubDeps - Flag indicating whether to include subpackages based on exports
|
|
21
|
+
* @param {SharedLibraryConfigOptions} options - Optional callbacks for customizing the configuration generation process. Includes:
|
|
22
|
+
* - configCallback: A function that receives the package name and current shared configuration, returning a modified configuration.
|
|
23
|
+
* configCallback?: (packageName: string, currentConfig: SharedLibraryConfig) => SharedLibraryConfig;
|
|
24
|
+
* - packageFilterCallback: A function that takes a package name and returns a boolean. Return true to EXCLUDE the package, false to INCLUDE it.
|
|
25
|
+
* packageFilterCallback?: (packageName: string) => boolean | undefined;
|
|
26
|
+
* @returns {Record<string, SharedLibraryConfig>} A map of package names to their shared library configuration
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* **Recommended usage for @module-federation/enhanced:**
|
|
30
|
+
* ```js
|
|
31
|
+
* const sharedEntries = getOneCXSharedLibraryConfig(dependencies, true);
|
|
32
|
+
* const config = {
|
|
33
|
+
* name: 'onecx-test-project-ui',
|
|
34
|
+
* filename: 'remoteEntry.js',
|
|
35
|
+
* shared: sharedEntries,
|
|
36
|
+
* shareScope: 'angular_21'
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* **Recommended usage for @angular-architects/module-federation:**
|
|
41
|
+
* The share function is from @angular-architects/module-federation.
|
|
42
|
+
* ```js
|
|
43
|
+
* function customConfigCallback(packageName: string, currentConfig: SharedLibraryConfig): SharedLibraryConfig {
|
|
44
|
+
* currentConfig[includeSecondaries]=true
|
|
45
|
+
* currentConfig[requiredVersion]='auto'
|
|
46
|
+
* return currentConfig
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* const sharedEntries = getOneCXSharedLibraryConfig(dependencies, false, { configCallback: customConfigCallback });
|
|
50
|
+
* const config = withModuleFederationPlugin({
|
|
51
|
+
* name: 'onecx-<%= remoteModuleFileName %>-ui',
|
|
52
|
+
* filename: 'remoteEntryOneCX.js',
|
|
53
|
+
* exposes: {
|
|
54
|
+
* './OneCX<%= remoteModuleName %>Module': './src/main.ts'
|
|
55
|
+
* },
|
|
56
|
+
* shared: share(sharedEntries),
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
* \
|
|
60
|
+
* **With options (custom filter and config override) you can customize the behavior as follows:**
|
|
61
|
+
* ```js
|
|
62
|
+
* const sharedEntries = getOneCXSharedLibraryConfig(dependencies, true, {
|
|
63
|
+
* packageFilterCallback: customPackageFilter,
|
|
64
|
+
* configCallback: customConfigCallback,
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
* \
|
|
68
|
+
* Following are some Custom Implementation:
|
|
69
|
+
* 1. Adding Custom Config or overiding default config
|
|
70
|
+
*```js
|
|
71
|
+
* function customConfigCallback(packageName: string, currentConfig: SharedLibraryConfig): SharedLibraryConfig {
|
|
72
|
+
* currentConfig[singleton]=true
|
|
73
|
+
* return currentConfig
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* 2. Custom Package without using onecxPckageFilter
|
|
78
|
+
* ```js
|
|
79
|
+
* function customPackageFilter(packageName: string): boolean {
|
|
80
|
+
* if (packageName.startsWith('@internal/')) return true;
|
|
81
|
+
* return false;
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* 3. Custom Package using onecxPckageFilter as defaut:
|
|
86
|
+
* ```js
|
|
87
|
+
* function customPackageFilter(packageName: string): boolean {
|
|
88
|
+
* if (packageName.startsWith('@internal/')) return true;
|
|
89
|
+
* return onecxPackageFilter(packageName);
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
*/
|
|
95
|
+
export declare function getOneCXSharedLibraryConfig(dependencies: Record<string, string>, shouldGenerateSubDeps: boolean, options?: SharedLibraryConfigOptions): Record<string, SharedLibraryConfig>;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { getOneCXSharedRecommendations } from "./get-onecx-shared-recommendations";
|
|
2
|
+
/**
|
|
3
|
+
* As we have { platform: 'browser'} in accelerator's & integration-interface project.json.
|
|
4
|
+
* We use dynamic require (provided by Node.js) to read package.json of dependencies, which is not supported in browser environment.
|
|
5
|
+
* So we need to check if the environment is node before using it. So it will only return valid require function while building
|
|
6
|
+
*/
|
|
7
|
+
const nodeRequire = (() => {
|
|
8
|
+
try {
|
|
9
|
+
if (typeof process !== 'undefined' && process?.versions?.node) {
|
|
10
|
+
return eval('require');
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
throw new Error('Node.js environment is required for dynamic require.');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
throw new Error('Node.js environment is required for dynamic require.');
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
const angularCore = '@angular/core';
|
|
21
|
+
/**
|
|
22
|
+
* Blacklist of export paths to exclude when generating subpackage entries.
|
|
23
|
+
*/
|
|
24
|
+
const EXPORTS_BLACKLIST = ['.', './package.json'];
|
|
25
|
+
/**
|
|
26
|
+
* Patterns for identifying dependencies that should be blacklisted.
|
|
27
|
+
*/
|
|
28
|
+
const DEFAULT_DEPENDENCY_BLACKLIST = [
|
|
29
|
+
/^@nx(\/.*)?$/,
|
|
30
|
+
/^@module-federation(\/.*)?$/,
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* For identifying full package paths that should be blacklisted.
|
|
34
|
+
*/
|
|
35
|
+
const DEFAULT_FULL_PACKAGE_BLACKLIST = [
|
|
36
|
+
'@angular/common/locales/global/*',
|
|
37
|
+
'@angular/common/locales/*',
|
|
38
|
+
'@angular/common/upgrade',
|
|
39
|
+
'@angular/core/schematics/*',
|
|
40
|
+
'@angular/core/event-dispatch-contract.min.js',
|
|
41
|
+
'@angular/service-worker/ngsw-worker.js',
|
|
42
|
+
'@angular/service-worker/safety-worker.js',
|
|
43
|
+
'@angular/service-worker/config/schema.json',
|
|
44
|
+
'@angular/router/upgrade',
|
|
45
|
+
'@angular/localize/tools',
|
|
46
|
+
'rxjs/internal/*',
|
|
47
|
+
'primeng/resources/',
|
|
48
|
+
'primeng/editor',
|
|
49
|
+
'@onecx/angular-accelerator/testing',
|
|
50
|
+
'@onecx/angular-accelerator/migrations.json',
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Removes the './' prefix from a string, typically used for export paths in package.json files.
|
|
54
|
+
* @param {string} str - The string from which to remove the './' prefix.
|
|
55
|
+
* @returns {string} The string without the './' prefix.
|
|
56
|
+
*/
|
|
57
|
+
function removeExportPrefix(str) {
|
|
58
|
+
return str.replace('./', '');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* onecxPackageFilter is the default OneCX package filter.
|
|
62
|
+
* @param {string} packageName - The full package name to check against the default blacklist.
|
|
63
|
+
* @returns {boolean} - Returns `true` if the package is on the default blacklist, `false` otherwise.
|
|
64
|
+
*/
|
|
65
|
+
export function onecxPackageFilter(packageName) {
|
|
66
|
+
if (isDependencyBlacklisted(packageName)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return DEFAULT_FULL_PACKAGE_BLACKLIST.includes(packageName);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check whether a dependency matches any blacklist entry. Supports RegExp entries and exact string matches.
|
|
73
|
+
*/
|
|
74
|
+
function isDependencyBlacklisted(dependency) {
|
|
75
|
+
return DEFAULT_DEPENDENCY_BLACKLIST.some((entry) => {
|
|
76
|
+
if (entry instanceof RegExp) {
|
|
77
|
+
return entry.test(dependency);
|
|
78
|
+
}
|
|
79
|
+
return entry === dependency;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolves and reads a dependency's package.json file.
|
|
84
|
+
* Handles module resolution across npm/yarn/pnpm layouts.
|
|
85
|
+
* @param {string} dependency - Package name to resolve
|
|
86
|
+
* @returns {Object|null} Parsed package.json or null if not found
|
|
87
|
+
*/
|
|
88
|
+
function readDependencyPackageJson(dependency) {
|
|
89
|
+
if (!nodeRequire)
|
|
90
|
+
return null;
|
|
91
|
+
let packagePath;
|
|
92
|
+
try {
|
|
93
|
+
packagePath = nodeRequire.resolve(`${dependency}/package.json`);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const fs = nodeRequire('fs');
|
|
99
|
+
if (!fs.existsSync(packagePath)) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const packageContent = fs.readFileSync(packagePath, 'utf-8');
|
|
103
|
+
return JSON.parse(packageContent);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Generates subpackages from a dependency's export entries. Reads the dependency's package.json to find all exported subpackages
|
|
107
|
+
* and creates fully qualified package names.
|
|
108
|
+
* @param {string} dependency - Package name
|
|
109
|
+
* @param {string} version - Package version
|
|
110
|
+
* @param {function} packageFilterCallback - Optional callback to filter out specific subpackages. Should return true to exclude a package, false to include it.
|
|
111
|
+
* @returns {Array} Array of subpackage objects with name and version
|
|
112
|
+
*/
|
|
113
|
+
function generateSubPackageConfig(dependency, version, packageFilterCallback) {
|
|
114
|
+
const subpackages = [];
|
|
115
|
+
const dependencyPackage = readDependencyPackageJson(dependency);
|
|
116
|
+
if (!dependencyPackage?.exports) {
|
|
117
|
+
return subpackages;
|
|
118
|
+
}
|
|
119
|
+
const exportKeys = Object.keys(dependencyPackage.exports);
|
|
120
|
+
for (const exportKey of exportKeys) {
|
|
121
|
+
if (EXPORTS_BLACKLIST.includes(exportKey))
|
|
122
|
+
continue;
|
|
123
|
+
const subpackageName = `${dependency}/${removeExportPrefix(exportKey)}`;
|
|
124
|
+
if (packageFilterCallback && packageFilterCallback(subpackageName))
|
|
125
|
+
continue;
|
|
126
|
+
subpackages.push({ name: subpackageName, requiredVersion: version });
|
|
127
|
+
}
|
|
128
|
+
return subpackages;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Generates all shared packages (main + subpackages) for a given dependency.
|
|
132
|
+
* Includes the main package plus all exported subpackages.
|
|
133
|
+
* @param {Object} versionMap - Map of dependency names to versions
|
|
134
|
+
* @param {string} dependency - Package name to generate packages for
|
|
135
|
+
* @param {boolean} shouldGenerateSubDeps - Flag indicating whether to include subpackages based on exports
|
|
136
|
+
* @param {function} packageFilterCallback - Optional callback to filter out specific packages. Should return true to exclude a package, false to include it.
|
|
137
|
+
* @returns {Array} Array of all packages (main + subpackages)
|
|
138
|
+
*/
|
|
139
|
+
function generatePackageConfig(versionMap, dependency, shouldGenerateSubDeps, packageFilterCallback = onecxPackageFilter) {
|
|
140
|
+
if (packageFilterCallback(dependency)) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
const allPackages = [];
|
|
144
|
+
const version = versionMap[dependency];
|
|
145
|
+
allPackages.push({ name: dependency, requiredVersion: version });
|
|
146
|
+
if (shouldGenerateSubDeps) {
|
|
147
|
+
const subpackages = generateSubPackageConfig(dependency, version, packageFilterCallback);
|
|
148
|
+
allPackages.push(...subpackages);
|
|
149
|
+
}
|
|
150
|
+
return allPackages;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Generates a shared library configuration object for all dependencies (main + subpackages if needed).
|
|
154
|
+
* @param {Record<string, string>} dependencies - Map of dependency names to versions
|
|
155
|
+
* @param {boolean} shouldGenerateSubDeps - Flag indicating whether to include subpackages based on exports
|
|
156
|
+
* @param {SharedLibraryConfigOptions} options - Optional callbacks for customizing the configuration generation process. Includes:
|
|
157
|
+
* - configCallback: A function that receives the package name and current shared configuration, returning a modified configuration.
|
|
158
|
+
* configCallback?: (packageName: string, currentConfig: SharedLibraryConfig) => SharedLibraryConfig;
|
|
159
|
+
* - packageFilterCallback: A function that takes a package name and returns a boolean. Return true to EXCLUDE the package, false to INCLUDE it.
|
|
160
|
+
* packageFilterCallback?: (packageName: string) => boolean | undefined;
|
|
161
|
+
* @returns {Record<string, SharedLibraryConfig>} A map of package names to their shared library configuration
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* **Recommended usage for @module-federation/enhanced:**
|
|
165
|
+
* ```js
|
|
166
|
+
* const sharedEntries = getOneCXSharedLibraryConfig(dependencies, true);
|
|
167
|
+
* const config = {
|
|
168
|
+
* name: 'onecx-test-project-ui',
|
|
169
|
+
* filename: 'remoteEntry.js',
|
|
170
|
+
* shared: sharedEntries,
|
|
171
|
+
* shareScope: 'angular_21'
|
|
172
|
+
* }
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* **Recommended usage for @angular-architects/module-federation:**
|
|
176
|
+
* The share function is from @angular-architects/module-federation.
|
|
177
|
+
* ```js
|
|
178
|
+
* function customConfigCallback(packageName: string, currentConfig: SharedLibraryConfig): SharedLibraryConfig {
|
|
179
|
+
* currentConfig[includeSecondaries]=true
|
|
180
|
+
* currentConfig[requiredVersion]='auto'
|
|
181
|
+
* return currentConfig
|
|
182
|
+
* }
|
|
183
|
+
*
|
|
184
|
+
* const sharedEntries = getOneCXSharedLibraryConfig(dependencies, false, { configCallback: customConfigCallback });
|
|
185
|
+
* const config = withModuleFederationPlugin({
|
|
186
|
+
* name: 'onecx-<%= remoteModuleFileName %>-ui',
|
|
187
|
+
* filename: 'remoteEntryOneCX.js',
|
|
188
|
+
* exposes: {
|
|
189
|
+
* './OneCX<%= remoteModuleName %>Module': './src/main.ts'
|
|
190
|
+
* },
|
|
191
|
+
* shared: share(sharedEntries),
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
* \
|
|
195
|
+
* **With options (custom filter and config override) you can customize the behavior as follows:**
|
|
196
|
+
* ```js
|
|
197
|
+
* const sharedEntries = getOneCXSharedLibraryConfig(dependencies, true, {
|
|
198
|
+
* packageFilterCallback: customPackageFilter,
|
|
199
|
+
* configCallback: customConfigCallback,
|
|
200
|
+
* });
|
|
201
|
+
* ```
|
|
202
|
+
* \
|
|
203
|
+
* Following are some Custom Implementation:
|
|
204
|
+
* 1. Adding Custom Config or overiding default config
|
|
205
|
+
*```js
|
|
206
|
+
* function customConfigCallback(packageName: string, currentConfig: SharedLibraryConfig): SharedLibraryConfig {
|
|
207
|
+
* currentConfig[singleton]=true
|
|
208
|
+
* return currentConfig
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* 2. Custom Package without using onecxPckageFilter
|
|
213
|
+
* ```js
|
|
214
|
+
* function customPackageFilter(packageName: string): boolean {
|
|
215
|
+
* if (packageName.startsWith('@internal/')) return true;
|
|
216
|
+
* return false;
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* 3. Custom Package using onecxPckageFilter as defaut:
|
|
221
|
+
* ```js
|
|
222
|
+
* function customPackageFilter(packageName: string): boolean {
|
|
223
|
+
* if (packageName.startsWith('@internal/')) return true;
|
|
224
|
+
* return onecxPackageFilter(packageName);
|
|
225
|
+
* }
|
|
226
|
+
*
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
export function getOneCXSharedLibraryConfig(dependencies, shouldGenerateSubDeps, options) {
|
|
231
|
+
const allDependencies = Object.keys(dependencies).flatMap((dependency) => {
|
|
232
|
+
return generatePackageConfig(dependencies, dependency, shouldGenerateSubDeps, options?.packageFilterCallback);
|
|
233
|
+
});
|
|
234
|
+
const sharedEntries = allDependencies.reduce((acc, packageEntry) => {
|
|
235
|
+
const sharedLibConfig = {};
|
|
236
|
+
sharedLibConfig['requiredVersion'] = packageEntry.requiredVersion;
|
|
237
|
+
sharedLibConfig['shareScope'] = 'default';
|
|
238
|
+
const angularCoreVersion = (dependencies[angularCore] || '').split('.')[0].replace('^', '');
|
|
239
|
+
if (angularCoreVersion && parseInt(angularCoreVersion, 10) >= 21) {
|
|
240
|
+
const shareScope = ('angular_').concat(angularCoreVersion);
|
|
241
|
+
sharedLibConfig['shareScope'] = shareScope;
|
|
242
|
+
}
|
|
243
|
+
const onecxRecommendation = getOneCXSharedRecommendations(packageEntry.name, sharedLibConfig);
|
|
244
|
+
if (!onecxRecommendation) {
|
|
245
|
+
return acc;
|
|
246
|
+
}
|
|
247
|
+
// Apply configCallback if provided to current config overriding the recommendation
|
|
248
|
+
const configFromCallback = options?.configCallback ? options.configCallback(packageEntry.name, onecxRecommendation) : undefined;
|
|
249
|
+
if (configFromCallback && typeof configFromCallback === 'object') {
|
|
250
|
+
Object.assign(onecxRecommendation, configFromCallback);
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
...acc,
|
|
254
|
+
[packageEntry.name]: {
|
|
255
|
+
...onecxRecommendation,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}, {});
|
|
259
|
+
return sharedEntries;
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=get-onecx-shared-library-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-onecx-shared-library-config.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/utils/get-onecx-shared-library-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAuB,MAAM,oCAAoC,CAAC;AAGxG;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE;IACxB,IAAI,CAAC;QACH,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC9D,OAAQ,IAAI,CAAC,SAAS,CAAoB,CAAC;QAC7C,CAAC;aAAI,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEL,MAAM,WAAW,GAAG,eAAe,CAAC;AAapC;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AAElD;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IAAI,kBAAkB,IAAI,QAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;YACjE,MAAM,UAAU,GAAG,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;YAC3D,eAAe,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC;QAC7C,CAAC;QAED,MAAM,mBAAmB,GAAG,6BAA6B,CAAC,YAAY,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAC9F,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,mFAAmF;QACnF,MAAM,kBAAkB,GAAG,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAChI,IAAI,kBAAkB,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;YACjE,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;QACzD,CAAC;QAED,OAAO;YACL,GAAG,GAAG;YACN,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;gBACnB,GAAG,mBAAmB;aACvB;SACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -5,5 +5,14 @@ export interface SharedLibraryConfig {
|
|
|
5
5
|
requiredVersion?: string | false;
|
|
6
6
|
version?: string;
|
|
7
7
|
includeSecondaries?: boolean;
|
|
8
|
+
shareScope?: string;
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Provides recommendations for shared library configurations for specific OneCX-related libraries.
|
|
12
|
+
* If the library name matches certain patterns (e.g., Angular, OneCX, RxJS, PrimeNG, ngx-translate, ngrx), it modifies the shared configuration to set singleton, strictVersion, and eager to false.
|
|
13
|
+
* For non-matching libraries, it returns false and does not modify the configuration.
|
|
14
|
+
* @param {string} libraryName - The name of the library being shared.
|
|
15
|
+
* @param {SharedLibraryConfig} sharedConfig - The existing shared configuration for the library, which may be modified if recommendations are applied.
|
|
16
|
+
* @returns {false | SharedLibraryConfig} - Returns the modified shared configuration if recommendations are applied, or false if no recommendations are applicable.
|
|
17
|
+
*/
|
|
9
18
|
export declare function getOneCXSharedRecommendations(libraryName: string, sharedConfig: SharedLibraryConfig): false | SharedLibraryConfig;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patterns for identifying shared libraries that should have specific configuration recommendations.
|
|
3
|
+
*/
|
|
1
4
|
const sharedLibraryPatterns = [
|
|
2
5
|
/^@angular.*$/,
|
|
3
6
|
/^@onecx.*$/,
|
|
@@ -6,6 +9,14 @@ const sharedLibraryPatterns = [
|
|
|
6
9
|
/^@ngx-translate.*$/,
|
|
7
10
|
/^@ngrx.*$/,
|
|
8
11
|
];
|
|
12
|
+
/**
|
|
13
|
+
* Provides recommendations for shared library configurations for specific OneCX-related libraries.
|
|
14
|
+
* If the library name matches certain patterns (e.g., Angular, OneCX, RxJS, PrimeNG, ngx-translate, ngrx), it modifies the shared configuration to set singleton, strictVersion, and eager to false.
|
|
15
|
+
* For non-matching libraries, it returns false and does not modify the configuration.
|
|
16
|
+
* @param {string} libraryName - The name of the library being shared.
|
|
17
|
+
* @param {SharedLibraryConfig} sharedConfig - The existing shared configuration for the library, which may be modified if recommendations are applied.
|
|
18
|
+
* @returns {false | SharedLibraryConfig} - Returns the modified shared configuration if recommendations are applied, or false if no recommendations are applicable.
|
|
19
|
+
*/
|
|
9
20
|
export function getOneCXSharedRecommendations(libraryName, sharedConfig) {
|
|
10
21
|
if (!sharedLibraryPatterns.some((pattern) => pattern.test(libraryName))) {
|
|
11
22
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-onecx-shared-recommendations.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/utils/get-onecx-shared-recommendations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-onecx-shared-recommendations.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/utils/get-onecx-shared-recommendations.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,qBAAqB,GAAa;IACtC,cAAc;IACd,YAAY;IACZ,UAAU;IACV,aAAa;IACb,oBAAoB;IACpB,WAAW;CACZ,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC3C,WAAmB,EACnB,YAAiC;IAEjC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAA;IACd,CAAC;IACD,YAAY,CAAC,SAAS,GAAG,KAAK,CAAA;IAC9B,YAAY,CAAC,aAAa,GAAG,KAAK,CAAA;IAClC,YAAY,CAAC,KAAK,GAAG,KAAK,CAAA;IAC1B,OAAO,YAAY,CAAA;AACrB,CAAC"}
|
package/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const LIB_NAME = "@onecx/accelerator";
|
|
2
|
-
export declare const LIB_VERSION = "8.
|
|
2
|
+
export declare const LIB_VERSION = "8.4.0";
|
package/src/version.js
CHANGED