()
| 168 | } |
| 169 | |
| 170 | function resolveDefine() { |
| 171 | /** @type {Record<string, string>} */ |
| 172 | const replacements = { |
| 173 | __COMMIT__: `"${process.env.COMMIT}"`, |
| 174 | __VERSION__: `"${masterVersion}"`, |
| 175 | // this is only used during Vue's internal tests |
| 176 | __TEST__: `false`, |
| 177 | // If the build is expected to run directly in the browser (global / esm builds) |
| 178 | __BROWSER__: String(isBrowserBuild), |
| 179 | __GLOBAL__: String(isGlobalBuild), |
| 180 | __ESM_BUNDLER__: String(isBundlerESMBuild), |
| 181 | __ESM_BROWSER__: String(isBrowserESMBuild), |
| 182 | // is targeting Node (SSR)? |
| 183 | __CJS__: String(isCJSBuild), |
| 184 | // need SSR-specific branches? |
| 185 | __SSR__: String(!isGlobalBuild), |
| 186 | |
| 187 | // 2.x compat build |
| 188 | __COMPAT__: String(isCompatBuild), |
| 189 | |
| 190 | // feature flags |
| 191 | __FEATURE_SUSPENSE__: `true`, |
| 192 | __FEATURE_OPTIONS_API__: isBundlerESMBuild |
| 193 | ? `__VUE_OPTIONS_API__` |
| 194 | : `true`, |
| 195 | __FEATURE_PROD_DEVTOOLS__: isBundlerESMBuild |
| 196 | ? `__VUE_PROD_DEVTOOLS__` |
| 197 | : `false`, |
| 198 | __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: isBundlerESMBuild |
| 199 | ? `__VUE_PROD_HYDRATION_MISMATCH_DETAILS__` |
| 200 | : `false`, |
| 201 | } |
| 202 | |
| 203 | if (!isBundlerESMBuild) { |
| 204 | // hard coded dev/prod builds |
| 205 | replacements.__DEV__ = String(!isProductionBuild) |
| 206 | } |
| 207 | |
| 208 | // allow inline overrides like |
| 209 | //__RUNTIME_COMPILE__=true pnpm build runtime-core |
| 210 | Object.keys(replacements).forEach(key => { |
| 211 | if (key in process.env) { |
| 212 | const value = process.env[key] |
| 213 | assert(typeof value === 'string') |
| 214 | replacements[key] = value |
| 215 | } |
| 216 | }) |
| 217 | return replacements |
| 218 | } |
| 219 | |
| 220 | // esbuild define is a bit strict and only allows literal json or identifiers |
| 221 | // so we still need replace plugin in some cases |
no test coverage detected