-
-
Notifications
You must be signed in to change notification settings - Fork 393
Expand file tree
/
Copy pathContainerEntryModuleFactory.ts
More file actions
45 lines (40 loc) · 1.35 KB
/
ContainerEntryModuleFactory.ts
File metadata and controls
45 lines (40 loc) · 1.35 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
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
*/
'use strict';
import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';
import ContainerEntryModule from './ContainerEntryModule';
import ContainerEntryDependency from './ContainerEntryDependency';
const ModuleFactory = require(
normalizeWebpackPath('webpack/lib/ModuleFactory'),
) as typeof import('webpack/lib/ModuleFactory');
import type {
ModuleFactoryCreateData,
ModuleFactoryResult,
} from 'webpack/lib/ModuleFactory';
export default class ContainerEntryModuleFactory extends ModuleFactory {
/**
* @param {ModuleFactoryCreateData} data data object
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
* @returns {void}
*/
override create(
data: ModuleFactoryCreateData,
callback: (error: Error | null, result: ModuleFactoryResult) => void,
): void {
const { dependencies } = data;
const containerDependencies =
dependencies as unknown as ContainerEntryDependency[];
const dep = containerDependencies[0];
callback(null, {
module: new ContainerEntryModule(
dep.name,
dep.exposes,
dep.shareScope,
dep.injectRuntimeEntry,
dep.dataPrefetch,
),
});
}
}