-
-
Notifications
You must be signed in to change notification settings - Fork 393
Expand file tree
/
Copy pathContainerEntryDependency.ts
More file actions
68 lines (58 loc) · 2.02 KB
/
ContainerEntryDependency.ts
File metadata and controls
68 lines (58 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
*/
import { ExposeOptions } from './ContainerEntryModule';
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
import type { containerPlugin } from '@module-federation/sdk';
const makeSerializable = require(
normalizeWebpackPath('webpack/lib/util/makeSerializable'),
);
const { Dependency } = require(
normalizeWebpackPath('webpack'),
) as typeof import('webpack');
class ContainerEntryDependency extends Dependency {
public name: string;
public exposes: [string, ExposeOptions][];
public shareScope: string | string[];
public injectRuntimeEntry: string;
public dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'];
/**
* @param {string} name entry name
* @param {[string, ExposeOptions][]} exposes list of exposed modules
* @param {string|string[]} shareScope name of the share scope
* @param {string[]} injectRuntimeEntry the path of injectRuntime file.
* @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
*/
constructor(
name: string,
exposes: [string, ExposeOptions][],
shareScope: string | string[],
injectRuntimeEntry: string,
dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'],
) {
super();
this.name = name;
this.exposes = exposes;
this.shareScope = shareScope;
this.injectRuntimeEntry = injectRuntimeEntry;
this.dataPrefetch = dataPrefetch;
}
/**
* @returns {string | null} an identifier to merge equal requests
*/
override getResourceIdentifier(): string | null {
return `container-entry-${this.name}`;
}
override get type(): string {
return 'container entry';
}
override get category(): string {
return 'esm';
}
}
makeSerializable(
ContainerEntryDependency,
'enhanced/lib/container/ContainerEntryDependency',
);
export default ContainerEntryDependency;