feat: refactoring project
This commit is contained in:
51
node_modules/webpack/lib/DynamicEntryPlugin.js
generated
vendored
51
node_modules/webpack/lib/DynamicEntryPlugin.js
generated
vendored
@@ -9,6 +9,7 @@ const EntryOptionPlugin = require("./EntryOptionPlugin");
|
||||
const EntryPlugin = require("./EntryPlugin");
|
||||
const EntryDependency = require("./dependencies/EntryDependency");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescriptionNormalized */
|
||||
/** @typedef {import("../declarations/WebpackOptions").EntryDynamicNormalized} EntryDynamic */
|
||||
/** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */
|
||||
/** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStatic */
|
||||
@@ -40,22 +41,27 @@ class DynamicEntryPlugin {
|
||||
}
|
||||
);
|
||||
|
||||
compiler.hooks.make.tapPromise(
|
||||
"DynamicEntryPlugin",
|
||||
(compilation, callback) =>
|
||||
Promise.resolve(this.entry())
|
||||
.then(entry => {
|
||||
const promises = [];
|
||||
for (const name of Object.keys(entry)) {
|
||||
const desc = entry[name];
|
||||
const options = EntryOptionPlugin.entryDescriptionToOptions(
|
||||
compiler,
|
||||
name,
|
||||
desc
|
||||
);
|
||||
for (const entry of desc.import) {
|
||||
promises.push(
|
||||
new Promise((resolve, reject) => {
|
||||
compiler.hooks.make.tapPromise("DynamicEntryPlugin", compilation =>
|
||||
Promise.resolve(this.entry())
|
||||
.then(entry => {
|
||||
const promises = [];
|
||||
for (const name of Object.keys(entry)) {
|
||||
const desc = entry[name];
|
||||
const options = EntryOptionPlugin.entryDescriptionToOptions(
|
||||
compiler,
|
||||
name,
|
||||
desc
|
||||
);
|
||||
for (const entry of /** @type {NonNullable<EntryDescriptionNormalized["import"]>} */ (
|
||||
desc.import
|
||||
)) {
|
||||
promises.push(
|
||||
new Promise(
|
||||
/**
|
||||
* @param {(value?: any) => void} resolve resolve
|
||||
* @param {(reason?: Error) => void} reject reject
|
||||
*/
|
||||
(resolve, reject) => {
|
||||
compilation.addEntry(
|
||||
this.context,
|
||||
EntryPlugin.createDependency(entry, options),
|
||||
@@ -65,13 +71,14 @@ class DynamicEntryPlugin {
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
return Promise.all(promises);
|
||||
})
|
||||
.then(x => {})
|
||||
}
|
||||
return Promise.all(promises);
|
||||
})
|
||||
.then(x => {})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user