Skip to content

Commit

Permalink
Merge branch 'main' into webpack-hot-middleware-lazy-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 19, 2022
2 parents 94fcfa0 + f875826 commit 74dcdee
Show file tree
Hide file tree
Showing 65 changed files with 860 additions and 433 deletions.
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

15 changes: 8 additions & 7 deletions examples/css/README.md
Expand Up @@ -208,7 +208,7 @@ module.exports = __webpack_require__.p + "89a353e9c515885abd8e.png";
/******/ var links = document.getElementsByTagName("link");
/******/ for(var i = 0; i < links.length; i++) {
/******/ var l = links[i];
/******/ if(l.href == url || l.getAttribute("href") == url || l.getAttribute("data-webpack") == uniqueName + ":" + key) { link = l; break; }
/******/ if(l.rel == "stylesheet" && (l.href == url || l.getAttribute("href") == url || l.getAttribute("data-webpack") == uniqueName + ":" + key)) { link = l; break; }
/******/ }
/******/ if(!done) return link;
/******/
Expand All @@ -233,6 +233,7 @@ module.exports = __webpack_require__.p + "89a353e9c515885abd8e.png";
/******/ link.onerror = onLinkComplete.bind(null, link.onerror);
/******/ link.onload = onLinkComplete.bind(null, link.onload);
/******/ } else onLinkComplete(undefined, { type: 'load', target: link });
/******/
/******/ needAttach && document.head.appendChild(link);
/******/ return link;
/******/ };
Expand Down Expand Up @@ -486,12 +487,12 @@ head{--webpack-app-1:_7;}
## Unoptimized

