(code, id)
| 136 | |
| 137 | transform: { |
| 138 | handler(code, id) { |
| 139 | if (this.environment.config.consumer === 'client') { |
| 140 | // for dev we inject actual global defines in the vite client to |
| 141 | // avoid the transform cost. see the `clientInjection` and |
| 142 | // `importAnalysis` plugin. |
| 143 | return |
| 144 | } |
| 145 | |
| 146 | if ( |
| 147 | // exclude html, css and static assets for performance |
| 148 | isHTMLRequest(id) || |
| 149 | isCSSRequest(id) || |
| 150 | isNonJsRequest(id) || |
| 151 | config.assetsInclude(id) |
| 152 | ) { |
| 153 | return |
| 154 | } |
| 155 | |
| 156 | const [define, pattern] = getPattern(this.environment) |
| 157 | if (!pattern) return |
| 158 | |
| 159 | // Check if our code needs any replacements before running esbuild |
| 160 | pattern.lastIndex = 0 |
| 161 | if (!pattern.test(code)) return |
| 162 | |
| 163 | const result = replaceDefine(this.environment, code, id, define) |
| 164 | return result |
| 165 | }, |
| 166 | }, |
| 167 | } |
| 168 | } |
nothing calls this directly
no test coverage detected