@rspack/core 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RuleSetCompiler.d.ts +6 -0
- package/dist/RuleSetCompiler.d.ts.map +1 -0
- package/dist/RuleSetCompiler.js +10 -0
- package/dist/RuleSetCompiler.js.map +1 -0
- package/dist/compilation.d.ts +5 -0
- package/dist/compilation.d.ts.map +1 -1
- package/dist/compilation.js +10 -1
- package/dist/compilation.js.map +1 -1
- package/dist/compiler.d.ts +11 -0
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +28 -5
- package/dist/compiler.js.map +1 -1
- package/dist/config/adapter-rule-use.d.ts +64 -6
- package/dist/config/adapter-rule-use.d.ts.map +1 -1
- package/dist/config/adapter-rule-use.js +45 -392
- package/dist/config/adapter-rule-use.js.map +1 -1
- package/dist/config/adapter.d.ts +4 -2
- package/dist/config/adapter.d.ts.map +1 -1
- package/dist/config/adapter.js +69 -9
- package/dist/config/adapter.js.map +1 -1
- package/dist/config/builtins.d.ts +14 -0
- package/dist/config/builtins.d.ts.map +1 -1
- package/dist/config/builtins.js +24 -0
- package/dist/config/builtins.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +92 -14
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/normalization.d.ts.map +1 -1
- package/dist/config/normalization.js +13 -1
- package/dist/config/normalization.js.map +1 -1
- package/dist/config/schema.check.d.ts.map +1 -1
- package/dist/config/schema.check.js +1555 -1120
- package/dist/config/schema.check.js.map +1 -1
- package/dist/config/schema.d.ts +1001 -887
- package/dist/config/schema.js +91 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/types.d.ts +49 -3
- package/dist/config/types.d.ts.map +1 -1
- package/dist/lib/Cache.d.ts +72 -0
- package/dist/lib/Cache.d.ts.map +1 -0
- package/dist/lib/Cache.js +131 -0
- package/dist/lib/Cache.js.map +1 -0
- package/dist/lib/CacheFacade.d.ts +192 -0
- package/dist/lib/CacheFacade.d.ts.map +1 -0
- package/dist/lib/CacheFacade.js +320 -0
- package/dist/lib/CacheFacade.js.map +1 -0
- package/dist/lib/HookWebpackError.d.ts +47 -0
- package/dist/lib/HookWebpackError.d.ts.map +1 -0
- package/dist/lib/HookWebpackError.js +83 -0
- package/dist/lib/HookWebpackError.js.map +1 -0
- package/dist/lib/WebpackError.d.ts +24 -0
- package/dist/lib/WebpackError.d.ts.map +1 -0
- package/dist/lib/WebpackError.js +35 -0
- package/dist/lib/WebpackError.js.map +1 -0
- package/dist/lib/cache/getLazyHashedEtag.d.ts +36 -0
- package/dist/lib/cache/getLazyHashedEtag.d.ts.map +1 -0
- package/dist/lib/cache/getLazyHashedEtag.js +74 -0
- package/dist/lib/cache/getLazyHashedEtag.js.map +1 -0
- package/dist/lib/cache/mergeEtags.d.ts +12 -0
- package/dist/lib/cache/mergeEtags.d.ts.map +1 -0
- package/dist/lib/cache/mergeEtags.js +72 -0
- package/dist/lib/cache/mergeEtags.js.map +1 -0
- package/dist/loader-runner/LoaderLoadingError.d.ts +5 -0
- package/dist/loader-runner/LoaderLoadingError.d.ts.map +1 -0
- package/dist/loader-runner/LoaderLoadingError.js +19 -0
- package/dist/loader-runner/LoaderLoadingError.js.map +1 -0
- package/dist/loader-runner/index.d.ts +18 -0
- package/dist/loader-runner/index.d.ts.map +1 -0
- package/dist/loader-runner/index.js +667 -0
- package/dist/loader-runner/index.js.map +1 -0
- package/dist/loader-runner/loadLoader.d.ts +3 -0
- package/dist/loader-runner/loadLoader.d.ts.map +1 -0
- package/dist/loader-runner/loadLoader.js +69 -0
- package/dist/loader-runner/loadLoader.js.map +1 -0
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +2 -2
- package/dist/stats.js.map +1 -1
- package/dist/util/fake.d.ts +1 -0
- package/dist/util/fake.d.ts.map +1 -1
- package/dist/util/fake.js +1 -0
- package/dist/util/fake.js.map +1 -1
- package/dist/util/index.d.ts +3 -0
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +28 -1
- package/dist/util/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
const { AsyncParallelHook, AsyncSeriesBailHook, SyncHook } = require("tapable");
|
|
7
|
+
const { makeWebpackError, makeWebpackErrorCallback } = require("./HookWebpackError.js");
|
|
8
|
+
/** @typedef {import("./WebpackError")} WebpackError */
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} Etag
|
|
11
|
+
* @property {function(): string} toString
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @template T
|
|
15
|
+
* @callback CallbackCache
|
|
16
|
+
* @param {(WebpackError | null)=} err
|
|
17
|
+
* @param {T=} result
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @callback GotHandler
|
|
22
|
+
* @param {any} result
|
|
23
|
+
* @param {function(Error=): void} callback
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
const needCalls = (times, callback) => {
|
|
27
|
+
return err => {
|
|
28
|
+
if (--times === 0) {
|
|
29
|
+
return callback(err);
|
|
30
|
+
}
|
|
31
|
+
if (err && times > 0) {
|
|
32
|
+
times = 0;
|
|
33
|
+
return callback(err);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
class Cache {
|
|
38
|
+
constructor() {
|
|
39
|
+
this.hooks = {
|
|
40
|
+
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>} */
|
|
41
|
+
get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
|
|
42
|
+
/** @type {AsyncParallelHook<[string, Etag | null, any]>} */
|
|
43
|
+
store: new AsyncParallelHook(["identifier", "etag", "data"]),
|
|
44
|
+
/** @type {AsyncParallelHook<[Iterable<string>]>} */
|
|
45
|
+
storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
|
|
46
|
+
/** @type {SyncHook<[]>} */
|
|
47
|
+
beginIdle: new SyncHook([]),
|
|
48
|
+
/** @type {AsyncParallelHook<[]>} */
|
|
49
|
+
endIdle: new AsyncParallelHook([]),
|
|
50
|
+
/** @type {AsyncParallelHook<[]>} */
|
|
51
|
+
shutdown: new AsyncParallelHook([])
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @template T
|
|
56
|
+
* @param {string} identifier the cache identifier
|
|
57
|
+
* @param {Etag | null} etag the etag
|
|
58
|
+
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
59
|
+
* @returns {void}
|
|
60
|
+
*/
|
|
61
|
+
get(identifier, etag, callback) {
|
|
62
|
+
const gotHandlers = [];
|
|
63
|
+
this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {
|
|
64
|
+
if (err) {
|
|
65
|
+
callback(makeWebpackError(err, "Cache.hooks.get"));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (result === null) {
|
|
69
|
+
result = undefined;
|
|
70
|
+
}
|
|
71
|
+
if (gotHandlers.length > 1) {
|
|
72
|
+
const innerCallback = needCalls(gotHandlers.length, () => callback(null, result));
|
|
73
|
+
for (const gotHandler of gotHandlers) {
|
|
74
|
+
gotHandler(result, innerCallback);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (gotHandlers.length === 1) {
|
|
78
|
+
gotHandlers[0](result, () => callback(null, result));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
callback(null, result);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @template T
|
|
87
|
+
* @param {string} identifier the cache identifier
|
|
88
|
+
* @param {Etag | null} etag the etag
|
|
89
|
+
* @param {T} data the value to store
|
|
90
|
+
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
91
|
+
* @returns {void}
|
|
92
|
+
*/
|
|
93
|
+
store(identifier, etag, data, callback) {
|
|
94
|
+
this.hooks.store.callAsync(identifier, etag, data, makeWebpackErrorCallback(callback, "Cache.hooks.store"));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* After this method has succeeded the cache can only be restored when build dependencies are
|
|
98
|
+
* @param {Iterable<string>} dependencies list of all build dependencies
|
|
99
|
+
* @param {CallbackCache<void>} callback signals when the dependencies are stored
|
|
100
|
+
* @returns {void}
|
|
101
|
+
*/
|
|
102
|
+
storeBuildDependencies(dependencies, callback) {
|
|
103
|
+
this.hooks.storeBuildDependencies.callAsync(dependencies, makeWebpackErrorCallback(callback, "Cache.hooks.storeBuildDependencies"));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @returns {void}
|
|
107
|
+
*/
|
|
108
|
+
beginIdle() {
|
|
109
|
+
this.hooks.beginIdle.call();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @param {CallbackCache<void>} callback signals when the call finishes
|
|
113
|
+
* @returns {void}
|
|
114
|
+
*/
|
|
115
|
+
endIdle(callback) {
|
|
116
|
+
this.hooks.endIdle.callAsync(makeWebpackErrorCallback(callback, "Cache.hooks.endIdle"));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @param {CallbackCache<void>} callback signals when the call finishes
|
|
120
|
+
* @returns {void}
|
|
121
|
+
*/
|
|
122
|
+
shutdown(callback) {
|
|
123
|
+
this.hooks.shutdown.callAsync(makeWebpackErrorCallback(callback, "Cache.hooks.shutdown"));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
Cache.STAGE_MEMORY = -10;
|
|
127
|
+
Cache.STAGE_DEFAULT = 0;
|
|
128
|
+
Cache.STAGE_DISK = 10;
|
|
129
|
+
Cache.STAGE_NETWORK = 20;
|
|
130
|
+
module.exports = Cache;
|
|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EAAE,mBAAmB,CAAC,CACvD,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,sBAAsB,CAAC,YAAY,EAAE,QAAQ;QAC5C,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,SAAS,CAC1C,YAAY,EACZ,wBAAwB,CAAC,QAAQ,EAAE,oCAAoC,CAAC,CACxE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS;QACR,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,QAAQ;QACf,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAC3B,wBAAwB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CACzD,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,QAAQ;QAChB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAC5B,wBAAwB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAC1D,CAAC;IACH,CAAC;CACD;AAED,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;AACzB,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC;AACxB,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC;AACtB,KAAK,CAAC,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export = CacheFacade;
|
|
2
|
+
declare class CacheFacade {
|
|
3
|
+
/**
|
|
4
|
+
* @param {Cache} cache the root cache
|
|
5
|
+
* @param {string} name the child cache name
|
|
6
|
+
* @param {string | HashConstructor} hashFunction the hash function to use
|
|
7
|
+
*/
|
|
8
|
+
constructor(cache: Cache, name: string, hashFunction: string | HashConstructor);
|
|
9
|
+
_cache: import("./Cache");
|
|
10
|
+
_name: string;
|
|
11
|
+
_hashFunction: any;
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} name the child cache name#
|
|
14
|
+
* @returns {CacheFacade} child cache
|
|
15
|
+
*/
|
|
16
|
+
getChildCache(name: string): CacheFacade;
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} identifier the cache identifier
|
|
19
|
+
* @param {Etag | null} etag the etag
|
|
20
|
+
* @returns {ItemCacheFacade} item cache
|
|
21
|
+
*/
|
|
22
|
+
getItemCache(identifier: string, etag: Etag | null): ItemCacheFacade;
|
|
23
|
+
/**
|
|
24
|
+
* @param {HashableObject} obj an hashable object
|
|
25
|
+
* @returns {Etag} an etag that is lazy hashed
|
|
26
|
+
*/
|
|
27
|
+
getLazyHashedEtag(obj: HashableObject): Etag;
|
|
28
|
+
/**
|
|
29
|
+
* @param {Etag} a an etag
|
|
30
|
+
* @param {Etag} b another etag
|
|
31
|
+
* @returns {Etag} an etag that represents both
|
|
32
|
+
*/
|
|
33
|
+
mergeEtags(a: Etag, b: Etag): Etag;
|
|
34
|
+
/**
|
|
35
|
+
* @template T
|
|
36
|
+
* @param {string} identifier the cache identifier
|
|
37
|
+
* @param {Etag | null} etag the etag
|
|
38
|
+
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
get<T>(identifier: string, etag: Etag | null, callback: CallbackCache<T>): void;
|
|
42
|
+
/**
|
|
43
|
+
* @template T
|
|
44
|
+
* @param {string} identifier the cache identifier
|
|
45
|
+
* @param {Etag | null} etag the etag
|
|
46
|
+
* @returns {Promise<T>} promise with the data
|
|
47
|
+
*/
|
|
48
|
+
getPromise<T_1>(identifier: string, etag: Etag | null): Promise<T_1>;
|
|
49
|
+
/**
|
|
50
|
+
* @template T
|
|
51
|
+
* @param {string} identifier the cache identifier
|
|
52
|
+
* @param {Etag | null} etag the etag
|
|
53
|
+
* @param {T} data the value to store
|
|
54
|
+
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
store<T_2>(identifier: string, etag: Etag | null, data: T_2, callback: CallbackCache<void>): void;
|
|
58
|
+
/**
|
|
59
|
+
* @template T
|
|
60
|
+
* @param {string} identifier the cache identifier
|
|
61
|
+
* @param {Etag | null} etag the etag
|
|
62
|
+
* @param {T} data the value to store
|
|
63
|
+
* @returns {Promise<void>} promise signals when the value is stored
|
|
64
|
+
*/
|
|
65
|
+
storePromise<T_3>(identifier: string, etag: Etag | null, data: T_3): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* @template T
|
|
68
|
+
* @param {string} identifier the cache identifier
|
|
69
|
+
* @param {Etag | null} etag the etag
|
|
70
|
+
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
|
|
71
|
+
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
|
72
|
+
* @returns {void}
|
|
73
|
+
*/
|
|
74
|
+
provide<T_4>(identifier: string, etag: Etag | null, computer: (arg0: CallbackNormalErrorCache<T_4>) => void, callback: CallbackNormalErrorCache<T_4>): void;
|
|
75
|
+
/**
|
|
76
|
+
* @template T
|
|
77
|
+
* @param {string} identifier the cache identifier
|
|
78
|
+
* @param {Etag | null} etag the etag
|
|
79
|
+
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
|
|
80
|
+
* @returns {Promise<T>} promise with the data
|
|
81
|
+
*/
|
|
82
|
+
providePromise<T_5>(identifier: string, etag: Etag | null, computer: () => T_5 | Promise<T_5>): Promise<T_5>;
|
|
83
|
+
}
|
|
84
|
+
declare namespace CacheFacade {
|
|
85
|
+
export { ItemCacheFacade, MultiItemCache, Cache, Etag, WebpackError, HashableObject, HashConstructor, CallbackCache, CallbackNormalErrorCache };
|
|
86
|
+
}
|
|
87
|
+
type Etag = import("./Cache").Etag;
|
|
88
|
+
declare class ItemCacheFacade {
|
|
89
|
+
/**
|
|
90
|
+
* @param {Cache} cache the root cache
|
|
91
|
+
* @param {string} name the child cache item name
|
|
92
|
+
* @param {Etag | null} etag the etag
|
|
93
|
+
*/
|
|
94
|
+
constructor(cache: Cache, name: string, etag: Etag | null);
|
|
95
|
+
_cache: import("./Cache");
|
|
96
|
+
_name: string;
|
|
97
|
+
_etag: import("./Cache").Etag | null;
|
|
98
|
+
/**
|
|
99
|
+
* @template T
|
|
100
|
+
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
101
|
+
* @returns {void}
|
|
102
|
+
*/
|
|
103
|
+
get<T>(callback: CallbackCache<T>): void;
|
|
104
|
+
/**
|
|
105
|
+
* @template T
|
|
106
|
+
* @returns {Promise<T>} promise with the data
|
|
107
|
+
*/
|
|
108
|
+
getPromise<T_1>(): Promise<T_1>;
|
|
109
|
+
/**
|
|
110
|
+
* @template T
|
|
111
|
+
* @param {T} data the value to store
|
|
112
|
+
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
113
|
+
* @returns {void}
|
|
114
|
+
*/
|
|
115
|
+
store<T_2>(data: T_2, callback: CallbackCache<void>): void;
|
|
116
|
+
/**
|
|
117
|
+
* @template T
|
|
118
|
+
* @param {T} data the value to store
|
|
119
|
+
* @returns {Promise<void>} promise signals when the value is stored
|
|
120
|
+
*/
|
|
121
|
+
storePromise<T_3>(data: T_3): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* @template T
|
|
124
|
+
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
|
|
125
|
+
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
|
126
|
+
* @returns {void}
|
|
127
|
+
*/
|
|
128
|
+
provide<T_4>(computer: (arg0: CallbackNormalErrorCache<T_4>) => void, callback: CallbackNormalErrorCache<T_4>): void;
|
|
129
|
+
/**
|
|
130
|
+
* @template T
|
|
131
|
+
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
|
|
132
|
+
* @returns {Promise<T>} promise with the data
|
|
133
|
+
*/
|
|
134
|
+
providePromise<T_5>(computer: () => T_5 | Promise<T_5>): Promise<T_5>;
|
|
135
|
+
}
|
|
136
|
+
type HashableObject = import("./cache/getLazyHashedEtag").HashableObject;
|
|
137
|
+
type CallbackCache<T> = (err?: (WebpackError | null) | undefined, result?: T | undefined) => void;
|
|
138
|
+
type CallbackNormalErrorCache<T> = (err?: (Error | null) | undefined, result?: T | undefined) => void;
|
|
139
|
+
type Cache = import("./Cache");
|
|
140
|
+
type HashConstructor = typeof import("./util/Hash");
|
|
141
|
+
/** @typedef {import("./Cache")} Cache */
|
|
142
|
+
/** @typedef {import("./Cache").Etag} Etag */
|
|
143
|
+
/** @typedef {import("./WebpackError")} WebpackError */
|
|
144
|
+
/** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */
|
|
145
|
+
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
|
146
|
+
/**
|
|
147
|
+
* @template T
|
|
148
|
+
* @callback CallbackCache
|
|
149
|
+
* @param {(WebpackError | null)=} err
|
|
150
|
+
* @param {T=} result
|
|
151
|
+
* @returns {void}
|
|
152
|
+
*/
|
|
153
|
+
/**
|
|
154
|
+
* @template T
|
|
155
|
+
* @callback CallbackNormalErrorCache
|
|
156
|
+
* @param {(Error | null)=} err
|
|
157
|
+
* @param {T=} result
|
|
158
|
+
* @returns {void}
|
|
159
|
+
*/
|
|
160
|
+
declare class MultiItemCache {
|
|
161
|
+
/**
|
|
162
|
+
* @param {ItemCacheFacade[]} items item caches
|
|
163
|
+
*/
|
|
164
|
+
constructor(items: ItemCacheFacade[]);
|
|
165
|
+
_items: ItemCacheFacade[];
|
|
166
|
+
/**
|
|
167
|
+
* @template T
|
|
168
|
+
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
169
|
+
* @returns {void}
|
|
170
|
+
*/
|
|
171
|
+
get<T>(callback: CallbackCache<T>): void;
|
|
172
|
+
/**
|
|
173
|
+
* @template T
|
|
174
|
+
* @returns {Promise<T>} promise with the data
|
|
175
|
+
*/
|
|
176
|
+
getPromise<T_1>(): Promise<T_1>;
|
|
177
|
+
/**
|
|
178
|
+
* @template T
|
|
179
|
+
* @param {T} data the value to store
|
|
180
|
+
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
181
|
+
* @returns {void}
|
|
182
|
+
*/
|
|
183
|
+
store<T_2>(data: T_2, callback: CallbackCache<void>): void;
|
|
184
|
+
/**
|
|
185
|
+
* @template T
|
|
186
|
+
* @param {T} data the value to store
|
|
187
|
+
* @returns {Promise<void>} promise signals when the value is stored
|
|
188
|
+
*/
|
|
189
|
+
storePromise<T_3>(data: T_3): Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
type WebpackError = import("./WebpackError");
|
|
192
|
+
//# sourceMappingURL=CacheFacade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheFacade.d.ts","sourceRoot":"","sources":["../../src/lib/CacheFacade.js"],"names":[],"mappings":";AA8LA;IACC;;;;OAIG;IACH,mBAJW,KAAK,QACL,MAAM,gBACN,MAAM,GAAG,eAAe,EAMlC;IAHA,0BAAmB;IACnB,cAAiB;IACjB,mBAAiC;IAGlC;;;OAGG;IACH,oBAHW,MAAM,GACJ,WAAW,CAQvB;IAED;;;;OAIG;IACH,yBAJW,MAAM,QACN,IAAI,GAAG,IAAI,GACT,eAAe,CAQ3B;IAED;;;OAGG;IACH,uBAHW,cAAc,GACZ,IAAI,CAIhB;IAED;;;;OAIG;IACH,cAJW,IAAI,KACJ,IAAI,GACF,IAAI,CAIhB;IAED;;;;;;OAMG;IACH,mBALW,MAAM,QACN,IAAI,GAAG,IAAI,+BAET,IAAI,CAIhB;IAED;;;;;OAKG;IACH,4BAJW,MAAM,QACN,IAAI,GAAG,IAAI,gBAarB;IAED;;;;;;;OAOG;IACH,uBANW,MAAM,QACN,IAAI,GAAG,IAAI,uBAEX,cAAc,IAAI,CAAC,GACjB,IAAI,CAIhB;IAED;;;;;;OAMG;IACH,8BALW,MAAM,QACN,IAAI,GAAG,IAAI,cAET,QAAQ,IAAI,CAAC,CAYzB;IAED;;;;;;;OAOG;IACH,yBANW,MAAM,QACN,IAAI,GAAG,IAAI,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|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
"use strict";
|
|
6
|
+
const { forEachBail } = require("enhanced-resolve");
|
|
7
|
+
const asyncLib = require("neo-async");
|
|
8
|
+
const getLazyHashedEtag = require("./cache/getLazyHashedEtag.js");
|
|
9
|
+
const mergeEtags = require("./cache/mergeEtags.js");
|
|
10
|
+
/** @typedef {import("./Cache")} Cache */
|
|
11
|
+
/** @typedef {import("./Cache").Etag} Etag */
|
|
12
|
+
/** @typedef {import("./WebpackError")} WebpackError */
|
|
13
|
+
/** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */
|
|
14
|
+
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
|
15
|
+
/**
|
|
16
|
+
* @template T
|
|
17
|
+
* @callback CallbackCache
|
|
18
|
+
* @param {(WebpackError | null)=} err
|
|
19
|
+
* @param {T=} result
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @template T
|
|
24
|
+
* @callback CallbackNormalErrorCache
|
|
25
|
+
* @param {(Error | null)=} err
|
|
26
|
+
* @param {T=} result
|
|
27
|
+
* @returns {void}
|
|
28
|
+
*/
|
|
29
|
+
class MultiItemCache {
|
|
30
|
+
/**
|
|
31
|
+
* @param {ItemCacheFacade[]} items item caches
|
|
32
|
+
*/
|
|
33
|
+
constructor(items) {
|
|
34
|
+
this._items = items;
|
|
35
|
+
if (items.length === 1)
|
|
36
|
+
return /** @type {any} */ (items[0]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @template T
|
|
40
|
+
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
43
|
+
get(callback) {
|
|
44
|
+
forEachBail(this._items, (item, callback) => item.get(callback), callback);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @template T
|
|
48
|
+
* @returns {Promise<T>} promise with the data
|
|
49
|
+
*/
|
|
50
|
+
getPromise() {
|
|
51
|
+
const next = i => {
|
|
52
|
+
return this._items[i].getPromise().then(result => {
|
|
53
|
+
if (result !== undefined)
|
|
54
|
+
return result;
|
|
55
|
+
if (++i < this._items.length)
|
|
56
|
+
return next(i);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return next(0);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @template T
|
|
63
|
+
* @param {T} data the value to store
|
|
64
|
+
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
store(data, callback) {
|
|
68
|
+
asyncLib.each(this._items, (item, callback) => item.store(data, callback), callback);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @template T
|
|
72
|
+
* @param {T} data the value to store
|
|
73
|
+
* @returns {Promise<void>} promise signals when the value is stored
|
|
74
|
+
*/
|
|
75
|
+
storePromise(data) {
|
|
76
|
+
return Promise.all(this._items.map(item => item.storePromise(data))).then(() => { });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class ItemCacheFacade {
|
|
80
|
+
/**
|
|
81
|
+
* @param {Cache} cache the root cache
|
|
82
|
+
* @param {string} name the child cache item name
|
|
83
|
+
* @param {Etag | null} etag the etag
|
|
84
|
+
*/
|
|
85
|
+
constructor(cache, name, etag) {
|
|
86
|
+
this._cache = cache;
|
|
87
|
+
this._name = name;
|
|
88
|
+
this._etag = etag;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @template T
|
|
92
|
+
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
93
|
+
* @returns {void}
|
|
94
|
+
*/
|
|
95
|
+
get(callback) {
|
|
96
|
+
this._cache.get(this._name, this._etag, callback);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @template T
|
|
100
|
+
* @returns {Promise<T>} promise with the data
|
|
101
|
+
*/
|
|
102
|
+
getPromise() {
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
this._cache.get(this._name, this._etag, (err, data) => {
|
|
105
|
+
if (err) {
|
|
106
|
+
reject(err);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
resolve(data);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @template T
|
|
116
|
+
* @param {T} data the value to store
|
|
117
|
+
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
118
|
+
* @returns {void}
|
|
119
|
+
*/
|
|
120
|
+
store(data, callback) {
|
|
121
|
+
this._cache.store(this._name, this._etag, data, callback);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @template T
|
|
125
|
+
* @param {T} data the value to store
|
|
126
|
+
* @returns {Promise<void>} promise signals when the value is stored
|
|
127
|
+
*/
|
|
128
|
+
storePromise(data) {
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
this._cache.store(this._name, this._etag, data, err => {
|
|
131
|
+
if (err) {
|
|
132
|
+
reject(err);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
resolve();
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* @template T
|
|
142
|
+
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
|
|
143
|
+
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
|
144
|
+
* @returns {void}
|
|
145
|
+
*/
|
|
146
|
+
provide(computer, callback) {
|
|
147
|
+
this.get((err, cacheEntry) => {
|
|
148
|
+
if (err)
|
|
149
|
+
return callback(err);
|
|
150
|
+
if (cacheEntry !== undefined)
|
|
151
|
+
return cacheEntry;
|
|
152
|
+
computer((err, result) => {
|
|
153
|
+
if (err)
|
|
154
|
+
return callback(err);
|
|
155
|
+
this.store(result, err => {
|
|
156
|
+
if (err)
|
|
157
|
+
return callback(err);
|
|
158
|
+
callback(null, result);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* @template T
|
|
165
|
+
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
|
|
166
|
+
* @returns {Promise<T>} promise with the data
|
|
167
|
+
*/
|
|
168
|
+
async providePromise(computer) {
|
|
169
|
+
const cacheEntry = await this.getPromise();
|
|
170
|
+
if (cacheEntry !== undefined)
|
|
171
|
+
return cacheEntry;
|
|
172
|
+
const result = await computer();
|
|
173
|
+
await this.storePromise(result);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
class CacheFacade {
|
|
178
|
+
/**
|
|
179
|
+
* @param {Cache} cache the root cache
|
|
180
|
+
* @param {string} name the child cache name
|
|
181
|
+
* @param {string | HashConstructor} hashFunction the hash function to use
|
|
182
|
+
*/
|
|
183
|
+
constructor(cache, name, hashFunction) {
|
|
184
|
+
this._cache = cache;
|
|
185
|
+
this._name = name;
|
|
186
|
+
this._hashFunction = hashFunction;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @param {string} name the child cache name#
|
|
190
|
+
* @returns {CacheFacade} child cache
|
|
191
|
+
*/
|
|
192
|
+
getChildCache(name) {
|
|
193
|
+
return new CacheFacade(this._cache, `${this._name}|${name}`, this._hashFunction);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @param {string} identifier the cache identifier
|
|
197
|
+
* @param {Etag | null} etag the etag
|
|
198
|
+
* @returns {ItemCacheFacade} item cache
|
|
199
|
+
*/
|
|
200
|
+
getItemCache(identifier, etag) {
|
|
201
|
+
return new ItemCacheFacade(this._cache, `${this._name}|${identifier}`, etag);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* @param {HashableObject} obj an hashable object
|
|
205
|
+
* @returns {Etag} an etag that is lazy hashed
|
|
206
|
+
*/
|
|
207
|
+
getLazyHashedEtag(obj) {
|
|
208
|
+
return getLazyHashedEtag(obj, this._hashFunction);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @param {Etag} a an etag
|
|
212
|
+
* @param {Etag} b another etag
|
|
213
|
+
* @returns {Etag} an etag that represents both
|
|
214
|
+
*/
|
|
215
|
+
mergeEtags(a, b) {
|
|
216
|
+
return mergeEtags(a, b);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @template T
|
|
220
|
+
* @param {string} identifier the cache identifier
|
|
221
|
+
* @param {Etag | null} etag the etag
|
|
222
|
+
* @param {CallbackCache<T>} callback signals when the value is retrieved
|
|
223
|
+
* @returns {void}
|
|
224
|
+
*/
|
|
225
|
+
get(identifier, etag, callback) {
|
|
226
|
+
this._cache.get(`${this._name}|${identifier}`, etag, callback);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* @template T
|
|
230
|
+
* @param {string} identifier the cache identifier
|
|
231
|
+
* @param {Etag | null} etag the etag
|
|
232
|
+
* @returns {Promise<T>} promise with the data
|
|
233
|
+
*/
|
|
234
|
+
getPromise(identifier, etag) {
|
|
235
|
+
return new Promise((resolve, reject) => {
|
|
236
|
+
this._cache.get(`${this._name}|${identifier}`, etag, (err, data) => {
|
|
237
|
+
if (err) {
|
|
238
|
+
reject(err);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
resolve(data);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @template T
|
|
248
|
+
* @param {string} identifier the cache identifier
|
|
249
|
+
* @param {Etag | null} etag the etag
|
|
250
|
+
* @param {T} data the value to store
|
|
251
|
+
* @param {CallbackCache<void>} callback signals when the value is stored
|
|
252
|
+
* @returns {void}
|
|
253
|
+
*/
|
|
254
|
+
store(identifier, etag, data, callback) {
|
|
255
|
+
this._cache.store(`${this._name}|${identifier}`, etag, data, callback);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @template T
|
|
259
|
+
* @param {string} identifier the cache identifier
|
|
260
|
+
* @param {Etag | null} etag the etag
|
|
261
|
+
* @param {T} data the value to store
|
|
262
|
+
* @returns {Promise<void>} promise signals when the value is stored
|
|
263
|
+
*/
|
|
264
|
+
storePromise(identifier, etag, data) {
|
|
265
|
+
return new Promise((resolve, reject) => {
|
|
266
|
+
this._cache.store(`${this._name}|${identifier}`, etag, data, err => {
|
|
267
|
+
if (err) {
|
|
268
|
+
reject(err);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
resolve();
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* @template T
|
|
278
|
+
* @param {string} identifier the cache identifier
|
|
279
|
+
* @param {Etag | null} etag the etag
|
|
280
|
+
* @param {function(CallbackNormalErrorCache<T>): void} computer function to compute the value if not cached
|
|
281
|
+
* @param {CallbackNormalErrorCache<T>} callback signals when the value is retrieved
|
|
282
|
+
* @returns {void}
|
|
283
|
+
*/
|
|
284
|
+
provide(identifier, etag, computer, callback) {
|
|
285
|
+
this.get(identifier, etag, (err, cacheEntry) => {
|
|
286
|
+
if (err)
|
|
287
|
+
return callback(err);
|
|
288
|
+
if (cacheEntry !== undefined)
|
|
289
|
+
return cacheEntry;
|
|
290
|
+
computer((err, result) => {
|
|
291
|
+
if (err)
|
|
292
|
+
return callback(err);
|
|
293
|
+
this.store(identifier, etag, result, err => {
|
|
294
|
+
if (err)
|
|
295
|
+
return callback(err);
|
|
296
|
+
callback(null, result);
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* @template T
|
|
303
|
+
* @param {string} identifier the cache identifier
|
|
304
|
+
* @param {Etag | null} etag the etag
|
|
305
|
+
* @param {function(): Promise<T> | T} computer function to compute the value if not cached
|
|
306
|
+
* @returns {Promise<T>} promise with the data
|
|
307
|
+
*/
|
|
308
|
+
async providePromise(identifier, etag, computer) {
|
|
309
|
+
const cacheEntry = await this.getPromise(identifier, etag);
|
|
310
|
+
if (cacheEntry !== undefined)
|
|
311
|
+
return cacheEntry;
|
|
312
|
+
const result = await computer();
|
|
313
|
+
await this.storePromise(identifier, etag, result);
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
module.exports = CacheFacade;
|
|
318
|
+
module.exports.ItemCacheFacade = ItemCacheFacade;
|
|
319
|
+
module.exports.MultiItemCache = MultiItemCache;
|
|
320
|
+
//# sourceMappingURL=CacheFacade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheFacade.js","sourceRoot":"","sources":["../../src/lib/CacheFacade.js"],"names":[],"mappings":"AAAA;;;EAGE;AAEF,YAAY,CAAC;AAEb,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACtC,MAAM,iBAAiB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAClE,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEpD,yCAAyC;AACzC,6CAA6C;AAC7C,uDAAuD;AACvD,mFAAmF;AACnF,8DAA8D;AAE9D;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH,MAAM,cAAc;IACnB;;OAEG;IACH,YAAY,KAAK;QAChB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,QAAQ;QACX,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EA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