Skip to content

Commit 8d9e1b6

Browse files
chore(enhanced): fix types of container plugin (#2896)
Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent 8633da6 commit 8d9e1b6

File tree

1 file changed

+44
-42
lines changed

1 file changed

+44
-42
lines changed

packages/enhanced/src/lib/container/ContainerPlugin.ts

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -182,69 +182,71 @@ class ContainerPlugin {
182182
compiler.options.output.enabledLibraryTypes.push(library.type);
183183
}
184184

185-
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
186-
const dep = new ContainerEntryDependency(
187-
name,
188-
//@ts-ignore
189-
exposes,
190-
shareScope,
191-
federationRuntimePluginInstance.entryFilePath,
192-
);
193-
const hasSingleRuntimeChunk =
194-
compilation.options?.optimization?.runtimeChunk;
195-
dep.loc = { name };
196-
compilation.addEntry(
197-
compilation.options.context || '',
198-
//@ts-ignore
199-
dep,
200-
{
185+
compiler.hooks.make.tapAsync(
186+
PLUGIN_NAME,
187+
(
188+
compilation: Compilation,
189+
callback: (error?: WebpackError | null | undefined) => void,
190+
) => {
191+
const dep = new ContainerEntryDependency(
201192
name,
202-
filename,
203-
runtime: hasSingleRuntimeChunk ? false : runtime,
204-
library,
205-
},
206-
(error: WebpackError | null | undefined) => {
207-
if (error) return callback(error);
208-
if (hasSingleRuntimeChunk) {
209-
// Add to single runtime chunk as well.
210-
// Allows for singleton runtime graph with all needed runtime modules for federation
211-
addEntryToSingleRuntimeChunk();
212-
} else {
213-
callback();
214-
}
215-
},
216-
);
217-
218-
// Function to add entry for undefined runtime
219-
const addEntryToSingleRuntimeChunk = () => {
193+
//@ts-ignore
194+
exposes,
195+
shareScope,
196+
federationRuntimePluginInstance.entryFilePath,
197+
);
198+
const hasSingleRuntimeChunk =
199+
compilation.options?.optimization?.runtimeChunk;
200+
dep.loc = { name };
220201
compilation.addEntry(
221202
compilation.options.context || '',
222-
//@ts-ignore
223203
dep,
224204
{
225-
name: name ? name + '_partial' : undefined, // give unique name name
226-
runtime: undefined,
205+
name,
206+
filename,
207+
runtime: hasSingleRuntimeChunk ? false : runtime,
227208
library,
228209
},
229210
(error: WebpackError | null | undefined) => {
230211
if (error) return callback(error);
231-
callback();
212+
if (hasSingleRuntimeChunk) {
213+
// Add to single runtime chunk as well.
214+
// Allows for singleton runtime graph with all needed runtime modules for federation
215+
addEntryToSingleRuntimeChunk();
216+
} else {
217+
callback();
218+
}
232219
},
233220
);
234-
};
235-
});
221+
222+
// Function to add entry for undefined runtime
223+
const addEntryToSingleRuntimeChunk = () => {
224+
compilation.addEntry(
225+
compilation.options.context || '',
226+
dep,
227+
{
228+
name: name ? name + '_partial' : undefined, // give unique name name
229+
runtime: undefined,
230+
library,
231+
},
232+
(error: WebpackError | null | undefined) => {
233+
if (error) return callback(error);
234+
callback();
235+
},
236+
);
237+
};
238+
},
239+
);
236240

237241
compiler.hooks.thisCompilation.tap(
238242
PLUGIN_NAME,
239243
(compilation: Compilation, { normalModuleFactory }) => {
240244
compilation.dependencyFactories.set(
241245
ContainerEntryDependency,
242-
//@ts-ignore
243246
new ContainerEntryModuleFactory(),
244247
);
245248

246249
compilation.dependencyFactories.set(
247-
//@ts-ignore
248250
ContainerExposedDependency,
249251
normalModuleFactory,
250252
);

0 commit comments

Comments
 (0)