allow to configure all hash functions used

fix default hash function for HttpUriPlugin to sha512
This commit is contained in:
Tobias Koppers 2021-09-22 12:12:46 +02:00
parent 69777d58f7
commit 4a8bf4c084
106 changed files with 674 additions and 174 deletions

View File

@ -4,6 +4,11 @@
* Run `yarn special-lint-fix` to update
*/
/**
* Algorithm used for generation the hash (see node.js crypto package).
*/
export type HashFunction = string | typeof import("../../lib/util/Hash");
export interface HashedModuleIdsPluginOptions {
/**
* The context directory for creating names.
@ -20,5 +25,5 @@ export interface HashedModuleIdsPluginOptions {
/**
* The hashing algorithm to use, defaults to 'md4'. All functions from Node.JS' crypto.createHash are supported.
*/
hashFunction?: string;
hashFunction?: HashFunction;
}

View File

@ -30,28 +30,14 @@ module.exports = {
## Unoptimized
```
asset output.js 61.9 KiB [emitted] (name: main)
asset output.js 82.6 KiB [emitted] (name: main)
runtime modules 670 bytes 3 modules
modules by path https:// 21.9 KiB
modules by path https://jspm.dev/ 8.43 KiB
modules by path https:// 30 KiB
modules by path https://jspm.dev/ 16.1 KiB
modules by path https://jspm.dev/*.0 6.04 KiB 5 modules
modules by path https://jspm.dev/npm:@jspm/ 1.99 KiB
https://jspm.dev/npm:@jspm/core@2/nodelibs/os 126 bytes [built] [code generated]
[exports: EOL, arch, cpus, default, endianness, freemem, getNetworkInterfaces, homedir, hostname, loadavg, networkInterfaces, platform, release, tmpDir, tmpdir, totalmem, type, uptime]
[used exports unknown]
harmony side effect evaluation /npm:@jspm/core@2/nodelibs/os https://jspm.dev/npm:clean-stack@4 1:0-39
harmony side effect evaluation ./npm:@jspm/core@2/nodelibs/os https://jspm.dev/npm:clean-stack@4.1.0 1:0-48
harmony import specifier ./npm:@jspm/core@2/nodelibs/os https://jspm.dev/npm:clean-stack@4.1.0 6:23-33
harmony import specifier ./npm:@jspm/core@2/nodelibs/os https://jspm.dev/npm:clean-stack@4.1.0 6:57-67
https://jspm.dev/npm:@jspm/core@2.0.0-beta.8/nodelibs/os 1.87 KiB [built] [code generated]
[exports: EOL, arch, cpus, default, endianness, freemem, getNetworkInterfaces, homedir, hostname, loadavg, networkInterfaces, platform, release, tmpDir, tmpdir, totalmem, type, uptime]
[used exports unknown]
harmony side effect evaluation /npm:@jspm/core@2.0.0-beta.8/nodelibs/os https://jspm.dev/npm:@jspm/core@2/nodelibs/os 1:0-57
harmony export imported specifier /npm:@jspm/core@2.0.0-beta.8/nodelibs/os https://jspm.dev/npm:@jspm/core@2/nodelibs/os 1:0-57
harmony side effect evaluation /npm:@jspm/core@2.0.0-beta.8/nodelibs/os https://jspm.dev/npm:@jspm/core@2/nodelibs/os 2:0-67
harmony export imported specifier /npm:@jspm/core@2.0.0-beta.8/nodelibs/os https://jspm.dev/npm:@jspm/core@2/nodelibs/os 2:0-67
modules by path https://jspm.dev/npm:@jspm/ 9.67 KiB 3 modules
4 modules
modules by path https://cdn.esm.sh/ 5.72 KiB 7 modules
modules by path https://cdn.esm.sh/ 6.15 KiB 7 modules
modules by path https://cdn.skypack.dev/ 7.46 KiB 6 modules
https://unpkg.com/p-map-series?module 263 bytes [built] [code generated]
[exports: default]
@ -62,17 +48,17 @@ modules by path https:// 21.9 KiB
[no exports]
[used exports unknown]
entry ./example.js main
webpack 5.51.1 compiled successfully
webpack 5.53.0 compiled successfully
```
## Production mode
```
asset output.js 11.4 KiB [emitted] [minimized] (name: main)
orphan modules 21.9 KiB [orphan] 25 modules
./example.js + 24 modules 22.1 KiB [built] [code generated]
asset output.js 12.5 KiB [emitted] [minimized] (name: main)
orphan modules 30 KiB [orphan] 26 modules
./example.js + 25 modules 30.2 KiB [built] [code generated]
[no exports]
[no exports used]
entry ./example.js main
webpack 5.51.1 compiled successfully
webpack 5.53.0 compiled successfully
```

View File

@ -1,19 +1,20 @@
{
"https://cdn.esm.sh/p-map": { "integrity": "sha512-Q1RsGrT9Fl5eqmmFQbaCy4PcXRx90TZQCcHDWC6sN0vfEnco9o66mi1DNjaWD2HE40qn0cNTWoZ21RIH+jmeiQ==", "contentType": "application/javascript; charset=utf-8" },
"https://cdn.esm.sh/v43/aggregate-error@4.0.0/es2015/aggregate-error.js": { "integrity": "sha512-nnqEIbQNpkAb5idk+07Wbc8lNzPloQrPAs+SOjccU+va8qftYFcn0htGVwUqwvkWJHZaJn9/B5bXB2YZVzwvUg==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v43/clean-stack@4.1.0/es2015/clean-stack.js": { "integrity": "sha512-B6h1ZeTzVvZeNUbWJUvEIBPaTvyUnbNEaO+V0aREh7nR1OrFUON/xnG+jwJwEzLWACqQNKFeFiPBOlFowUZ5FQ==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v43/escape-string-regexp@5.0.0/es2015/escape-string-regexp.js": { "integrity": "sha512-e6uaGCpjIjNgUN5K6nm+BQ3HrIKj59Z/ySJDt86eOM1j7ri1PFvpRFq7JwyjGZ0mhNq/j4ywqNmmk7HEji1Chg==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v43/indent-string@5.0.0/es2015/indent-string.js": { "integrity": "sha512-yNbq6+IcXe6jW+HIM/dCPxvi1+NJRxo5msNe0Vdg4NqVVUV4DF8U2eJPehmKT0Xhv1viyaTiReidhB1BmE1f/A==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v43/os-browserify@0.3.0/es2015/browser.js": { "integrity": "sha512-/BeiBawWpXZlWTjmXwtmrZbBeYgD0BqB9LE3EDf4yxBYqASwZ7Xj2dYNruM3/WMbJYyjP/TSRdwuKMsNLWdZbw==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v43/p-map@5.1.0/es2015/p-map.js": { "integrity": "sha512-DLSkffQJHasMXlosBDDFEIn7zgcLUW5KrTHy5/3IFsrmQO+9zlYjlWQbDJEShfvDzFEhXJc9D4ppP6zykBK/ZA==", "contentType": "application/javascript" },
"https://cdn.esm.sh/p-map": { "integrity": "sha512-TfztRxlC5elIRa7x3oz4bfhtxJr5hIhoa+bliQkroNj8haEMPp1mv/eAsfzBt032G1oK6JT6y3135FP0vRh13Q==", "contentType": "application/javascript; charset=utf-8" },
"https://cdn.esm.sh/v53/aggregate-error@4.0.0/es2015/aggregate-error.js": { "integrity": "sha512-4iHvwySJO0Dn0aenl2XY1XCGEoMZFaJ+PkuO8Op0BRVNwHiZaKrCuMnPZqUblPhvAG2o8SEA4JdB/fhS3IQZLg==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v53/clean-stack@4.1.0/es2015/clean-stack.js": { "integrity": "sha512-VzcwF50IxKsmW4O2DpY8WB6TmYh9caBctTqA2EkE3p9K8JjITMD/qBNqfVmUKAlmq4CFgI3c0xegzMf1BRWbyQ==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v53/escape-string-regexp@5.0.0/es2015/escape-string-regexp.js": { "integrity": "sha512-vst7rz+jFlvZMjo5GUzNBSq7QvFoaqOQ+hDq0m40ZJYGts6ptt+QKLZOMDWgoEq3Fabnhiy+hsoIfaHMmVdbSQ==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v53/indent-string@5.0.0/es2015/indent-string.js": { "integrity": "sha512-o1hDF1EyRTCiDpcxD2i0XpIuHCMFrc9XkKrkMISIaiWpJdKU7HBRhtqXfBcpVfJF1uNAFJ7/1v40vpPH2r7X8w==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v53/os-browserify@0.3.0/es2015/browser.js": { "integrity": "sha512-8JOZWkDGX6WNFtXIk/aOawVo35LZSIgCdbMrleK4QL8kHcYti2oTjfqfn99AJm6SOUsTt0uY5K808uHAvVe3eA==", "contentType": "application/javascript" },
"https://cdn.esm.sh/v53/p-map@5.1.0/es2015/p-map.js": { "integrity": "sha512-3kEIICBOLKnEn6SNNixOBy+VGgwh0DYtn07yxHfagwiSJV8om7q/37RdHVbQ2pol8B/6oVMHo7Y6YYhmpYKDUA==", "contentType": "application/javascript" },
"https://cdn.skypack.dev/-/aggregate-error@v4.0.0-rCH8s5R9g4kQQ807o58j/dist=es2020,mode=imports/optimized/aggregate-error.js": { "integrity": "sha512-E5rN3mgPTqyfHSovQ++ZyZWQkMUniuyjbeHHX+E4G3MStEx6TfObScB8tfHeIyuawSp86nVsFfMZjCruD61rdg==", "contentType": "application/javascript; charset=utf-8" },
"https://cdn.skypack.dev/-/clean-stack@v4.1.0-DgWUKXHVzThBBZtsHXhC/dist=es2020,mode=imports/optimized/clean-stack.js": { "integrity": "sha512-1nEMT4Vc2YLu3EbeBnck7Traj0/D6G9MMSGraGpsoQIMKVuhQjq4gP76X6RxUn5GoiHv90KfrFMSWlbBn26Dhw==", "contentType": "application/javascript; charset=utf-8" },
"https://cdn.skypack.dev/-/escape-string-regexp@v5.0.0-SUDdAhYOdAgXIYndxZss/dist=es2020,mode=imports/optimized/escape-string-regexp.js": { "integrity": "sha512-54oHYow5obgsKb0twQZMNLvCH2tV5MCOY4YHB0LQH+zVonIAn7JYZseUPWhC3MMkJFK5EkeNWDAX7P2camp27g==", "contentType": "application/javascript; charset=utf-8" },
"https://cdn.skypack.dev/-/indent-string@v5.0.0-VgKPSgi4hUX5NbF4n3aC/dist=es2020,mode=imports/optimized/indent-string.js": { "integrity": "sha512-lSZAs06jEHkVlPMEeMtKbygGhrSmJUMVmpB6/2ChdG2F0694vRU1v6N12bUyqR5uGbbteTJ7atP5PmPtTVmlcw==", "contentType": "application/javascript; charset=utf-8" },
"https://cdn.skypack.dev/-/p-map@v5.1.0-7ixXvZxXPKKt9unR9LT0/dist=es2020,mode=imports/optimized/p-map.js": { "integrity": "sha512-mZyhNJe8VlqEqafSkUGTooFrKcQPSwVjB3UxAAPqywSFD+age77uTRP6ul8uAMEQ3lllmengXX1q45igRxRcDw==", "contentType": "application/javascript; charset=utf-8" },
"https://cdn.skypack.dev/p-map": { "integrity": "sha512-FFu6R9j8mrGqTvw8WL37XsWhI9P65XdPD9Jfs/47jiYNdex12f0XJNsIy+fI81PbOkCuEQRgm2nf0P76ieBlag==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:@jspm/core@2.0.0-beta.8/nodelibs/os": { "integrity": "sha512-bNMLa9/IfXCZprEMIuXuHM/9s4OFAl4ZKy8r6EdXNkduLNLHQ626srFqLRdWHx6ZWGIgppc1bI9+tRJT3FzfAw==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:@jspm/core@2/nodelibs/os": { "integrity": "sha512-rPwqsk0nq0tqTCdbeGoopnlzAVh5BsaVUsXoFKQCcb04LWJrXmOhQEwj1Yj/WHfNj2ZIPzODlZdKtWZl5bbIpA==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:@jspm/core@2.0.0-beta.11/nodelibs/os": { "integrity": "sha512-Jsg9UMzfNTnlPDu6FeftYzdp6XULJwLDI7xFSzULhMqjQUoOIHJhkAToEgr3NnEKCkLZQMIPuBvHAn0ud6gT+w==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:@jspm/core@2.0.0-beta.11/nodelibs/process": { "integrity": "sha512-KIYEmkrnT7TL5EKA5coPbbdoqfL2twHFBVXKTZS+PU5aZFX90yELxZHrm4DhxSQ33FLAWo51/nQLQmqGekWNMw==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:@jspm/core@2/nodelibs/os": { "integrity": "sha512-g2ppEW1AVdbIpc486D0ZmLIR5CtzMITkBwqoBgxvhiIq5/qHP4/unZ7Czk3q8A1UwdTI4wbGzRWndXAUa4/Q0Q==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:aggregate-error@4": { "integrity": "sha512-XfXd6EZ09/SKLmWFFvjPCSkqv0E08IxKc8mFm9mePyLIiEiGyAKokeFt1wql+kG8ikGmI7YqKBsDf07/I31VvA==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:aggregate-error@4.0.0": { "integrity": "sha512-HEobsVYXVCp5H4Z+6qAlKno8XAJwHQrfF4ivR4PHrp4ttM0Yg0zDfOcsjqJOnTP5hEnKR1K6OzQdPfR2r9of4g==", "contentType": "application/javascript; charset=utf-8" },
"https://jspm.dev/npm:clean-stack@4": { "integrity": "sha512-3wh/QTJY4tw/GInIcn5I+0hsHSirJi8Tf3kmH85hzQsuwB5k2lghBFZyKZPO7/Ql3muvZeDgN02pYkZap59Qrw==", "contentType": "application/javascript; charset=utf-8" },

View File

@ -1,3 +0,0 @@
/* esm.sh - p-map@5.1.0 */
export * from "https://cdn.esm.sh/v43/p-map@5.1.0/es2015/p-map.js";
export { default } from "https://cdn.esm.sh/v43/p-map@5.1.0/es2015/p-map.js";

View File

@ -0,0 +1,3 @@
/* esm.sh - p-map@5.1.0 */
export * from "https://cdn.esm.sh/v53/p-map@5.1.0/es2015/p-map.js";
export { default } from "https://cdn.esm.sh/v53/p-map@5.1.0/es2015/p-map.js";

View File

@ -1,3 +0,0 @@
var f=Object.defineProperty;var l=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var i=(e,t,n)=>(l(e,typeof t!="symbol"?t+"":t,n),n),g=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var c=(e,t,n)=>(g(e,t,"read from private field"),n?n.call(e):t.get(e)),o=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},p=(e,t,n,a)=>(g(e,t,"write to private field"),a?a.call(e,n):t.set(e,n),n);import u from"/v43/indent-string@5.0.0/es2015/indent-string.js";import m from"/v43/clean-stack@4.1.0/es2015/clean-stack.js";var d=e=>e.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""),r,s=class extends Error{constructor(t){o(this,r,void 0);i(this,"name","AggregateError");if(!Array.isArray(t))throw new TypeError(`Expected input to be an Array, got ${typeof t}`);t=t.map(a=>a instanceof Error?a:a!==null&&typeof a=="object"?Object.assign(new Error(a.message),a):new Error(a));let n=t.map(a=>typeof a.stack=="string"?d(m(a.stack)):String(a)).join(`
`);n=`
`+u(n,4),super(n),p(this,r,t)}get errors(){return c(this,r).slice()}};r=new WeakMap;export{s as default};

View File

@ -1,3 +0,0 @@
import s from"/v43/os-browserify@0.3.0/es2015/browser.js";import i from"/v43/escape-string-regexp@5.0.0/es2015/escape-string-regexp.js";var p=/\s+at.*[(\s](.*)\)?/,f=/^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/,u=typeof s.homedir=="undefined"?"":s.homedir().replace(/\\/g,"/");function c(a,{pretty:l=!1,basePath:n}={}){let o=n&&new RegExp(`(at | \\()${i(n.replace(/\\/g,"/"))}`,"g");if(typeof a=="string")return a.replace(/\\/g,"/").split(`
`).filter(e=>{let r=e.match(p);if(r===null||!r[1])return!0;let t=r[1];return t.includes(".app/Contents/Resources/electron.asar")||t.includes(".app/Contents/Resources/default_app.asar")?!1:!f.test(t)}).filter(e=>e.trim()!=="").map(e=>(o&&(e=e.replace(o,"$1")),l&&(e=e.replace(p,(r,t)=>r.replace(t,t.replace(u,"~")))),e)).join(`
`)}export{c as default};

View File

@ -1 +0,0 @@
var m=(p,s,e)=>new Promise((f,x)=>{var h=t=>{try{o(e.next(t))}catch(r){x(r)}},l=t=>{try{o(e.throw(t))}catch(r){x(r)}},o=t=>t.done?f(t.value):Promise.resolve(t.value).then(h,l);o((e=e.apply(p,s)).next())});import S from"/v43/aggregate-error@4.0.0/es2015/aggregate-error.js";function N(x,h){return m(this,arguments,function*(p,s,{concurrency:e=Number.POSITIVE_INFINITY,stopOnError:f=!0}={}){return new Promise((l,o)=>{if(typeof s!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(e)||e===Number.POSITIVE_INFINITY)&&e>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${e}\` (${typeof e})`);let t=[],r=[],g=[],y=p[Symbol.iterator](),u=!1,c=!1,a=0,b=0,I=()=>{if(u)return;let i=y.next(),d=b;if(b++,i.done){if(c=!0,a===0)if(!f&&r.length>0)o(new S(r));else{for(let n of g)t.splice(n,1);l(t)}return}a++,(()=>m(this,null,function*(){try{let n=yield i.value;if(u)return;let w=yield s(n,d);w===T?g.push(d):t[d]=w,a--,I()}catch(n){f?(u=!0,o(n)):(r.push(n),a--,I())}}))()};for(let i=0;i<e&&(I(),!c);i++);})})}var T=Symbol("skip");export{N as default};

View File

@ -0,0 +1,4 @@
/* esm.sh - esbuild bundle(aggregate-error@4.0.0) es2015 production */
var l=Object.defineProperty;var f=(n,t,e)=>t in n?l(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var s=(n,t,e)=>(f(n,typeof t!="symbol"?t+"":t,e),e),i=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)};var c=(n,t,e)=>(i(n,t,"read from private field"),e?e.call(n):t.get(n)),g=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},o=(n,t,e,a)=>(i(n,t,"write to private field"),a?a.call(n,e):t.set(n,e),e);import u from"/v53/indent-string@5.0.0/es2015/indent-string.js";import m from"/v53/clean-stack@4.1.0/es2015/clean-stack.js";var d=n=>n.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""),r,p=class extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError(`Expected input to be an Array, got ${typeof t}`);t=t.map(a=>a instanceof Error?a:a!==null&&typeof a=="object"?Object.assign(new Error(a.message),a):new Error(a));let e=t.map(a=>typeof a.stack=="string"?d(m(a.stack)):String(a)).join(`
`);e=`
`+u(e,4);super(e);g(this,r,void 0);s(this,"name","AggregateError");o(this,r,t)}get errors(){return c(this,r).slice()}};r=new WeakMap;export{p as default};

View File

@ -0,0 +1,4 @@
/* esm.sh - esbuild bundle(clean-stack@4.1.0) es2015 production */
import s from"/v53/os-browserify@0.3.0/es2015/browser.js";import i from"/v53/escape-string-regexp@5.0.0/es2015/escape-string-regexp.js";var p=/\s+at.*[(\s](.*)\)?/,l=/^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/,f=typeof s.homedir=="undefined"?"":s.homedir().replace(/\\/g,"/");function u(n,{pretty:c=!1,basePath:a}={}){let o=a&&new RegExp(`(at | \\()${i(a.replace(/\\/g,"/"))}`,"g");if(typeof n=="string")return n.replace(/\\/g,"/").split(`
`).filter(e=>{let r=e.match(p);if(r===null||!r[1])return!0;let t=r[1];return t.includes(".app/Contents/Resources/electron.asar")||t.includes(".app/Contents/Resources/default_app.asar")?!1:!l.test(t)}).filter(e=>e.trim()!=="").map(e=>(o&&(e=e.replace(o,"$1")),c&&(e=e.replace(p,(r,t)=>r.replace(t,t.replace(f,"~")))),e)).join(`
`)}export{u as default};

View File

@ -1 +1,2 @@
function r(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}export{r as default};
/* esm.sh - esbuild bundle(escape-string-regexp@5.0.0) es2015 production */
function r(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}export{r as default};

View File

@ -1 +1,2 @@
function o(t,e=1,n={}){let{indent:r=" ",includeEmptyLines:p=!1}=n;if(typeof t!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(e<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${e}\``);if(typeof r!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r}\``);if(e===0)return t;let i=p?/^/gm:/^(?!\s*$)/gm;return t.replace(i,r.repeat(e))}export{o as default};
/* esm.sh - esbuild bundle(indent-string@5.0.0) es2015 production */
function i(t,e=1,o={}){let{indent:r=" ",includeEmptyLines:n=!1}=o;if(typeof t!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(e<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${e}\``);if(typeof r!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r}\``);if(e===0)return t;let p=n?/^/gm:/^(?!\s*$)/gm;return t.replace(p,r.repeat(e))}export{i as default};

View File

@ -1,2 +1,3 @@
/* esm.sh - esbuild bundle(os-browserify@0.3.0/browser) es2015 production */
var f=Object.create;var o=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var d=e=>o(e,"__esModule",{value:!0});var l=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var w=(e,t,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!p.call(e,n)&&n!=="default"&&o(e,n,{get:()=>t[n],enumerable:!(i=s(t,n))||i.enumerable});return e},a=e=>w(d(o(e!=null?f(c(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var u=l(r=>{r.endianness=function(){return"LE"};r.hostname=function(){return typeof location!="undefined"?location.hostname:""};r.loadavg=function(){return[]};r.uptime=function(){return 0};r.freemem=function(){return Number.MAX_VALUE};r.totalmem=function(){return Number.MAX_VALUE};r.cpus=function(){return[]};r.type=function(){return"Browser"};r.release=function(){return typeof navigator!="undefined"?navigator.appVersion:""};r.networkInterfaces=r.getNetworkInterfaces=function(){return{}};r.arch=function(){return"javascript"};r.platform=function(){return"browser"};r.tmpdir=r.tmpDir=function(){return"/tmp"};r.EOL=`
`;r.homedir=function(){return"/"}});var b=a(u()),h=a(u()),{cpus:v,release:E,tmpDir:L,loadavg:k,uptime:A,totalmem:I,arch:N,tmpdir:_,homedir:V,endianness:x,hostname:D,type:M,freemem:O,networkInterfaces:U,getNetworkInterfaces:X,platform:j,EOL:B}=b;var export_default=h.default;export{B as EOL,N as arch,v as cpus,export_default as default,x as endianness,O as freemem,X as getNetworkInterfaces,V as homedir,D as hostname,k as loadavg,U as networkInterfaces,j as platform,E as release,L as tmpDir,_ as tmpdir,I as totalmem,M as type,A as uptime};
`;r.homedir=function(){return"/"}});var b=a(u()),h=a(u()),{endianness:v,hostname:E,loadavg:L,uptime:k,freemem:A,totalmem:I,cpus:N,type:_,release:V,networkInterfaces:x,getNetworkInterfaces:D,arch:M,platform:O,tmpdir:U,tmpDir:X,EOL:j,homedir:B}=b;var export_default=h.default;export{j as EOL,M as arch,N as cpus,export_default as default,v as endianness,A as freemem,D as getNetworkInterfaces,B as homedir,E as hostname,L as loadavg,x as networkInterfaces,O as platform,V as release,X as tmpDir,U as tmpdir,I as totalmem,_ as type,k as uptime};

View File

@ -0,0 +1,2 @@
/* esm.sh - esbuild bundle(p-map@5.1.0) es2015 production */
var g=(l,s,e)=>new Promise((f,x)=>{var N=t=>{try{n(e.next(t))}catch(r){x(r)}},p=t=>{try{n(e.throw(t))}catch(r){x(r)}},n=t=>t.done?f(t.value):Promise.resolve(t.value).then(N,p);n((e=e.apply(l,s)).next())});import y from"/v53/aggregate-error@4.0.0/es2015/aggregate-error.js";function S(x,N){return g(this,arguments,function*(l,s,{concurrency:e=Number.POSITIVE_INFINITY,stopOnError:f=!0}={}){return new Promise((p,n)=>{if(typeof s!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(e)||e===Number.POSITIVE_INFINITY)&&e>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${e}\` (${typeof e})`);let t=[],r=[],m=[],h=l[Symbol.iterator](),u=!1,c=!1,a=0,b=0,I=()=>{if(u)return;let i=h.next(),d=b;if(b++,i.done){if(c=!0,a===0)if(!f&&r.length>0)n(new y(r));else{for(let o of m)t.splice(o,1);p(t)}return}a++,(()=>g(this,null,function*(){try{let o=yield i.value;if(u)return;let w=yield s(o,d);w===T?m.push(d):t[d]=w,a--,I()}catch(o){f?(u=!0,n(o)):(r.push(o),a--,I())}}))()};for(let i=0;i<e&&(I(),!c);i++);})})}var T=Symbol("skip");export{S as default,T as pMapSkip};

View File

@ -0,0 +1,277 @@
function unimplemented(name) {
throw new Error('Node.js process ' + name + ' is not supported by JSPM core outside of Node.js');
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue)
return;
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
}
else {
queueIndex = -1;
}
if (queue.length)
drainQueue();
}
function drainQueue() {
if (draining)
return;
var timeout = setTimeout(cleanUpNextTick, 0);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue)
currentQueue[queueIndex].run();
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
clearTimeout(timeout);
}
function nextTick (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++)
args[i - 1] = arguments[i];
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining)
setTimeout(drainQueue, 0);
}
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
var title = 'browser';
var arch = 'x64';
var platform = 'browser';
var env = {
PATH: '/usr/bin',
LANG: navigator.language + '.UTF-8',
PWD: '/',
HOME: '/home',
TMP: '/tmp',
};
var argv = ['/usr/bin/node'];
var execArgv = [];
var version = 'v16.8.0';
var versions = { node: '16.8.0' };
var emitWarning = function(message, type) {
console.warn((type ? (type + ': ') : '') + message);
};
var binding = function(name) { unimplemented('binding'); };
var umask = function(mask) { return 0; };
var cwd = function() { return '/'; };
var chdir = function(dir) {};
var release = {
name: 'node',
sourceUrl: '',
headersUrl: '',
libUrl: '',
};
function noop() {}
var _rawDebug = noop;
var moduleLoadList = [];
function _linkedBinding(name) { unimplemented('_linkedBinding'); }
var domain = {};
var _exiting = false;
var config = {};
function dlopen(name) { unimplemented('dlopen'); }
function _getActiveRequests() { return []; }
function _getActiveHandles() { return []; }
var reallyExit = noop;
var _kill = noop;
var cpuUsage = function() { return {}; };
var resourceUsage = cpuUsage;
var memoryUsage = cpuUsage;
var kill = noop;
var exit = noop;
var openStdin = noop;
var allowedNodeEnvironmentFlags = {};
function assert(condition, message) {
if (!condition) throw new Error(message || 'assertion error');
}
var features = {
inspector: false,
debug: false,
uv: false,
ipv6: false,
tls_alpn: false,
tls_sni: false,
tls_ocsp: false,
tls: false,
cached_builtins: true,
};
var _fatalExceptions = noop;
var setUncaughtExceptionCaptureCallback = noop;
function hasUncaughtExceptionCaptureCallback() { return false; }var _tickCallback = noop;
var _debugProcess = noop;
var _debugEnd = noop;
var _startProfilerIdleNotifier = noop;
var _stopProfilerIdleNotifier = noop;
var stdout = undefined;
var stderr = undefined;
var stdin = undefined;
var abort = noop;
var pid = 2;
var ppid = 1;
var execPath = '/bin/usr/node';
var debugPort = 9229;
var argv0 = 'node';
var _preload_modules = [];
var setSourceMapsEnabled = noop;
var _performance = {
now: typeof performance !== 'undefined' ? performance.now.bind(performance) : undefined,
timing: typeof performance !== 'undefined' ? performance.timing : undefined,
};
if (_performance.now === undefined) {
var nowOffset = Date.now();
if (_performance.timing && _performance.timing.navigationStart) {
nowOffset = _performance.timing.navigationStart;
}
_performance.now = () => Date.now() - nowOffset;
}
function uptime() {
return _performance.now() / 1000;
}
var nanoPerSec = 1000000000;
function hrtime(previousTimestamp) {
var baseNow = Math.floor((Date.now() - _performance.now()) * 1e-3);
var clocktime = _performance.now() * 1e-3;
var seconds = Math.floor(clocktime) + baseNow;
var nanoseconds = Math.floor((clocktime % 1) * 1e9);
if (previousTimestamp) {
seconds = seconds - previousTimestamp[0];
nanoseconds = nanoseconds - previousTimestamp[1];
if (nanoseconds < 0) {
seconds--;
nanoseconds += nanoPerSec;
}
}
return [seconds, nanoseconds];
}hrtime.bigint = function(time) {
var diff = hrtime(time);
if (typeof BigInt === 'undefined') {
return diff[0] * nanoPerSec + diff[1];
}
return BigInt(diff[0] * nanoPerSec) + BigInt(diff[1]);
};
var _maxListeners = 10;
var _events = {};
var _eventsCount = 0;
function on () { return process }var addListener = on;
var once = on;
var off = on;
var removeListener = on;
var removeAllListeners = on;
var emit = noop;
var prependListener = on;
var prependOnceListener = on;
function listeners (name) { return []; }
var process = {
version,
versions,
arch,
platform,
release,
_rawDebug,
moduleLoadList,
binding,
_linkedBinding,
_events,
_eventsCount,
_maxListeners,
on,
addListener,
once,
off,
removeListener,
removeAllListeners,
emit,
prependListener,
prependOnceListener,
listeners,
domain,
_exiting,
config,
dlopen,
uptime,
_getActiveRequests,
_getActiveHandles,
reallyExit,
_kill,
cpuUsage,
resourceUsage,
memoryUsage,
kill,
exit,
openStdin,
allowedNodeEnvironmentFlags,
assert,
features,
_fatalExceptions,
setUncaughtExceptionCaptureCallback,
hasUncaughtExceptionCaptureCallback,
emitWarning,
nextTick,
_tickCallback,
_debugProcess,
_debugEnd,
_startProfilerIdleNotifier,
_stopProfilerIdleNotifier,
stdout,
stdin,
stderr,
abort,
umask,
chdir,
cwd,
env,
title,
argv,
execArgv,
pid,
ppid,
execPath,
debugPort,
hrtime,
argv0,
_preload_modules,
setSourceMapsEnabled,
};
export { _debugEnd, _debugProcess, _events, _eventsCount, _exiting, _fatalExceptions, _getActiveHandles, _getActiveRequests, _kill, _linkedBinding, _maxListeners, _preload_modules, _rawDebug, _startProfilerIdleNotifier, _stopProfilerIdleNotifier, _tickCallback, abort, addListener, allowedNodeEnvironmentFlags, arch, argv, argv0, assert, binding, chdir, config, cpuUsage, cwd, debugPort, process as default, dlopen, domain, emit, emitWarning, env, execArgv, execPath, exit, features, hasUncaughtExceptionCaptureCallback, hrtime, kill, listeners, memoryUsage, moduleLoadList, nextTick, off, on, once, openStdin, pid, platform, ppid, prependListener, prependOnceListener, reallyExit, release, removeAllListeners, removeListener, resourceUsage, setSourceMapsEnabled, setUncaughtExceptionCaptureCallback, stderr, stdin, stdout, title, umask, uptime, version, versions };
//# sourceMappingURL=process.map

View File

@ -1,3 +1,6 @@
import { uptime } from './process';
export { uptime } from './process';
var exports = {},
_dewExec = false;
function dew() {
@ -73,25 +76,38 @@ function dew() {
var os = dew();
var EOL = os.EOL;
var arch = os.arch;
var cpus = os.cpus;
var endianness = os.endianness;
var freemem = os.freemem;
var getNetworkInterfaces = os.getNetworkInterfaces;
var homedir = os.homedir;
var hostname = os.hostname;
var loadavg = os.loadavg;
var networkInterfaces = os.networkInterfaces;
var platform = os.platform;
var release = os.release;
var tmpDir = os.tmpDir;
var tmpdir = os.tmpdir;
var totalmem = os.totalmem;
var _endianness = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1 ? 'LE' : 'BE';
os.endianness = function() { return _endianness; };
os.homedir = function() { return '/home'; };
os.version = function() { return ''; };
os.arch = function() { return 'x64'; };
os.totalmem = function() {
return navigator.deviceMemory !== undefined ? navigator.deviceMemory * (1 << 30) : 2 * (1 << 30);
};
os.cpus = function () {
return Array(navigator.hardwareConcurrency || 0).fill({ model: '', times: {} });
};
os.uptime = uptime;
os.constants = {};
var version = os.version;
var constants = os.constants;
var EOL = os.EOL;
var arch = os.arch;
var cpus = os.cpus;
var endianness = os.endianness;
var freemem = os.freemem;
var getNetworkInterfaces = os.getNetworkInterfaces;
var homedir = os.homedir;
var hostname = os.hostname;
var loadavg = os.loadavg;
var networkInterfaces = os.networkInterfaces;
var platform = os.platform;
var release = os.release;
var tmpDir = os.tmpDir;
var tmpdir = os.tmpdir;
var totalmem = os.totalmem;
var type = os.type;
var uptime = os.uptime;
export default os;
export { EOL, arch, cpus, endianness, freemem, getNetworkInterfaces, homedir, hostname, loadavg, networkInterfaces, platform, release, tmpDir, tmpdir, totalmem, type, uptime };
export { EOL, arch, constants, cpus, os as default, endianness, freemem, getNetworkInterfaces, homedir, hostname, loadavg, networkInterfaces, platform, release, tmpDir, tmpdir, totalmem, type, version };
//# sourceMappingURL=os.map

View File

@ -0,0 +1,3 @@
import "/npm:@jspm/core@2.0.0-beta.11/nodelibs/process";
export * from "/npm:@jspm/core@2.0.0-beta.11/nodelibs/os";
export { default } from "/npm:@jspm/core@2.0.0-beta.11/nodelibs/os";

View File

@ -1,2 +0,0 @@
export * from "/npm:@jspm/core@2.0.0-beta.8/nodelibs/os";
export { default } from "/npm:@jspm/core@2.0.0-beta.8/nodelibs/os";

View File

@ -13,6 +13,7 @@ const mergeEtags = require("./cache/mergeEtags");
/** @typedef {import("./Cache").Etag} Etag */
/** @typedef {import("./WebpackError")} WebpackError */
/** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */
/** @typedef {typeof import("./util/Hash")} HashConstructor */
/**
* @template T
@ -198,10 +199,12 @@ class CacheFacade {
/**
* @param {Cache} cache the root cache
* @param {string} name the child cache name
* @param {string | HashConstructor} hashFunction the hash function to use
*/
constructor(cache, name) {
constructor(cache, name, hashFunction) {
this._cache = cache;
this._name = name;
this._hashFunction = hashFunction;
}
/**
@ -209,7 +212,11 @@ class CacheFacade {
* @returns {CacheFacade} child cache
*/
getChildCache(name) {
return new CacheFacade(this._cache, `${this._name}|${name}`);
return new CacheFacade(
this._cache,
`${this._name}|${name}`,
this._hashFunction
);
}
/**
@ -230,7 +237,7 @@ class CacheFacade {
* @returns {Etag} an etag that is lazy hashed
*/
getLazyHashedEtag(obj) {
return getLazyHashedEtag(obj);
return getLazyHashedEtag(obj, this._hashFunction);
}
/**

View File

@ -34,6 +34,7 @@ const {
/** @typedef {import("./Module")} Module */
/** @typedef {import("./ModuleGraph")} ModuleGraph */
/** @typedef {import("./RuntimeModule")} RuntimeModule */
/** @typedef {typeof import("./util/Hash")} Hash */
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
/** @type {ReadonlySet<string>} */
@ -217,8 +218,9 @@ class ChunkGraphChunk {
class ChunkGraph {
/**
* @param {ModuleGraph} moduleGraph the module graph
* @param {string | Hash} hashFunction the hash function to use
*/
constructor(moduleGraph) {
constructor(moduleGraph, hashFunction = "md4") {
/** @private @type {WeakMap<Module, ChunkGraphModule>} */
this._modules = new WeakMap();
/** @private @type {WeakMap<Chunk, ChunkGraphChunk>} */
@ -230,6 +232,8 @@ class ChunkGraph {
/** @type {ModuleGraph} */
this.moduleGraph = moduleGraph;
this._hashFunction = hashFunction;
this._getGraphRoots = this._getGraphRoots.bind(this);
// Caching
@ -1487,7 +1491,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
cgm.graphHashes = new RuntimeSpecMap();
}
const graphHash = cgm.graphHashes.provide(runtime, () => {
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
hash.update(`${cgm.id}`);
hash.update(`${this.moduleGraph.isAsync(module)}`);
this.moduleGraph.getExportsInfo(module).updateHash(hash, runtime);
@ -1575,7 +1579,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
connectedModules.size > 1
? Array.from(connectedModules).sort(([a], [b]) => (a < b ? -1 : 1))
: connectedModules;
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
const addModuleToHash = module => {
hash.update(
this._getModuleGraphHashBigInt(

View File

@ -13,12 +13,17 @@ const { runtimeToString, RuntimeSpecMap } = require("./util/runtime");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
/** @typedef {typeof import("./util/Hash")} Hash */
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
class CodeGenerationResults {
constructor() {
/**
* @param {string | Hash} hashFunction the hash function to use
*/
constructor(hashFunction = "md4") {
/** @type {Map<Module, RuntimeSpecMap<CodeGenerationResult>>} */
this.map = new Map();
this._hashFunction = hashFunction;
}
/**
@ -124,7 +129,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
getHash(module, runtime) {
const info = this.get(module, runtime);
if (info.hash !== undefined) return info.hash;
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
for (const [type, source] of info.sources) {
hash.update(type);
source.updateHash(hash);

View File

@ -852,7 +852,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this.fileSystemInfo = new FileSystemInfo(this.inputFileSystem, {
managedPaths: compiler.managedPaths,
immutablePaths: compiler.immutablePaths,
logger: this.getLogger("webpack.FileSystemInfo")
logger: this.getLogger("webpack.FileSystemInfo"),
hashFunction: compiler.options.output.hashFunction
});
if (compiler.fileTimestamps) {
this.fileSystemInfo.addFileTimestamps(compiler.fileTimestamps, true);
@ -2255,7 +2256,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this.addModuleQueue.clear();
return callback(err);
};
const chunkGraph = new ChunkGraph(this.moduleGraph);
const chunkGraph = new ChunkGraph(
this.moduleGraph,
this.outputOptions.hashFunction
);
this.chunkGraph = chunkGraph;
for (const module of this.modules) {
@ -2609,7 +2613,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
codeGeneration(callback) {
const { chunkGraph } = this;
this.codeGenerationResults = new CodeGenerationResults();
this.codeGenerationResults = new CodeGenerationResults(
this.outputOptions.hashFunction
);
/** @type {{module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}[]} */
const jobs = [];
for (const module of this.modules) {
@ -4071,7 +4077,10 @@ This prevents using hashes of each other and should be avoided.`);
if (err) return callback(err);
// Create new chunk graph, chunk and entrypoint for the build time execution
const chunkGraph = new ChunkGraph(this.moduleGraph);
const chunkGraph = new ChunkGraph(
this.moduleGraph,
this.outputOptions.hashFunction
);
const runtime = "build time";
const { hashFunction, hashDigest, hashDigestLength } =
this.outputOptions;
@ -4114,7 +4123,9 @@ This prevents using hashes of each other and should be avoided.`);
);
}
const codeGenerationResults = new CodeGenerationResults();
const codeGenerationResults = new CodeGenerationResults(
this.outputOptions.hashFunction
);
/** @type {WebpackError[]} */
const errors = [];
/**

View File

@ -276,7 +276,11 @@ class Compiler {
* @returns {CacheFacade} the cache facade instance
*/
getCache(name) {
return new CacheFacade(this.cache, `${this.compilerPath}${name}`);
return new CacheFacade(
this.cache,
`${this.compilerPath}${name}`,
this.options.output.hashFunction
);
}
/**

View File

@ -9,14 +9,20 @@ const createHash = require("./util/createHash");
/** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
/** @typedef {typeof import("./util/Hash")} Hash */
/** @typedef {new (...args: any[]) => Dependency} DependencyConstructor */
class DependencyTemplates {
constructor() {
/**
* @param {string | Hash} hashFunction the hash function to use
*/
constructor(hashFunction = "md4") {
/** @type {Map<Function, DependencyTemplate>} */
this._map = new Map();
/** @type {string} */
this._hash = "31d6cfe0d16ae931b73c59d7e0c089c0";
this._hashFunction = hashFunction;
}
/**
@ -41,7 +47,7 @@ class DependencyTemplates {
* @returns {void}
*/
updateHash(part) {
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
hash.update(this._hash);
hash.update(part);
this._hash = /** @type {string} */ (hash.digest("hex"));

View File

@ -61,7 +61,8 @@ class EvalDevToolModulePlugin {
},
{
requestShortener: runtimeTemplate.requestShortener,
chunkGraph
chunkGraph,
hashFunction: compilation.outputOptions.hashFunction
}
);
const footer =

View File

@ -138,7 +138,8 @@ class EvalSourceMapDevToolPlugin {
},
{
requestShortener: runtimeTemplate.requestShortener,
chunkGraph
chunkGraph,
hashFunction: compilation.outputOptions.hashFunction
}
);
});

View File

@ -38,6 +38,7 @@ const { register } = require("./util/serialization");
/** @typedef {import("./WebpackError")} WebpackError */
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
/** @typedef {import("./util/Hash")} Hash */
/** @typedef {typeof import("./util/Hash")} HashConstructor */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
@ -160,11 +161,16 @@ const getSourceForImportExternal = (moduleAndSpecifiers, runtimeTemplate) => {
};
class ModuleExternalInitFragment extends InitFragment {
constructor(request, ident) {
/**
* @param {string} request import source
* @param {string=} ident recomputed ident
* @param {string | HashConstructor=} hashFunction the hash function to use
*/
constructor(request, ident, hashFunction = "md4") {
if (ident === undefined) {
ident = Template.toIdentifier(request);
if (ident !== request) {
ident += `_${createHash("md4")
ident += `_${createHash(hashFunction)
.update(request)
.digest("hex")
.slice(0, 8)}`;
@ -230,21 +236,25 @@ const generateModuleRemapping = (input, exportsInfo, runtime) => {
};
/**
* @param {string|number} id the module id
* @param {string|string[]} moduleAndSpecifiers the module request
* @param {ExportsInfo} exportsInfo exports info of this module
* @param {RuntimeSpec} runtime the runtime
* @param {string | HashConstructor=} hashFunction the hash function to use
* @returns {SourceData} the generated source
*/
const getSourceForModuleExternal = (
id,
moduleAndSpecifiers,
exportsInfo,
runtime
runtime,
hashFunction
) => {
if (!Array.isArray(moduleAndSpecifiers))
moduleAndSpecifiers = [moduleAndSpecifiers];
const initFragment = new ModuleExternalInitFragment(moduleAndSpecifiers[0]);
const initFragment = new ModuleExternalInitFragment(
moduleAndSpecifiers[0],
undefined,
hashFunction
);
const baseAccess = `${initFragment.getNamespaceIdentifier()}${propertyAccess(
moduleAndSpecifiers,
1
@ -566,12 +576,11 @@ class ExternalModule extends Module {
"The target environment doesn't support EcmaScriptModule syntax so it's not possible to use external type 'module'"
);
}
const id = chunkGraph.getModuleId(this);
return getSourceForModuleExternal(
id !== null ? id : this.identifier(),
request,
moduleGraph.getExportsInfo(this),
runtime
runtime,
runtimeTemplate.outputOptions.hashFunction
);
}
case "var":

View File

@ -16,6 +16,7 @@ const processAsyncTree = require("./util/processAsyncTree");
/** @typedef {import("./WebpackError")} WebpackError */
/** @typedef {import("./logging/Logger").Logger} Logger */
/** @typedef {typeof import("./util/Hash")} Hash */
/** @typedef {import("./util/fs").IStats} IStats */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
@ -856,12 +857,22 @@ class FileSystemInfo {
* @param {Iterable<string>=} options.managedPaths paths that are only managed by a package manager
* @param {Iterable<string>=} options.immutablePaths paths that are immutable
* @param {Logger=} options.logger logger used to log invalid snapshots
* @param {string | Hash=} options.hashFunction the hash function to use
*/
constructor(fs, { managedPaths = [], immutablePaths = [], logger } = {}) {
constructor(
fs,
{
managedPaths = [],
immutablePaths = [],
logger,
hashFunction = "md4"
} = {}
) {
this.fs = fs;
this.logger = logger;
this._remainingLogs = logger ? 40 : 0;
this._loggedPaths = logger ? new Set() : undefined;
this._hashFunction = hashFunction;
/** @type {WeakMap<Snapshot, boolean | (function(WebpackError=, boolean=): void)[]>} */
this._snapshotCache = new WeakMap();
this._fileTimestampsOptimization = new SnapshotOptimization(
@ -2793,7 +2804,7 @@ class FileSystemInfo {
return callback(err);
}
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
hash.update(content);
@ -2976,7 +2987,7 @@ class FileSystemInfo {
reduce: (files, tsEntries) => {
let symlinks = undefined;
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
for (const file of files) hash.update(file);
let safeTime = 0;
@ -3044,7 +3055,7 @@ class FileSystemInfo {
},
err => {
if (err) return callback(err);
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
hash.update(entry.timestampHash);
if (entry.safeTime) {
safeTime = Math.max(safeTime, entry.safeTime);
@ -3094,7 +3105,7 @@ class FileSystemInfo {
*/
reduce: (files, fileHashes) => {
let symlinks = undefined;
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
for (const file of files) hash.update(file);
for (const entry of fileHashes) {
@ -3143,7 +3154,7 @@ class FileSystemInfo {
},
err => {
if (err) return callback(err);
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
hash.update(entry.hash);
hashes.sort();
for (const h of hashes) {
@ -3221,8 +3232,8 @@ class FileSystemInfo {
reduce: (files, results) => {
let symlinks = undefined;
const tsHash = createHash("md4");
const hash = createHash("md4");
const tsHash = createHash(this._hashFunction);
const hash = createHash(this._hashFunction);
for (const file of files) {
tsHash.update(file);
@ -3300,8 +3311,8 @@ class FileSystemInfo {
},
err => {
if (err) return callback(err);
const hash = createHash("md4");
const tsHash = createHash("md4");
const hash = createHash(this._hashFunction);
const tsHash = createHash(this._hashFunction);
hash.update(entry.hash);
if (entry.timestampHash) tsHash.update(entry.timestampHash);
if (entry.safeTime) {

View File

@ -8,6 +8,11 @@
const createHash = require("./util/createHash");
const memoize = require("./util/memoize");
/** @typedef {import("./ChunkGraph")} ChunkGraph */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./RequestShortener")} RequestShortener */
/** @typedef {typeof import("./util/Hash")} Hash */
const ModuleFilenameHelpers = exports;
// TODO webpack 6: consider removing these
@ -53,9 +58,9 @@ const getBefore = (strFn, token) => {
};
};
const getHash = strFn => {
const getHash = (strFn, hashFunction) => {
return () => {
const hash = createHash("md4");
const hash = createHash(hashFunction);
hash.update(strFn());
const digest = /** @type {string} */ (hash.digest("hex"));
return digest.substr(0, 4);
@ -91,10 +96,20 @@ const lazyObject = obj => {
const REGEXP = /\[\\*([\w-]+)\\*\]/gi;
/**
*
* @param {Module | string} module the module
* @param {TODO} options options
* @param {Object} contextInfo context info
* @param {RequestShortener} contextInfo.requestShortener requestShortener
* @param {ChunkGraph} contextInfo.chunkGraph chunk graph
* @param {string | Hash} contextInfo.hashFunction the hash function to use
* @returns {string} the filename
*/
ModuleFilenameHelpers.createFilename = (
module,
module = "",
options,
{ requestShortener, chunkGraph }
{ requestShortener, chunkGraph, hashFunction = "md4" }
) => {
const opts = {
namespace: "",
@ -111,13 +126,12 @@ ModuleFilenameHelpers.createFilename = (
let identifier;
let moduleId;
let shortIdentifier;
if (module === undefined) module = "";
if (typeof module === "string") {
shortIdentifier = memoize(() => requestShortener.shorten(module));
identifier = shortIdentifier;
moduleId = () => "";
absoluteResourcePath = () => module.split("!").pop();
hash = getHash(identifier);
hash = getHash(identifier, hashFunction);
} else {
shortIdentifier = memoize(() =>
module.readableIdentifier(requestShortener)
@ -125,7 +139,7 @@ ModuleFilenameHelpers.createFilename = (
identifier = memoize(() => requestShortener.shorten(module.identifier()));
moduleId = () => chunkGraph.getModuleId(module);
absoluteResourcePath = () => module.identifier().split("!").pop();
hash = getHash(identifier);
hash = getHash(identifier, hashFunction);
}
const resource = memoize(() => shortIdentifier().split("!").pop());

View File

@ -297,7 +297,8 @@ class SourceMapDevToolPlugin {
},
{
requestShortener,
chunkGraph
chunkGraph,
hashFunction: compilation.outputOptions.hashFunction
}
)
);
@ -358,7 +359,8 @@ class SourceMapDevToolPlugin {
},
{
requestShortener,
chunkGraph
chunkGraph,
hashFunction: compilation.outputOptions.hashFunction
}
);
hasName = usedNamesSet.has(sourceName);
@ -442,7 +444,9 @@ class SourceMapDevToolPlugin {
const sourceMapContentHash =
usesContentHash &&
/** @type {string} */ (
createHash("md4").update(sourceMapString).digest("hex")
createHash(compilation.outputOptions.hashFunction)
.update(sourceMapString)
.digest("hex")
);
const pathParams = {
chunk,

View File

@ -431,7 +431,9 @@ class WebpackOptionsApply extends OptionsApply {
"hashed",
"deterministic"
).apply(compiler);
new HashedModuleIdsPlugin().apply(compiler);
new HashedModuleIdsPlugin({
hashFunction: options.output.hashFunction
}).apply(compiler);
break;
}
case "deterministic": {

View File

@ -995,7 +995,8 @@ class PackFileCacheStrategy {
this.fileSystemInfo = new FileSystemInfo(fs, {
managedPaths: snapshot.managedPaths,
immutablePaths: snapshot.immutablePaths,
logger: logger.getChildLogger("webpack.FileSystemInfo")
logger: logger.getChildLogger("webpack.FileSystemInfo"),
hashFunction: compiler.options.output.hashFunction
});
this.compiler = compiler;
this.context = context;

View File

@ -8,6 +8,7 @@
const createHash = require("../util/createHash");
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {typeof import("../util/Hash")} HashConstructor */
/**
* @typedef {Object} HashableObject
@ -17,10 +18,12 @@ const createHash = require("../util/createHash");
class LazyHashedEtag {
/**
* @param {HashableObject} obj object with updateHash method
* @param {string | HashConstructor} hashFunction the hash function to use
*/
constructor(obj) {
constructor(obj, hashFunction = "md4") {
this._obj = obj;
this._hash = undefined;
this._hashFunction = hashFunction;
}
/**
@ -28,7 +31,7 @@ class LazyHashedEtag {
*/
toString() {
if (this._hash === undefined) {
const hash = createHash("md4");
const hash = createHash(this._hashFunction);
this._obj.updateHash(hash);
this._hash = /** @type {string} */ (hash.digest("base64"));
}
@ -36,18 +39,42 @@ class LazyHashedEtag {
}
}
/** @type {WeakMap<HashableObject, LazyHashedEtag>} */
const map = new WeakMap();
/** @type {Map<string | HashConstructor, WeakMap<HashableObject, LazyHashedEtag>>} */
const mapStrings = new Map();
/** @type {WeakMap<HashConstructor, WeakMap<HashableObject, LazyHashedEtag>>} */
const mapObjects = new WeakMap();
/**
* @param {HashableObject} obj object with updateHash method
* @param {string | HashConstructor} hashFunction the hash function to use
* @returns {LazyHashedEtag} etag
*/
const getter = obj => {
const hash = map.get(obj);
const getter = (obj, hashFunction = "md4") => {
let innerMap;
if (typeof hashFunction === "string") {
innerMap = mapStrings.get(hashFunction);
if (innerMap === undefined) {
const newHash = new LazyHashedEtag(obj, hashFunction);
innerMap = new WeakMap();
innerMap.set(obj, newHash);
mapStrings.set(hashFunction, innerMap);
return newHash;
}
} else {
innerMap = mapObjects.get(hashFunction);
if (innerMap === undefined) {
const newHash = new LazyHashedEtag(obj, hashFunction);
innerMap = new WeakMap();
innerMap.set(obj, newHash);
mapObjects.set(hashFunction, innerMap);
return newHash;
}
}
const hash = innerMap.get(obj);
if (hash !== undefined) return hash;
const newHash = new LazyHashedEtag(obj);
map.set(obj, newHash);
const newHash = new LazyHashedEtag(obj, hashFunction);
innerMap.set(obj, newHash);
return newHash;
};

View File

@ -13,14 +13,16 @@ const numberHash = require("../util/numberHash");
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module")} Module */
/** @typedef {typeof import("../util/Hash")} Hash */
/**
* @param {string} str string to hash
* @param {number} len max length of the hash
* @param {string | Hash} hashFunction hash function to use
* @returns {string} hash
*/
const getHash = (str, len) => {
const hash = createHash("md4");
const getHash = (str, len, hashFunction) => {
const hash = createHash(hashFunction);
hash.update(str);
const digest = /** @type {string} */ (hash.digest("hex"));
return digest.substr(0, len);
@ -61,12 +63,15 @@ exports.requestToId = requestToId;
/**
* @param {string} string the string
* @param {string} delimiter separator for string and hash
* @param {string | Hash} hashFunction hash function to use
* @returns {string} string with limited max length to 100 chars
*/
const shortenLongString = (string, delimiter) => {
const shortenLongString = (string, delimiter, hashFunction) => {
if (string.length < 100) return string;
return (
string.slice(0, 100 - 6 - delimiter.length) + delimiter + getHash(string, 6)
string.slice(0, 100 - 6 - delimiter.length) +
delimiter +
getHash(string, 6, hashFunction)
);
};
@ -92,6 +97,7 @@ exports.getShortModuleName = getShortModuleName;
* @param {string} shortName the short name
* @param {Module} module the module
* @param {string} context context directory
* @param {string | Hash} hashFunction hash function to use
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {string} long module name
*/
@ -99,10 +105,11 @@ const getLongModuleName = (
shortName,
module,
context,
hashFunction,
associatedObjectForCache
) => {
const fullName = getFullModuleName(module, context, associatedObjectForCache);
return `${shortName}?${getHash(fullName, 4)}`;
return `${shortName}?${getHash(fullName, 4, hashFunction)}`;
};
exports.getLongModuleName = getLongModuleName;
@ -126,6 +133,7 @@ exports.getFullModuleName = getFullModuleName;
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {string} context context directory
* @param {string} delimiter delimiter for names
* @param {string | Hash} hashFunction hash function to use
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {string} short chunk name
*/
@ -134,6 +142,7 @@ const getShortChunkName = (
chunkGraph,
context,
delimiter,
hashFunction,
associatedObjectForCache
) => {
const modules = chunkGraph.getChunkRootModules(chunk);
@ -145,7 +154,7 @@ const getShortChunkName = (
.concat(shortModuleNames)
.filter(Boolean)
.join(delimiter);
return shortenLongString(chunkName, delimiter);
return shortenLongString(chunkName, delimiter, hashFunction);
};
exports.getShortChunkName = getShortChunkName;
@ -154,6 +163,7 @@ exports.getShortChunkName = getShortChunkName;
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {string} context context directory
* @param {string} delimiter delimiter for names
* @param {string | Hash} hashFunction hash function to use
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {string} short chunk name
*/
@ -162,6 +172,7 @@ const getLongChunkName = (
chunkGraph,
context,
delimiter,
hashFunction,
associatedObjectForCache
) => {
const modules = chunkGraph.getChunkRootModules(chunk);
@ -169,14 +180,16 @@ const getLongChunkName = (
requestToId(getShortModuleName(m, context, associatedObjectForCache))
);
const longModuleNames = modules.map(m =>
requestToId(getLongModuleName("", m, context, associatedObjectForCache))
requestToId(
getLongModuleName("", m, context, hashFunction, associatedObjectForCache)
)
);
chunk.idNameHints.sort();
const chunkName = Array.from(chunk.idNameHints)
.concat(shortModuleNames, longModuleNames)
.filter(Boolean)
.join(delimiter);
return shortenLongString(chunkName, delimiter);
return shortenLongString(chunkName, delimiter, hashFunction);
};
exports.getLongChunkName = getLongChunkName;

View File

@ -31,6 +31,7 @@ class NamedChunkIdsPlugin {
*/
apply(compiler) {
compiler.hooks.compilation.tap("NamedChunkIdsPlugin", compilation => {
const { hashFunction } = compilation.outputOptions;
compilation.hooks.chunkIds.tap("NamedChunkIdsPlugin", chunks => {
const chunkGraph = compilation.chunkGraph;
const context = this.context ? this.context : compiler.context;
@ -50,6 +51,7 @@ class NamedChunkIdsPlugin {
chunkGraph,
context,
delimiter,
hashFunction,
compiler.root
),
chunk =>
@ -58,6 +60,7 @@ class NamedChunkIdsPlugin {
chunkGraph,
context,
delimiter,
hashFunction,
compiler.root
),
compareChunksNatural(chunkGraph),

View File

@ -30,6 +30,7 @@ class NamedModuleIdsPlugin {
apply(compiler) {
const { root } = compiler;
compiler.hooks.compilation.tap("NamedModuleIdsPlugin", compilation => {
const { hashFunction } = compilation.outputOptions;
compilation.hooks.moduleIds.tap("NamedModuleIdsPlugin", modules => {
const chunkGraph = compilation.chunkGraph;
const context = this.options.context
@ -43,7 +44,8 @@ class NamedModuleIdsPlugin {
return chunkGraph.getModuleId(module) === null;
}),
m => getShortModuleName(m, context, root),
(m, shortName) => getLongModuleName(shortName, m, context, root),
(m, shortName) =>
getLongModuleName(shortName, m, context, hashFunction, root),
compareModulesByIdentifier,
getUsedModuleIds(compilation),
(m, name) => chunkGraph.setModuleId(m, name)

View File

@ -58,6 +58,7 @@ const {
/** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {typeof import("../util/Hash")} HashConstructor */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
@ -647,13 +648,21 @@ class ConcatenatedModule extends Module {
* @param {Set<Module>} modules all modules in the concatenation (including the root module)
* @param {RuntimeSpec} runtime the runtime
* @param {Object=} associatedObjectForCache object for caching
* @param {string | HashConstructor=} hashFunction hash function to use
* @returns {ConcatenatedModule} the module
*/
static create(rootModule, modules, runtime, associatedObjectForCache) {
static create(
rootModule,
modules,
runtime,
associatedObjectForCache,
hashFunction = "md4"
) {
const identifier = ConcatenatedModule._createIdentifier(
rootModule,
modules,
associatedObjectForCache
associatedObjectForCache,
hashFunction
);
return new ConcatenatedModule({
identifier,
@ -1010,7 +1019,19 @@ class ConcatenatedModule extends Module {
return list;
}
static _createIdentifier(rootModule, modules, associatedObjectForCache) {
/**
* @param {Module} rootModule the root module of the concatenation
* @param {Set<Module>} modules all modules in the concatenation (including the root module)
* @param {Object=} associatedObjectForCache object for caching
* @param {string | HashConstructor=} hashFunction hash function to use
* @returns {string} the identifier
*/
static _createIdentifier(
rootModule,
modules,
associatedObjectForCache,
hashFunction = "md4"
) {
const cachedMakePathsRelative = makePathsRelative.bindContextCache(
rootModule.context,
associatedObjectForCache
@ -1020,7 +1041,7 @@ class ConcatenatedModule extends Module {
identifiers.push(cachedMakePathsRelative(module.identifier()));
}
identifiers.sort();
const hash = createHash("md4");
const hash = createHash(hashFunction);
hash.update(identifiers.join(" "));
return rootModule.identifier() + "|" + hash.digest("hex");
}

View File

@ -366,7 +366,8 @@ class ModuleConcatenationPlugin {
rootModule,
modules,
concatConfiguration.runtime,
compiler.root
compiler.root,
compilation.outputOptions.hashFunction
);
const build = () => {

View File

@ -311,8 +311,7 @@ class HttpUriPlugin {
: lockfileLocation + ".data";
const upgrade = this._upgrade || false;
const frozen = this._frozen || false;
const hashFunction =
this._hashFunction || compilation.outputOptions.hashFunction;
const hashFunction = this._hashFunction || "sha512";
const hashDigest =
this._hashDigest || compilation.outputOptions.hashDigest;
const hashDigestLength =

View File

@ -18,6 +18,7 @@ const { dirname, join, mkdirp } = require("../util/fs");
const memoize = require("../util/memoize");
const SerializerMiddleware = require("./SerializerMiddleware");
/** @typedef {typeof import("../util/Hash")} Hash */
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
/** @typedef {import("./types").BufferSerializableType} BufferSerializableType */
@ -39,8 +40,14 @@ Section -> Buffer
// "wpc" + 1 in little-endian
const VERSION = 0x01637077;
const hashForName = buffers => {
const hash = createHash("md4");
/**
* @param {Buffer[]} buffers buffers
* @param {string | Hash} hashFunction hash function to use
* @returns {string} hash
*/
const hashForName = (buffers, hashFunction) => {
const hash = createHash(hashFunction);
for (const buf of buffers) hash.update(buf);
return /** @type {string} */ (hash.digest("hex"));
};
@ -81,9 +88,16 @@ const readUInt64LE = Buffer.prototype.readBigUInt64LE
* @param {BufferSerializableType[] | Promise<BufferSerializableType[]>} data data to be serialized
* @param {string | boolean} name file base name
* @param {function(string | false, Buffer[]): Promise<void>} writeFile writes a file
* @param {string | Hash} hashFunction hash function to use
* @returns {Promise<SerializeResult>} resulting file pointer and promise
*/
const serialize = async (middleware, data, name, writeFile) => {
const serialize = async (
middleware,
data,
name,
writeFile,
hashFunction = "md4"
) => {
/** @type {(Buffer[] | Buffer | SerializeResult | Promise<SerializeResult>)[]} */
const processedData = [];
/** @type {WeakMap<SerializeResult, function(): any | Promise<any>>} */
@ -118,7 +132,8 @@ const serialize = async (middleware, data, name, writeFile) => {
middleware,
content,
(options && options.name) || true,
writeFile
writeFile,
hashFunction
).then(result => {
/** @type {any} */ (item).options.size = result.size;
resultToLazy.set(result, item);
@ -195,7 +210,7 @@ const serialize = async (middleware, data, name, writeFile) => {
}
}
if (name === true) {
name = hashForName(buf);
name = hashForName(buf, hashFunction);
}
backgroundJobs.push(writeFile(name, buf));
let size = 0;
@ -386,10 +401,12 @@ const deserialize = async (middleware, name, readFile) => {
class FileMiddleware extends SerializerMiddleware {
/**
* @param {IntermediateFileSystem} fs filesystem
* @param {string | Hash} hashFunction hash function to use
*/
constructor(fs) {
constructor(fs, hashFunction = "md4") {
super();
this.fs = fs;
this._hashFunction = hashFunction;
}
/**
* @param {DeserializedType} data data
@ -446,7 +463,7 @@ class FileMiddleware extends SerializerMiddleware {
};
resolve(
serialize(this, data, false, writeFile).then(
serialize(this, data, false, writeFile, this._hashFunction).then(
async ({ backgroundJob }) => {
await backgroundJob;

View File

@ -15,6 +15,7 @@ const RegExpObjectSerializer = require("./RegExpObjectSerializer");
const SerializerMiddleware = require("./SerializerMiddleware");
const SetObjectSerializer = require("./SetObjectSerializer");
/** @typedef {typeof import("../util/Hash")} Hash */
/** @typedef {import("./types").ComplexSerializableType} ComplexSerializableType */
/** @typedef {import("./types").PrimitiveSerializableType} PrimitiveSerializableType */
@ -76,8 +77,13 @@ const setMapSize = (map, size) => {
}
};
const toHash = buffer => {
const hash = createHash("md4");
/**
* @param {Buffer} buffer buffer
* @param {string | Hash} hashFunction hash function to use
* @returns {string} hash
*/
const toHash = (buffer, hashFunction) => {
const hash = createHash(hashFunction);
hash.update(buffer);
return /** @type {string} */ (hash.digest("latin1"));
};
@ -149,9 +155,14 @@ const loaders = new Map();
* @extends {SerializerMiddleware<DeserializedType, SerializedType>}
*/
class ObjectMiddleware extends SerializerMiddleware {
constructor(extendContext) {
/**
* @param {function(any): void} extendContext context extensions
* @param {string | Hash} hashFunction hash function to use
*/
constructor(extendContext, hashFunction = "md4") {
super();
this.extendContext = extendContext;
this._hashFunction = hashFunction;
}
/**
* @param {RegExp} regExp RegExp for which the request is tested
@ -275,11 +286,11 @@ class ObjectMiddleware extends SerializerMiddleware {
bufferDedupeMap.set(len, [entry, buf]);
return buf;
} else {
const hash = toHash(entry);
const hash = toHash(entry, this._hashFunction);
const newMap = new Map();
newMap.set(hash, entry);
bufferDedupeMap.set(len, newMap);
const hashBuf = toHash(buf);
const hashBuf = toHash(buf, this._hashFunction);
if (hash === hashBuf) {
return entry;
}
@ -296,10 +307,10 @@ class ObjectMiddleware extends SerializerMiddleware {
return buf;
} else {
const newMap = new Map();
const hash = toHash(buf);
const hash = toHash(buf, this._hashFunction);
let found;
for (const item of entry) {
const itemHash = toHash(item);
const itemHash = toHash(item, this._hashFunction);
newMap.set(itemHash, item);
if (found === undefined && itemHash === hash) found = item;
}
@ -312,7 +323,7 @@ class ObjectMiddleware extends SerializerMiddleware {
}
}
} else {
const hash = toHash(buf);
const hash = toHash(buf, this._hashFunction);
const item = entry.get(hash);
if (item !== undefined) {
return item;

View File

@ -89,15 +89,15 @@ module.exports = {
);
};
}
}),
}, "md4"),
binaryMiddleware
]));
},
createFileSerializer: fs => {
createFileSerializer: (fs, hashFunction) => {
registerSerializers();
const Serializer = getSerializer();
const FileMiddleware = require("../serialization/FileMiddleware");
const fileMiddleware = new FileMiddleware(fs);
const fileMiddleware = new FileMiddleware(fs, hashFunction);
const binaryMiddleware = getBinaryMiddlewareInstance();
const SerializerMiddleware = getSerializerMiddleware();
const SingleItemMiddleware = getSingleItemMiddleware();
@ -120,7 +120,7 @@ module.exports = {
return lazy;
};
}
}),
}, hashFunction),
binaryMiddleware,
fileMiddleware
]);

View File

@ -96,7 +96,7 @@
"style-loader": "^2.0.0",
"terser": "^5.7.0",
"toml": "^3.0.0",
"tooling": "webpack/tooling#v1.19.0",
"tooling": "webpack/tooling#v1.20.0",
"ts-loader": "^8.0.2",
"typescript": "^4.2.0-beta",
"url-loader": "^4.1.0",

View File

@ -3,4 +3,4 @@
* DO NOT MODIFY BY HAND.
* Run `yarn special-lint-fix` to update
*/
const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function t(e,{instancePath:s="",parentData:i,parentDataProperty:n,rootData:a=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return t.errors=[{params:{type:"object"}}],!1;{const s=0;for(const r in e)if("context"!==r&&"hashDigest"!==r&&"hashDigestLength"!==r&&"hashFunction"!==r)return t.errors=[{params:{additionalProperty:r}}],!1;if(0===s){if(void 0!==e.context){let s=e.context;const i=0;if(0===i){if("string"!=typeof s)return t.errors=[{params:{type:"string"}}],!1;if(s.includes("!")||!0!==r.test(s))return t.errors=[{params:{}}],!1}var o=0===i}else o=!0;if(o){if(void 0!==e.hashDigest){let r=e.hashDigest;const s=0;if("hex"!==r&&"latin1"!==r&&"base64"!==r)return t.errors=[{params:{}}],!1;o=0===s}else o=!0;if(o){if(void 0!==e.hashDigestLength){let r=e.hashDigestLength;const s=0;if(0===s){if("number"!=typeof r||!isFinite(r))return t.errors=[{params:{type:"number"}}],!1;if(r<1||isNaN(r))return t.errors=[{params:{comparison:">=",limit:1}}],!1}o=0===s}else o=!0;if(o)if(void 0!==e.hashFunction){let r=e.hashFunction;const s=0;if(0===s){if("string"!=typeof r)return t.errors=[{params:{type:"string"}}],!1;if(r.length<1)return t.errors=[{params:{}}],!1}o=0===s}else o=!0}}}}return t.errors=null,!0}module.exports=t,module.exports.default=t;
const t=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function e(r,{instancePath:s="",parentData:n,parentDataProperty:i,rootData:a=r}={}){let o=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const s=l;for(const t in r)if("context"!==t&&"hashDigest"!==t&&"hashDigestLength"!==t&&"hashFunction"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(s===l){if(void 0!==r.context){let s=r.context;const n=l;if(l===n){if("string"!=typeof s)return e.errors=[{params:{type:"string"}}],!1;if(s.includes("!")||!0!==t.test(s))return e.errors=[{params:{}}],!1}var u=n===l}else u=!0;if(u){if(void 0!==r.hashDigest){let t=r.hashDigest;const s=l;if("hex"!==t&&"latin1"!==t&&"base64"!==t)return e.errors=[{params:{}}],!1;u=s===l}else u=!0;if(u){if(void 0!==r.hashDigestLength){let t=r.hashDigestLength;const s=l;if(l===s){if("number"!=typeof t||!isFinite(t))return e.errors=[{params:{type:"number"}}],!1;if(t<1||isNaN(t))return e.errors=[{params:{comparison:">=",limit:1}}],!1}u=s===l}else u=!0;if(u)if(void 0!==r.hashFunction){let t=r.hashFunction;const s=l,n=l;let i=!1,a=null;const p=l,h=l;let c=!1;const m=l;if(l===m)if("string"==typeof t){if(t.length<1){const t={params:{}};null===o?o=[t]:o.push(t),l++}}else{const t={params:{type:"string"}};null===o?o=[t]:o.push(t),l++}var f=m===l;if(c=c||f,!c){const e=l;if(!(t instanceof Function)){const t={params:{}};null===o?o=[t]:o.push(t),l++}f=e===l,c=c||f}if(c)l=h,null!==o&&(h?o.length=h:o=null);else{const t={params:{}};null===o?o=[t]:o.push(t),l++}if(p===l&&(i=!0,a=0),!i){const t={params:{passingSchemas:a}};return null===o?o=[t]:o.push(t),l++,e.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),u=s===l}else u=!0}}}}}return e.errors=o,0===l}module.exports=e,module.exports.default=e;

View File

@ -1,4 +1,19 @@
{
"definitions": {
"HashFunction": {
"description": "Algorithm used for generation the hash (see node.js crypto package).",
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"instanceof": "Function",
"tsType": "typeof import('../../lib/util/Hash')"
}
]
}
},
"title": "HashedModuleIdsPluginOptions",
"type": "object",
"additionalProperties": false,
@ -19,8 +34,11 @@
},
"hashFunction": {
"description": "The hashing algorithm to use, defaults to 'md4'. All functions from Node.JS' crypto.createHash are supported.",
"type": "string",
"minLength": 1
"oneOf": [
{
"$ref": "#/definitions/HashFunction"
}
]
}
}
}

View File

@ -111,7 +111,8 @@ describe("FileSystemInfo", () => {
const fsInfo = new FileSystemInfo(fs, {
logger,
managedPaths,
immutablePaths
immutablePaths,
hashFunction: "sha256"
});
for (const method of ["warn", "info", "log", "debug"]) {
fsInfo.logs = [];

Some files were not shown because too many files have changed in this diff Show More