@module-federation/esbuild 0.0.95 → 0.0.97

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.
Files changed (61) hide show
  1. package/dist/adapters/lib/collect-exports.js +151 -0
  2. package/dist/adapters/lib/collect-exports.mjs +87 -0
  3. package/dist/adapters/lib/commonjs.js +260 -0
  4. package/dist/adapters/lib/commonjs.mjs +209 -0
  5. package/dist/adapters/lib/containerPlugin.js +232 -0
  6. package/dist/adapters/lib/containerPlugin.mjs +182 -0
  7. package/dist/adapters/lib/containerReference.js +219 -0
  8. package/dist/adapters/lib/containerReference.mjs +154 -0
  9. package/dist/adapters/lib/lexer.js +184 -0
  10. package/dist/adapters/lib/lexer.mjs +138 -0
  11. package/dist/adapters/lib/linkRemotesPlugin.js +115 -0
  12. package/dist/adapters/lib/linkRemotesPlugin.mjs +50 -0
  13. package/dist/adapters/lib/manifest.js +229 -0
  14. package/dist/adapters/lib/manifest.mjs +168 -0
  15. package/dist/adapters/lib/plugin.js +339 -0
  16. package/dist/adapters/lib/plugin.mjs +282 -0
  17. package/dist/adapters/lib/react-replacements.js +81 -0
  18. package/dist/adapters/lib/react-replacements.mjs +35 -0
  19. package/dist/adapters/lib/transform.js +169 -0
  20. package/dist/adapters/lib/transform.mjs +120 -0
  21. package/dist/adapters/lib/utils.js +83 -0
  22. package/dist/adapters/lib/utils.mjs +33 -0
  23. package/dist/build.js +131 -473
  24. package/dist/build.mjs +13 -380
  25. package/dist/index.js +41 -26
  26. package/dist/index.mjs +4 -1
  27. package/dist/lib/config/configuration-context.js +70 -0
  28. package/dist/lib/config/configuration-context.mjs +20 -0
  29. package/dist/lib/config/federation-config.js +31 -0
  30. package/dist/lib/config/federation-config.mjs +4 -0
  31. package/dist/lib/config/share-utils.js +339 -0
  32. package/dist/lib/config/share-utils.mjs +254 -0
  33. package/dist/lib/config/with-native-federation.js +118 -0
  34. package/dist/lib/config/with-native-federation.mjs +71 -0
  35. package/dist/lib/core/build-adapter.js +70 -0
  36. package/dist/lib/core/build-adapter.mjs +18 -0
  37. package/dist/lib/core/createContainerTemplate.js +231 -0
  38. package/dist/lib/core/createContainerTemplate.mjs +185 -0
  39. package/dist/lib/core/default-skip-list.js +99 -0
  40. package/dist/lib/core/default-skip-list.mjs +47 -0
  41. package/dist/lib/core/federation-options.js +31 -0
  42. package/dist/lib/core/federation-options.mjs +4 -0
  43. package/dist/lib/core/get-externals.js +65 -0
  44. package/dist/lib/core/get-externals.mjs +19 -0
  45. package/dist/lib/core/load-federation-config.js +69 -0
  46. package/dist/lib/core/load-federation-config.mjs +20 -0
  47. package/dist/lib/core/write-federation-info.js +65 -0
  48. package/dist/lib/core/write-federation-info.mjs +16 -0
  49. package/dist/lib/utils/logger.js +111 -0
  50. package/dist/lib/utils/logger.mjs +46 -0
  51. package/dist/lib/utils/mapped-paths.js +94 -0
  52. package/dist/lib/utils/mapped-paths.mjs +46 -0
  53. package/dist/lib/utils/normalize.js +63 -0
  54. package/dist/lib/utils/normalize.mjs +17 -0
  55. package/dist/lib/utils/package-info.js +324 -0
  56. package/dist/lib/utils/package-info.mjs +265 -0
  57. package/dist/plugin.d.ts +1 -0
  58. package/dist/plugin.js +79 -1231
  59. package/dist/plugin.mjs +2 -1187
  60. package/dist/resolve/esm-resolver.mjs +15 -22
  61. package/package.json +2 -2
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ /************************************************************************/
13
+ // webpack/runtime/compat_get_default_export
14
+ (() => {
15
+ // getDefaultExport function for compatibility with non-ESM modules
16
+ __webpack_require__.n = (module) => {
17
+ var getter = module && module.__esModule ?
18
+ () => (module['default']) :
19
+ () => (module);
20
+ __webpack_require__.d(getter, { a: getter });
21
+ return getter;
22
+ };
23
+
24
+ })();
25
+ // webpack/runtime/define_property_getters
26
+ (() => {
27
+ __webpack_require__.d = (exports, definition) => {
28
+ for(var key in definition) {
29
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31
+ }
32
+ }
33
+ };
34
+ })();
35
+ // webpack/runtime/has_own_property
36
+ (() => {
37
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
38
+ })();
39
+ // webpack/runtime/make_namespace_object
40
+ (() => {
41
+ // define __esModule on exports
42
+ __webpack_require__.r = (exports) => {
43
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
44
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
45
+ }
46
+ Object.defineProperty(exports, '__esModule', { value: true });
47
+ };
48
+ })();
49
+ /************************************************************************/
50
+ var __webpack_exports__ = {};
51
+ // ESM COMPAT FLAG
52
+ __webpack_require__.r(__webpack_exports__);
53
+
54
+ // EXPORTS
55
+ __webpack_require__.d(__webpack_exports__, {
56
+ share: () => (/* binding */ share),
57
+ getDefaultEntry: () => (/* binding */ getDefaultEntry),
58
+ shareAll: () => (/* binding */ shareAll),
59
+ DEFAULT_SECONARIES_SKIP_LIST: () => (/* binding */ DEFAULT_SECONARIES_SKIP_LIST),
60
+ findRootTsConfigJson: () => (/* binding */ findRootTsConfigJson),
61
+ lookupVersionInMap: () => (/* binding */ lookupVersionInMap),
62
+ lookupVersion: () => (/* binding */ lookupVersion),
63
+ addSecondaries: () => (/* binding */ addSecondaries),
64
+ _findSecondaries: () => (/* binding */ _findSecondaries),
65
+ findSecondaries: () => (/* binding */ findSecondaries),
66
+ readConfiguredSecondaries: () => (/* binding */ readConfiguredSecondaries),
67
+ findPackageJson: () => (/* binding */ findPackageJson),
68
+ getSecondaries: () => (/* binding */ getSecondaries),
69
+ setInferVersion: () => (/* binding */ setInferVersion)
70
+ });
71
+
72
+ ;// CONCATENATED MODULE: external "fs"
73
+ const external_fs_namespaceObject = require("fs");
74
+ var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
75
+ ;// CONCATENATED MODULE: external "path"
76
+ const external_path_namespaceObject = require("path");
77
+ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
78
+ ;// CONCATENATED MODULE: external "process"
79
+ const external_process_namespaceObject = require("process");
80
+ var external_process_default = /*#__PURE__*/__webpack_require__.n(external_process_namespaceObject);
81
+ ;// CONCATENATED MODULE: external "./configuration-context.js"
82
+ const external_configuration_context_js_namespaceObject = require("./configuration-context.js");
83
+ ;// CONCATENATED MODULE: external "../utils/package-info.js"
84
+ const package_info_js_namespaceObject = require("../utils/package-info.js");
85
+ ;// CONCATENATED MODULE: external "../utils/logger.js"
86
+ const logger_js_namespaceObject = require("../utils/logger.js");
87
+ ;// CONCATENATED MODULE: external "../core/default-skip-list.js"
88
+ const default_skip_list_js_namespaceObject = require("../core/default-skip-list.js");
89
+ ;// CONCATENATED MODULE: ./src/lib/config/share-utils.ts
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ let share_utils_inferVersion = false;
98
+ const DEFAULT_SECONARIES_SKIP_LIST = [
99
+ '@angular/router/upgrade',
100
+ '@angular/common/upgrade'
101
+ ];
102
+ function findRootTsConfigJson() {
103
+ const packageJson = findPackageJson(external_process_default().cwd());
104
+ const projectRoot = external_path_default().dirname(packageJson);
105
+ const tsConfigBaseJson = external_path_default().join(projectRoot, 'tsconfig.base.json');
106
+ const tsConfigJson = external_path_default().join(projectRoot, 'tsconfig.json');
107
+ if (external_fs_default().existsSync(tsConfigBaseJson)) {
108
+ return tsConfigBaseJson;
109
+ } else if (external_fs_default().existsSync(tsConfigJson)) {
110
+ return tsConfigJson;
111
+ }
112
+ throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
113
+ }
114
+ function findPackageJson(folder) {
115
+ while(!external_fs_default().existsSync(external_path_default().join(folder, 'package.json')) && external_path_default().dirname(folder) !== folder){
116
+ folder = external_path_default().dirname(folder);
117
+ }
118
+ const filePath = external_path_default().join(folder, 'package.json');
119
+ if (external_fs_default().existsSync(filePath)) {
120
+ return filePath;
121
+ }
122
+ throw new Error(`No package.json found. Searched the following folder and all parents: ${folder}`);
123
+ }
124
+ function lookupVersion(key, workspaceRoot) {
125
+ const versionMaps = (0,package_info_js_namespaceObject.getVersionMaps)(workspaceRoot, workspaceRoot);
126
+ for (const versionMap of versionMaps){
127
+ const version = lookupVersionInMap(key, versionMap);
128
+ if (version) {
129
+ return version;
130
+ }
131
+ }
132
+ throw new Error(`Shared Dependency ${key} has requiredVersion:'auto'. However, this dependency is not found in your package.json`);
133
+ }
134
+ function lookupVersionInMap(key, versions) {
135
+ const parts = key.split('/');
136
+ if (parts.length >= 2 && parts[0].startsWith('@')) {
137
+ key = `${parts[0]}/${parts[1]}`;
138
+ } else {
139
+ key = parts[0];
140
+ }
141
+ if (key.toLowerCase() === '@angular-architects/module-federation-runtime') {
142
+ key = '@angular-architects/module-federation';
143
+ }
144
+ return versions[key] || null;
145
+ }
146
+ function _findSecondaries(libPath, excludes, shareObject, acc) {
147
+ const files = external_fs_default().readdirSync(libPath);
148
+ const dirs = files.map((f)=>external_path_default().join(libPath, f)).filter((f)=>external_fs_default().lstatSync(f).isDirectory() && f !== 'node_modules');
149
+ const secondaries = dirs.filter((d)=>external_fs_default().existsSync(external_path_default().join(d, 'package.json')));
150
+ for (const s of secondaries){
151
+ const secondaryLibName = s.replace(/\\/g, '/').replace(/^.*node_modules[/]/, '');
152
+ if (excludes.includes(secondaryLibName)) {
153
+ continue;
154
+ }
155
+ if ((0,default_skip_list_js_namespaceObject.isInSkipList)(secondaryLibName, default_skip_list_js_namespaceObject.PREPARED_DEFAULT_SKIP_LIST)) {
156
+ continue;
157
+ }
158
+ acc[secondaryLibName] = {
159
+ ...shareObject
160
+ };
161
+ _findSecondaries(s, excludes, shareObject, acc);
162
+ }
163
+ }
164
+ function findSecondaries(libPath, excludes, shareObject) {
165
+ const acc = {};
166
+ _findSecondaries(libPath, excludes, shareObject, acc);
167
+ return acc;
168
+ }
169
+ function getSecondaries(includeSecondaries, libPath, key, shareObject) {
170
+ let exclude = [
171
+ ...DEFAULT_SECONARIES_SKIP_LIST
172
+ ];
173
+ if (typeof includeSecondaries === 'object') {
174
+ if (Array.isArray(includeSecondaries.skip)) {
175
+ exclude = includeSecondaries.skip;
176
+ } else if (typeof includeSecondaries.skip === 'string') {
177
+ exclude = [
178
+ includeSecondaries.skip
179
+ ];
180
+ }
181
+ }
182
+ if (!external_fs_default().existsSync(libPath)) {
183
+ return {};
184
+ }
185
+ const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject);
186
+ if (configured) {
187
+ return configured;
188
+ }
189
+ // Fallback: Search folders
190
+ return findSecondaries(libPath, exclude, shareObject);
191
+ }
192
+ function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
193
+ const libPackageJson = external_path_default().join(libPath, 'package.json');
194
+ if (!external_fs_default().existsSync(libPackageJson)) {
195
+ return null;
196
+ }
197
+ const packageJson = JSON.parse(external_fs_default().readFileSync(libPackageJson, 'utf-8'));
198
+ const exports = packageJson['exports'];
199
+ if (!exports) {
200
+ return null;
201
+ }
202
+ const keys = Object.keys(exports).filter((key)=>key !== '.' && key !== './package.json' && !key.endsWith('*') && (exports[key]['default'] || typeof exports[key] === 'string'));
203
+ const result = {};
204
+ for (const key of keys){
205
+ const secondaryName = external_path_default().join(parent, key).replace(/\\/g, '/');
206
+ if (exclude.includes(secondaryName)) {
207
+ continue;
208
+ }
209
+ if ((0,default_skip_list_js_namespaceObject.isInSkipList)(secondaryName, default_skip_list_js_namespaceObject.PREPARED_DEFAULT_SKIP_LIST)) {
210
+ continue;
211
+ }
212
+ const entry = getDefaultEntry(exports, key);
213
+ if (typeof entry !== 'string') {
214
+ console.log(`No entry point found for ${secondaryName}`);
215
+ continue;
216
+ }
217
+ if ([
218
+ '.css',
219
+ '.scss',
220
+ '.less'
221
+ ].some((ext)=>entry.endsWith(ext))) {
222
+ continue;
223
+ }
224
+ result[secondaryName] = {
225
+ ...shareObject
226
+ };
227
+ }
228
+ return result;
229
+ }
230
+ function getDefaultEntry(exports, key) {
231
+ let entry;
232
+ if (typeof exports[key] === 'string') {
233
+ entry = exports[key];
234
+ } else {
235
+ var _exports_key;
236
+ entry = (_exports_key = exports[key]) === null || _exports_key === void 0 ? void 0 : _exports_key['default'];
237
+ if (typeof entry === 'object') {
238
+ entry = entry['default'];
239
+ }
240
+ }
241
+ return entry;
242
+ }
243
+ function shareAll(config, skip = default_skip_list_js_namespaceObject.DEFAULT_SKIP_LIST, projectPath = '') {
244
+ projectPath = inferProjectPath(projectPath);
245
+ const versionMaps = (0,package_info_js_namespaceObject.getVersionMaps)(projectPath, projectPath);
246
+ const shareConfig = {};
247
+ for (const versions of versionMaps){
248
+ const preparedSkipList = (0,default_skip_list_js_namespaceObject.prepareSkipList)(skip);
249
+ for(const key in versions){
250
+ if ((0,default_skip_list_js_namespaceObject.isInSkipList)(key, preparedSkipList)) {
251
+ continue;
252
+ }
253
+ const inferVersion = !config.requiredVersion || config.requiredVersion === 'auto';
254
+ const requiredVersion = inferVersion ? versions[key] : config.requiredVersion;
255
+ if (!shareConfig[key]) {
256
+ shareConfig[key] = {
257
+ ...config,
258
+ requiredVersion
259
+ };
260
+ }
261
+ }
262
+ }
263
+ return share(share, projectPath);
264
+ }
265
+ function inferProjectPath(projectPath) {
266
+ if (!projectPath) {
267
+ projectPath = external_path_default().dirname((0,external_configuration_context_js_namespaceObject.getConfigContext)().packageJson || '');
268
+ }
269
+ if (!projectPath && (0,external_configuration_context_js_namespaceObject.getConfigContext)().workspaceRoot) {
270
+ projectPath = (0,external_configuration_context_js_namespaceObject.getConfigContext)().workspaceRoot || '';
271
+ }
272
+ if (!projectPath) {
273
+ projectPath = external_process_default().cwd();
274
+ }
275
+ return projectPath;
276
+ }
277
+ function setInferVersion(infer) {
278
+ share_utils_inferVersion = infer;
279
+ }
280
+ function share(shareObjects, projectPath = '') {
281
+ projectPath = inferProjectPath(projectPath);
282
+ const packagePath = findPackageJson(projectPath);
283
+ const result = {};
284
+ let includeSecondaries;
285
+ for(const key in shareObjects){
286
+ includeSecondaries = false;
287
+ const shareObject = shareObjects[key];
288
+ if (shareObject.requiredVersion === 'auto' || share_utils_inferVersion && typeof shareObject.requiredVersion === 'undefined') {
289
+ const version = lookupVersion(key, projectPath);
290
+ shareObject.requiredVersion = version;
291
+ shareObject.version = version.replace(/^\D*/, '');
292
+ }
293
+ if (typeof shareObject.includeSecondaries === 'undefined') {
294
+ shareObject.includeSecondaries = true;
295
+ }
296
+ if (shareObject.includeSecondaries) {
297
+ includeSecondaries = shareObject.includeSecondaries;
298
+ delete shareObject.includeSecondaries;
299
+ }
300
+ result[key] = shareObject;
301
+ if (includeSecondaries) {
302
+ const libPackageJson = (0,package_info_js_namespaceObject.findDepPackageJson)(key, external_path_default().dirname(packagePath));
303
+ if (!libPackageJson) {
304
+ logger_js_namespaceObject.logger.error(`Could not find folder containing dep ${key}`);
305
+ continue;
306
+ }
307
+ const libPath = external_path_default().dirname(libPackageJson);
308
+ const secondaries = getSecondaries(includeSecondaries, libPath, key, shareObject);
309
+ if (secondaries) {
310
+ addSecondaries(secondaries, result);
311
+ }
312
+ }
313
+ }
314
+ return result;
315
+ }
316
+ function addSecondaries(secondaries, result) {
317
+ Object.assign(result, secondaries);
318
+ }
319
+
320
+ exports.DEFAULT_SECONARIES_SKIP_LIST = __webpack_exports__.DEFAULT_SECONARIES_SKIP_LIST;
321
+ exports._findSecondaries = __webpack_exports__._findSecondaries;
322
+ exports.addSecondaries = __webpack_exports__.addSecondaries;
323
+ exports.findPackageJson = __webpack_exports__.findPackageJson;
324
+ exports.findRootTsConfigJson = __webpack_exports__.findRootTsConfigJson;
325
+ exports.findSecondaries = __webpack_exports__.findSecondaries;
326
+ exports.getDefaultEntry = __webpack_exports__.getDefaultEntry;
327
+ exports.getSecondaries = __webpack_exports__.getSecondaries;
328
+ exports.lookupVersion = __webpack_exports__.lookupVersion;
329
+ exports.lookupVersionInMap = __webpack_exports__.lookupVersionInMap;
330
+ exports.readConfiguredSecondaries = __webpack_exports__.readConfiguredSecondaries;
331
+ exports.setInferVersion = __webpack_exports__.setInferVersion;
332
+ exports.share = __webpack_exports__.share;
333
+ exports.shareAll = __webpack_exports__.shareAll;
334
+ for(var __webpack_i__ in __webpack_exports__) {
335
+ if(["DEFAULT_SECONARIES_SKIP_LIST","_findSecondaries","addSecondaries","findPackageJson","findRootTsConfigJson","findSecondaries","getDefaultEntry","getSecondaries","lookupVersion","lookupVersionInMap","readConfiguredSecondaries","setInferVersion","share","shareAll"].indexOf(__webpack_i__) === -1) {
336
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
337
+ }
338
+ }
339
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,254 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import process from "process";
4
+ import { getConfigContext } from "./configuration-context.mjs";
5
+ import { findDepPackageJson, getVersionMaps } from "../utils/package-info.mjs";
6
+ import { logger } from "../utils/logger.mjs";
7
+ import { DEFAULT_SKIP_LIST, PREPARED_DEFAULT_SKIP_LIST, isInSkipList, prepareSkipList } from "../core/default-skip-list.mjs";
8
+
9
+ ;// CONCATENATED MODULE: external "fs"
10
+
11
+ ;// CONCATENATED MODULE: external "path"
12
+
13
+ ;// CONCATENATED MODULE: external "process"
14
+
15
+ ;// CONCATENATED MODULE: external "./configuration-context.mjs"
16
+
17
+ ;// CONCATENATED MODULE: external "../utils/package-info.mjs"
18
+
19
+ ;// CONCATENATED MODULE: external "../utils/logger.mjs"
20
+
21
+ ;// CONCATENATED MODULE: external "../core/default-skip-list.mjs"
22
+
23
+ ;// CONCATENATED MODULE: ./src/lib/config/share-utils.ts
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ let share_utils_inferVersion = false;
32
+ const DEFAULT_SECONARIES_SKIP_LIST = [
33
+ '@angular/router/upgrade',
34
+ '@angular/common/upgrade'
35
+ ];
36
+ function findRootTsConfigJson() {
37
+ const packageJson = findPackageJson(process.cwd());
38
+ const projectRoot = path.dirname(packageJson);
39
+ const tsConfigBaseJson = path.join(projectRoot, 'tsconfig.base.json');
40
+ const tsConfigJson = path.join(projectRoot, 'tsconfig.json');
41
+ if (fs.existsSync(tsConfigBaseJson)) {
42
+ return tsConfigBaseJson;
43
+ } else if (fs.existsSync(tsConfigJson)) {
44
+ return tsConfigJson;
45
+ }
46
+ throw new Error('Neither a tsconfig.json nor a tsconfig.base.json was found');
47
+ }
48
+ function findPackageJson(folder) {
49
+ while(!fs.existsSync(path.join(folder, 'package.json')) && path.dirname(folder) !== folder){
50
+ folder = path.dirname(folder);
51
+ }
52
+ const filePath = path.join(folder, 'package.json');
53
+ if (fs.existsSync(filePath)) {
54
+ return filePath;
55
+ }
56
+ throw new Error(`No package.json found. Searched the following folder and all parents: ${folder}`);
57
+ }
58
+ function lookupVersion(key, workspaceRoot) {
59
+ const versionMaps = getVersionMaps(workspaceRoot, workspaceRoot);
60
+ for (const versionMap of versionMaps){
61
+ const version = lookupVersionInMap(key, versionMap);
62
+ if (version) {
63
+ return version;
64
+ }
65
+ }
66
+ throw new Error(`Shared Dependency ${key} has requiredVersion:'auto'. However, this dependency is not found in your package.json`);
67
+ }
68
+ function lookupVersionInMap(key, versions) {
69
+ const parts = key.split('/');
70
+ if (parts.length >= 2 && parts[0].startsWith('@')) {
71
+ key = `${parts[0]}/${parts[1]}`;
72
+ } else {
73
+ key = parts[0];
74
+ }
75
+ if (key.toLowerCase() === '@angular-architects/module-federation-runtime') {
76
+ key = '@angular-architects/module-federation';
77
+ }
78
+ return versions[key] || null;
79
+ }
80
+ function _findSecondaries(libPath, excludes, shareObject, acc) {
81
+ const files = fs.readdirSync(libPath);
82
+ const dirs = files.map((f)=>path.join(libPath, f)).filter((f)=>fs.lstatSync(f).isDirectory() && f !== 'node_modules');
83
+ const secondaries = dirs.filter((d)=>fs.existsSync(path.join(d, 'package.json')));
84
+ for (const s of secondaries){
85
+ const secondaryLibName = s.replace(/\\/g, '/').replace(/^.*node_modules[/]/, '');
86
+ if (excludes.includes(secondaryLibName)) {
87
+ continue;
88
+ }
89
+ if (isInSkipList(secondaryLibName, PREPARED_DEFAULT_SKIP_LIST)) {
90
+ continue;
91
+ }
92
+ acc[secondaryLibName] = {
93
+ ...shareObject
94
+ };
95
+ _findSecondaries(s, excludes, shareObject, acc);
96
+ }
97
+ }
98
+ function findSecondaries(libPath, excludes, shareObject) {
99
+ const acc = {};
100
+ _findSecondaries(libPath, excludes, shareObject, acc);
101
+ return acc;
102
+ }
103
+ function getSecondaries(includeSecondaries, libPath, key, shareObject) {
104
+ let exclude = [
105
+ ...DEFAULT_SECONARIES_SKIP_LIST
106
+ ];
107
+ if (typeof includeSecondaries === 'object') {
108
+ if (Array.isArray(includeSecondaries.skip)) {
109
+ exclude = includeSecondaries.skip;
110
+ } else if (typeof includeSecondaries.skip === 'string') {
111
+ exclude = [
112
+ includeSecondaries.skip
113
+ ];
114
+ }
115
+ }
116
+ if (!fs.existsSync(libPath)) {
117
+ return {};
118
+ }
119
+ const configured = readConfiguredSecondaries(key, libPath, exclude, shareObject);
120
+ if (configured) {
121
+ return configured;
122
+ }
123
+ // Fallback: Search folders
124
+ return findSecondaries(libPath, exclude, shareObject);
125
+ }
126
+ function readConfiguredSecondaries(parent, libPath, exclude, shareObject) {
127
+ const libPackageJson = path.join(libPath, 'package.json');
128
+ if (!fs.existsSync(libPackageJson)) {
129
+ return null;
130
+ }
131
+ const packageJson = JSON.parse(fs.readFileSync(libPackageJson, 'utf-8'));
132
+ const exports = packageJson['exports'];
133
+ if (!exports) {
134
+ return null;
135
+ }
136
+ const keys = Object.keys(exports).filter((key)=>key !== '.' && key !== './package.json' && !key.endsWith('*') && (exports[key]['default'] || typeof exports[key] === 'string'));
137
+ const result = {};
138
+ for (const key of keys){
139
+ const secondaryName = path.join(parent, key).replace(/\\/g, '/');
140
+ if (exclude.includes(secondaryName)) {
141
+ continue;
142
+ }
143
+ if (isInSkipList(secondaryName, PREPARED_DEFAULT_SKIP_LIST)) {
144
+ continue;
145
+ }
146
+ const entry = getDefaultEntry(exports, key);
147
+ if (typeof entry !== 'string') {
148
+ console.log(`No entry point found for ${secondaryName}`);
149
+ continue;
150
+ }
151
+ if ([
152
+ '.css',
153
+ '.scss',
154
+ '.less'
155
+ ].some((ext)=>entry.endsWith(ext))) {
156
+ continue;
157
+ }
158
+ result[secondaryName] = {
159
+ ...shareObject
160
+ };
161
+ }
162
+ return result;
163
+ }
164
+ function getDefaultEntry(exports, key) {
165
+ let entry;
166
+ if (typeof exports[key] === 'string') {
167
+ entry = exports[key];
168
+ } else {
169
+ var _exports_key;
170
+ entry = (_exports_key = exports[key]) === null || _exports_key === void 0 ? void 0 : _exports_key['default'];
171
+ if (typeof entry === 'object') {
172
+ entry = entry['default'];
173
+ }
174
+ }
175
+ return entry;
176
+ }
177
+ function shareAll(config, skip = DEFAULT_SKIP_LIST, projectPath = '') {
178
+ projectPath = inferProjectPath(projectPath);
179
+ const versionMaps = getVersionMaps(projectPath, projectPath);
180
+ const shareConfig = {};
181
+ for (const versions of versionMaps){
182
+ const preparedSkipList = prepareSkipList(skip);
183
+ for(const key in versions){
184
+ if (isInSkipList(key, preparedSkipList)) {
185
+ continue;
186
+ }
187
+ const inferVersion = !config.requiredVersion || config.requiredVersion === 'auto';
188
+ const requiredVersion = inferVersion ? versions[key] : config.requiredVersion;
189
+ if (!shareConfig[key]) {
190
+ shareConfig[key] = {
191
+ ...config,
192
+ requiredVersion
193
+ };
194
+ }
195
+ }
196
+ }
197
+ return share(share, projectPath);
198
+ }
199
+ function inferProjectPath(projectPath) {
200
+ if (!projectPath) {
201
+ projectPath = path.dirname(getConfigContext().packageJson || '');
202
+ }
203
+ if (!projectPath && getConfigContext().workspaceRoot) {
204
+ projectPath = getConfigContext().workspaceRoot || '';
205
+ }
206
+ if (!projectPath) {
207
+ projectPath = process.cwd();
208
+ }
209
+ return projectPath;
210
+ }
211
+ function setInferVersion(infer) {
212
+ share_utils_inferVersion = infer;
213
+ }
214
+ function share(shareObjects, projectPath = '') {
215
+ projectPath = inferProjectPath(projectPath);
216
+ const packagePath = findPackageJson(projectPath);
217
+ const result = {};
218
+ let includeSecondaries;
219
+ for(const key in shareObjects){
220
+ includeSecondaries = false;
221
+ const shareObject = shareObjects[key];
222
+ if (shareObject.requiredVersion === 'auto' || share_utils_inferVersion && typeof shareObject.requiredVersion === 'undefined') {
223
+ const version = lookupVersion(key, projectPath);
224
+ shareObject.requiredVersion = version;
225
+ shareObject.version = version.replace(/^\D*/, '');
226
+ }
227
+ if (typeof shareObject.includeSecondaries === 'undefined') {
228
+ shareObject.includeSecondaries = true;
229
+ }
230
+ if (shareObject.includeSecondaries) {
231
+ includeSecondaries = shareObject.includeSecondaries;
232
+ delete shareObject.includeSecondaries;
233
+ }
234
+ result[key] = shareObject;
235
+ if (includeSecondaries) {
236
+ const libPackageJson = findDepPackageJson(key, path.dirname(packagePath));
237
+ if (!libPackageJson) {
238
+ logger.error(`Could not find folder containing dep ${key}`);
239
+ continue;
240
+ }
241
+ const libPath = path.dirname(libPackageJson);
242
+ const secondaries = getSecondaries(includeSecondaries, libPath, key, shareObject);
243
+ if (secondaries) {
244
+ addSecondaries(secondaries, result);
245
+ }
246
+ }
247
+ }
248
+ return result;
249
+ }
250
+ function addSecondaries(secondaries, result) {
251
+ Object.assign(result, secondaries);
252
+ }
253
+
254
+ export { DEFAULT_SECONARIES_SKIP_LIST, _findSecondaries, addSecondaries, findPackageJson, findRootTsConfigJson, findSecondaries, getDefaultEntry, getSecondaries, lookupVersion, lookupVersionInMap, readConfiguredSecondaries, setInferVersion, share, shareAll };