mirror of https://github.com/webpack/webpack.git
fix: logic
This commit is contained in:
parent
b0b8515bd6
commit
7ffa4eb81a
|
|
@ -2287,11 +2287,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
this.hooks.failedEntry.call(entry, options, err);
|
||||
return callback(err);
|
||||
}
|
||||
this.hooks.succeedEntry.call(
|
||||
entry,
|
||||
options,
|
||||
/** @type {Module} */ (module)
|
||||
);
|
||||
this.hooks.succeedEntry.call(entry, options, module);
|
||||
return callback(null, module);
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const RawModule = require("./RawModule");
|
||||
const EntryDependency = require("./dependencies/EntryDependency");
|
||||
const createSchemaValidation = require("./util/create-schema-validation");
|
||||
|
||||
/** @typedef {import("../declarations/plugins/IgnorePlugin").IgnorePluginOptions} IgnorePluginOptions */
|
||||
|
|
@ -73,7 +75,23 @@ class IgnorePlugin {
|
|||
*/
|
||||
apply(compiler) {
|
||||
compiler.hooks.normalModuleFactory.tap("IgnorePlugin", nmf => {
|
||||
nmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
|
||||
nmf.hooks.beforeResolve.tap("IgnorePlugin", resolveData => {
|
||||
const result = this.checkIgnore(resolveData);
|
||||
|
||||
if (
|
||||
result === false &&
|
||||
resolveData.dependencies.length > 0 &&
|
||||
resolveData.dependencies[0] instanceof EntryDependency
|
||||
) {
|
||||
resolveData.ignoredModule = new RawModule(
|
||||
"",
|
||||
"ignored-entry-module",
|
||||
"(ignored-entry-module)"
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
});
|
||||
compiler.hooks.contextModuleFactory.tap("IgnorePlugin", cmf => {
|
||||
cmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ const {
|
|||
* @property {LazySet<string>} fileDependencies
|
||||
* @property {LazySet<string>} missingDependencies
|
||||
* @property {LazySet<string>} contextDependencies
|
||||
* @property {Module=} ignoredModule
|
||||
* @property {boolean} cacheable allow to use the unsafe cache
|
||||
*/
|
||||
|
||||
|
|
@ -885,12 +886,19 @@ class NormalModuleFactory extends ModuleFactory {
|
|||
|
||||
// Ignored
|
||||
if (result === false) {
|
||||
return callback(null, {
|
||||
/** @type {ModuleFactoryResult} * */
|
||||
const factoryResult = {
|
||||
fileDependencies,
|
||||
missingDependencies,
|
||||
contextDependencies,
|
||||
cacheable: resolveData.cacheable
|
||||
});
|
||||
};
|
||||
|
||||
if (resolveData.ignoredModule) {
|
||||
factoryResult.module = resolveData.ignoredModule;
|
||||
}
|
||||
|
||||
return callback(null, factoryResult);
|
||||
}
|
||||
|
||||
if (typeof result === "object")
|
||||
|
|
@ -911,6 +919,7 @@ class NormalModuleFactory extends ModuleFactory {
|
|||
});
|
||||
}
|
||||
|
||||
/** @type {ModuleFactoryResult} * */
|
||||
const factoryResult = {
|
||||
module,
|
||||
fileDependencies,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ const chunkHasJs = (chunk, chunkGraph) => {
|
|||
* @param {ChunkGraph} chunkGraph the chunk graph
|
||||
* @returns {boolean} true, when a JS file is needed for this chunk
|
||||
*/
|
||||
const chunkHasJsOrRuntime = (chunk, chunkGraph) => {
|
||||
const chunkHasRuntimeOrJs = (chunk, chunkGraph) => {
|
||||
if (
|
||||
chunkGraph.getChunkModulesIterableBySourceType(
|
||||
chunk,
|
||||
|
|
@ -313,7 +313,7 @@ class JavascriptModulesPlugin {
|
|||
hooks
|
||||
);
|
||||
} else if (chunk.hasRuntime()) {
|
||||
if (!chunkHasJsOrRuntime(chunk, chunkGraph)) {
|
||||
if (!chunkHasRuntimeOrJs(chunk, chunkGraph)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
module.exports = {
|
||||
findBundle: function () {
|
||||
return [
|
||||
// TODO improve me?
|
||||
// "./a.js",
|
||||
// "./b.js",
|
||||
"./bundle0.js"
|
||||
];
|
||||
return ["./a.js", "./b.js", "./bundle0.js"];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11929,6 +11929,7 @@ declare interface ResolveData {
|
|||
fileDependencies: LazySet<string>;
|
||||
missingDependencies: LazySet<string>;
|
||||
contextDependencies: LazySet<string>;
|
||||
ignoredModule?: Module;
|
||||
|
||||
/**
|
||||
* allow to use the unsafe cache
|
||||
|
|
|
|||
Loading…
Reference in New Issue