* Returns code. * @param {JavascriptParser} parser the parser * @param {ValueCacheVersions} valueCacheVersions valueCacheVersions * @param {string} key the defined key * @returns {CodeValuePrimitive} code
(parser, valueCacheVersions, key)
| 83 | * @returns {CodeValuePrimitive} code |
| 84 | */ |
| 85 | exec(parser, valueCacheVersions, key) { |
| 86 | const buildInfo = /** @type {BuildInfo} */ (parser.state.module.buildInfo); |
| 87 | if (this.options === true) { |
| 88 | buildInfo.cacheable = false; |
| 89 | } else { |
| 90 | if (this.options.fileDependencies) { |
| 91 | for (const dep of this.options.fileDependencies) { |
| 92 | /** @type {NonNullable<BuildInfo[class="st">"fileDependencies"]>} */ |
| 93 | (buildInfo.fileDependencies).add(dep); |
| 94 | } |
| 95 | } |
| 96 | if (this.options.contextDependencies) { |
| 97 | for (const dep of this.options.contextDependencies) { |
| 98 | /** @type {NonNullable<BuildInfo[class="st">"contextDependencies"]>} */ |
| 99 | (buildInfo.contextDependencies).add(dep); |
| 100 | } |
| 101 | } |
| 102 | if (this.options.missingDependencies) { |
| 103 | for (const dep of this.options.missingDependencies) { |
| 104 | /** @type {NonNullable<BuildInfo[class="st">"missingDependencies"]>} */ |
| 105 | (buildInfo.missingDependencies).add(dep); |
| 106 | } |
| 107 | } |
| 108 | if (this.options.buildDependencies) { |
| 109 | for (const dep of this.options.buildDependencies) { |
| 110 | /** @type {NonNullable<BuildInfo[class="st">"buildDependencies"]>} */ |
| 111 | (buildInfo.buildDependencies).add(dep); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return this.fn({ |
| 117 | module: parser.state.module, |
| 118 | key, |
| 119 | get version() { |
| 120 | return /** @type {ValueCacheVersion} */ ( |
| 121 | valueCacheVersions.get(VALUE_DEP_PREFIX + key) |
| 122 | ); |
| 123 | } |
| 124 | }); |
| 125 | } |
| 126 | |
| 127 | getCacheVersion() { |
| 128 | return this.options === true |
no test coverage detected