@module-federation/managers 0.13.0 → 0.13.1
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/dist/index.cjs.js
CHANGED
|
@@ -13,30 +13,36 @@ class BasicPluginOptionsManager {
|
|
|
13
13
|
get options() {
|
|
14
14
|
return this._options;
|
|
15
15
|
}
|
|
16
|
+
get root() {
|
|
17
|
+
return this._root;
|
|
18
|
+
}
|
|
16
19
|
init(options, extraArgs) {
|
|
17
20
|
this._options = options;
|
|
18
21
|
}
|
|
19
22
|
setOptions(options) {
|
|
20
23
|
this._options = options;
|
|
21
24
|
}
|
|
25
|
+
constructor(root = process.cwd()){
|
|
26
|
+
this._root = root;
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
class PKGJsonManager {
|
|
25
31
|
setPKGJson(pkg) {
|
|
26
32
|
this._pkg = pkg;
|
|
27
33
|
}
|
|
28
|
-
readPKGJson(
|
|
34
|
+
readPKGJson(root = process.cwd()) {
|
|
29
35
|
if (this._pkg) {
|
|
30
36
|
return this._pkg;
|
|
31
37
|
}
|
|
32
38
|
try {
|
|
33
39
|
// eslint-disable-next-line no-restricted-globals
|
|
34
|
-
const pkg = JSON.parse(fs.readFileSync(path.resolve(
|
|
40
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf8'));
|
|
35
41
|
this._pkg = pkg;
|
|
36
42
|
return pkg;
|
|
37
43
|
} catch (_err) {
|
|
38
44
|
try {
|
|
39
|
-
const pkg = finder.sync(
|
|
45
|
+
const pkg = finder.sync(root);
|
|
40
46
|
this._pkg = pkg;
|
|
41
47
|
return pkg;
|
|
42
48
|
} catch (err) {
|
|
@@ -45,9 +51,9 @@ class PKGJsonManager {
|
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
|
-
getExposeGarfishModuleType(
|
|
54
|
+
getExposeGarfishModuleType(root = process.cwd()) {
|
|
49
55
|
var _pkg_mf;
|
|
50
|
-
const pkg = this.readPKGJson(
|
|
56
|
+
const pkg = this.readPKGJson(root);
|
|
51
57
|
return (pkg == null ? void 0 : (_pkg_mf = pkg['mf']) == null ? void 0 : _pkg_mf.type) === sdk.MFModuleType.NPM ? sdk.MFModuleType.NPM : sdk.MFModuleType.APP;
|
|
52
58
|
}
|
|
53
59
|
}
|
|
@@ -386,7 +392,7 @@ let SharedManager = class SharedManager extends BasicPluginOptionsManager {
|
|
|
386
392
|
if (path.isAbsolute(shareConfig.import)) {
|
|
387
393
|
pkgPath = shareConfig.import;
|
|
388
394
|
} else if (shareConfig.import.startsWith('.')) {
|
|
389
|
-
pkgPath = path.resolve(
|
|
395
|
+
pkgPath = path.resolve(this.root, shareConfig.import);
|
|
390
396
|
}
|
|
391
397
|
} else {
|
|
392
398
|
if (shareConfig.packageName) {
|
|
@@ -395,7 +401,7 @@ let SharedManager = class SharedManager extends BasicPluginOptionsManager {
|
|
|
395
401
|
}
|
|
396
402
|
pkgPath = pkgPath || require.resolve(depName, {
|
|
397
403
|
paths: [
|
|
398
|
-
|
|
404
|
+
this.root
|
|
399
405
|
]
|
|
400
406
|
});
|
|
401
407
|
const pkgJsonPath = finder.sync(pkgPath);
|
package/dist/index.esm.js
CHANGED
|
@@ -11,30 +11,36 @@ class BasicPluginOptionsManager {
|
|
|
11
11
|
get options() {
|
|
12
12
|
return this._options;
|
|
13
13
|
}
|
|
14
|
+
get root() {
|
|
15
|
+
return this._root;
|
|
16
|
+
}
|
|
14
17
|
init(options, extraArgs) {
|
|
15
18
|
this._options = options;
|
|
16
19
|
}
|
|
17
20
|
setOptions(options) {
|
|
18
21
|
this._options = options;
|
|
19
22
|
}
|
|
23
|
+
constructor(root = process.cwd()){
|
|
24
|
+
this._root = root;
|
|
25
|
+
}
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
class PKGJsonManager {
|
|
23
29
|
setPKGJson(pkg) {
|
|
24
30
|
this._pkg = pkg;
|
|
25
31
|
}
|
|
26
|
-
readPKGJson(
|
|
32
|
+
readPKGJson(root = process.cwd()) {
|
|
27
33
|
if (this._pkg) {
|
|
28
34
|
return this._pkg;
|
|
29
35
|
}
|
|
30
36
|
try {
|
|
31
37
|
// eslint-disable-next-line no-restricted-globals
|
|
32
|
-
const pkg = JSON.parse(fs.readFileSync(path.resolve(
|
|
38
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf8'));
|
|
33
39
|
this._pkg = pkg;
|
|
34
40
|
return pkg;
|
|
35
41
|
} catch (_err) {
|
|
36
42
|
try {
|
|
37
|
-
const pkg = finder.sync(
|
|
43
|
+
const pkg = finder.sync(root);
|
|
38
44
|
this._pkg = pkg;
|
|
39
45
|
return pkg;
|
|
40
46
|
} catch (err) {
|
|
@@ -43,9 +49,9 @@ class PKGJsonManager {
|
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
|
-
getExposeGarfishModuleType(
|
|
52
|
+
getExposeGarfishModuleType(root = process.cwd()) {
|
|
47
53
|
var _pkg_mf;
|
|
48
|
-
const pkg = this.readPKGJson(
|
|
54
|
+
const pkg = this.readPKGJson(root);
|
|
49
55
|
return (pkg == null ? void 0 : (_pkg_mf = pkg['mf']) == null ? void 0 : _pkg_mf.type) === MFModuleType.NPM ? MFModuleType.NPM : MFModuleType.APP;
|
|
50
56
|
}
|
|
51
57
|
}
|
|
@@ -384,7 +390,7 @@ let SharedManager = class SharedManager extends BasicPluginOptionsManager {
|
|
|
384
390
|
if (path.isAbsolute(shareConfig.import)) {
|
|
385
391
|
pkgPath = shareConfig.import;
|
|
386
392
|
} else if (shareConfig.import.startsWith('.')) {
|
|
387
|
-
pkgPath = path.resolve(
|
|
393
|
+
pkgPath = path.resolve(this.root, shareConfig.import);
|
|
388
394
|
}
|
|
389
395
|
} else {
|
|
390
396
|
if (shareConfig.packageName) {
|
|
@@ -393,7 +399,7 @@ let SharedManager = class SharedManager extends BasicPluginOptionsManager {
|
|
|
393
399
|
}
|
|
394
400
|
pkgPath = pkgPath || require.resolve(depName, {
|
|
395
401
|
paths: [
|
|
396
|
-
|
|
402
|
+
this.root
|
|
397
403
|
]
|
|
398
404
|
});
|
|
399
405
|
const pkgJsonPath = finder.sync(pkgPath);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare class BasicPluginOptionsManager<T> {
|
|
2
2
|
private _options?;
|
|
3
|
+
private _root;
|
|
4
|
+
constructor(root?: string);
|
|
3
5
|
get enable(): boolean;
|
|
4
6
|
get options(): T;
|
|
7
|
+
get root(): string;
|
|
5
8
|
init(options: T, extraArgs?: Record<string, any>): void;
|
|
6
9
|
setOptions(options: T): void;
|
|
7
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class PKGJsonManager {
|
|
2
2
|
private _pkg?;
|
|
3
3
|
setPKGJson(pkg: Record<string, any>): void;
|
|
4
|
-
readPKGJson(
|
|
5
|
-
getExposeGarfishModuleType(
|
|
4
|
+
readPKGJson(root?: string): Record<string, any>;
|
|
5
|
+
getExposeGarfishModuleType(root?: string): string;
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/managers",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Provide managers for helping handle mf data .",
|
|
6
6
|
"keywords": [
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"find-pkg": "2.0.0",
|
|
28
28
|
"fs-extra": "9.1.0",
|
|
29
|
-
"@module-federation/sdk": "0.13.
|
|
29
|
+
"@module-federation/sdk": "0.13.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"webpack": "5.94.0"
|