1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| const cachePrefix = require('./util').cachePrefix;
| const logMessages = require('./util/log-messages');
| const pluginCompat = require('./util/plugin-compat');
|
| class TransformCompilationPlugin {
| apply(compiler) {
| let store;
|
| pluginCompat.tap(
| compiler,
| '_hardSourceMethods',
| 'TransformCompilationPlugin copy methods',
| methods => {
| store = methods.store;
| // fetch = methods.fetch;
| // freeze = methods.freeze;
| // thaw = methods.thaw;
| },
| );
|
| pluginCompat.tap(
| compiler,
| '_hardSourceFreezeCompilation',
| 'TransformCompilationPlugin freeze',
| (_, compilation) => {
| compilation.modules.forEach(module => {
| const identifierPrefix = cachePrefix(compilation);
| if (identifierPrefix === null) {
| return;
| }
| const identifier = identifierPrefix + module.identifier();
|
| try {
| store('Module', identifier, module, {
| id: identifier,
| compilation,
| });
| } catch (e) {
| logMessages.moduleFreezeError(compilation, module, e);
| }
| });
| },
| );
| }
| }
|
| module.exports = TransformCompilationPlugin;
|
|