```
assets by chunk 16.8 KiB (name: main)
asset output.js 16.4 KiB [emitted] (name: main)
assets by chunk 16.9 KiB (name: main)
asset output.js 16.5 KiB [emitted] (name: main)
asset output.css 385 bytes [emitted] (name: main)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main)
asset 1.output.css 49 bytes [emitted]
Entrypoint main 16.8 KiB (14.6 KiB) = output.js 16.4 KiB output.css 385 bytes 1 auxiliary asset
Entrypoint main 16.9 KiB (14.6 KiB) = output.js 16.5 KiB output.css 385 bytes 1 auxiliary asset
chunk (runtime: main) output.js, output.css (main) 218 bytes (javascript) 335 bytes (css) 14.6 KiB (asset) 42 bytes (css-import) 10 KiB (runtime) [entry] [rendered]
> ./example.js main
runtime modules 10 KiB 9 modules
Expand All @@ -512,12 +513,12 @@ webpack 5.66.0 compiled successfully
## Production mode

```
assets by chunk 4.23 KiB (name: main)
asset output.js 3.85 KiB [emitted] [minimized] (name: main)
assets by chunk 4.25 KiB (name: main)
asset output.js 3.87 KiB [emitted] [minimized] (name: main)
asset output.css 385 bytes [emitted] (name: main)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: images/file.png] (auxiliary name: main)
asset 159.output.css 53 bytes [emitted]
Entrypoint main 4.23 KiB (14.6 KiB) = output.js 3.85 KiB output.css 385 bytes 1 auxiliary asset
Entrypoint main 4.25 KiB (14.6 KiB) = output.js 3.87 KiB output.css 385 bytes 1 auxiliary asset
chunk (runtime: main) 159.output.css 23 bytes
> ./lazy-style.css ./example.js 4:0-26
./lazy-style.css 23 bytes [built] [code generated]
Expand Down
2 changes: 1 addition & 1 deletion lib/Cache.js
Expand Up @@ -21,7 +21,7 @@ const {
/**
* @template T
* @callback CallbackCache
* @param {WebpackError=} err
* @param {(WebpackError | null)=} err
* @param {T=} result
* @returns {void}
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/CacheFacade.js
Expand Up @@ -19,15 +19,15 @@ const mergeEtags = require("./cache/mergeEtags");
/**
* @template T
* @callback CallbackCache
* @param {WebpackError=} err
* @param {(WebpackError | null)=} err
* @param {T=} result
* @returns {void}
*/

/**
* @template T
* @callback CallbackNormalErrorCache
* @param {Error=} err
* @param {(Error | null)=} err
* @param {T=} result
* @returns {void}
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/CleanPlugin.js
Expand Up @@ -45,7 +45,7 @@ const validate = createSchemaValidation(
* @param {OutputFileSystem} fs filesystem
* @param {string} outputPath output path
* @param {Set<string>} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
* @param {function(Error=, Set<string>=): void} callback returns the filenames of the assets that shouldn't be there
* @param {function((Error | null)=, Set<string>=): void} callback returns the filenames of the assets that shouldn't be there
* @returns {void}
*/
const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
Expand Down
14 changes: 8 additions & 6 deletions lib/Compilation.js
Expand Up @@ -116,34 +116,34 @@ const { isSourceEqual } = require("./util/source");

/**
* @callback Callback
* @param {WebpackError=} err
* @param {(WebpackError | null)=} err
* @returns {void}
*/

/**
* @callback ModuleCallback
* @param {WebpackError=} err
* @param {(WebpackError | null)=} err
* @param {Module=} result
* @returns {void}
*/

/**
* @callback ModuleFactoryResultCallback
* @param {WebpackError=} err
* @param {(WebpackError | null)=} err
* @param {ModuleFactoryResult=} result
* @returns {void}
*/

/**
* @callback ModuleOrFactoryResultCallback
* @param {WebpackError=} err
* @param {(WebpackError | null)=} err
* @param {Module | ModuleFactoryResult=} result
* @returns {void}
*/

/**
* @callback ExecuteModuleCallback
* @param {WebpackError=} err
* @param {(WebpackError | null)=} err
* @param {ExecuteModuleResult=} result
* @returns {void}
*/
Expand Down Expand Up @@ -1020,7 +1020,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
/** @type {Map<DepConstructor, ModuleFactory>} */
this.dependencyFactories = new Map();
/** @type {DependencyTemplates} */
this.dependencyTemplates = new DependencyTemplates();
this.dependencyTemplates = new DependencyTemplates(
this.outputOptions.hashFunction
);
this.childrenCounters = {};
/** @type {Set<number|string>} */
this.usedChunkIds = null;
Expand Down
4 changes: 2 additions & 2 deletions lib/Compiler.js
Expand Up @@ -58,13 +58,13 @@ const { isSourceEqual } = require("./util/source");
/**
* @template T
* @callback Callback
* @param {Error=} err
* @param {(Error | null)=} err
* @param {T=} result
*/

/**
* @callback RunAsChildCallback
* @param {Error=} err
* @param {(Error | null)=} err
* @param {Chunk[]=} entries
* @param {Compilation=} compilation
*/
Expand Down
38 changes: 21 additions & 17 deletions lib/ContextModule.js
Expand Up @@ -71,7 +71,7 @@ const makeSerializable = require("./util/makeSerializable");

/**
* @callback ResolveDependenciesCallback
* @param {Error=} err
* @param {(Error | null)=} err
* @param {ContextElementDependency[]=} dependencies
*/

Expand Down Expand Up @@ -149,12 +149,9 @@ class ContextModule extends Module {
this.resolveDependencies = undefined;
}

prettyRegExp(regexString) {
// remove the "/" at the front and the beginning
// "/foo/" -> "foo"
return regexString
.substring(1, regexString.length - 1)
.replace(/!/g, "%21");
_prettyRegExp(regexString, stripSlash = true) {
const str = (regexString + "").replace(/!/g, "%21").replace(/\|/g, "%7C");
return stripSlash ? str.substring(1, str.length - 1) : str;
}

_createIdentifier() {
Expand All @@ -175,13 +172,19 @@ class ContextModule extends Module {
identifier += `|${this.options.addon}`;
}
if (this.options.regExp) {
identifier += `|${this.options.regExp}`;
identifier += `|${this._prettyRegExp(this.options.regExp, false)}`;
}
if (this.options.include) {
identifier += `|include: ${this.options.include}`;
identifier += `|include: ${this._prettyRegExp(
this.options.include,
false
)}`;
}
if (this.options.exclude) {
identifier += `|exclude: ${this.options.exclude}`;
identifier += `|exclude: ${this._prettyRegExp(
this.options.exclude,
false
)}`;
}
if (this.options.referencedExports) {
identifier += `|referencedExports: ${JSON.stringify(
Expand Down Expand Up @@ -231,13 +234,13 @@ class ContextModule extends Module {
identifier += ` ${requestShortener.shorten(this.options.addon)}`;
}
if (this.options.regExp) {
identifier += ` ${this.prettyRegExp(this.options.regExp + "")}`;
identifier += ` ${this._prettyRegExp(this.options.regExp)}`;
}
if (this.options.include) {
identifier += ` include: ${this.prettyRegExp(this.options.include + "")}`;
identifier += ` include: ${this._prettyRegExp(this.options.include)}`;
}
if (this.options.exclude) {
identifier += ` exclude: ${this.prettyRegExp(this.options.exclude + "")}`;
identifier += ` exclude: ${this._prettyRegExp(this.options.exclude)}`;
}
if (this.options.referencedExports) {
identifier += ` referencedExports: ${this.options.referencedExports
Expand Down Expand Up @@ -272,6 +275,7 @@ class ContextModule extends Module {
this.context,
options.associatedObjectForCache
);
if (this.layer) identifier = `(${this.layer})/${identifier}`;
if (this.options.mode) {
identifier += ` ${this.options.mode}`;
}
Expand All @@ -286,13 +290,13 @@ class ContextModule extends Module {
)}`;
}
if (this.options.regExp) {
identifier += ` ${this.prettyRegExp(this.options.regExp + "")}`;
identifier += ` ${this._prettyRegExp(this.options.regExp)}`;
}
if (this.options.include) {
identifier += ` include: ${this.prettyRegExp(this.options.include + "")}`;
identifier += ` include: ${this._prettyRegExp(this.options.include)}`;
}
if (this.options.exclude) {
identifier += ` exclude: ${this.prettyRegExp(this.options.exclude + "")}`;
identifier += ` exclude: ${this._prettyRegExp(this.options.exclude)}`;
}
if (this.options.referencedExports) {
identifier += ` referencedExports: ${this.options.referencedExports
Expand All @@ -312,7 +316,7 @@ class ContextModule extends Module {

/**
* @param {NeedBuildContext} context context info
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild({ fileSystemInfo }, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/DelegatedModule.js
Expand Up @@ -91,7 +91,7 @@ class DelegatedModule extends Module {

/**
* @param {NeedBuildContext} context context info
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/DependencyTemplates.js
Expand Up @@ -57,7 +57,7 @@ class DependencyTemplates {
}

clone() {
const newInstance = new DependencyTemplates();
const newInstance = new DependencyTemplates(this._hashFunction);
newInstance._map = new Map(this._map);
newInstance._hash = this._hash;
return newInstance;
Expand Down
2 changes: 1 addition & 1 deletion lib/DllModule.js
Expand Up @@ -96,7 +96,7 @@ class DllModule extends Module {

/**
* @param {NeedBuildContext} context context info
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ExternalModule.js
Expand Up @@ -432,7 +432,7 @@ class ExternalModule extends Module {

/**
* @param {NeedBuildContext} context context info
* @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
* @returns {void}
*/
needBuild(context, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ExternalModuleFactoryPlugin.js
Expand Up @@ -117,7 +117,7 @@ class ExternalModuleFactoryPlugin {

/**
* @param {Externals} externals externals config
* @param {function(Error=, ExternalModule=): void} callback callback
* @param {function((Error | null)=, ExternalModule=): void} callback callback
* @returns {void}
*/
const handleExternals = (externals, callback) => {
Expand Down

0 comments on commit 74dcdee

Please sign in to comment.